Skip to main content
The Carbon Business API SDKs provide a convenient way to integrate with our platform, offering pre-built functions for common operations like account creation, payouts, and transaction management.

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

Payouts

Transaction Management

Error Handling

Implement robust error handling for production applications:

Best Practices

  • Use environment variables for API keys and configuration
  • Never commit sensitive credentials to version control
  • Use different API keys for sandbox and live environments
  • Always implement try-catch blocks for async operations
  • Log errors appropriately for debugging
  • Provide meaningful error messages to users
  • Use unique, timestamp-based references for payouts
  • Keep references under 30 characters
  • Include identifiable prefixes for easier tracking
  • 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

Ensure you’re using the correct API key for your environment (sandbox vs live).
Implement retry logic for network failures and timeout errors.
Check that all required fields are provided and account numbers are valid before making API calls.

Additional Resources

For other programming languages or framework-specific integrations, please contact our support team at sme@getcarbon.co.