Skip to main content

Offramp Transfer (Crypto → Fiat)

Convert cryptocurrency to fiat and send to a bank account.

Method Signature

align.transfers.createOfframpTransfer(
  customerId: string,
  quoteId: string,
  data: CreateOfframpTransferRequest
): Promise<Transfer>

Parameters

customerId
string
required
The unique customer identifier (UUID format)
quoteId
string
required
Quote ID from a previous createOfframpQuote call
transfer_purpose
string
required
Transfer purpose code (e.g., personal_expenses, business_payment)
destination_external_account_id
string
Bank account ID to receive the fiat funds. Required if destination_bank_account is not provided.
destination_bank_account
object
Inline bank account details (alternative to destination_external_account_id)

Example

import Align from "@tolbel/align";

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

// Step 1: Get a quote
const quote = await align.transfers.createOfframpQuote(customerId, {
  source_amount: "100.00",
  source_token: "usdc",
  source_network: "polygon",
  destination_currency: "usd",
  destination_payment_rails: "ach",
});

// Step 2: Execute the transfer
const transfer = await align.transfers.createOfframpTransfer(
  customerId,
  quote.quote_id,
  {
    destination_external_account_id: "ext_123",
    transfer_purpose: "personal_expenses",
  }
);

console.log(`Transfer ID: ${transfer.id}`);
console.log(`Status: ${transfer.status}`);

Onramp Transfer (Fiat → Crypto)

Convert fiat to cryptocurrency and send to a wallet.

Method Signature

align.transfers.createOnrampTransfer(
  customerId: string,
  quoteId: string,
  data: CreateOnrampTransferRequest
): Promise<Transfer>

Parameters

customerId
string
required
The unique customer identifier (UUID format)
quoteId
string
required
Quote ID from a previous createOnrampQuote call
destination_address
string
required
Wallet address to receive the cryptocurrency

Example

// Step 1: Get a quote
const quote = await align.transfers.createOnrampQuote(customerId, {
  source_amount: "100.00",
  source_currency: "usd",
  source_payment_rails: "ach",
  destination_token: "usdc",
  destination_network: "polygon",
});

// Step 2: Execute the transfer
const transfer = await align.transfers.createOnrampTransfer(
  customerId,
  quote.quote_id,
  {
    destination_address: "0x742d35Cc6634C0532925a3b844Bc9e7595f0aB42",
  }
);

console.log(`Transfer ID: ${transfer.id}`);
// Funds will be sent to the wallet once fiat is deposited

Transfer Response

Calls return a Transfer object containing status and amounts.

Transfer Statuses

StatusDescription
pendingTransfer initiated, waiting for funds
processingTransfer is being processed
completedTransfer completed successfully
failedTransfer failed
refundedTransfer was refunded

Error Handling

import { AlignError, AlignValidationError } from "@tolbel/align";

try {
  const transfer = await align.transfers.createOfframpTransfer(
    customerId,
    quote.quote_id,
    {
      destination_external_account_id: "ext_123",
      transfer_purpose: "personal_expenses",
    }
  );
} catch (error) {
  if (error instanceof AlignError) {
    if (error.statusCode === 400) {
      console.error("Quote expired or invalid");
    } else if (error.statusCode === 403) {
      console.error("KYC verification required");
    }
  }
}
Quotes expire after a short time. If you receive a “quote expired” error, request a new quote before creating the transfer.