POST
/
v1
/
users
curl https://api.usertour.io/v1/users \
-XPOST \
-H 'Authorization: Bearer ak_123456789' \
-H 'Content-Type: application/json' \
-d '{
      "id": "usr_123456789",
      "attributes": {
        "name": "John Doe",
        "email": "john.doe@example.com",
        "signed_up_at": "2024-03-20T08:30:00.000Z"
      }
    }'
{
  "id": "usr_123456789",
  "object": "user",
  "attributes": {
    "name": "John Doe",
    "email": "john.doe@example.com"
  },
  "created_at": "2024-03-20T08:30:00.000Z"
}

This endpoint allows you to create a new user or update an existing one. The operation is idempotent - if a user with the specified ID already exists, the request will update the user’s attributes. If the user doesn’t exist, a new user will be created.

Body Parameters

id
string
required

Unique identifier for the user. This should match the user’s ID in your system.

attributes
object

A map of user attributes to update. You can include any custom attributes. Existing attributes not included in the request will remain unchanged. See Attributes for details.

companies
array

An array of company objects to associate with the user. Each company object must contain an ID and can include additional attributes. This is the recommended approach when you only need to establish company associations without additional relationship attributes.

memberships
array

An array of membership objects that define the relationship between a user and a company. Use this when you need to specify attributes that describe the user’s relationship with each company. Each membership object must include a company object with at least its ID.

Only one of companies and memberships can be set.
curl https://api.usertour.io/v1/users \
-XPOST \
-H 'Authorization: Bearer ak_123456789' \
-H 'Content-Type: application/json' \
-d '{
      "id": "usr_123456789",
      "attributes": {
        "name": "John Doe",
        "email": "john.doe@example.com",
        "signed_up_at": "2024-03-20T08:30:00.000Z"
      }
    }'
{
  "id": "usr_123456789",
  "object": "user",
  "attributes": {
    "name": "John Doe",
    "email": "john.doe@example.com"
  },
  "created_at": "2024-03-20T08:30:00.000Z"
}