localsDocs Get sandbox keys
Get started/Requests, idempotency and errors

Requests, idempotency and errors

Conventions every endpoint follows: JSON in and out, decimal strings for money, safe retries and errors you can act on.

Format

Pagination

GET/v1/customers, GET/v1/routes and GET/v1/transfers page in two ways: by page number or by cursor. Both take limit (1 to 100, default 20).

By page

page starts at 1:

{ "data": [], "page": 1, "totalCount": 42, "totalPages": 3, "hasMore": true, "nextCursor": "WyIyMDI2LTEwLTIxVDA5OjEy…" }

Customers and routes are sorted newest first (by createdAt, then id); transfers by their latest update, newest first. A page past the end returns data: [].

By cursor

Every answer of these lists carries nextCursor, an opaque string, null on the last page. Send it back as cursor, with limit if you want, for the next page:

curl "https://api.locals.money/v1/customers?cursor=WyIyMDI2LTEwLTIxVDA5OjEy…&limit=100"   -H "Authorization: Bearer $LOCALS_KEY"
{ "data": [], "page": null, "totalCount": null, "totalPages": null, "hasMore": true, "nextCursor": "WyIyMDI2LTEwLTIxVDA4OjU5…" }

Without cursor, the lists answer as before, with nextCursor added. GET/v1/events pages with after and limit instead: see Events.

Idempotency

Send an Idempotency-Key header with every POST: 1 to 255 printable ASCII characters, without spaces. Use a new UUID per operation and reuse it when you retry that same operation.

curl -X POST https://api.locals.money/v1/transfers \
  -H "Authorization: Bearer $LOCALS_KEY" \
  -H "Idempotency-Key: 4e6b2d81-7a9c-4f30-b5e2-1c8d3a9f6b70" \
  -H "Content-Type: application/json" \
  -d @transfer.json

Keys are per partner: another partner using the same key does not affect you.

Some operations are safe to repeat even without the header: a quote becomes only one transfer, so a retried POST/v1/transfers with the same details returns the first transfer (and 409 quote_already_used if the quote is reused with other details); creating a route for the same customer, source currency and destination (stablecoin, chain and address) returns the existing route; and creating a customer twice for the same externalId returns 409 customer_exists instead of creating a second one.

Response headers

HeaderWhen
Request-IdEvery answer. The same value as requestId in an error.
RateLimit-Limit, RateLimit-RemainingEvery answer except the 401 and 403 of the key checks: the requests the key may make per minute, and what is left.
Retry-AfterWith 429, and with a 503 you can send again: seconds to wait. See Retry later.
Idempotent-Replayed: trueAn answer repeated for an Idempotency-Key.

Rate limits

Each key may make a number of requests per minute, 120 by default. Past it, requests get 429 rate_limited with Retry-After. Spread bulk work over time and read RateLimit-Remaining instead of waiting for the 429. If you need more, tell us.

Retry later

Some requests are refused before anything is done, and come back with Retry-After: send the same request again after that many seconds.

In the first four nothing was done. In all of them the same request, with the same Idempotency-Key, is safe to send again: these answers are not kept for the key, and the retry runs. A payout refused for a busy object, a long wait or the banking partner does not use its quote: send it again with the same quote, before it expires. The body is the same as every other error.

Errors

Errors use HTTP status codes and one body shape:

{
  "statusCode": 422,
  "code": "customer_not_ready",
  "message": "Customer cus_8Hq2Lm is not enabled for AUD routes (processing)",
  "requestId": "req_0c1f5b"
}

Validation errors add fields, with the path of each field that failed:

{
  "statusCode": 400,
  "code": "validation_failed",
  "message": "Some fields are invalid",
  "fields": [ { "field": "destination.address", "message": "address must be an EVM address" } ],
  "requestId": "req_7a21de"
}

A body that is not valid JSON is 400 validation_failed with the parser's message and no fields.

limit_exceeded adds limit: which limit the operation would go over, and what is left of it. See Limits and blocks.

{
  "statusCode": 422,
  "code": "limit_exceeded",
  "message": "Customer cus_8Hq2Lm would go over its daily offramp limit of 800 USD: 100.00 USD left",
  "limit": { "direction": "offramp", "scope": "customer", "window": "daily", "currency": "USD", "limit": "800", "used": "700.00", "remaining": "100.00" },
  "requestId": "req_3b9e40"
}

scope is customer or tenant (the cap on your whole volume); window is perOperation, daily (the last 24 hours) or monthly (the last 30 days); used is null for perOperation.

StatusCodeWhat to do
400validation_failedFix the request; fields says what is wrong.
401unauthorizedCheck the key and the environment: a key only works on its own environment, and the message says why it was refused.
403forbiddenYour account is suspended, or Locals does not allow that country, wallet or bank account. Talk to us.
403ip_not_allowedThe key cannot be used from that address. Add your servers' addresses to the key. See Allowed IPs.
403customer_blockedThe customer is blocked: no payouts or new routes. See Blocked customers.
404not_foundThe id does not exist, is malformed, or is not yours. The three answer the same.
409customer_existsUse the existing customer.
409quote_already_usedThe quote is already used for another customer, purpose code or payout account. Request a new quote.
409idempotency_conflictSame key, different body or endpoint. Use a new key.
409request_in_progressThe first request with this key is still running. Retry shortly.
409operation_in_doubtOnly on POST/v1/transfers: what became of an earlier attempt of the same payout at the banking partner is not known yet, and nothing was sent this time. The quote stays taken by that payout. Send the same payout again later: it is looked up again. If it does not settle, contact us with the quote id.
409conflictThe object is not in a state that allows it, for example a third webhook secret. The message says why.
409too_many_pending_deliveries50 or more deliveries of yours are waiting to go out: redeliver once they have gone. See Redeliver an event.
413payload_too_largeSend a smaller body.
415unsupported_media_typeSend UTF-8 JSON, without an unknown Content-Encoding.
422customer_not_readyThe customer is still being created, or the capability the call needs is not enabled: the message says which, with its status. See Capabilities.
422quote_expiredRequest a new quote.
422limit_exceededThe operation would go over a limit. Read limit, and GET/v1/customers/{id}/limits.
429rate_limitedPast your key's or your account's rate limit, too many requests for the same object at once, or too many of your requests waiting on the banking partner at once. Wait Retry-After seconds, then send the same request.
500internal_errorRetry with backoff, and tell us with the requestId if it persists.
502upstream_unavailableA banking partner did not answer. Retry with the same idempotency key.
502upstream_rejectedThe banking partner refused the request. Quote the reference in the message when you contact us.
503service_unavailableWith Retry-After: send the same request again after that many seconds, it is safe. See Retry later. Without it, retry with backoff.

Quote requestId when you contact us; it lets us find the exact request.

Retries

Retry on 500, 502, 503 and network errors, with exponential backoff (for example 1 s, 2 s, 4 s, up to 5 attempts) and the same Idempotency-Key. On 429, and on a 503 with Retry-After, wait Retry-After; on 409 request_in_progress, wait a moment; on 409 operation_in_doubt, send the same payout again later, it is not kept for the Idempotency-Key. Do not retry other 4xx errors without changing the request.