Generate Delegation Token
Generate a single-use token to initiate wallet delegation (Step 1 of 3)
GET
Overview
This endpoint generates a single-use delegation token required to initiate the wallet delegation flow. This is Step 1 of a 3-step process that allows users to delegate spending authority from their non-custodial wallets to the platform for card payments.When to Use: Call this endpoint when a user initiates the delegation flow in your application. The returned token is required to finalize delegation in Step 3 after the user completes wallet connection and blockchain approval.
Delegation Workflow
The complete delegation process involves three steps:- Backend (This Endpoint): Request delegation token from API
- Frontend (Your Implementation): User connects wallet and approves blockchain transaction
- Backend: Submit delegation proof using blockchain-specific endpoint:
POST /v1/delegation/evm/post-approvalfor EVM chains (Linea/Ethereum)POST /v1/delegation/solana/post-approvalfor Solana
Authentication
string
required
Your public client key for API authentication
string
required
Bearer token format:
Bearer {access_token}Query Parameters
string
Region identifier for environment routing. Use
us for US-specific Linea routing.Example: ?region=usAlternatively, you can use the
x-us-env: true header instead of the region query parameter.Response
string
required
Single-use delegation token (UUID format). This token is used in Step 3 to finalize the delegation.Characteristics:
- Single-use only - becomes invalid after use in POST approval endpoint
- ~10 minute lifetime - complete the delegation flow before expiration
- Must be passed to your frontend for use after wallet connection
string
required
Unique nonce that must be included in the post-approval request. This nonce links the delegation token request to the final approval submission.Example:
5f8a9b2c4d3e1a7b9c6d8e2fImportant: Store this nonce alongside the token and pass both to your frontend. Both values are required when submitting the delegation proof in Step 3.Response Codes
Next Steps
After receiving the delegation token:- Store the token temporarily in your application state or session
- Pass it to your frontend where the user will connect their wallet
- Proceed to Step 2 - implement wallet connection UI (MetaMask, WalletConnect, Phantom, etc.)
- Complete Step 3 - submit delegation proof to the appropriate endpoint:
- POST /v1/delegation/evm/post-approval for EVM chains
- POST /v1/delegation/solana/post-approval for Solana
Token Characteristics
Implementation Example
Here’s a complete backend flow example:Python Backend Flow
Common Error Scenarios
Token Expiration
If the user takes longer than 10 minutes to complete the wallet connection and approval:Invalid Access Token
If the user’s access token is invalid or expired:Missing Authentication
If required headers are missing:x-client-key and Authorization headers are included.
Best Practices
Security Considerations
Security Considerations
- Never expose tokens to client-side logging - delegation tokens should be handled securely
- Use HTTPS only - all API communication must be encrypted
- Implement token cleanup - clear expired tokens from your storage
- Validate token format - ensure received token is a valid UUID before passing to frontend
Error Handling
Error Handling
- Implement retry logic with exponential backoff for network failures
- Handle token expiration gracefully - inform users they need to restart the flow
- Provide clear user feedback - explain why delegation failed and next steps
- Log errors appropriately - track failures for debugging without exposing sensitive data
User Experience
User Experience
- Display progress indicators - show users they’re on Step 1 of 3
- Set user expectations - inform users about the ~10 minute time limit
- Provide help documentation - link to guides explaining the delegation process
- Enable easy restart - if token expires, make it simple to generate a new one
Related Endpoints
- POST /v1/delegation/evm/post-approval - Complete EVM wallet delegation (Step 3)
- POST /v1/delegation/solana/post-approval - Complete Solana wallet delegation (Step 3)
- GET /v1/wallet/external - List delegated wallets
- Manage External Wallet Priority - Get and update wallet priority order
Further Reading
- Delegation Overview - Understand delegation concepts
- Implementation Guide - Complete integration walkthrough
- EVM Chains - EVM-specific implementation details
- Solana - Solana-specific implementation details