Skip to main content
Quotes are valid for a limited time. Execute the transfer promptly after receiving a quote to lock in the rate.

Offramp Quote (Crypto → Fiat)

Get a quote for converting cryptocurrency to fiat currency and withdrawing to a bank account.

Method Signature

align.transfers.createOfframpQuote(
  customerId: string,
  data: CreateOfframpQuoteRequest
): Promise<QuoteResponse>

Parameters

customerId
string
required
The unique customer identifier (UUID format)
source_amount
string
Amount of crypto to send. Specify either source_amount or destination_amount.
destination_amount
string
Amount of fiat to receive. Specify either source_amount or destination_amount.
source_token
'usdc' | 'usdt' | 'eurc'
required
Cryptocurrency token to convert
source_network
string
required
Blockchain network: polygon, ethereum, solana, base, arbitrum, tron
destination_currency
'usd' | 'eur' | 'aed'
required
Fiat currency to receive
destination_payment_rails
'ach' | 'wire' | 'sepa' | 'swift' | 'uaefts'
required
Payment method for fiat withdrawal
developer_fee_percent
string
Optional developer fee as a percentage (e.g., "0.5" for 0.5%)

Example

import Align from "@tolbel/align";

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

// Quote for selling 100 USDC
const quote = await align.transfers.createOfframpQuote(
  "123e4567-e89b-12d3-a456-426614174000",
  {
    source_amount: "100.00",
    source_token: "usdc",
    source_network: "polygon",
    destination_currency: "usd",
    destination_payment_rails: "ach",
  }
);

console.log(`Send: ${quote.source_amount} USDC`);
console.log(`Receive: $${quote.destination_amount} USD`);
console.log(`Exchange Rate: ${quote.exchange_rate}`);
console.log(`Fee: $${quote.fee_amount}`);
console.log(`Quote ID: ${quote.quote_id}`);

Onramp Quote (Fiat → Crypto)

Get a quote for converting fiat currency to cryptocurrency.

Method Signature

align.transfers.createOnrampQuote(
  customerId: string,
  data: CreateOnrampQuoteRequest
): Promise<QuoteResponse>

Parameters

customerId
string
required
The unique customer identifier (UUID format)
source_amount
string
Amount of fiat to send. Specify either source_amount or destination_amount.
destination_amount
string
Amount of crypto to receive. Specify either source_amount or destination_amount.
source_currency
'usd' | 'eur' | 'aed'
required
Fiat currency to convert
source_payment_rails
'ach' | 'wire' | 'sepa' | 'uaefts'
required
Payment method for fiat deposit
destination_token
'usdc' | 'usdt' | 'eurc'
required
Cryptocurrency token to receive
destination_network
string
required
Blockchain network: polygon, ethereum, solana, base, arbitrum, tron
developer_fee_percent
string
Optional developer fee as a percentage

Example

// Quote for buying USDC with $100
const quote = await align.transfers.createOnrampQuote(customerId, {
  source_amount: "100.00",
  source_currency: "usd",
  source_payment_rails: "ach",
  destination_token: "usdc",
  destination_network: "polygon",
});

console.log(`Send: $${quote.source_amount} USD`);
console.log(`Receive: ${quote.destination_amount} USDC`);

Quote Response

Both methods return a QuoteResponse object:
{
  "quote_id": "qt_123e4567-e89b-12d3-a456-426614174000",
  "source_amount": "100.00",
  "destination_amount": "98.50",
  "exchange_rate": "0.985",
  "fee_amount": "1.50",
  "developer_fee_amount": "0.00",
  "expires_at": "2024-01-15T12:30:00Z"
}
FieldDescription
quote_idUnique identifier to use when creating the transfer
source_amountAmount to send
destination_amountAmount to receive after fees
exchange_rateConversion rate applied
fee_amountPlatform fee
developer_fee_amountYour custom fee (if applicable)
expires_atQuote expiration timestamp

Usage Patterns

Calculate by Source Amount

When you know how much the user wants to send:
const quote = await align.transfers.createOfframpQuote(customerId, {
  source_amount: "100.00", // User sends 100 USDC
  source_token: "usdc",
  source_network: "polygon",
  destination_currency: "usd",
  destination_payment_rails: "ach",
});

console.log(`User receives: $${quote.destination_amount}`);

Calculate by Destination Amount

When you know how much the user wants to receive:
const quote = await align.transfers.createOfframpQuote(customerId, {
  destination_amount: "100.00", // User receives $100
  source_token: "usdc",
  source_network: "polygon",
  destination_currency: "usd",
  destination_payment_rails: "ach",
});

console.log(`User sends: ${quote.source_amount} USDC`);
Specify either source_amount or destination_amount, not both. The API will calculate the other amount based on exchange rates and fees.

Error Handling

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

try {
  const quote = await align.transfers.createOfframpQuote(customerId, {
    source_amount: "100.00",
    source_token: "usdc",
    source_network: "polygon",
    destination_currency: "usd",
    destination_payment_rails: "ach",
  });
} catch (error) {
  if (error instanceof AlignValidationError) {
    console.error("Invalid quote request:", error.errors);
  } else if (error instanceof AlignError) {
    console.error(`API Error: ${error.message}`);
  }
}