Skip to main content

Orders

An Order is what actually moves money: it spends a previously created quotation and executes the payout to a named beneficiary. createOrder creates one, listOrders walks the company's order history, and getOrder reads a single order by id. See order status for what the status field reports through the order's lifecycle.

createOrder(...)​

Spends a quotation and creates an order for the specified beneficiary and payment instructions.

Signature​

createOrder(req: CreateOrderRequest, idempotencyKey?: string): Promise<Order>

Parameters​

NameTypeRequiredDescription
req.quotation_idstringYesUUID of the quotation from createQuotation. Single-use.
req.metadataRecord<string, string>NoFree-form key/value pairs, echoed back untouched on reads.
req.purposestringYesRemittance purpose. One of FAMILY_SUPPORT, PAYMENT_OF_BILLS, PURCHASE_OF_GOODS, PROFESSIONAL_SERVICES, RENTAL_OF_SPACES, INVESTMENTS, COMMISSIONS_LOANS_CAPITAL_INCREASE, TRANSPORTATION_COSTS, FEES.
req.sender.namesstringYesSender's given name(s).
req.sender.last_namesstringYesSender's last name(s).
req.sender.document.typestringYesDocument type, e.g. "CC".
req.sender.document.idstringYesDocument number.
req.sender.document.countrystringYes2-character ISO alpha-2 country the document was issued in.
req.sender.countrystringYes2-character ISO alpha-2 sender country.
req.sender.phonestringNoSender phone, E.164 format (e.g. "+584121234567"). Validated client-side when present. Round-trips in sender on reads only when you sent it on create.
req.sender.emailstringNoSender email. Validated as an email address when present. Round-trips in sender on reads only when you sent it on create.
req.destination.receiver.namesstringYesBeneficiary's given name(s).
req.destination.receiver.last_namesstringYesBeneficiary's last name(s).
req.destination.receiver.document.typestringYesBeneficiary document type, e.g. "V".
req.destination.receiver.document.idstringYesBeneficiary document number.
req.destination.receiver.document.countrystringYes2-character ISO alpha-2 country the document was issued in.
req.destination.receiver.emailstringNoBeneficiary email. Validated as an email address when present.
req.destination.receiver.countrystringYes2-character ISO alpha-2 beneficiary country.
req.destination.payment_instructions.bank_accountobjectOne of two{ bank_name, number, type }. Mutually exclusive with bank_phone_account.
req.destination.payment_instructions.bank_account.bank_namestringβ€”A closed catalog code from the Venezuela bank catalog, e.g. "BANCO_BANESCO_VE" β€” never a commercial name.
req.destination.payment_instructions.bank_account.numberstringβ€”Account number.
req.destination.payment_instructions.bank_account.type"CHECKING" | "SAVINGS" | "CORRIENTE" | "AHORRO"β€”Account type.
req.destination.payment_instructions.bank_phone_accountobjectOne of two{ bank_name, phone_number, document_id? }. Mutually exclusive with bank_account.
req.destination.payment_instructions.bank_phone_account.bank_namestringβ€”Same closed catalog as bank_account.bank_name.
req.destination.payment_instructions.bank_phone_account.phone_numberstringβ€”E.164 format, e.g. "+584121234567".
req.destination.payment_instructions.bank_phone_account.document_idstringNoFalls back to destination.receiver.document.id server-side when omitted.
idempotencyKeystringNoYour idempotency reference. Auto-generated as a UUID v4 when omitted. Echoed back as idempotency_key on the returned order.

payment_instructions takes exactly one of bank_account or bank_phone_account β€” never both, never neither.

Returns​

Order:

