PATCH
/
users
/
{id}
JavaScript
import { TrophyApiClient } from '@trophyso/node';

const trophy = new TrophyApiClient({
  apiKey: 'YOUR_API_KEY'
});

const response = await trophy.users.update("user-id", {
  email: 'user@example.com',
  tz: 'Europe/London',
  attributes: {
    department: 'engineering',
    role: 'developer'
  }
});
{
  "email": "user@example.com",
  "name": "User",
  "tz": "Europe/London",
  "deviceTokens": [
    "token1",
    "token2"
  ],
  "subscribeToEmails": true,
  "attributes": {
    "department": "engineering",
    "role": "developer"
  },
  "id": "user-id",
  "control": false,
  "created": "2021-01-01T00:00:00Z",
  "updated": "2021-01-01T00:00:00Z"
}

Authorizations

X-API-KEY
string
header
required

Path Parameters

id
string
required

ID of the user to update.

Body

application/json

The user object.

email
string
required

The user's email address. Required if subscribeToEmails is true.

Example:

"user@example.com"

name
string
required

The name to refer to the user by in emails.

Example:

"User"

deviceTokens
string[]
required

The user's device tokens, used for push notifications.

The device token.

Example:
["token1", "token2"]
subscribeToEmails
boolean
default:true
required

Whether the user should receive Trophy-powered emails. If false, Trophy will not store the user's email address.

Example:

true

attributes
object
required

User attributes as key-value pairs. Keys must match existing user attributes set up in the Trophy dashboard.

Example:
{
"department": "engineering",
"role": "developer"
}
tz
string | null

The user's timezone (used for email scheduling).

Example:

"Europe/London"

Response

Updated user

A user of your application. An object with editable user fields.

control
boolean
required

Whether the user is in the control group, meaning they do not receive emails or other communications from Trophy.

Example:

false

created
string<date-time>
required

The date and time the user was created, in ISO 8601 format.

Example:

"2021-01-01T00:00:00Z"

updated
string<date-time>
required

The date and time the user was last updated, in ISO 8601 format.

Example:

"2021-01-01T00:00:00Z"

email
string
required

The user's email address. Required if subscribeToEmails is true.

Example:

"user@example.com"

name
string
required

The name to refer to the user by in emails.

Example:

"User"

deviceTokens
string[]
required

The user's device tokens, used for push notifications.

The device token.

Example:
["token1", "token2"]
subscribeToEmails
boolean
default:true
required

Whether the user should receive Trophy-powered emails. If false, Trophy will not store the user's email address.

Example:

true

attributes
object
required

User attributes as key-value pairs. Keys must match existing user attributes set up in the Trophy dashboard.

Example:
{
"department": "engineering",
"role": "developer"
}
id
string
required

The ID of the user in your database. Must be a string.

Example:

"user-id"

tz
string | null

The user's timezone (used for email scheduling).

Example:

"Europe/London"