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
The unique customer identifier (UUID format)
Quote ID from a previous createOfframpQuote call
Transfer purpose code (e.g., personal_expenses, business_payment)
destination_external_account_id
Bank account ID to receive the fiat funds. Required if
destination_bank_account is not provided.
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}`);
const quote = await align.transfers.createOfframpQuote(customerId, {
source_amount: "100.00",
source_token: "usdc",
source_network: "polygon",
destination_currency: "usd",
destination_payment_rails: "ach",
});
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);
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
The unique customer identifier (UUID format)
Quote ID from a previous createOnrampQuote call
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
| Status | Description |
|---|
pending | Transfer initiated, waiting for funds |
processing | Transfer is being processed |
completed | Transfer completed successfully |
failed | Transfer failed |
refunded | Transfer 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.