Skip to main content

Get a user with the Node.js SDK

permit.api.users.get() fetches one user, identified by key or ID, from the Permit.io environment that your Node.js SDK client is connected to. This reference is for backend developers who read user data from Permit, for example to check whether a user was synced.

Prerequisites

Method signature

MethodSignature
permit.api.users.getget(userKey: string): Promise<UserRead>

Parameters

NameTypeRequiredDescription
userKeystringYesKey or ID of the user to fetch.

Example

await permit.api.users.get(userKey);

Return value

The method resolves to a UserRead object with these fields:

FieldTypeDescription
keystringKey of the user.
idstringUnique ID of the user.
email, first_name, last_namestringProfile fields of the user, if set.
attributesobjectUser attributes.
rolesarrayRoles assigned to the user.
associated_tenantsarrayTenants the user belongs to.
organization_id, project_id, environment_idstringIDs of the organization, project, and environment of the user.
created_at, updated_atstringISO 8601 timestamps.

If the user doesn't exist or the Permit API returns another error status code, the method throws a PermitApiError.