Conventions
The rules every request follows, from money and IDs to idempotency and pagination.
Every Superpay object follows the same rules. One example shows most of them.
curl https://api.withsuperpay.com/v1/conversions/quotes/fxq_01M2FPWJ40B1MVJFJRHGFWTP27 \
-H "Authorization: Bearer $SUPERPAY_TOKEN"{
"object": "fx_quote",
"id": "fxq_01M2FPWJ40B1MVJFJRHGFWTP27",
"status": "ACTIVE",
"sell": { "amount": 100000, "currency": "USD" },
"buy": { "amount": 8308250, "currency": "INR" },
"rate": { "value": "83.08250000", "base": "USD", "quote": "INR" },
"spread": { "amount": 500, "currency": "USD" },
"spread_bps": 50,
"origin": "API",
"expires_at": "2026-09-30T10:21:00Z",
"livemode": false,
"created_at": "2026-09-30T10:20:00Z"
}| Convention | In the example |
|---|---|
object names the type | "object": "fx_quote" |
| IDs are prefixed | fxq_01M2FPWJ40B1MVJFJRHGFWTP27 |
| Money is an integer in minor units | "amount": 100000 is 1,000.00 USD |
| Rates are decimal strings | "value": "83.08250000" |
| Timestamps are RFC 3339, UTC | "2026-09-30T10:20:00Z" |
livemode says which mode | false in test mode |
Base URL#
| What | URL |
|---|---|
| API resources | https://api.withsuperpay.com/v1/... |
| Access tokens | https://api.withsuperpay.com/oauth2/token |
- Use HTTPS. Every response carries
Strict-Transport-Security. - One host for test and live. Your credentials pick the mode, not the URL. See Test mode and live mode.
- Paths are exact. A trailing slash (
/v1/payouts/) or an unsupported method returns404 UNKNOWN_ENDPOINT. The API never returns405. - Every
/v1request is authenticated before the route is matched. A bad token on an unknown path returns401, not404. - Call the API from your servers. It sends no CORS headers, so browsers cannot call it directly.
Requests#
curl https://api.withsuperpay.com/v1/payouts \
-H "Authorization: Bearer $SUPERPAY_TOKEN" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 3f6c9a4e-2b1d-4c8e-9f7a-5d2e1b0c4a67" \
-d '{
"originator_id": "org_01M2FPKH20W4N5X6M3P9R2T1VA",
"beneficiary_id": "ben_01M2FPNHGG6C8D0F2H4K6M8P0R",
"amount": { "amount": 5000000, "currency": "INR" },
"purpose_code": "P1301",
"reference": "INV-2026-0042"
}'- Bodies are one JSON object. Send
Content-Type: application/json. - Field names are
snake_case. Use them exactly as documented. - Unknown fields are rejected, including inside nested objects. A typo fails loudly instead of being dropped.
- Query parameters you misspell are ignored, not rejected. Check them.
Exceptions to JSON bodies:
| Endpoint | Body |
|---|---|
POST /oauth2/token | Form-encoded. See Authentication |
| The three document uploads | multipart/form-data |
POST /v1/payouts/{id}/cancel, POST /v1/conversions/quotes/{id}/reject | None |
POST /v1/webhook-subscriptions/{id}/rotate-secret | Optional |
| Code | HTTP | When |
|---|---|---|
REQUEST_BODY_INVALID | 400 | Empty body, malformed JSON, an unknown field, a value of the wrong JSON type, data after the JSON object, or a null in a correction (PATCH) |
REQUEST_BODY_TOO_LARGE | 400 | A JSON body larger than 1 MiB. Document uploads have their own limit |
INVALID_ARGUMENT | 400 | One or more fields or query parameters failed validation. The failing fields are listed in errors, each with a code, message and field |
detail and each error's message are for people. Branch on code. See Errors.
Corrections and updates#
| Endpoint | How it merges |
|---|---|
PATCH /v1/originators/{id}, PATCH /v1/beneficiaries/{id} | Send only what changes. A field left out is unchanged; "" clears an optional field; null is refused. An originator's and a beneficiary's address and id_document are replaced whole; a beneficiary's account takes only the fields you send, and its date_of_birth and nationality cannot be emptied |
POST /v1/webhook-subscriptions/{id} | Send only what changes. A field left out, or sent as null, is unchanged |
Responses#
- Successful bodies are JSON. Errors are problem documents, described in Errors.
- Every resource has an
objectfield naming its type, and alivemodefield. - Optional fields with no value are left out. Two kinds of object send
nullinstead: webhook subscriptions and their deliveries. A custody wallet'sbalanceisnullwhen it could not be read.
| Status | Returned by |
|---|---|
200 OK | Reads, lists, corrections (PATCH), POST /v1/payouts/{id}/cancel, quote rejection, webhook subscription updates and secret rotations, POST /oauth2/token, and a repeated business verification, custody account opening or document upload |
201 Created | Creates. Most also send a Location header with the new object's path, e.g. /v1/payouts/po_01M2FPYTCG9B1D3F5H7K9M1P3R. Quotes, business verification, the custody account and document uploads do not |
202 Accepted | POST /v1/webhook-subscriptions/{id}/deliveries, which queues a redelivery |
204 No Content | DELETE /v1/beneficiaries/{id} and DELETE /v1/webhook-subscriptions/{id}. No body |
object | Resource |
|---|---|
business_verification | Business verification |
custody_account | Custody account |
fx_quote, fx_order | Conversions |
balance, treasury_capacity, treasury_funding | Balances |
originator | Originators |
beneficiary | Beneficiaries |
party_verification | Verification |
kyc_document | Documents |
payout | Payouts |
event | Events |
webhook_subscription, webhook_delivery | Webhooks |
list | A page of objects. See Pagination |
Most work is asynchronous: verifications, conversions and payouts progress after the request returns. Follow them with webhooks, or by polling each object's GET endpoint.
Money#
Every amount is an object with an integer in the currency's minor units.
{ "amount": 5000000, "currency": "INR" }| Currency | Decimal places | 1 unit is | Example |
|---|---|---|---|
INR | 2 | 100 | ₹50,000.00 = 5000000 |
USD | 2 | 100 | 1,000.00 USD = 100000 |
USDC and USDT, with 6 decimal places, appear only in stablecoin fundings made before custody accounts. Custody wallet balances are shown in USD.
| Do | Don't |
|---|---|
"amount": 5000000 | "amount": "5000000" |
"amount": 5000000 | "amount": 50000.00 or "amount": 5e6 |
"currency": "INR" | "currency": "inr" |
amountmust be a bare JSON integer. Strings, decimals, exponents and a leading+are rejected with400 REQUEST_BODY_INVALID.currencyis an upper-case code.- Amounts you send must be positive. Zero or negative amounts fail validation on that field.
- Never use floating point. Keep amounts as integers (
BigIntin JavaScript,intin Python,int64in Go) and convert to decimals only for display.
Rates#
Exchange rates are objects with a decimal string, never a number.
{ "value": "83.08250000", "base": "USD", "quote": "INR" }value is how many units of quote one unit of base buys. Parse it with a decimal type. See Conversions.
Identifiers#
po_01M2FPYTCG9B1D3F5H7K9M1P3R: a type prefix, an underscore, then a 26-character ULID.
| Prefix | Object |
|---|---|
cus_ | Business verification, and the custody account it opened |
ctr_ | A pull from your custody account |
fxq_ | Quote |
fxo_ | Conversion (FX order) |
org_ | Originator |
ben_ | Beneficiary |
kyd_ | Document |
po_ | Payout |
evt_ | Event |
whs_ | Webhook subscription |
whd_ | Webhook delivery |
tf_ | Stablecoin funding |
req_ | Request ID |
cli_ | API client ID (your credentials) |
- IDs are time-ordered: the ULID starts with its creation time in milliseconds, so a newer ID sorts after an older one. Most lists use them as cursors. Events are the exception: they are listed in publication order, not ID order.
- Treat IDs as opaque, case-sensitive strings. Store them exactly as received.
- A malformed ID in a path returns the resource's not-found error, e.g.
404 PAYOUT_NOT_FOUND, not a400. One exception:POST /v1/originators/{id}/beneficiariesreports a malformed originator ID as a400field error onoriginator_id. - An ID from the other mode, or from another account, also returns not found.
Timestamps#
"created_at": "2026-09-30T10:20:00Z"- RFC 3339, in UTC, with a
Zsuffix and whole seconds. - Date-only fields, such as
date_of_birthandid_document.expires_on, areYYYY-MM-DD. - One exception: on payout capacity,
banking_window.next_openandbanking_window.next_cutoffare in the banking window's local time with its UTC offset, e.g.2026-10-01T09:30:00+05:30.banking_window.zonenames the time zone. - Webhook requests carry
Webhook-Timestampin Unix seconds. See Webhooks.
Parse every timestamp with an RFC 3339 parser that honours offsets.
Test mode and live mode#
| Test mode | Live mode | |
|---|---|---|
| Client secret starts with | sk_test_ | sk_live_ |
livemode on objects and tokens | false | true |
- The mode comes from the credentials used to get the access token. No header, parameter or path changes it.
- Test and live data are fully separate: business verification, custody account, balances, parties, conversions, payouts, events and webhook subscriptions alike. Objects created in one mode are invisible in the other.
- Idempotency keys are separate per mode too.
- Every object carries
livemode. Thelistenvelope does not; each item indatadoes.
See Authentication and Testing.
Idempotency#
Retry a create safely. It runs once, however many times you send it.
Idempotency-Key: 3f6c9a4e-2b1d-4c8e-9f7a-5d2e1b0c4a67When to send a key#
Required on these requests:
| Endpoint | Scope |
|---|---|
POST /v1/business-verification | treasury:manage |
POST /v1/conversions/quotes | fx:quote |
POST /v1/conversions | fx:execute |
POST /v1/originators | originators:write |
PATCH /v1/originators/{id} | originators:write |
POST /v1/originators/{id}/beneficiaries | beneficiaries:write |
POST /v1/beneficiaries | beneficiaries:write |
PATCH /v1/beneficiaries/{id} | beneficiaries:write |
POST /v1/payouts | payouts:write |
POST /v1/payouts/{id}/cancel | payouts:write |
POST /v1/webhook-subscriptions | webhooks:manage |
POST /v1/webhook-subscriptions/{id} | webhooks:manage |
POST /v1/webhook-subscriptions/{id}/rotate-secret | webhooks:manage |
POST /v1/webhook-subscriptions/{id}/deliveries | webhooks:manage |
POST /v1/fx/quotes, POST /v1/fx/orders, the older names of the conversion routes | fx:quote, fx:execute |
POST /v1/treasury/fundings, retired | treasury:manage |
Not taken, and ignored if you send one:
GETandDELETErequests.DELETEis safe to repeat: it returns204again.- The three document uploads, which are idempotent by content.
POST /v1/conversions/quotes/{id}/reject, which is safe to repeat.POST /v1/custody/account, which returns the existing account when repeated.POST /oauth2/token. Each call issues a new token.
Key format#
- 16 to 64 characters.
- Printable ASCII only. No spaces.
- Use a UUID. Generate one per operation, not per attempt.
What counts as the same request#
A retry matches the original when all of these are equal:
| Part | Compared as |
|---|---|
| Method and path | Exactly. A key belongs to one path: a key used on /v1/fx/quotes cannot be replayed on /v1/conversions/quotes |
| JSON body | By content. Key order and whitespace don't matter. Values, number spelling (1 vs 1.0) and field-name casing do |
| Mode | Test and live keys never collide |
Query strings and headers are not compared. For POST /v1/payouts/{id}/cancel, send the same body on every attempt; an empty body and {} are different requests.
Keys are shared by every credential on your account, per mode. Two systems using different credentials on one account still share one key space, so a key one of them used is taken for the other. UUIDs avoid collisions.
Outcomes#
| You send | You get |
|---|---|
| A new key | The request runs. Normal response |
The same key and request, after it finished with a 2xx or 4xx | The stored response: same status, same body, plus Idempotent-Replayed: true |
| The same key and request, while the first is still running | 409 RESOURCE_LOCKED, "retryable": true. Retry shortly with the same key |
| The same key with a different request | 409 IDEMPOTENCY_KEY_REUSED. Use a new key |
| No key | 400 IDEMPOTENCY_KEY_REQUIRED |
| A key of the wrong length or with invalid characters | 400 IDEMPOTENCY_KEY_INVALID |
HTTP/1.1 201 Created
Content-Type: application/json
Location: /v1/payouts/po_01M2FPYTCG9B1D3F5H7K9M1P3R
Idempotent-Replayed: true
X-Request-Id: req_01M2FPYWB0HQWV1N8F1VM1C2BHA replay shows the object as it was when first created. A payout replayed an hour later still shows its original status. GET the object for its current state.
A replay only restores Content-Type and Location. X-Request-Id is the retry's own ID, while a replayed error body keeps the original request_id.
A replay of a webhook subscription's create or secret rotation shows the same signing secret again. That is the only way to see a secret twice.
Errors are replayed too#
The response is stored once the request finishes with any 2xx or 4xx. A 400 validation error, a 404, 409 REFERENCE_EXISTS, a 410 or a 422 is replayed on every retry with that key.
Fixed the request? Use a new key.
Resending a corrected body with the old key returns 409 IDEMPOTENCY_KEY_REUSED. Resending the same body with the old key replays the old error, even if the condition behind a 422 has since cleared.
These are not stored. Fix the cause and retry with the same key:
401and403errors from a missing or invalid token, or a missing scope400 IDEMPOTENCY_KEY_REQUIRED,400 IDEMPOTENCY_KEY_INVALID,400 REQUEST_BODY_TOO_LARGE409 IDEMPOTENCY_KEY_REUSEDand409 RESOURCE_LOCKED- Any
5xx
Timeouts and server errors#
Retry with the same key.
- After a
5xx, the retry runs the request again. If the failed attempt had already created the object, the retry returns that object instead of creating a second one. - After a timeout or dropped connection, the original may still be running. Retries get
409 RESOURCE_LOCKEDfor up to about a minute. Keep retrying with backoff. - If the original was interrupted after creating the object, a later retry returns that object with
Idempotent-Replayed: true. It shows the object's current state. - Quotes are the exception. If a quote request is interrupted before its response is stored, a retry with the same key may price and return a new quote. Quotes move no money and expire on their own.
| Code | HTTP | When | What to do |
|---|---|---|---|
IDEMPOTENCY_LEASE_LOST | 409 | The original attempt ran for over a minute and a retry with the same key took it over | Retry with the same key to get that result |
IDEMPOTENCY_RECOVERY_FAILED | 503 | A retry of an interrupted request could not complete. "retryable": true | Wait Retry-After seconds, then retry with the same key |
Retention#
A key's stored response is kept for 24 hours from its first request. After that the key is forgotten, and sending it again starts a new request. Treat a key as permanently bound to its first request and never reuse one.
Retry pattern#
import { randomUUID } from 'node:crypto';
export async function createPayout(payout, getToken) {
const key = randomUUID(); // once per payout, reused on every attempt
const body = JSON.stringify(payout); // identical bytes on every attempt
for (let attempt = 0; attempt < 6; attempt++) {
let res = null;
try {
res = await fetch('https://api.withsuperpay.com/v1/payouts', {
method: 'POST',
headers: {
Authorization: `Bearer ${await getToken()}`,
'Content-Type': 'application/json',
'Idempotency-Key': key,
},
body,
});
} catch {
// Network error: the payout may exist. Retry with the same key.
}
if (res && res.status < 400) return res.json();
if (res && res.status < 500 && res.status !== 401) {
const problem = await res.json();
const retry = problem.retryable || problem.code === 'IDEMPOTENCY_LEASE_LOST';
if (!retry) throw problem; // Fix the request, then send it with a new key.
}
const retryAfter = Number(res?.headers.get('Retry-After')) * 1000;
await new Promise((r) => setTimeout(r, retryAfter || 250 * 2 ** attempt));
}
throw new Error(`Gave up. Retry later with Idempotency-Key ${key}`);
}getToken should return a cached token and fetch a new one when it has expired. A 401 is never stored, so retrying it with a fresh token and the same key is safe.
Pagination#
These lists are paged. All return newest first.
| Endpoint | Cursors | Filters |
|---|---|---|
GET /v1/payouts | starting_after, ending_before | status, beneficiary_id. See Payouts |
GET /v1/events | starting_after, ending_before | type, resource_id. See Events |
GET /v1/webhook-subscriptions | starting_after, ending_before | status |
GET /v1/webhook-subscriptions/{id}/deliveries | starting_after, ending_before | status, event_id, event_type, kind |
GET /v1/treasury/fundings | starting_after | None |
GET /v1/balances uses the same envelope but returns everything in one page: its has_next is always false. The document lists return the newest 100 documents with no cursors.
Parameters#
limitintegerItems per page, 1 to 100. Default 10. A value that is not an integer from 1 to 100 returns 400 INVALID_ARGUMENT with a parameter_range_invalid error on limit.
starting_afterstringAn object ID. Returns the page of objects older than it. Pass the id of the last item in data to get the next page.
ending_beforestringAn object ID. Returns the page of objects newer than it, still newest first. Pass the id of the first item in data to go back a page. Sending both cursors returns 400 INVALID_ARGUMENT with a parameter_value_invalid error on starting_after.
The list object#
curl "https://api.withsuperpay.com/v1/payouts?limit=2" \
-H "Authorization: Bearer $SUPERPAY_TOKEN"{
"object": "list",
"data": [
{ "object": "payout", "id": "po_01M2FQEY0G6G8J0M2P4R6T8W0Y", "status": "CANCELLED" },
{ "object": "payout", "id": "po_01M2FPYTCG9B1D3F5H7K9M1P3R", "status": "COMPLETED" }
],
"has_next": true
}| Field | Type | Description |
|---|---|---|
object | string | Always list |
data | array | The page of objects. [] when empty, never null |
has_next | boolean | true when another, older page exists |
There is no total count and no next-page URL. Walk the list with the last id.
- With
ending_before,has_nextis alwaystrue, because the older pages you came from still exist. It cannot tell you that you reached the newest page; stop whendatahas fewer items thanlimit, or, for events, when it is empty. - Payout and funding cursors are compared, not looked up: an unknown ID still returns the objects before or after it, which may be an empty page. Event cursors must be published events of yours from the last 30 days, and webhook cursors must be well-formed
whs_orwhd_IDs.
Fetch everything#
async function* allPayouts(token) {
let cursor;
while (true) {
const qs = new URLSearchParams({ limit: '100' });
if (cursor) qs.set('starting_after', cursor);
const res = await fetch(`https://api.withsuperpay.com/v1/payouts?${qs}`, {
headers: { Authorization: `Bearer ${token}` },
});
const page = await res.json();
if (!res.ok) throw page; // a problem document
yield* page.data;
if (!page.has_next) return;
cursor = page.data.at(-1).id;
}
}Request IDs#
Every response carries an X-Request-Id header. Log it, and quote it when you contact Superpay.
X-Request-Id: req_01M2FPWK38HE29JN297FGY8D2J- Send your own
X-Request-Idto tie our logs to yours. It must be 1 to 128 characters of letters, digits,_,.,:or-. - If you send none, or one that breaks those rules, Superpay replaces it with a
req_ID. An invalid value is not an error. - Problem documents repeat it as
request_id. A replayed error body keeps therequest_idof the original request.
Headers#
Request headers#
| Header | When |
|---|---|
Authorization: Bearer <token> | Every /v1 request. See Authentication |
Content-Type | application/json with a JSON body. multipart/form-data for document uploads |
Idempotency-Key | The requests in When to send a key |
X-Request-Id | Optional. See Request IDs |
Response headers#
| Header | When |
|---|---|
X-Request-Id | Always |
Content-Type | application/json on success bodies (a 204 has no body), application/problem+json on /v1 errors. Token endpoint errors are application/json; see Authentication |
Location | Most 201 creates and the 202 redelivery. A path, not a full URL. POST /v1/conversions points at /v1/fx/orders/{id}, which serves the same object as /v1/conversions/{id} |
Idempotent-Replayed: true | The response is a stored replay |
Retry-After | 503 responses. Seconds to wait before retrying |
WWW-Authenticate | 401 responses |
Cache-Control: no-store | All /v1 responses. Do not cache them |
X-Content-Type-Options: nosniff | All responses |
Versioning#
- The version is in the path:
/v1. There is no version header and no per-request version pinning. - Build tolerant clients: ignore response fields you don't recognise, and handle status values you don't recognise without crashing.
- Branch on error
code, never ontitleordetail. - Events have their own rules for how they change.
These older forms still work, so existing integrations keep running:
| Older form | Now | Status |
|---|---|---|
/v1/fx/quotes, /v1/fx/quotes/{id}, /v1/fx/orders, /v1/fx/orders/{id} | /v1/conversions/quotes, /v1/conversions/quotes/{id}, /v1/conversions, /v1/conversions/{id} | Same objects and behaviour. Use the new paths |
POST /v1/custody/account | POST /v1/business-verification | Deprecated |
Corridor IN-NRE | IN-INR-BANK | Accepted as a corridor value. Payouts created before the change keep IN-NRE |
POST /v1/treasury/fundings | Deposit into custody | Retired: announcing a USDC or USDT funding returns 410 |