Node.js
import { createHmac } from "node:crypto";
// Node.js 18+. Set credentials and resource values on your server.
function required(name) {
const value = process.env[name];
if (!value) throw new Error(`Set ${name} before running this example.`);
return value;
}
const baseUrl = process.env.LEDIG_API_BASE_URL ?? "https://api-sandbox.ledig.io";
const method = "POST";
const path = `/v1/transfers`;
const pathWithQuery = path;
const body = {
"quoteId": required("LEDIG_QUOTE_ID"),
"reference": required("LEDIG_REFERENCE")
};
const rawBody = JSON.stringify(body);
const headers = { "Accept": "application/json" };
headers["Content-Type"] = "application/json";
const timestamp = Math.floor(Date.now() / 1000).toString();
const payload = `${timestamp}.${method}.${pathWithQuery}.${rawBody}`;
headers["x-ledig-key"] = required("LEDIG_API_KEY");
headers["x-ledig-timestamp"] = timestamp;
headers["x-ledig-signature"] = "v1=" + createHmac("sha256", required("LEDIG_API_SECRET"))
.update(payload).digest("base64");
const response = await fetch(`${baseUrl}${pathWithQuery}`, {
method,
headers,
body: rawBody,
});
const result = await response.json();
// Use result in your application; do not log credentials or upload links.
console.log(response.status);{
"status": "success",
"data": {
"id": "transfer_example_001",
"profileId": "profile_example_001",
"reference": "invoice-example-001",
"sourceCurrency": "USDT",
"destinationCurrency": "USD",
"sourceAmount": "100.00",
"destinationAmount": "100.00",
"rate": "1.00",
"createdAt": "2026-01-15T10:00:00.000Z",
"updatedAt": "2026-01-15T10:00:00.000Z",
"feeAmount": "0.50",
"feeCurrency": "USDT",
"sourceDebitAmount": "100.50",
"payoutFeeAmount": "0",
"payoutFeeCurrency": "USD",
"payoutFeeSourceAmount": "0",
"totalFeeAmount": "0.50",
"totalFeeCurrency": "USDT",
"totalSourceDebitAmount": "100.50",
"meta": {
"rate": {
"product": "USDTUSD",
"sourceCurrency": "USDT",
"destinationCurrency": "USD",
"rate": "1.00",
"side": "sell",
"type": "fixed"
}
},
"quoteId": "quote_example_001",
"status": "processing",
"failureReason": null,
"events": [
{
"eventType": "created",
"sourceId": null,
"status": "pending",
"createdAt": "2026-01-15T10:00:00.000Z",
"updatedAt": "2026-01-15T10:00:00.000Z",
"meta": {}
}
],
"customerPresentation": {
"status": "processing",
"label": "Processing",
"message": "Your conversion is processing.",
"actionRequired": false
},
"balanceImpact": {
"state": "on_hold",
"lines": [
{
"code": "principal",
"currency": "USDT",
"amount": "100.00",
"state": "reserved"
},
{
"code": "conversion_fee",
"currency": "USDT",
"amount": "0.50",
"state": "reserved"
}
]
}
},
"replayed": false
}Transfers
Confirm a quote
Start the conversion or payment described by a quote.
POST
/
v1
/
transfers
Node.js
import { createHmac } from "node:crypto";
// Node.js 18+. Set credentials and resource values on your server.
function required(name) {
const value = process.env[name];
if (!value) throw new Error(`Set ${name} before running this example.`);
return value;
}
const baseUrl = process.env.LEDIG_API_BASE_URL ?? "https://api-sandbox.ledig.io";
const method = "POST";
const path = `/v1/transfers`;
const pathWithQuery = path;
const body = {
"quoteId": required("LEDIG_QUOTE_ID"),
"reference": required("LEDIG_REFERENCE")
};
const rawBody = JSON.stringify(body);
const headers = { "Accept": "application/json" };
headers["Content-Type"] = "application/json";
const timestamp = Math.floor(Date.now() / 1000).toString();
const payload = `${timestamp}.${method}.${pathWithQuery}.${rawBody}`;
headers["x-ledig-key"] = required("LEDIG_API_KEY");
headers["x-ledig-timestamp"] = timestamp;
headers["x-ledig-signature"] = "v1=" + createHmac("sha256", required("LEDIG_API_SECRET"))
.update(payload).digest("base64");
const response = await fetch(`${baseUrl}${pathWithQuery}`, {
method,
headers,
body: rawBody,
});
const result = await response.json();
// Use result in your application; do not log credentials or upload links.
console.log(response.status);{
"status": "success",
"data": {
"id": "transfer_example_001",
"profileId": "profile_example_001",
"reference": "invoice-example-001",
"sourceCurrency": "USDT",
"destinationCurrency": "USD",
"sourceAmount": "100.00",
"destinationAmount": "100.00",
"rate": "1.00",
"createdAt": "2026-01-15T10:00:00.000Z",
"updatedAt": "2026-01-15T10:00:00.000Z",
"feeAmount": "0.50",
"feeCurrency": "USDT",
"sourceDebitAmount": "100.50",
"payoutFeeAmount": "0",
"payoutFeeCurrency": "USD",
"payoutFeeSourceAmount": "0",
"totalFeeAmount": "0.50",
"totalFeeCurrency": "USDT",
"totalSourceDebitAmount": "100.50",
"meta": {
"rate": {
"product": "USDTUSD",
"sourceCurrency": "USDT",
"destinationCurrency": "USD",
"rate": "1.00",
"side": "sell",
"type": "fixed"
}
},
"quoteId": "quote_example_001",
"status": "processing",
"failureReason": null,
"events": [
{
"eventType": "created",
"sourceId": null,
"status": "pending",
"createdAt": "2026-01-15T10:00:00.000Z",
"updatedAt": "2026-01-15T10:00:00.000Z",
"meta": {}
}
],
"customerPresentation": {
"status": "processing",
"label": "Processing",
"message": "Your conversion is processing.",
"actionRequired": false
},
"balanceImpact": {
"state": "on_hold",
"lines": [
{
"code": "principal",
"currency": "USDT",
"amount": "100.00",
"state": "reserved"
},
{
"code": "conversion_fee",
"currency": "USDT",
"amount": "0.50",
"state": "reserved"
}
]
}
},
"replayed": false
}Required scope:
transfers:write
For a new transfer, use a pending, unexpired quote belonging to your business and keep enough available funds to cover it. This endpoint does not use Idempotency-Key. Save the quoteId and any reference you sent. After a timeout, retry with those same values and a fresh signature and timestamp. Once your credentials and business access are checked, a retry matching an existing quoteId or reference returns the original transfer. A reused reference with a new quoteId returns the original transfer and leaves the new quote unused. A reused quoteId with a new reference returns the original transfer without saving the new reference. If quoteId and reference identify different existing transfers, the response is 409 IDEMPOTENCY_CONFLICT. Concurrent retries do not create another transfer. A new quoteId with an unused reference, or without a reference, starts a new request. HTTP 201 means the request was accepted, not that funds were delivered. replayed=false identifies a new transfer; replayed=true identifies the original transfer returned without another payment. Follow GET /v1/transfers/ for the current outcome.Authorizations
Response
Transfer created or the original transfer recovered. Acceptance does not mean payment completion.