The User API allows you to retrieve and update the current user’s profile information, manage tokens, view audit logs, and access billing and organization details.
Get user details
Retrieve details about the current user.
const user = await client.user.get();
console.log(user.first_name, user.last_name);
The country in which the user lives
The zipcode or postal code where the user lives
two_factor_authentication_enabled
Indicates whether two-factor authentication is enabled for the user account (does not apply to API authentication)
two_factor_authentication_locked
Indicates whether two-factor authentication is required by one of the accounts the user is a member of
Indicates whether user has any pro zones
Indicates whether user has any business zones
Indicates whether user has any enterprise zones
Indicates whether user has been suspended
Lists the betas that the user is participating in
Organizations the user belongs to
Update user details
Edit part of the user’s details.
const response = await client.user.edit({
first_name: 'Jane',
last_name: 'Doe',
telephone: '+1-555-1234',
country: 'US',
zipcode: '94107'
});
The country in which the user lives
The zipcode or postal code where the user lives
Sub-resources
The User resource provides access to several sub-resources:
Audit logs
Access user-level audit logs:
for await (const log of client.user.auditLogs.list()) {
console.log(log.action, log.when);
}
Billing
Access user billing information:
const profile = await client.user.billing.profiles.get({
account_id: 'account-id'
});
Invites
Manage user invitations:
for await (const invite of client.user.invites.list()) {
console.log(invite.status);
}
Organizations
Access user organizations:
for await (const org of client.user.organizations.list()) {
console.log(org.name);
}
Tokens
Manage API tokens:
const token = await client.user.tokens.create({
name: 'My API Token',
policies: [{
effect: 'allow',
resources: { '*': '*' },
permission_groups: [{
id: 'token_permissions_read'
}]
}]
});
Subscriptions
Manage user subscriptions:
const subscription = await client.user.subscriptions.update(
'subscription-id',
{ /* subscription params */ }
);