Node.js/JavaScript SDK
Our official Node.js SDK simplifies integration with the Carbon Business API, providing TypeScript support and comprehensive error handling.Installation
Install the SDK via npm:Requires Node.js 14.0 or higher for optimal compatibility.
Configuration
Initialize the SDK with your API key and environment mode.Always use environment variables to store your API keys securely. Never hardcode them in your source code.
Environment Setup
CommonJS Example
ES6/TypeScript Example
Core Operations
Account Management
Create Collection Account
Create Collection Account
Create Customer-Linked Account
Create Customer-Linked Account
Fetch Account Details
Fetch Account Details
Check Account Balance
Check Account Balance
Payouts
Validate Beneficiary Account
Validate Beneficiary Account
Create Payout
Create Payout
Track Payout Status
Track Payout Status
Transaction Management
Fetch Transactions
Fetch Transactions
Verify Transaction
Verify Transaction
Error Handling
Implement robust error handling for production applications:Best Practices
Environment Configuration
Environment Configuration
- Use environment variables for API keys and configuration
- Never commit sensitive credentials to version control
- Use different API keys for sandbox and live environments
Error Handling
Error Handling
- Always implement try-catch blocks for async operations
- Log errors appropriately for debugging
- Provide meaningful error messages to users
Reference Generation
Reference Generation
- Use unique, timestamp-based references for payouts
- Keep references under 30 characters
- Include identifiable prefixes for easier tracking
Rate Limiting
Rate Limiting
- Implement retry logic with exponential backoff
- Monitor API usage to stay within limits
- Cache frequently accessed data when appropriate
Webhook Integration
Handle webhook events for real-time notifications:Troubleshooting
Authentication Issues
Authentication Issues
Network Errors
Network Errors
Implement retry logic for network failures and timeout errors.
Validation Errors
Validation Errors
Check that all required fields are provided and account numbers are valid before making API calls.
Additional Resources
- Payment Operations Guide - Complete workflow examples
- Webhook Documentation - Real-time event handling
- API Reference - Detailed endpoint documentation
- Environment Setup - Sandbox vs Live configuration
For other programming languages or framework-specific integrations, please contact our support team at sme@getcarbon.co.