POST/ companies/
Create company
You can create a company.
Attributes
Optional unless marked required
- custom_id
- The unique identifier for the company which is provided by the client.
- address
- A company’s address.
- city
- A company city of residence.
- country
- A company country of residence.
- created_at
- Set by User. A value sent here is ignored.
- description
- A description of a company.
- A company’s email address.
- name
- A company name.
- phone_numbers
- A list of phone numbers.
- postal_code
- A postal code according to the address of your company..
- region
- A company region of residence.
- size
- An approximate size of your company.
- tags
- A list of tags associated with a company
- updated_at
- Set by User. A value sent here is ignored.
- assigned_to
- ID of the agent the company is assigned to.
Request
- cURL
- JavaScript
- PHP
- Python
curl -X POST "https://<your_app_subdomain>.user.com/api/public/companies/" \
-H "Authorization: Token <your_64_char_api_key>" \
-H "Accept: */*; version=2" \
-H "Content-Type: application/json" \
-d '{
"name": "Acme Inc",
"custom_id": "acme-inc",
"description": "Online store selling outdoor gear.",
"size": 10
}'
const response = await fetch(
"https://<your_app_subdomain>.user.com/api/public/companies/",
{
method: "POST",
headers: {
Authorization: "Token <your_64_char_api_key>",
Accept: "*/*; version=2",
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "Acme Inc",
custom_id: "acme-inc",
description: "Online store selling outdoor gear.",
size: 10,
}),
},
);
const data = await response.json();
console.log(data);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://<your_app_subdomain>.user.com/api/public/companies/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Token <your_64_char_api_key>",
"Accept: */*; version=2",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"name" => "Acme Inc",
"custom_id" => "acme-inc",
"description" => "Online store selling outdoor gear.",
"size" => 10,
]),
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
response = requests.post(
"https://<your_app_subdomain>.user.com/api/public/companies/",
headers={
"Authorization": "Token <your_64_char_api_key>",
"Accept": "*/*; version=2",
},
json={
"name": "Acme Inc",
"custom_id": "acme-inc",
"description": "Online store selling outdoor gear.",
"size": 10,
},
)
print(response.json())
Response examples
- 201 Created
- 400 Bad Request
{"id": 34,"name": "Acme Inc","description": "Online store selling outdoor gear.","email": null,"country": null,"region": null,"city": null,"address": null,"postal_code": null,"size": 10,"created_at": "2026-11-09T13:40:25.713466Z","updated_at": "2026-11-09T13:40:25.713494Z","tags": [],"employees": [],"phone_numbers": null,"custom_id": "acme-inc","assigned_to": null}{"custom_id": ["This field must be unique."]}A 400 names every field that was rejected, each with its messages. The ones you're most likely to see:
| Field | Message | When |
|---|---|---|
custom_id | This field must be unique. | Another company already has that custom_id. |
size | A valid integer is required. | The value isn't a whole number. |
assigned_to | Invalid pk "123" - object does not exist. | No agent has that ID. |
email | Enter a valid email address. | The value isn't an email address. |
phone_numbers | Expected a list of items but got type "str". | A single string instead of a list. |
The API doesn't enforce name: a body without it creates a company with "name": null. Always send it.
Response fields
Fields returned in the 201 Created response body.
- id
- A unique identifier for the company which is given by User automatically.
- name
- A company name.
- description
- A description of a company.
- A company’s email address.
- country
- A company country of residence.
- region
- A company region of residence.
- city
- A company city of residence.
- address
- A company’s address.
- postal_code
- A postal code according to the address of your company..
- size
- An approximate size of your company.
- created_at
- A creation date of a company.
- updated_at
- A date of last company update.
- tags
- A list of tags associated with a company
- employees
- IDs of the contacts who belong to the company.
- phone_numbers
- A list of phone numbers.
- custom_id
- The unique identifier for the company which is provided by the client.
- assigned_to
- ID of the agent group the company is assigned to.
note
Errors that can come from any endpoint (401, 429, 500, 502, 504) are described in HTTP response codes.