Skip to main content
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'
  }
});
{
  "id": "user-id",
  "email": "user@example.com",
  "name": "John Doe",
  "tz": "Europe/London",
  "deviceTokens": [
    "token1",
    "token2"
  ],
  "subscribeToEmails": true,
  "attributes": {
    "department": "engineering",
    "role": "developer"
  },
  "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

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

Example:

"user@example.com"

name
string

The name to refer to the user by in emails.

Example:

"User"

tz
string | null

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

Example:

"Europe/London"

deviceTokens
string[]

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

The device token.

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

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

Example:

true

attributes
object

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

Example:
{
"department": "engineering",
"role": "developer"
}

Response

Updated user

A user of your application.

id
string
required

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

Example:

"user-id"

email
string | null
required

The user's email address.

Example:

"user@example.com"

name
string | null
required

The name of the user.

Example:

"John Doe"

tz
string | null
required

The user's timezone.

Example:

"Europe/London"

deviceTokens
string[]
required

The user's device tokens.

The device token.

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

Whether the user is opted into receiving Trophy-powered emails.

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"
}
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"