Search…
User

getUser

Arguments
Return
Example
Name
Description
userId
string
The ID of the User to retrieve.
Returns a promise that resolves to a User object.
1
import { setClerkApiKey, users } from '@clerk/clerk-sdk-node';
2
3
// This is unnecessary if CLERK_API_KEY is set as
4
// an environment variable
5
setClerkApiKey("api-key")
6
7
userId = "user-id";
8
const user = await users.getUser(userId);
Copied!

updateUser

Arguments
Return
Example
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.
Returns a promise that resolves to a User object.
1
import { setClerkApiKey, users } from '@clerk/clerk-sdk-node';
2
3
// This is unnecessary if CLERK_API_KEY is set as
4
// an environment variable
5
setClerkApiKey("api-key")
6
7
userId = "user-id";
8
try {
9
await users.updateUser(userId, {
10
publicMetadata: {foo: "bar"}
11
});
12
} catch (error) {
13
// handle error
14
}
Copied!
Last modified 1mo ago
Copy link
Edit on GitHub