User

getUser

Arguments
Return
Example
Arguments

Name

Description

userId

string

The ID of the User to retrieve.

Return

Returns a promise that resolves to a User object.

Example
import { setClerkApiKey, users } from '@clerk/clerk-sdk-node';
// This is unnecessary if CLERK_API_KEY is set as
// an environment variable
setClerkApiKey("api-key")
userId = "user-id";
const user = await users.getUser(userId);

updateUser

Arguments
Return
Example
Arguments

Name

Description

userId

string

The ID of the User to retrieve.

attributes

See below.

Attributes that can be updated.

Name

Description

firstName

string

The user's first name.

lastName

string

The user's first name.

password

string

The user's password.

primaryEmailAddressID

string

The ID of the email address to set as primary.

primaryPhoneNumberID

string

The ID of the phone number to set as primary.

privateMetadata

{[string]: any}

Secure metadata that can only be accessed with your API key or from your Clerk Dashboard. The data is kept hidden from your frontend.

publicMetadata

{[string]: any}

Metadata that is accessible on your frontend with the useUser() hook and on window.Clerk.user.

Return

Returns a promise that resolves to a User object.

Example
import { setClerkApiKey, users } from '@clerk/clerk-sdk-node';
// This is unnecessary if CLERK_API_KEY is set as
// an environment variable
setClerkApiKey("api-key")
userId = "user-id";
try {
await users.updateUser(userId, {
publicMetadata: {foo: "bar"}
});
} catch (error) {
// handle error
}