Skip to main content
POST/users/update_or_create/

Update or create user

You can create or update users based on the "custom_id" key value. If a user with the provided value exists, we will update his profile with provided data, otherwise, a new user will be created. You can also set up any custom attribute of your choice. Custom attributes have to be created in the User app before sending them within requests.

Attributes

Optional unless marked required

custom_idstring
The unique identifier for the user which is provided by the client.
company_custom_idstring
A unique identifier for the company which is provided by the client.
custom_attrstring
An example value of your custom attribute.
emailstring
A user email address.
first_namestring
A first name for a user (the maximum number of characters is 40).
last_namestring
A last name for a user (the maximum number of characters is 40).
tagslist(strings)
A list of tag names.

Request​

curl -X POST "https://<your_app_subdomain>.user.com/api/public/users/update_or_create/" \
-H "Authorization: Token <your_64_char_api_key>" \
-H "Accept: */*; version=2" \
-H "Content-Type: application/json" \
-d '{
"custom_id": "alex",
"first_name": "John",
"last_name": "Doe"
}'

Response examples​

{
"created": true,
"id": 5577
}

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

MessageWhen
email: Enter a valid email address.The value isn't an email address.
gender: "abc" is not a valid choice.The value isn't one of the gender values.
<custom attribute>: A valid integer is required.The value doesn't fit the attribute's type (a number attribute here).

Without custom_id, every call creates a new contact ("created": true). A company_custom_id no company has is ignored.

Response fields​

Fields returned in the 200 OK response body.

createdboolean
true if a new contact was created, false if the contact with this custom_id was updated.
idinteger
A unique identifier for the user which is given by User automatically.
note

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