POST/ users/
Create user
You can create a user. The table below includes any possible attributes that can be updated. 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
- company_custom_id
- A unique identifier for the company which is provided by the client.
- custom_attr
- A name of your custom attribute.
- A user email address.
- first_name
- A first name for a user (the maximum number of characters is 40).
- last_name
- A last name for a user (the maximum number of characters is 40).
- tags
- A list of tag names.
Request
- cURL
- JavaScript
- PHP
- Python
curl -X POST "https://<your_app_subdomain>.user.com/api/public/users/" \
-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",
"email": "johndoe@example.com",
"unsubscribed": true
}'
const response = await fetch(
"https://<your_app_subdomain>.user.com/api/public/users/",
{
method: "POST",
headers: {
Authorization: "Token <your_64_char_api_key>",
Accept: "*/*; version=2",
"Content-Type": "application/json",
},
body: JSON.stringify({
custom_id: "alex",
first_name: "John",
last_name: "Doe",
email: "johndoe@example.com",
unsubscribed: true,
}),
},
);
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/users/",
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([
"custom_id" => "alex",
"first_name" => "John",
"last_name" => "Doe",
"email" => "johndoe@example.com",
"unsubscribed" => true,
]),
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
response = requests.post(
"https://<your_app_subdomain>.user.com/api/public/users/",
headers={
"Authorization": "Token <your_64_char_api_key>",
"Accept": "*/*; version=2",
},
json={
"custom_id": "alex",
"first_name": "John",
"last_name": "Doe",
"email": "johndoe@example.com",
"unsubscribed": True,
},
)
print(response.json())
Response examples
- 201 Created
- 400 Bad Request
{"id": 1924,"user_key": "g7lvoickax9e","name": "Alex Doe","email": "johndoe@example.com","gender": "unknown","status": "visitor","phone_number": null,"first_seen": null,"last_seen": null,"page_views": 0,"last_ip": null,"timezone": null,"city": null,"region": null,"country": null,"unsubscribed": true,"browser_language": null,"widget_language": null,"score": 0,"browser": null,"os_type": null,"resolution": null,"created_at": "2026-11-10T14:20:02.361287Z","updated_at": "2026-11-10T14:20:02.361297Z","companies": [],"gravatar_url": null,"lists": [],"tags": [],"notifications": true,"facebook_url": null,"linkedin_url": null,"twitter_url": null,"google_url": null,"last_contacted": null,"custom_id": "alex","web_push_subscription": false,"assigned_to": null,"most_active_time": null,"lt_opened_email": null,"lt_clicked_email": null,"email_mx_valid": null,"referrer": null,"last_heard_from": null,"spambounced": false,"softbounced": false,"hardbounced": false,"marked_email_as_spam": true,"email_opt_in": null,"email_tracking_optin": null}{"email": ["Enter a valid email address."]}A 400 names every field that was rejected, each with its messages. The ones you're most likely to see:
| Message | When |
|---|---|
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). |
custom_id: Client User with user_id abc already exists | Another contact already has that custom_id. |
A company_custom_id no company has is ignored: the contact is created without a company.
Response fields
Fields returned in the 201 Created response body.
- id
- A unique identifier for the user which is given by User automatically.
- user_key
- A unique identifier (12 random characters) for the user which is given by User automatically.
- name
- Read-only attribute, made from the combination of the first_name and last_name attributes.
- A user email
- gender
unknown(default),maleorfemale. Not detected automatically.- status
userif the contact's email address has been sent to User through the code on your website, otherwisevisitor.- phone_number
- A user phone number
- first_seen
- A date for user's first website visit.
- last_seen
- A date of last user's website visit.
- page_views
- A total number of user's page visits occurrences.
- last_ip
- An address IP (identifier assigned to each device, e.g., laptop, printer, mobile etc.) from the last user visit.
- timezone
- A timezone of the user's browser.
- city
- City of the contact's last visit, based on the IP address.
- region
- Region of the contact's last visit, based on the IP address.
- country
- Country of the contact's last visit, based on the IP address.
- unsubscribed
- A flag true/false informing if user is unsubscribed from emails.
- browser_language
- A user's browser language
- widget_language
- Language of the chat widget for this contact, used when the widget is set to follow it;
nullif not set. - score
- A number of points assinged to the user.
- browser
- A name of user's browser last used to visit your website.
- os_type
- An operating system of the user’s device
- resolution
- A screen resolution of the device the user has visited your website.
- created_at
- A creation date of a user.
- updated_at
- A date of last user update.
- companies
- Companies the contact is a member of, each with
id,nameandmember_since. - gravatar_url
- A user avatar url from gravatar.
- lists
- Lists the contact is on, each with
id,nameanddescription. - tags
- Tags on the contact, each with
idandname. - notifications
- A flag true/false informing if your team is receiving notifications about new chat messages from this user.
- facebook_url
- A URL of user's Facebook profile.
- linkedin_url
- A URL of user's LinkedIn profile.
- twitter_url
- A URL of user's Twitter profile.
- google_url
- A URL of user's Google+ profile.
- last_contacted
- A date of last contact with user - any communication (email or chat, automated or otherwise) sent from your team to the user.
- custom_id
- The unique identifier for the user which is provided by the client.
- web_push_subscription
trueif the contact has at least one web push subscription.- assigned_to
- ID of the agent group the contact is assigned to, or
null. - most_active_time
- Most Active Time is an attribute that is based on historical data determined by the hours of previous use and the most likely active use. Time in this attribute is positioned in the UTC timezone, and there's no possible way to change the timezone for the attribute.
- lt_opened_email
- When the contact last opened one of your emails.
- lt_clicked_email
- When the contact last clicked a link in one of your emails.
- email_mx_valid
- Whether the email address passed User's validation; set to
falseafter a hard bounce. - referrer
- URL of the page the contact came to your website from.
- last_heard_from
- When the contact last sent your team a message (chat or email). Emails count only once your inbox is connected over IMAP.
- spambounced
trueonce an email to the contact bounced as spam.- softbounced
trueonce an email to the contact soft-bounced.- hardbounced
trueonce an email to the contact hard-bounced or was dropped.- marked_email_as_spam
- Defaults to
trueand isn't changed when emails bounce; checkspambouncedfor spam bounces. - email_opt_in
- Email marketing consent:
truegiven,falserefused,nullnot recorded. - email_tracking_optin
- Consent to email open and click tracking:
truegiven,falserefused,nullnot recorded.
note
Errors that can come from any endpoint (401, 429, 500, 502, 504) are described in HTTP response codes.