Clerk logo

Clerk Docs

Ctrl + K
Go to clerk.devGet API keys

User

updateUser

Arguments

NameTypeDescription
userId string

The ID of the User to retrieve.

attributes

Attributes that can be updated. See below.

firstNamestring

The user's first name.

lastNamestring

The user's first name.

passwordstring

The user's password.

primaryEmailAddressIDprimaryEmailAddressID string

The ID of the email address to set as primary.

primaryPhoneNumberIDstring

The ID of the phone number to set as primary.

privateMetadataprivateMetadata {[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";
const user = await users.getUser(userId);

getUser

Arguments

NameTypeDescription
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";
try {
await users.updateUser(userId, {
publicMetadata: {foo: "bar"}
});
} catch (error) {
// handle error
}

Was this helpful?

Clerk © 2022