Skip to main content

Align SDK

The unofficial TypeScript/JavaScript SDK for the AlignLab API. Build production-ready payment infrastructure with comprehensive type safety, validation, and error handling.
This is an unofficial SDK. For the official API documentation, visit docs.alignlabs.dev.

Why Align SDK?

Type-Safe

Full TypeScript support with comprehensive type definitions. Catch errors at compile time, not runtime.

Validated Requests

Built-in request validation with Zod schemas. Invalid data is caught before hitting the API.

Secure Webhooks

HMAC-SHA256 webhook signature verification out of the box. Prevent replay attacks and tampering.

Automatic Retry

Built-in retry mechanism with exponential backoff for transient network errors.

What Can You Build?

Allow users to purchase cryptocurrency with fiat currency. Support for ACH, wire transfers, SEPA, and more.
// Create a quote for buying USDC with USD
const quote = await align.transfers.createOnrampQuote(customerId, {
  source_amount: "100.00",
  source_currency: "usd",
  source_payment_rails: "ach",
  destination_token: "usdc",
  destination_network: "polygon",
});
Enable users to convert cryptocurrency back to fiat currency and withdraw to their bank accounts.
// Create a quote for selling USDC to USD
const quote = await align.transfers.createOfframpQuote(customerId, {
  source_amount: "100.00",
  source_token: "usdc",
  source_network: "polygon",
  destination_currency: "usd",
  destination_payment_rails: "ach",
});
Move assets seamlessly between different blockchain networks.
// Transfer USDC from Ethereum to Polygon
const transfer = await align.crossChain.createTransfer(customerId, {
  source_network: "ethereum",
  source_token: "usdc",
  destination_network: "polygon",
  destination_token: "usdc",
  amount: "100.00",
});
Create dedicated virtual bank accounts for seamless fiat deposits.
// Create a USD virtual account
const account = await align.virtualAccounts.create(customerId, {
  source_currency: "usd",
  destination_token: "usdc",
  destination_network: "polygon",
  destination_address: "0xYourWalletAddress...", // Address to receive funds
});

Supported Networks & Tokens

NetworkChain IDStatus
Ethereum1Mainnet
Polygon137Mainnet
Base8453Mainnet
Arbitrum42161Mainnet
Solana-Mainnet
Tron-Mainnet

Quick Example

Here’s a complete example of onboarding a user and processing their first deposit:
import Align from "@tolbel/align";

const align = new Align({
  apiKey: process.env.ALIGN_API_KEY!,
  environment: "sandbox",
});

// 1. Create a customer
const customer = await align.customers.create({
  email: "[email protected]",
  type: "individual",
  first_name: "Alice",
  last_name: "Smith",
});

// 2. Start KYC verification
const kyc = await align.customers.createKycSession(customer.customer_id);
console.log(`KYC Link: ${kyc.kycs.kyc_flow_link}`);

// 3. Create virtual account for deposits (after KYC approved)
const virtualAccount = await align.virtualAccounts.create(
  customer.customer_id,
  {
    source_currency: "usd",
    destination_token: "usdc",
    destination_network: "polygon",
    destination_address: "0x742d35Cc6634C0532925a3b844Bc9e7595f0aB42",
  }
);

if ("us" in virtualAccount.deposit_instructions) {
  console.log(
    "Routing:",
    virtualAccount.deposit_instructions.us.routing_number
  );
  console.log(
    "Account:",
    virtualAccount.deposit_instructions.us.account_number
  );
}

Next Steps