Users
Provision and manage users and memberships
Use the user client to provision people, manage organization memberships, and assign roles.
Common flows: invite or create a user, attach them to an organization, update profile fields, and look up users by Scalekit ID or your external ID.
createUserAndMembership
Section titled “createUserAndMembership”#asynccreateUserAndMembership
Creates a new user and adds them as a member of an organization in a single operation.
The organization ID to add the user to
Optional request settings.
The created resource.
const response = await scalekit.user.createUserAndMembership( 'org_123456', { email: 'john.doe@company.com', userProfile: { firstName: 'John', lastName: 'Doe' }, sendInvitationEmail: true, metadata: { department: 'Engineering' } });
console.log('User created:', response.user.id);getUser
Section titled “getUser”#asyncgetUser
Retrieves comprehensive details about a specific user including their profile and memberships.
Scalekit user ID (usr_...).
The user.
const response = await scalekit.user.getUser('usr_123456');const user = response.user;
console.log('User:', user.email);console.log('Name:', user.userProfile?.firstName, user.userProfile?.lastName);console.log('Organizations:', user.memberships?.length);listUsers
Section titled “listUsers”#asynclistUsers
Retrieves a paginated list of all users across your Scalekit environment.
Optional fields: pageSize, pageToken.
Paginated users.
// pageSize: Results per page (default 10, max 100)// pageToken: Token for the next pageconst response = await scalekit.user.listUsers({ pageSize: 20});
console.log('Users:', response.users.length);console.log('Total users:', response.totalSize);updateUser
Section titled “updateUser”#asyncupdateUser
Updates a user’s profile information and custom metadata.
The Scalekit user identifier (format: “usr_…”)
Fields to update.
The updated user.
// metadata: Custom key-value metadataconst response = await scalekit.user.updateUser('usr_123456', { userProfile: { firstName: 'John', lastName: 'Smith' }, metadata: { department: 'Engineering', title: 'Senior Developer' }});deleteUser
Section titled “deleteUser”#asyncdeleteUser
Permanently deletes a user from your Scalekit environment.
Scalekit user ID (usr_...).
Empty response on successful deletion
await scalekit.user.deleteUser('usr_123456');console.log('User deleted successfully');createMembership
Section titled “createMembership”#asynccreateMembership
Adds an existing user as a member of a new organization with specified roles.
Organization ID.
The user ID to add as a member (format: “usr_…”)
Optional fields: roles, metadata, sendInvitationEmail.
The created resource.
// roles: Assigned roles// sendInvitationEmail: send invitation emailconst response = await scalekit.user.createMembership( 'org_123456', 'usr_789012', { roles: ['admin'], sendInvitationEmail: true });deleteMembership
Section titled “deleteMembership”#asyncdeleteMembership
Removes a user’s membership from a specific organization.
Organization ID.
The user ID to remove (format: “usr_…”)
Empty response on successful removal
await scalekit.user.deleteMembership('org_123456', 'usr_789012');console.log('User removed from organization');updateMembership
Section titled “updateMembership”#asyncupdateMembership
Updates a user’s roles and metadata within a specific organization.
Organization ID.
Scalekit user ID (usr_...).
Optional fields: roles, metadata.
The updated resource.
// roles: Assigned rolesconst response = await scalekit.user.updateMembership( 'org_123456', 'usr_789012', { roles: ['admin'] });listOrganizationUsers
Section titled “listOrganizationUsers”#asynclistOrganizationUsers
Retrieves a paginated list of all users who are members of a specific organization.
Organization ID.
Optional fields: pageSize, pageToken.
Paginated users.
// pageSize: Results per page (default 10, max 100)// pageToken: Token for the next pageconst response = await scalekit.user.listOrganizationUsers('org_123456', { pageSize: 25});
console.log('Organization users:', response.users.length);console.log('Total members:', response.totalSize);resendInvite
Section titled “resendInvite”#asyncresendInvite
Resends an invitation email to a user for a specific organization.
The organization ID for which to resend the invite.
Scalekit user ID (usr_...).
Resend invite.
const response = await scalekit.user.resendInvite('org_123456', 'usr_789012');console.log('Invitation resent:', response.invite);listUserRoles
Section titled “listUserRoles”#asynclistUserRoles
Lists all roles assigned to a user within a specific organization.
Organization ID.
The user ID whose roles to list (format: “usr_…”)
Paginated roles.
listUserPermissions
Section titled “listUserPermissions”#asynclistUserPermissions
Lists all effective permissions for a user within a specific organization.
Organization ID.
Scalekit user ID (usr_...).
Paginated permissions.
searchUsers
Section titled “searchUsers”#asyncsearchUsers
Searches for users matching a query string across the environment.
Search query string
Optional. Number of results per page
Optional. Pagination token for the next page
Paginated results.
searchOrganizationUsers
Section titled “searchOrganizationUsers”#asyncsearchOrganizationUsers
Searches for users matching a query string within a specific organization.
The organization ID to search within
Search query string
Optional. Number of results per page
Optional. Pagination token for the next page
Paginated results.
assignUserRoles
Section titled “assignUserRoles”#asyncassignUserRoles
Assigns roles to a user within a specific organization.
The organization ID
The user ID to assign roles to
Array of role names to assign
Assign user roles.
removeUserRole
Section titled “removeUserRole”#asyncremoveUserRole
Removes a specific role from a user within an organization.
The organization ID
The user ID to remove the role from
The name of the role to remove
Empty response on success
getUserByExternalId
Section titled “getUserByExternalId”#asyncgetUserByExternalId
Retrieves a user by their external ID.
The external identifier for the user
The user.
updateUserByExternalId
Section titled “updateUserByExternalId”#asyncupdateUserByExternalId
Updates a user identified by their external ID.
The external identifier for the user
Fields to update.
The updated user.
deleteUserByExternalId
Section titled “deleteUserByExternalId”#asyncdeleteUserByExternalId
Permanently deletes a user identified by their external ID.
The external identifier for the user
Empty response on success
createMembershipByExternalId
Section titled “createMembershipByExternalId”#asynccreateMembershipByExternalId
Adds a user identified by external ID as a member of an organization.
The organization ID to add the user to
The external identifier for the user
Optional fields: roles, metadata, sendInvitationEmail.
The created resource.
deleteMembershipByExternalId
Section titled “deleteMembershipByExternalId”#asyncdeleteMembershipByExternalId
Removes the membership of a user identified by external ID from an organization.
The organization ID to remove the user from
The external identifier for the user
Empty response on success
updateMembershipByExternalId
Section titled “updateMembershipByExternalId”#asyncupdateMembershipByExternalId
Updates the membership of a user identified by external ID within an organization.
The organization ID where the membership exists
The external identifier for the user
Optional fields: roles, metadata.
The updated resource.