Represents a user identity in your application. A user can sign up in your application directly with a method like password, or they can be JIT-provisioned through an organization’s SSO connection.
Users may belong to organizations as members.
See the events reference documentation for the user events.
const user = { object: 'user', id: 'user_01E4ZCR3C56J083X43JQXF3JK5', email: 'marcelina.davis@example.com', firstName: 'Marcelina', lastName: 'Davis', emailVerified: true, profilePictureUrl: 'https://workoscdn.com/images/v1/123abc', lastSignInAt: '2021-06-25T19:07:33.155Z', externalId: 'f1ffa2b2-c20b-4d39-be5c-212726e11222', metadata: { timezone: 'America/New_York', }, createdAt: '2021-06-25T19:07:33.155Z', updatedAt: '2021-06-25T19:07:33.155Z', };
interface UserGet the details of an existing user.
import { WorkOS } from '@workos-inc/node'; const workos = new WorkOS('sk_example_123456789'); const user = await workos.userManagement.getUser( 'user_01E4ZCR3C56J083X43JQXF3JK5', );
Get the details of an existing user by an external identifier.
import { WorkOS } from '@workos-inc/node'; const workos = new WorkOS('sk_example_123456789'); const user = await workos.userManagement.getUserByExternalId( 'f1ffa2b2-c20b-4d39-be5c-212726e11222', );
Get a list of all of your existing users matching the criteria specified.
import { WorkOS } from '@workos-inc/node'; const workos = new WorkOS('sk_example_123456789'); const users = await workos.userManagement.listUsers(); console.log(users.data);
userManagement .listUsers()Parameters objectReturns objectCreate a new user in the current environment.
import { WorkOS } from '@workos-inc/node'; const workos = new WorkOS('sk_example_123456789'); const user = await workos.userManagement.createUser({ email: 'marcelina@example.com', password: 'i8uv6g34kd490s', firstName: 'Marcelina', lastName: 'Davis', });
Updates properties of a user. The omitted properties will be left unchanged.
import { WorkOS } from '@workos-inc/node'; const workos = new WorkOS('sk_example_123456789'); const user = await workos.userManagement.updateUser({ userId: 'user_01EHQ7ZGZ2CZVQJGZ5ZJZ1ZJGZ', firstName: 'Marcelina', lastName: 'Davis', emailVerified: true, externalId: '2fe01467-f7ea-4dd2-8b79-c2b4f56d0191', metadata: { timezone: 'America/New_York', }, });
Permanently deletes a user in the current environment. It cannot be undone.
import { WorkOS } from '@workos-inc/node'; const workos = new WorkOS('sk_example_123456789'); await workos.userManagement.deleteUser('user_01F3GZ5ZGZBZVQGZVHJFVXZJGZ');
userManagement .deleteUser()Parameters