> ## Documentation Index
> Fetch the complete documentation index at: https://developers.chameleon.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Companies (Incoming Webhook)

> Send Company data to Chameleon from services like Customer.io, Heap, Zapier or from your own backend.

Looking for the [JavaScript API](/js/profiles#company)?

***

A Company that does not yet exist by `uid` will first be created and then updated with the other data included in this request.

> Company data updates are processed synchronously on the application server.

<a id="companies-update" />

## Create/Update a Company

* When you are creating the Company, simply send the `uid` and any other properties pertinent to that company.
* When you are updating the Company, simply send the Chameleon `id` field or use the `uid` and any other properties pertinent to that company.

#### HTTP Request

```http title="POST" theme={null}
https://api.chameleon.io/v3/observe/hooks/companies
```

or

```http title="POST" theme={null}
https://api.chameleon.io/v3/observe/hooks/:account_secret/companies
```

| param    | -        | description                                                          |
| -------- | -------- | -------------------------------------------------------------------- |
| `id`     | optional | The Chameleon ID of the Company                                      |
| `uid`    | optional | The Company Identifier (typically the Database ID from your backend) |
| \*others | optional | All other properties will be stored on the Company                   |

```json theme={null}
{
  "uid": "18821",
  "domain": "chmln.co",
  "name": "Leon Inc.",
  "plan": "Growth",
  "clv": 24920,
  "last_action_at": "2029-04-07T12:18:00Z",
   ...
}
```

#### HTTP Response

```json theme={null}
{
  "company": {
    "id": "5f3c4232c712de665632a2a3"
  }
}
```

### Limits

* Up to a total of 768 bytes are stored for each scalar value where each Array item and each Hash value can reach this limit.
* See the full page on [Normalization](/concepts/normalization#limits) for more information on these limits.

### Normalization

* Property names are normalized to lower case and underscored i.e. `companyName` => `company_name`.
* See the full page on [Normalization](/concepts/normalization#properties) for more information on how properties are normalized.

<a id="companies-bulk" />

## Bulk Create/Update Companies

* When sending a bulk create/update, send an array of Company objects as the `companies` parameter
* For each Company, send the Company ID as `uid` and any other properties pertinent to that Company.

#### HTTP Request

```http title="POST" theme={null}
https://api.chameleon.io/v3/observe/hooks/companies/batch
```

or

```http title="POST" theme={null}
https://api.chameleon.io/v3/observe/hooks/:account_secret/companies/batch
```

| param              | -                 | description                                                                                                                         |
| ------------------ | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| `companies`        | array\<Company>   | The list of Companies to update; each item has the same schema as the [Single Company update](/webhooks/companies#companies-update) |
| `on_model_missing` | optional        m | The treatment of Companies not previously sent to Chameleon. Defaults to `create`. One of `create`, `ignore`                        |

```json theme={null}
{
  "companies": [
    {
      "uid": 18821,
      "domain": "acme.ai",
      "last_import_at": "2029-04-07T12:18:00Z",
      "number_of_employees": 73,
      ...
    },
    {
      "uid": 28421,
      "domain": "highlighter.com",
      "last_import_at": "2029-04-02T16:11:06Z",
      "number_of_employees": 42,
      ...
    },
    ...
  ]
}
```

#### HTTP Response

```json theme={null}
{
  "batch": {
    "id": "7f332c712de6c4265632a32a"
  }
}
```

#### HTTP Response error

When the 930th item had no value for the `uid` key

Note: The status code will be the normal 202 for (Accepted for processing)

```json theme={null}
{
  "batch": {
    "id": "7f332c712de6c4265632a32a"
  },
  "errors": [
    {
      "code": 422,
      "index": 929,
      "message": "No identifier found for the 930th item. Pass your Company ID as the `uid` parameter"
    }
  ]
}
```

## Limits

* The size of each batch request is limited to 16mb
* As with the [Single Company update](/webhooks/companies#companies-update), up to a total of 768 bytes are stored for each scalar value where each Array item and each Hash value can reach this limit.
* See the full page on [Normalization](/concepts/normalization#limits) for more information on these limits.

#### Examples

> Either set the number of items per batch to *10,000* OR to approximate the number of
> items per batch (based on the average payload size), divide (16777216 / "Average characters in JSON payload per item") \* 0.95

With the following update, you can send approximately *257,000 Companies* per batch request

```json theme={null}
{
  "uid": "20ee87e2-f144-4611-8c24-e41549573fa9",
  "plan": "bronze"
}
```

With the following update, you can send approximately *47,000 Companies* per batch request

```json theme={null}
{
  "uid": "20ee87e2-f144-4611-8c24-e41549573fa9",
  "domain": "acme.ai",
  "company_name": "Jane",
  "last_name": "Chameleon",
  "last_login": "2029-04-29T09:00:00.000Z",
  "subscription_type": "platinum",
  "buyer_role": "CRO",
  "plan": "longer than normal plan name",
  "industry": "SaaS",
  "number_of_employees": 70,
  "founded_year": 2029,
  "annual_revenue": 57000000
}
```

#### HTTP Response error

When the request was larger than 16mb. The status code will be 413 (Request too large)

```json theme={null}
{
  "code": 413,
  "messages": ["Each batch must be less than 16mb, try splitting the batch in half"]
}
```
