Initialization
Basic Initialization
Advanced Initialization
Step-by-Step Integration Guide
Step 1: Initialize the SDK
Ensure the SDK is properly initialized before using any methods:Step 2: Implement Account Linking
Step 3: Handle Authorization Callback
After the user authorizes access, they are redirected back to your callback URL. Handle the response to confirm consent:Step 4: Access Account Data
Once consent is granted, you can retrieve account information:Complete Example
Error Handling
Implement proper error handling for all SDK operations:Best Practices
User Experience
- Provide clear instructions for account linking
- Show loading states during API calls
- Handle errors gracefully with user-friendly messages
Security
- Never expose sensitive credentials in client-side code
- Validate all user inputs
- Use HTTPS for all communications
Performance
- Cache account data when appropriate
- Implement pagination for large datasets
- Minimize API calls by batching requests
API Reference
Account Class
Constructor
Methods
linkAccount(options)
Initiates account linking flow and redirects user to Token.io hosted page.
Parameters:
merchantId: string- Your merchant IDuserId: string- Customer’s user IDpermissions: string[]- Array of permission stringsauthorizationToken: string- Your API authorization token
Promise<AccountLinkingResponse>
getLinkedAccounts(options)
Retrieves user’s linked accounts.
Parameters:
merchantId: stringuserId: stringconsentId: string
Promise<Account[]>
getAccountBalance(options)
Gets balance for a specific account.
Parameters:
merchantId: stringuserId: stringaccountId: stringconsentId: string
Promise<Balance>
getAccountTransactions(options)
Retrieves transaction history for an account.
Parameters:
merchantId: stringuserId: stringaccountId: stringconsentId: stringpageLimit?: number
Promise<Transaction[]>
Types
AccountLinkingResponse
AccountLinkingOptions
Constants
ACCOUNT_PERMISSIONS
Predefined permission constants:
ACCOUNT_PERMISSIONS.READ_ACCOUNTS_DETAIL- “ReadAccountsDetail”ACCOUNT_PERMISSIONS.READ_BALANCES- “ReadBalances”ACCOUNT_PERMISSIONS.READ_TRANSACTIONS_DETAIL- “ReadTransactionsDetail”

