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
The unique customer identifier (UUID format)
Amount of crypto to send. Specify either source_amount or
destination_amount.
Amount of fiat to receive. Specify either source_amount or
destination_amount.
source_token
'usdc' | 'usdt' | 'eurc'
required
Cryptocurrency token to convert
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
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}`);
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");
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
The unique customer identifier (UUID format)
Amount of fiat to send. Specify either source_amount or
destination_amount.
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
Blockchain network: polygon, ethereum, solana, base, arbitrum,
tron
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"
}
| Field | Description |
|---|
quote_id | Unique identifier to use when creating the transfer |
source_amount | Amount to send |
destination_amount | Amount to receive after fees |
exchange_rate | Conversion rate applied |
fee_amount | Platform fee |
developer_fee_amount | Your custom fee (if applicable) |
expires_at | Quote 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}`);
}
}