FieldTypeMeaning
idstringOrder identifier.
idempotency_keystring (optional)The idempotency key echoed back.
typestringOrder type, e.g. "REMITTANCE".
statusstringSee order status.
quotation_idstringThe quotation this order spent.
amountstringSource-currency amount, as a decimal string.
currencystringSource currency.
metadataRecord<string, string>Echoed back untouched.
purposestring | null (optional)Remittance purpose, when reported.
senderobject (optional)Same shape as the request's sender. Omitted in some states.
destination.receiverobject (optional)Same shape as the request's receiver.
destination.payment_instructionsobject (optional)Adds a read-only bank_display_name (the commercial name resolved from the catalog) next to the codes you sent.
destination.target_amount / destination.target_currencystring (optional)Payout amount/currency, once the payout has been dispatched.
execution.source.status / execution.destination.statusstringPer-leg execution status, e.g. "COMPLETED", "PENDING".
execution.source.reference_id / execution.destination.reference_idstring | nullPer-leg reference id.
eventsarray (optional)Status-change timeline: { id, from_status, to_status, trigger, reason, message, created_at }.
failure_code / failure_reasonstring | null (optional)Populated only when status === "FAILED".
created_at / updated_atstringISO 8601 timestamps.

Example​

import {
RetornaClientBuilder,
RetornaEnvironment,
} from "@retorna-tech/retorna-gateway-sdk";

const client = new RetornaClientBuilder()
.environment(RetornaEnvironment.SANDBOX)
.clientId(process.env.RETORNA_CLIENT_ID!)
.clientSecret(process.env.RETORNA_CLIENT_SECRET!)
.privateKey(process.env.RETORNA_PRIVATE_KEY!)
.buildClient();

const quotation = await client.createQuotation({
source: { currency: "USDR" },
destination: {
country: "VE",
currency: "VES",
payout_method: { type: "P2P_PHONE_TRANSFER" },
},
quote: { mode: "SEND_EXACT", amount: "10.00" },
});

const order = await client.createOrder(
{
quotation_id: quotation.id,
purpose: "FAMILY_SUPPORT",
metadata: { invoice_id: "INV-2026-00456" },
sender: {
names: "Ana MarΓ­a",
last_names: "PΓ©rez GΓ³mez",
document: { type: "CC", id: "1020304050", country: "CO" },
country: "CO",
},
destination: {
receiver: {
names: "Carlos AndrΓ©s",
last_names: "RodrΓ­guez LΓ³pez",
document: { type: "V", id: "12345678", country: "VE" },
country: "VE",
},
payment_instructions: {
bank_phone_account: {
bank_name: "BNC_VE",
phone_number: "+584121234567",
document_id: "12345678",
},
},
},
},
"invoice-2026-00456", // idempotency key β€” comes back as order.idempotency_key
);

console.log(order.id, order.status, order.idempotency_key);

Errors​

Client-side, before any network call (RetornaSdkError):

  • req.quotation_id is not a valid UUID.
  • req.purpose is missing or outside the closed catalog.
  • Any required sender/receiver field is empty, a country code is not 2 characters, the receiver email is not a valid address, sender.phone is not E.164, or sender.email is not a valid address.
  • payment_instructions has zero or both of bank_account / bank_phone_account set.
  • bank_name is outside the bank catalog, the bank account type is outside CHECKING/SAVINGS/CORRIENTE/AHORRO, or phone_number is not E.164.
  • idempotencyKey was passed explicitly as an empty string.

From the API (RetornaB2BError, see the error catalog):

  • B2B_UNAUTHORIZED β€” credentials, token, or signature rejected.
  • B2B_QUOTATION_NOT_FOUND β€” the quotation does not exist or is not yours.
  • B2B_QUOTATION_EXPIRED β€” the quotation expired before the order was created.
  • B2B_QUOTATION_MISMATCH β€” the order does not match the quotation's terms.
  • B2B_QUOTATION_ALREADY_USED β€” the quotation already backs another order.
  • B2B_INSUFFICIENT_BALANCE β€” wallet balance is lower than the order requires.
  • B2B_BENEFICIARY_INVALID β€” beneficiary data is invalid for the payout method.
  • B2B_IDEMPOTENCY_CONFLICT β€” the same X-Idempotency-Key was reused with a different request body.
  • B2B_RATE_LIMITED / B2B_PROVIDER_REJECTED / B2B_PROVIDER_UNAVAILABLE / B2B_UNKNOWN β€” see the category-based retry policy.

