Server-side SDKs (Beta)
Learn how to install and use Airwallex's server-side SDKs
Airwallex currently provides server-side SDK support through its Node.js SDK (Beta).
@airwallex/node-sdk
is a TypeScript-first SDK designed for integrating with the Airwallex platform APIs using Node.js. It includes features such as strongly-typed request and response models, built-in error handling, automatic retries, token refresh, and support for custom requests across all Airwallex services — including payment acceptance, issuing, accounts, payouts, and more.
The SDK is currently in Beta and supports API versions from 2025-02-14
onwards. You don’t need to update to the latest SDK versions unless you are adopting a new major API version.
During the Beta phase, we plan to release updates alongside new Client API versions or to deliver patch fixes. We’ll continue refining the SDK during this period to improve stability, and will release a stable version once it’s ready.
Minimum requirements
- Node.js: 14.x
- TypeScript: 4.5x
Installation and setup
Install the package using npm, yarn or pnpm.
Bash1# npm2npm install @airwallex/node-sdk@beta34# yarn5yarn add @airwallex/node-sdk@beta67# pnpm8pnpm install @airwallex/node-sdk@beta
After completing the installation, you will need to initialize the SDK. The SDK can be configured with the following options:
JavaScript1import { Airwallex } from '@airwallex/node-sdk';23const client = new Airwallex({4 // Required fields5 clientId: 'your_client_id', // Your Airwallex API client ID6 apiKey: 'your_api_key', // Your Airwallex API key78 // Optional fields with defaults9 env: 'demo', // API environment: 'demo','prod'10 apiVersion: '2025-02-14', // API version (default: '2025-02-14')11 timeout: 30000, // Request timeout in milliseconds (default: 30000)12 retry: 3, // Number of retry attempts for failed requests (default: 3)13});
Configuration Options
Option | Type | Required | Default | Description |
---|---|---|---|---|
clientId | string | Yes | - | Your Airwallex API client ID. |
apiKey | string | Yes | - | Your Airwallex API key. |
env | string | No | demo | API environment: demo or production |
apiVersion | string | No | 2025-02-14 | API version |
timeout | number | No | 30000 | Request timeout in milliseconds |
enableTelemetry | boolean | No | true | Enable usage analytics |
retry | number | No | 1 | Number of retry attempts for failed requests |
API requests
The following sample requests show how to manipulate Airwallex API resources using Node.js SDK.
Example: Creating a card
JavaScript1// Create a new card2const newCard = await airwallex.issuing.cards.createCard({3 authorization_controls: {4 allowed_merchant_categories: ["7531"],5 allowed_transaction_count: "SINGLE",6 transaction_limits: {7 cash_withdrawal_limits: [8 {9 amount: 1000,10 interval: "PER_TRANSACTION"11 }12 ],13 currency: "USD",14 limits: [15 {16 amount: 1000,17 interval: "PER_TRANSACTION"18 }19 ]20 }21 },22 created_by: "John Smith",23 form_factor: "VIRTUAL",24 note: "API SDK Test",25 request_id: generateRequestId(),26 cardholder_id: "ef2ba01c-50a2-44e9-ae06-6114d92a9b63",27 is_personalized: false,28 program: {29 purpose: "COMMERCIAL"30 }31});3233console.log('Card created:', newCard);
Example: Update a card
JavaScript1// Update a card status2const updatedCard = await airwallex.issuing.cards.updateCard(cards!.items[0].card_id, {3 card_status: 'SUSPENDED',4 reason: 'Temporary suspension for testing',5 });6 console.log(`Card updated:`, updatedCard);
Example: Retrieving Cards
JavaScript12// Get active cards3const cards = await airwallex.issuing.cards.getCards({card_status: 'ACTIVE'});4console.log('Active cards:', cards);56// Get a specific card by ID7const cardId = 'card_12345678';8const cardDetails = await airwallex.issuing.cards.getCardById(cardId);9console.log('Card details:', cardDetails);
Example: Set custom headers and/or timeout for a request
JavaScript1const cards = await airwallex.issuing.cards.getCards(2 {3 card_status: 'ACTIVE'4 },5 {6 headers: {7 ‘custom-header1’: ‘value1’8 },9 timeout: 5000010 });
Example: Pagination requests
Right now the SDK doesn’t provide native support for pagination requests. But we can pass the pagination parameters for the requests.
JavaScript1import { Airwallex, IssuingNonPciCardSummaryDto } from ‘@airwallex/node-sdk’;23// Get all active cards4const PAGE_SIZE = 10;5const all_cards: IssuingNonPciCardSummaryDto[] = [];6let page_num = 0;7let has_more = false;8while (has_more) {9 const cards = await airwallex.issuing.cards.getCards({card_status: 'ACTIVE', page_num: page_num, page_size: PAGE_SIZE});10 all_cards.push(...cards.items);11 has_more = cards.has_more;12 page_num++;13}1415console.log('Active cards:', all_cards);
Example: Processing Payments
JavaScript1// Create a payment intent2const paymentIntent = await airwallex.paymentAcceptance.paymentIntents.create({3 request_id: generateRequestId(),4 amount: 10.99,5 currency: 'USD',6 merchant_order_id: 'order_12345',7 descriptor: 'Your Company Name',8 return_url: 'https://your-website.com/return',9 source: {10 type: 'card',11 card: {12 number: '4012000033330026',13 expiry_month: '12',14 expiry_year: '2025',15 cvc: '123',16 name: 'John Smith'17 }18 }19});2021console.log('Payment intent created:', paymentIntent);2223// Confirm the payment intent24const confirmedPayment = await airwallex.paymentAcceptance.paymentIntents.confirm(25 paymentIntent.id,26 {27 request_id: generateRequestId(),28 return_url: 'https://your-website.com/return?payment_confirmed=true'29 }30);3132console.log('Payment confirmed:', confirmedPayment);
Custom API Requests
For API endpoints not explicitly covered by the SDK, you can use the generic request methods:
JavaScript1// GET request2const response = await airwallex.get('/api/v1/custom/endpoint', {3 params: {4 param1: value1,5 …6 },7 headers: {8 header1: value1,9 …10 }11});1213// POST request14const createResponse = await airwallex.post('/api/v1/custom/endpoint', {15 name: 'Test Resource',16 amount: 1000,17 currency: 'USD'18}, {19 headers: {20 header1: value1,21 …22 }23});
API responses
The SDK returns a response for every API request. When you create, retrieve, or update an object, the response contains the object itself, including all relevant fields.
Example: Retrieve cards
JSON1Cards: {2 has_more: true,3 items: [4 {5 brand: 'VISA',6 card_id: '84fac3a5-97a3-46ad-97d6-849153ff8252',7 card_number: '************3717',8 card_status: 'ACTIVE',9 cardholder_id: 'c821f1e3-bf71-4f88-b928-e44f1f946995',10 created_at: '2025-01-02T01:28:33.558+0000',11 nick_name: 'Adell',12 updated_at: '2025-01-02T01:28:35.093+0000'13 },14 {15 brand: 'VISA',16 card_id: 'f0651ef4-dbca-4e3d-8eb7-86990464b6c3',17 card_number: '************5225',18 card_status: 'ACTIVE',19 cardholder_id: 'c821f1e3-bf71-4f88-b928-e44f1f946995',20 created_at: '2025-01-02T01:28:44.562+0000',21 nick_name: 'Adrien',22 updated_at: '2025-01-02T01:28:45.141+0000'23 },24 {25 brand: 'VISA',26 card_id: '9a36106a-c486-49c1-8e00-c822c3544d34',27 card_number: '************9114',28 card_status: 'ACTIVE',29 cardholder_id: 'c821f1e3-bf71-4f88-b928-e44f1f946995',30 created_at: '2025-01-02T01:29:47.590+0000',31 nick_name: 'Savannah',32 updated_at: '2025-01-02T01:29:47.943+0000'33 },34 {35 brand: 'VISA',36 card_id: 'eaa0df13-ffed-4aa6-a753-86f82fa2e8da',37 card_number: '************7745',38 card_status: 'ACTIVE',39 cardholder_id: 'c821f1e3-bf71-4f88-b928-e44f1f946995',40 created_at: '2025-01-02T02:05:38.732+0000',41 nick_name: 'Mercedes',42 updated_at: '2025-01-02T02:05:39.068+0000'43 }44 ]45}4647Card: {48 all_card_versions: [49 {50 card_number: '************3717',51 card_status: 'ACTIVE',52 card_version: 1,53 created_at: '2025-01-02T01:28:33.558+0000'54 }55 ],56 authorization_controls: {57 allowed_currencies: [],58 allowed_merchant_categories: [],59 allowed_transaction_count: 'MULTIPLE',60 blocked_transaction_usages: [],61 transaction_limits: {62 cash_withdrawal_limits: [Array],63 currency: 'USD',64 limits: [Array]65 }66 },67 brand: 'VISA',68 card_id: '84fac3a5-97a3-46ad-97d6-849153ff8252',69 card_number: '************3717',70 card_status: 'ACTIVE',71 card_version: 1,72 cardholder_id: 'c821f1e3-bf71-4f88-b928-e44f1f946995',73 created_at: '2025-01-02T01:28:33.558+0000',74 created_by: 'card creator from e2e test',75 delivery_details: {76 delivery_mode: 'MAIL',77 delivery_vendor: 'DHL',78 status: 'PRINTED',79 tracked: true,80 tracking_link: 'https://www.dhl.com/global-en/home/tracking/tracking-parcel.html?submit=1&tracking-id=ABCD1234',81 tracking_number: 'ABCD1234',82 updated_at: '2025-04-01T00:00:00.000+0000'83 },84 form_factor: 'VIRTUAL',85 is_personalized: false,86 name_on_card: 'Tom John',87 nick_name: 'Adell',88 note: 'client note for the card',89 program: { purpose: 'COMMERCIAL', type: 'DEBIT' },90 purpose: 'BUSINESS_EXPENSES',91 request_id: 'fd31c758-a12f-4d97-a573-a902b7c7b8a8',92 updated_at: '2025-01-02T01:28:35.101+0000'93}
Error handling
The SDK uses specific error types to help you handle different error scenarios:
Error type | Description |
---|---|
ApiError | Base error class for all API-related errors. Properties include:
|
AuthenticationError | Thrown when authentication fails (extends ApiError). |
ValidationError | Thrown when request parameters fail validation (extends ApiError). |
RateLimitError | Thrown when API rate limits are exceeded (extends ApiError). |
NotFoundError | Thrown when a requested resource doesn't exist (extends ApiError). |
AuthorizationError | Thrown when the API client lacks permissions for an operation (extends ApiError). |
NetworkError | Thrown for network-related issues like connection failures (extends ApiError). |
TimeoutError | Thrown for timeout issues (extends ApiError). |
ServerError | Thrown when Airwallex servers return a 5xx error (extends ApiError). |
Retryable errors: Only ServerError, TimeoutError, NetworkError will be retried by the SDK if retry is enabled.
Example
JavaScript1import {2 Airwallex,3 ApiError,4 AuthenticationError,5 ValidationError,6} from '@airwallex/node-sdk';78// Example with specific error types9try {10 const result = await client.issuing.cards.getCards('ACTIVE');11 console.log('Operation succeeded:', result);12} catch (error) {13 if (error instanceof AuthenticationError) {14 console.error('Authentication failed. Check your API credentials.');15 // Refresh credentials or prompt for re-login16 }17 else if (error instanceof ValidationError) {18 console.error(`Validation error on field '${error.field}': ${error.message}`);19 // Fix the validation issue20 }21 else if (error instanceof ApiError) {22 console.error(`API Error (${error.status}):`, error.data);23 }24 else {25 console.error('Unexpected error:', error);26 }27}
Supported APIs
The SDK provides access to the following Airwallex API modules. Each module contains methods corresponding to the respective Airwallex API endpoints. Refer to the Airwallex API Documentation API for detailed information about specific endpoints and request/response formats.
Account Capability | |
---|---|
Account Capability API |
|
Authentication | |
Authentication API |
|
Authentication Embedded Components API |
|
Confirmation Letter | |
Confirmation Letter API |
|
Core Resources | |
Deposits API |
|
Linked Accounts API |
|
Finance | |
Finance Settlement API |
|
Issuing | |
Issuing Authorizations API |
|
Issuing Cardholders API |
|
Issuing Cards API |
|
Issuing Config API |
|
Issuing Digital Wallet Tokens API |
|
Issuing Transaction Disputes API |
|
Issuing Transactions API |
|
Payment Acceptance | |
Payment Acceptance Config API |
|
Payment Acceptance Customers API |
|
Payment Acceptance Customs Declarations API |
|
Payment Acceptance Funds Split Destinations API |
|
Payment Acceptance Funds Split Reversals API |
|
Payment Acceptance Funds Splits API |
|
Payment Acceptance Payment Attempts API |
|
Payment Acceptance Payment Consents API |
|
Payment Acceptance Payment Disputes API |
|
Payment Acceptance Payment Intents API |
|
Payment Acceptance Payment Methods API |
|
Payment Acceptance Refunds API |
|
Payouts | |
Payouts Beneficiaries API |
|
Payouts Batch Transfers API |
|
Payouts Transfers API |
|
Payouts Wallet Transfers API |
|
Risk | |
Risk Request For Information (RFI) API |
|
Scale | |
Accounts API |
|
Scale Invitation Links API |
|
Scale Settlements Reports API |
|
Simulation | |
Simulation Sandbox Only Accounts API |
|
Simulation Sandbox Only Cards API |
|
Simulation Sandbox Only Deposits API |
|
Simulation Sandbox Only Payment Acceptance API |
|
Simulation Sandbox Only Payouts API |
|
Simulation Sandbox Only Request For Information API |
|
Simulation Sandbox Only Transfers API |
|
Transactional FX | |
Transactional FX Conversion Amendments API |
|
Transactional FX Quotes API |
|
Transactional FX Rates API |
|
Versioning: Client API vs. SDK
Client APIs use a date-based versioning system, and new versions are only released when there are backward-incompatible changes. In contrast, SDKs manage implementation details and may receive version updates for various reasons — including backward-compatible changes, backward-incompatible changes, or internal updates like bug fixes, even if the API itself hasn't changed.
SDK semantic versioning format: <Major>.<Minor>.<Patch>-beta.<Beta version>. For example, 1.0.0-beta.1
.
- MajorBETA: Follows the existing Platform APIs versioning for backwards-incompatible changes.
- Minor: Follows the existing Platform APIs versioning for backwards-compatible changes.
- PatchBETA: Reserved for bug fixes and changes that do not introduce changes to the API.
- Beta version: Iteration number of the Beta release.