- NodeJS
- NodeJS (server-auth)
- Java
- Rust
- REST API
You can create a user by calling the Refer to the API reference for more details on the available
parameters and returns.
.users().create() method on the PrivyClient.Report incorrect code
Copy
Ask AI
import {PrivyClient} from '@privy-io/node';
const privy = new PrivyClient({
appId: 'insert-your-app-id',
appSecret: 'insert-your-app-secret'
});
try {
const user = await privy.users().create({
linked_accounts: [{type: 'email', address: '[email protected]'}],
wallets: [{chain_type: 'ethereum'}],
custom_metadata: {key: 'value'}
});
} catch (error) {
console.error(error);
}
The
@privy-io/server-auth library is deprecated. We recommend integrating @privy-io/node for
the latest features and support.PrivyClient’s importUser method to create or import a single user into your Privy app.Report incorrect code
Copy
Ask AI
const user = await privy.importUser({
linkedAccounts: [
{
type: 'email',
address: '[email protected]'
}
],
wallets: [{chainType: "ethereum"}]
customMetadata: {
key: 'value'
}
});
Parameters
An array including all of the user’s linked accounts. These objects are in the same shape as the
linked accounts returned by
(See Discord docs)
(See Farcaster docs. Note that the Privy import interface differs slightly from the Farcaster public interface in order to maintain consistency with other Privy
(See GitHub docs)
(See Instagram docs)
(See Linkedin docs)
While
(See Spotify docs)
(See Telegram docs)
(See Twitter docs)
getUser. For
each linked account, you must specify the type and must not include a verifiedAt timestamp.LinkedAccount types
LinkedAccount types
AppleAccount
AppleAccount
| Field | Type | Description |
|---|---|---|
type | 'apple_oauth' | N/A |
email | string | Email address associated with the user’s Apple account. |
subject | number | ID of user from Apple’s user API. |
CustomJwtAccount
CustomJwtAccount
| Field | Type | Description |
|---|---|---|
type | 'custom_auth' | N/A |
API: custom_user_id SDK: customUserId | string | ID of user from custom auth provider. |
DiscordAccount
DiscordAccount
| Field | Type | Description |
|---|---|---|
type | 'discord_oauth' | N/A |
subject | string | ID of user from Discord user API response. |
email | string | Email of user from Discord user API response |
username | string | Username of user from Discord user API response. Include the 4-digit discriminator prefixed by ’#’. |
EmailAccount
EmailAccount
| Field | Type | Description |
|---|---|---|
type | 'email' | N/A |
address | string | Email address of user account. |
FarcasterAccount
FarcasterAccount
| Field | Type | Description |
|---|---|---|
type | 'farcaster' | N/A |
fid | number | FID of the user from Farcaster user API response. |
API: owner_address SDK: ownerAddress | string | Wallet address of the user from Farcaster user API response. Note that this is the Farcaster wallet address, and not the Privy embedded wallet address. |
username | string | (Optional) Username of user from Farcaster user API response. Do not include the ’@’. |
API: display_name SDK: displayName | string | (Optional) Display name of user from Farcaster user API response. |
bio | string | (Optional) Bio of user from Farcaster user API response. |
API: profile_picture_url SDK: profilePictureUrl | string | (Optional) Profile picture URL of the user from Farcaster user API response. Must be a valid image URL. |
API: homepage_url SDK: homepageUrl | string | (Optional) Profile URL of the user from Farcaster user API response. |
LinkedAccount types.)GithubAccount
GithubAccount
| Field | Type | Description |
|---|---|---|
type | 'github_oauth' | N/A |
subject | string | ID of user from GitHub user API response. |
email | string | Email of user from GitHub user API response |
name | string | Name of user from GitHub user API response |
username | string | Username of user from GitHub user API response |
GoogleAccount
GoogleAccount
| Field | Type | Description |
|---|---|---|
type | 'google_oauth' | N/A |
subject | string | sub pulled from Google-provided JWT with “openid” scope. |
email | string | email from Google-provided JWT with “email” scope. |
name | string | name from Google-provided JWT with “profile” scope. |
InstagramAccount
InstagramAccount
| Field | Type | Description |
|---|---|---|
type | 'instagram_oauth' | N/A |
subject | string | ID of user from Instagram user API response. |
username | string | The name displayed on a user’s profile from Instagram’s /me API response. |
LinkedinAccount
LinkedinAccount
| Field | Type | Description |
|---|---|---|
type | 'linkedin_oauth' | N/A |
subject | string | ID of user from LinkedIn user API response. |
email | string | Email of user from LinkedIn user API response |
name | string | Name of user from LinkedIn user API response. Do not include the ’@’. |
PhoneAccount
PhoneAccount
| Field | Type | Description |
|---|---|---|
type | 'phone' | N/A |
number | string | Phone number of user account (non-international numbers default to US). |
number is accepted as input, phoneNumber is returned in the response.SpotifyAccount
SpotifyAccount
| Field | Type | Description |
|---|---|---|
type | 'spotify_oauth' | N/A |
subject | string | ID of user from Spotify user API response. |
email | string | Email of user from Spotify user API. |
name | string | The name displayed on a user’s profile from Spotify display_name API response. |
TelegramAccount
TelegramAccount
| Field | Type | Description |
|---|---|---|
type | 'telegram' | N/A |
telegramUserId | string | ID of a user’s telegram account. |
firstName | string | The first name displayed on a user’s telegram account. |
lastName | string | (Optional) The last name displayed on a user’s telegram account. |
username | string | (Optional) The username displayed on a user’s telegram account. |
photo_url | string | (Optional) The url of a user’s telegram account profile picture. |
TwitterAccount
TwitterAccount
| Field | Type | Description |
|---|---|---|
type | 'twitter_oauth' | N/A |
subject | string | ID of user from Twitter user API response. |
name | string | Name of user from Twitter user API response |
username | string | Username of user from Twitter user API response. Do not include the ’@’. |
API: profile_picture_url<br/>SDK: profilePictureUrl | string | (Optional) Profile picture URL of the user from Twitter user API response. Must be a valid image URL. |
SmartWalletAccount
SmartWalletAccount
| Field | Type | Description |
|---|---|---|
type | 'smart_wallet' | N/A |
address | string | Checksummed smart wallet address. |
smart_wallet_type | SmartWalletType | One of 'kernel', 'safe', 'biconomy', 'thirdweb', 'light_account' or 'coinbase_smart_wallet' |
WalletAccount
WalletAccount
| Field | Type | Description |
|---|---|---|
type | 'wallet' | N/A |
API:chain_type SDK: chainType | 'ethereum' | 'solana' | Type of chain for the wallet. EVM chains ('ethereum') and Solana ('solana') are currently supported. |
address | string | Checksummed wallet address. |
An object containing any custom metadata you want to associate with the user. This metadata will
be returned in the user object when the user logs in.
(Optional) An array of wallets to create for the user.
Hide child attributes
Hide child attributes
chainType
'ethereum' | 'solana' | 'stellar' | 'cosmos' | 'sui' | 'tron' | 'bitcoin-segwit' | 'near' | 'ton' | 'starknet' | 'aptos'
required
The chain type of the wallet to create.
Set to
true to create a smart wallet with the user’s wallet as the signer. Can only be set
on wallets where chainType is ethereum.You can create a user by calling the
.users().create() method on the PrivyClient.Report incorrect code
Copy
Ask AI
try {
List<LinkedAccountInput> createUserLinkedAccounts = List.of(
LinkedAccountInput.email("[email protected]")
);
Map<String, CustomMetadata> customMetadata = Map.of("username", CustomMetadata.of("name"));
// Pregenerate an Ethereum wallet for the user
List<UserWalletRequest> wallets = List.of(
UserWalletRequest.builder()
.chainType(WalletChainType.ETHEREUM)
.build()
);
UserCreateRequestBody requestBody = UserCreateRequestBody.builder()
.linkedAccounts(createUserLinkedAccounts)
.customMetadata(customMetadata)
.wallets(wallets)
.build();
UserCreateResponse response = privyClient
.users()
.create(requestBody);
if (response.user().isPresent()) {
User user = response.user().get();
}
} catch (APIException e) {
String errorBody = e.bodyAsString();
System.err.println(errorBody);
} catch (Exception e) {
System.err.println(e.getMessage());
}
Parameters
You can specify the following values on theUserCreateRequestBody builder:A list of linked accounts to create for the user.
An object containing any custom metadata you want to associate with the user. This metadata will
be returned in the user object when the user logs in.
A list of wallets to create for the user.
Returns
TheUserCreateResponse object contains an optional user() field, present if the user was created successfully.The created
User object. See the user object for more
details.You can create a user by calling the
.users().create() method on the PrivyClient.Report incorrect code
Copy
Ask AI
use privy_rs::{PrivyClient, generated::types::*};
use std::collections::HashMap;
let client = PrivyClient::new(app_id, app_secret)?;
// Create custom metadata with proper typing
let mut metadata_map = HashMap::new();
metadata_map.insert("key".to_string(), CustomMetadataValue::String("value".to_string()));
let custom_metadata = CustomMetadata::from(metadata_map);
let user = client
.users()
.create(&CreateUserBody {
linked_accounts: vec![
LinkedAccountInput::EmailInput(LinkedAccountEmailInput {
address: "[email protected]".to_string(),
type_: LinkedAccountEmailInputType::Email,
}),
],
wallets: vec![
CreateWalletBody {
chain_type: WalletChainType::Ethereum,
additional_signers: None,
owner: None,
owner_id: None,
policy_ids: vec![],
},
],
custom_metadata: Some(custom_metadata),
})
.await?;
println!("Created user: {}", user.id);
Parameters and Returns
See the Rust SDK documentation for detailed parameter and return types, including embedded examples:For REST API details, see the API reference.Make a Below is a sample cURL command for creating a new user:A successful response will include the new user object along with their DID:
POST request to:Report incorrect code
Copy
Ask AI
https://auth.privy.io/api/v1/users
Report incorrect code
Copy
Ask AI
$ curl --request POST https://auth.privy.io/api/v1/users \
-u "<your-privy-app-id>:<your-privy-app-secret>" \
-H "privy-app-id: <your-privy-app-id>" \
-H 'Content-Type: application/json' \
-d '{
"linked_accounts": [
{
"address": "[email protected]",
"type": "email"
}
]
}'
Parameters
An array including all of the user’s linked accounts. These objects are in the same shape as the
linked accounts returned by
getUser. For
each linked account, you must specify the type and must not include a verifiedAt timestamp.An object containing any custom metadata you want to associate with the user. This metadata will
be returned in the user object when the user logs in.
(Optional) An array of wallets to create for the user.
Hide child attributes
Hide child attributes
chainType
'ethereum' | 'solana' | 'stellar' | 'cosmos' | 'sui' | 'tron' | 'bitcoin-segwit' | 'near' | 'ton' | 'starknet' | 'aptos'
required
The chain type of the wallet to create.
List of policy IDs for policies that should be enforced on the wallet. Currently, only one
policy is supported per wallet.
Set to
true to create a smart wallet with the user’s wallet as the signer. Can only be set
on wallets where chainType is ethereum.Report incorrect code
Copy
Ask AI
{
"id": "did:privy:clddy332f002tyqpq3b3lv327",
"created_at": 1674788927,
"linked_accounts": [
{
"address": "[email protected]",
"type": "email",
"verified_at": 1674788927
}
]
}
User creation endpoints have a rate limit of 240 users in total per minute. If you are being rate
limited, responses will have status code 429. We suggest you set up exponential back-offs starting
at 1 second to seamlessly recover.

