Skip to main content
POST/companies/update_or_create/

Update or create company

You can create or update companies based on the "custom_id" key-value. If a company with the provided value exists, we will update its profile with provided data, otherwise, a new company will be created.

Attributes

Optional unless marked required

custom_idstring
The unique identifier for the company which is provided by the client.
addressstring
A company’s address.
citystring
A company city of residence.
countrystring
A company country of residence.
created_atstring
Set by User. A value sent here is ignored.
descriptionstring
A description of a company.
emailstring(email)
A company’s email address.
namestringrequired
A company name. Not needed when custom_id matches an existing company.
phone_numberslist of strings
A list of phone numbers.
postal_codestring
A postal code according to the address of your company..
regionstring
A company region of residence.
sizeinteger
An approximate size of your company.
tagsstring
A list of tags associated with a company
updated_atstring
Set by User. A value sent here is ignored.
assigned_tointeger
An agent group ID.

Request​

curl -X POST "https://<your_app_subdomain>.user.com/api/public/companies/update_or_create/" \
-H "Authorization: Token <your_64_char_api_key>" \
-H "Accept: */*; version=2" \
-H "Content-Type: application/json" \
-d '{
"custom_id": "acme-inc",
"name": "Acme Inc",
"description": "Online store selling outdoor gear since 2015."
}'

Response examples​

{
"created": false,
"id": 34
}

A 400 names every field that was rejected, each with its messages. The ones you're most likely to see:

FieldMessageWhen
sizeA valid integer is required.The value isn't a whole number.
assigned_toInvalid pk "123" - object does not exist.No agent has that ID.
assigned_toIncorrect type. Expected pk value, received str.The value isn't a number.
emailEnter a valid email address.The value isn't an email address.
phone_numbersExpected a list of items but got type "str".A single string instead of a list.

The numbers inside phone_numbers aren't checked: any string is saved as it is.

Response fields​

Fields returned in the 200 OK response body.

createdboolean
true if a new company was created, false if an existing one was updated.
idinteger
Unique identifier of the company, assigned by User.
note

Errors that can come from any endpoint (401, 429, 500, 502, 504) are described in HTTP response codes.