Overview
The End User API allows you to create and manage end users who can own CDP EVM accounts, EVM smart accounts, and Solana accounts. End users can authenticate using various methods including email, SMS, and external wallets.
EndUserAccount Type
type EndUserAccount = {
userId : string ;
authenticationMethods : AuthenticationMethod [];
evmAccounts ?: EvmAccount [];
evmSmartAccounts ?: EvmSmartAccount [];
solanaAccounts ?: SolanaAccount [];
createdAt : string ;
updatedAt : string ;
addEvmAccount : () => Promise < AddEndUserEvmAccountResult >;
addEvmSmartAccount : ( options : AddEvmSmartAccountOptions ) => Promise < AddEndUserEvmSmartAccountResult >;
addSolanaAccount : () => Promise < AddEndUserSolanaAccountResult >;
};
Unique identifier for the end user.
authenticationMethods
AuthenticationMethod[]
required
Array of authentication methods configured for the user.
Array of EVM EOA accounts owned by the user (max 10).
Array of EVM smart accounts owned by the user.
Array of Solana accounts owned by the user (max 10).
ISO 8601 timestamp when the user was created.
ISO 8601 timestamp when the user was last updated.
Authentication Methods
Email Authentication
type EmailAuthMethod = {
type : "email" ;
email : string ;
};
SMS Authentication
type SmsAuthMethod = {
type : "sms" ;
phoneNumber : string ;
};
CDPEndUserClient Methods
createEndUser
Creates a new end user with authentication methods.
Custom user ID (UUID generated if not provided).
authenticationMethods
AuthenticationMethod[]
required
Array of authentication methods.
Options for creating an EVM account. Whether to create a smart account (true) or EOA (false).
Enable spend permissions (smart accounts only).
Whether to create a Solana account.
// Create end user with email authentication
const endUser = await cdp . endUser . createEndUser ({
authenticationMethods: [
{ type: "email" , email: "[email protected] " },
],
});
// Create with EVM EOA account
const endUserWithEOA = await cdp . endUser . createEndUser ({
authenticationMethods: [
{ type: "email" , email: "[email protected] " },
],
evmAccount: {
createSmartAccount: false ,
},
});
// Create with EVM smart account and spend permissions
const endUserWithSmartAccount = await cdp . endUser . createEndUser ({
authenticationMethods: [
{ type: "sms" , phoneNumber: "+12055555555" },
],
evmAccount: {
createSmartAccount: true ,
enableSpendPermissions: true ,
},
});
getEndUser
Retrieves an end user by their ID.
const endUser = await cdp . endUser . getEndUser ({
userId: "user-123" ,
});
console . log ( endUser . evmAccounts );
console . log ( endUser . evmSmartAccounts );
console . log ( endUser . solanaAccounts );
listEndUsers
Lists all end users in the project.
Number of users per page (default: 20).
Array of sort criteria (e.g., [“createdAt=desc”]).
// List all end users
const result = await cdp . endUser . listEndUsers ();
// With pagination
let page = await cdp . endUser . listEndUsers ({ pageSize: 10 });
while ( page . nextPageToken ) {
page = await cdp . endUser . listEndUsers ({
pageSize: 10 ,
pageToken: page . nextPageToken ,
});
}
// With sorting
const result = await cdp . endUser . listEndUsers ({
sort: [ "createdAt=desc" ],
});
importEndUser
Imports an end user with an existing private key.
Custom user ID (UUID generated if not provided).
authenticationMethods
AuthenticationMethod[]
required
Array of authentication methods.
privateKey
string | Uint8Array
required
The private key to import (hex for EVM, base58 for Solana).
The type of key being imported.
Optional RSA public key for encryption.
// Import EVM private key
const endUser = await cdp . endUser . importEndUser ({
authenticationMethods: [
{ type: "email" , email: "[email protected] " },
],
privateKey: "0x1234567890123456789012345678901234567890123456789012345678901234" ,
keyType: "evm" ,
});
// Import Solana private key
const solanaEndUser = await cdp . endUser . importEndUser ({
authenticationMethods: [
{ type: "sms" , phoneNumber: "+12055555555" },
],
privateKey: "3Kzj..." , // base58 encoded
keyType: "solana" ,
});
addEndUserEvmAccount
Adds an EVM EOA account to an existing end user.
The created EVM account details.
const result = await cdp . endUser . addEndUserEvmAccount ({
userId: "user-123" ,
});
console . log ( result . evmAccount . address );
addEndUserEvmSmartAccount
Adds an EVM smart account to an existing end user.
Whether to enable spend permissions.
The created smart account details.
const result = await cdp . endUser . addEndUserEvmSmartAccount ({
userId: "user-123" ,
enableSpendPermissions: true ,
});
console . log ( result . evmSmartAccount . address );
console . log ( result . evmAccount . address ); // Owner account
addEndUserSolanaAccount
Adds a Solana account to an existing end user.
The created Solana account details.
const result = await cdp . endUser . addEndUserSolanaAccount ({
userId: "user-123" ,
});
console . log ( result . solanaAccount . address );
validateAccessToken
Validates an end user’s access token.
The access token to validate.
The end user if token is valid.
try {
const endUser = await cdp . endUser . validateAccessToken ({
accessToken: "token-from-client" ,
});
console . log ( "Valid user:" , endUser . userId );
} catch ( error ) {
console . error ( "Invalid token" );
}
EndUserAccount Methods
These methods are available directly on EndUserAccount objects:
addEvmAccount
Adds an EVM EOA account to this end user.
const endUser = await cdp . endUser . getEndUser ({ userId: "user-123" });
const result = await endUser . addEvmAccount ();
console . log ( result . evmAccount . address );
addEvmSmartAccount
Adds an EVM smart account to this end user.
Whether to enable spend permissions.
const result = await endUser . addEvmSmartAccount ({
enableSpendPermissions: true ,
});
console . log ( result . evmSmartAccount . address );
addSolanaAccount
Adds a Solana account to this end user.
const result = await endUser . addSolanaAccount ();
console . log ( result . solanaAccount . address );
Complete Example
import { CdpClient } from "@coinbase/cdp-sdk" ;
const cdp = new CdpClient ();
// Create end user with email auth
const endUser = await cdp . endUser . createEndUser ({
authenticationMethods: [
{ type: "email" , email: "[email protected] " },
],
});
console . log ( "User ID:" , endUser . userId );
// Add EVM EOA account
const evmResult = await endUser . addEvmAccount ();
console . log ( "EVM Address:" , evmResult . evmAccount . address );
// Add EVM smart account
const smartResult = await endUser . addEvmSmartAccount ({
enableSpendPermissions: true ,
});
console . log ( "Smart Account:" , smartResult . evmSmartAccount . address );
// Add Solana account
const solResult = await endUser . addSolanaAccount ();
console . log ( "Solana Address:" , solResult . solanaAccount . address );
// Retrieve updated user
const updatedUser = await cdp . endUser . getEndUser ({
userId: endUser . userId ,
});
console . log ( "Total EVM accounts:" , updatedUser . evmAccounts ?. length );
console . log ( "Total smart accounts:" , updatedUser . evmSmartAccounts ?. length );
console . log ( "Total Solana accounts:" , updatedUser . solanaAccounts ?. length );
Account Limits
Maximum 10 EVM EOA accounts per end user
Maximum 10 Solana accounts per end user
No limit on EVM smart accounts