Notes​

  • Omit idempotencyKey and the SDK generates a UUID v4 for you; pass your own reference (an invoice id, a payment run id) and it comes back as order.idempotency_key β€” see idempotency.
  • A retry of createOrder is only safe with the same idempotency key as the original attempt.
  • bank_name is always a catalog code, never a commercial name β€” "BANCO_BANESCO_VE", not "Banesco".

API reference​

POST /orders

listOrders(params)​

Lists the company's orders, newest activity first, with cursor pagination and optional filters.

Signature​

listOrders(params?: ListOrdersParams): Promise<OrdersListResponse>

Parameters​

NameTypeRequiredDescription
params.cursorstringNoOpaque cursor from a previous page's pagination.next_cursor. Omit for the first page.
params.limitnumberNoPage size, 1–100, default 20. Fixed for the whole walk once you pass a cursor.
params.statusstringNoFilter by order status.
params.typestringNoFilter by transaction type, e.g. "WALLET_TO_POG". Free-form string, a single value β€” unlike status, it does not take a comma-separated list.
params.idempotency_keystringNoFilter by the idempotency key you sent on create.
params.created_fromstringNoISO 8601 date or date-time, inclusive lower bound.
params.created_tostringNoISO 8601 date or date-time, inclusive upper bound.

Returns​

OrdersListResponse:

FieldTypeMeaning
dataOrder[]See the Order field table under createOrder above.
pagination.next_cursorstring | nullOpaque next-page token; null once the walk is finished.
pagination.has_morebooleanSame end-of-list condition as a null next_cursor.
pagination.limitnumberEffective page size of the walk.
pagination.totalnumber | nullTotal of the filtered dataset, or null when unknown.

Example​

let cursor: string | undefined;

do {
const page = await client.listOrders({ cursor, limit: 50, status: "COMPLETED" });

for (const order of page.data) {
console.log(order.id, order.status, order.amount, order.currency);
}

cursor = page.pagination.next_cursor ?? undefined;
} while (cursor);

Errors​

Client-side (RetornaSdkError):

  • params.limit set but not an integer between 1 and 100.

From the API (RetornaB2BError):

  • B2B_UNAUTHORIZED β€” credentials, token, or signature rejected.
  • B2B_INVALID_PAGINATION_CURSOR β€” the cursor could not be decoded, or was not issued by this listing.
  • B2B_RATE_LIMITED β€” too many requests; retry with backoff.

Notes​

  • See pagination for the full cursor rules β€” they apply identically to order listings and wallet transactions.
  • Keep filters identical across every call in a paging loop; changing them mid-walk invalidates the cursor's assumptions.
  • idempotency_key is precise enough to make paging moot when you already know the idempotency key you are looking for.

API reference​

GET /orders

getOrder(id)​

Reads a single order by id.

Signature​

getOrder(id: string): Promise<Order>

Parameters​

NameTypeRequiredDescription
idstringYesThe order id. Between 1 and 100 characters.

Returns​

Order β€” same shape as createOrder above.

Example​

const order = await client.getOrder("0190f9b2-3c4d-4e5f-8a6b-7c8d9e0f1a2b");
console.log(order.status, order.execution.destination.status);

Errors​

Client-side (RetornaSdkError):

  • id empty or longer than 100 characters.

From the API (RetornaB2BError):

  • B2B_UNAUTHORIZED β€” credentials, token, or signature rejected.
  • B2B_ORDER_NOT_FOUND β€” the order does not exist, or does not belong to your company.

Notes​

  • Read-only. Poll it (or better, use events) to follow an order across status transitions instead of assuming a single terminal call.

API reference​

GET /orders/{id}