To import an existing user, Privy allows you to create a user with their linked accounts (wallet, email, etc.) as part of the user creation request. You can also generate a wallet when you create a user.
When the user logs in, all of their linked accounts will be included in the user object. If the user has a pregenerated embedded wallet, that wallet will be available to the user upon sign in.
NodeJS
NodeJS (server-auth)
Java
Rust
REST API
You can create a user by calling the .users().create()
method on the PrivyClient
.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);
}
Refer to the API reference for more details on the available
parameters and returns.
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.