The envelope
Every route except the token endpoint answers in the Laces envelope.{
"code": 200,
"message": "Events retrieved successfully",
"data": { "...": "..." }
}
{
"code": 403,
"message": "Forbidden",
"error": "Missing scope: orders:read",
"error_code": "insufficient_scope"
}
| Field | Notes |
|---|---|
code | The HTTP status, repeated in the body |
message | A short outcome. On some payment errors it is a slug (for example hold_expired); on cart errors it is "Checkout failed". Kept for backward compatibility. |
error | Human-readable detail. May be reworded at any time. Don’t parse it. |
error_code | A stable, machine-readable code. Branch on this. |
data | The success payload |
details | Only on prompt_in_progress, charge_pending_same_number and payer_prompt_limit: { "retry_after_seconds": n } (charge_pending_same_number adds masked_msisdn, and network when known) |
error_details | On some refusals of the event routes: an object of string values. field names the body field at fault; see Create and publish events |
error_code, including rate
limits (rate_limited), unknown paths (not_found), malformed bodies
(invalid_json) and unexpected failures (server_error).
The token endpoint is the exception
to all of this: it uses the OAuth { "error", "error_description" } shape
(below).
Request ids
Every response carries anX-Request-Id header, for example
X-Request-Id: req_V1StGXR8Z5jdHi6BmyT2. Log it with your errors, and quote it
when you contact support@laces.run: it lets Laces
find your exact request. A 500 server_error also repeats the id as
request_id in the JSON body. Its error text is deliberately generic and
never names the cause. Browsers can read the header too: the API exposes
X-Request-Id and Retry-After to your page’s scripts through CORS, so
res.headers.get("X-Request-Id") works in fetch.
Wrong host
Partner credentials are accepted only onhttps://connect.laces.run. If
you send a bearer token, client credentials or a publishable key to another
Laces host (for example https://api.laces.run), the request is refused before
anything else:
{
"code": 401,
"message": "Unauthorized",
"error": "Partner API credentials are not accepted on this host. Use https://connect.laces.run (see https://docs.laces.run).",
"error_code": "partner_credential_not_accepted"
}
https://connect.laces.run/v1.
async function laces(method, path, { body, idempotencyKey } = {}) {
const res = await fetch(`${BASE}${path}`, {
method,
headers: {
Authorization: `Bearer ${await getLacesToken()}`,
"Content-Type": "application/json",
...(idempotencyKey && { "Idempotency-Key": idempotencyKey }),
},
body: body && JSON.stringify(body),
});
const json = await res.json().catch(() => ({}));
if (!res.ok) {
const err = new Error(json.error_code ?? `http_${res.status}`);
err.status = res.status;
err.code = json.error_code ?? null; // stable
err.retryAfter = Number(res.headers.get("Retry-After")) || null;
err.requestId = res.headers.get("X-Request-Id"); // quote this to support
err.body = json;
throw err;
}
return json.data;
}
Which error codes can the API return?
Authentication (every route)
| HTTP | error_code | Meaning | What to do |
|---|---|---|---|
| 401 | unauthorized | No credential sent | Send a bearer token or publishable key |
| 401 | invalid_token | Token malformed, unknown, expired, revoked, or not a Laces token | Fetch a new token once, then retry |
| 401 | invalid_key | Publishable key malformed, unknown or revoked | Check the key in the app; it may have been replaced by Regenerate keys |
| 401 | partner_credential_not_accepted | A partner credential sent to a Laces host other than connect.laces.run | Use https://connect.laces.run/v1 |
| 403 | credential_not_permitted | This route doesn’t accept that credential, e.g. a publishable key on an order route | Call it from your server with a bearer token |
| 403 | origin_not_allowed | Publishable key with no Origin, or one not in your allowed domains | Add the exact origin in the app |
| 403 | insufficient_scope | The credential lacks the scope this route needs | Enable the permission on the key |
Events
| HTTP | error_code | Meaning |
|---|---|---|
| 400 | invalid_request | limit is not a whole number of at least 1 |
| 400 | invalid_cursor | Cursor malformed or from another organization |
| 404 | not_found | No such event, another organization’s event, or one the list wouldn’t show (draft, code-locked, demo, ended, not on sale) |
Checkout sessions
| HTTP | error_code | Meaning |
|---|---|---|
| 400 | invalid_request | event_id missing, or a bad client_reference_id or prefill |
| 400 | invalid_ui_mode | ui_mode is not redirect or embedded |
| 400 | invalid_return_url | A return URL is missing (redirect mode), not https, too long, malformed, or its origin isn’t in your return URL domains |
| 400 | invalid_embed_origin | Embedded session: the page origin isn’t in your allowed domains |
| 400 | invalid_theme | A theme field is invalid or unknown; the error names the field. Fix it to match the theme rules: primary_color exactly #RRGGBB, logo_url an https URL on a domain name, color_scheme light, dark or auto. |
| 401 | unauthorized | The API client is not active |
| 403 | payments_disabled | Your organization isn’t cleared to take payments yet |
| 404 | not_found | Event not yours, demo or code-locked; or (on read) no such session, another organization’s session, or one deleted after expiry |
| 409 | sale_closed | Registration hasn’t opened, has closed, or the event isn’t on sale |
Create and publish events
Scopeevents:write, bearer token only. Details that carry extra information
use error_details (for example { "field": "timezone" }).
| HTTP | error_code | Route | Meaning | What to do |
|---|---|---|---|---|
| 400 | unknown_field | all four | A key Laces doesn’t accept. error_details.field names it. | Remove it |
| 400 | validation_failed | all four | A value of the wrong type, or a missing required field. error_details.field names it. Nothing is coerced. | Fix the field |
| 400 | invalid_timezone | create | timezone is missing, or is not an IANA zone name (EAT and +03:00 are refused) | Send a name such as Africa/Kampala |
| 400 | invalid_starts_at, invalid_ends_at | create | Not an ISO 8601 string, or outside the allowed range: starts_at from 5 minutes ago to 3 years ahead; ends_at not before starts_at and within 31 days of it | Fix the date |
| 400 | invalid_event_type, invalid_visibility | create | Unknown event_type, or visibility other than public or unlisted | Fix the field |
| 400 | invalid_cover_url | create | cover_url isn’t a clean https URL (at most 2048 characters), or is a shortener or shared host | Use a stable https image link you control |
| 400 | invalid_registration_url | create, update | Not https, or its origin isn’t one of this key’s registration domains, or the host is always refused | Ask an owner to list the origin on the key |
| 400 | invalid_partner_reference | create | partner_reference isn’t a string of at most 128 characters | Fix the field |
| 400 | free_ticket_not_supported | ticket types | price_minor is 0. The API creates paid tickets only. | Create free events in the Laces app |
| 400 | idempotency_key_required | create, ticket types | No Idempotency-Key header | Send one |
| 400 | invalid_idempotency_key | create, ticket types | The key isn’t 1 to 255 visible ASCII characters | Use a UUID |
| 404 | not_found | ticket types, publish, update | The event doesn’t exist or this API client didn’t create it | Check the event_id and the key |
| 409 | draft_limit_reached | create | This key already has 25 unpublished drafts. A retry with the same Idempotency-Key replays the stored result instead; only a new key gets this error | Publish some, or remove them in the app |
| 409 | invalid_event_status | ticket types, publish | The event is closed, completed or cancelled (ticket types also allow draft, scheduled, open) | Re-read the event |
| 409 | nothing_to_sell | publish | No ticket type to sell yet | Add a ticket type |
| 409 | currency_cannot_sell | publish | The organization’s currency can’t be sold on Laces | Contact support |
| 409 | ticket_type_limit_reached | ticket types | The event has 20 ticket types, counting ones added in the app. A retry with the same Idempotency-Key replays the stored result instead; only a new key gets this error | Stop adding |
| 409 | idempotency_in_progress | create, ticket types | The same key is still being processed | Retry shortly with the same key |
| 422 | price_below_minimum | ticket types | price_minor is below the minimum Laces can collect. error_details has minimum_price_minor and currency. | Raise the price |
| 422 | idempotency_key_reuse | create, ticket types | The key was used with a different body (on ticket types, a different eventId counts) | Use a new key |
| 429 | event_limit_reached | create | 20 API-created events today in this organization. Retry-After is the seconds until 00:00 UTC. | Wait, or create the rest in the app |
| 409 | registration_external | POST /v1/checkout (the laces.run checkout, not the Partner API) | The event registers on the organizer’s own site. error_details.registration_url is that URL. Partner orders and checkout sessions are not refused. | Send the buyer to that URL |
Create an order
| HTTP | error_code | Meaning |
|---|---|---|
| 400 | idempotency_key_required | No Idempotency-Key header |
| 400 | validation_failed | Required fields missing or invalid (event_id, lines, buyer_name, buyer_email, buyer_phone) |
| 400 | invalid_email | buyer_email isn’t a valid email |
| 400 | invalid_payment_method | payment_method isn’t momo, card or airtel |
| 400 | rail_unavailable | Card or bank transfer isn’t offered in the event’s country. Use only methods in the event’s payment_methods. |
| 422 | no_rate_for_method | Mobile money (momo or airtel) was asked for on a card-only event (US, UK, EU). Use only methods in the event’s payment_methods. |
| 400 | invalid_donation_amount | donation_amount isn’t a non-negative whole number |
| 400 | invalid_partner_reference | partner_reference isn’t a string of at most 128 characters |
| 400 | waiver_required | The event has a waiver and waiver_accepted isn’t true |
| 400 | waiver_version_mismatch | waiver_version isn’t the current one. Re-read the event and ask the buyer again. |
| 400 | ticket_type_not_in_event | A ticket type belongs to another event |
| 400 | invalid_discount | The discount code isn’t valid for this cart |
| 400 | distance_required, invalid_distance, distance_not_offered | The event has distances and a participant’s distance_km is missing or not offered |
| 403 | payments_disabled | Your organization isn’t cleared to take payments yet |
| 404 | not_found | The event doesn’t exist or isn’t yours |
| 404 / 409 | ticket_type_not_found | A ticket type id is unknown |
| 409 | sale_closed | Registration isn’t open |
| 409 | ticket_not_on_sale | A ticket type is outside its sales window |
| 409 | insufficient_inventory | Not enough places left (sold out) |
| 409 | invalid_quantity, wrong_event | The cart couldn’t be held as sent |
| 409 | idempotency_in_progress | The same key is still being processed. Retry shortly with the same key. |
| 422 | idempotency_key_reuse | The key was already used with different parameters |
Create or quote a payment
Scopepayments:write, bearer token only. The full list with what to do is on
Payment errors.
| HTTP | error_code | Meaning |
|---|---|---|
| 400 | idempotency_key_required | Create only: no Idempotency-Key header |
| 400 | invalid_request | A missing or bad field, partner_reference included; error names it |
| 400 | invalid_amount | amount isn’t a whole number above 0, or is too large or too small to charge |
| 400 | amount_too_large | Over the most Laces allows your organization to ask for |
| 400 | currency_mismatch | currency isn’t your organization’s |
| 400 | unsupported_country | payer_country isn’t accepted; error lists the accepted codes |
| 400 | invalid_payment_method | Unknown payment_method |
| 400 | rail_unavailable | Card or bank transfer isn’t offered for that country |
| 400 | invalid_metadata | Not a flat map of strings, or over a limit |
| 400 | invalid_source_url | Not an https page on one of the key’s Return URL domains, or a shared host or link shortener |
| 400 | invalid_return_url | Not on a Return URL domain, or too long with the order id and status added |
| 403 | shop_payments_not_enabled | Laces has not turned payments on for your organization, or has turned them off. Payments already created can still be paid. |
| 403 | shop_payments_blocked | Laces has stopped payments for your organization. Also on pay. |
| 403 | payments_disabled | Your organization isn’t cleared to take payments yet |
| 404 | org_not_found | The organization no longer exists |
| 409 | idempotency_in_progress | The same key is still being processed |
| 409 | sale_closed, shop_event_conflict | Payments are unavailable for your organization. Contact Laces. |
| 422 | idempotency_key_reuse | The key was used with a different body |
| 422 | no_rate_for_method | That method has no price there (mobile money for a US, GB or EU organization) |
| 503 | fx_unavailable | No exchange rate right now. Retry shortly. |
Pay an order
| HTTP | error_code | Meaning |
|---|---|---|
| 400 | idempotency_key_required | No Idempotency-Key header |
| 400 | msisdn_required | A paid mobile money order needs msisdn |
| 400 | invalid_msisdn | Not a valid mobile money number for the order’s country, or the country code is missing outside Uganda |
| 400 | validation_failed | The body is invalid |
| 400 | rail_unavailable | Nothing was charged. Mobile money isn’t available on this number’s network for this event (for example the network is switched off), or the order’s method isn’t offered for the event’s country. Ask for a different number or method. The Idempotency-Key is released, so a corrected retry can reuse it. |
| 404 | not_found | No such order, or another organization’s |
| 409 | order_not_payable | The order is not in a state that can be charged (already paid, cancelled, …) |
| 409 | hold_expired | The place hold lapsed. Create a new order. |
| 409 | reprice_required | The number’s network doesn’t match the order’s payment_method (an Airtel number on a momo order, or an MTN number on an airtel order). Create a new order with the right method. |
| 403 | shop_payments_blocked | Payments only: Laces has stopped new payments for your organization. Nothing was charged. |
| 409 | rate_lock_expired | The exchange rate on a cross-border order ran out. Nothing was charged. Create a new order or payment. |
| 409 | prompt_in_progress | A prompt is already on the payer’s phone. Wait for Retry-After / details.retry_after_seconds; this is not a failure. |
| 409 | charge_pending_same_number | That number already has a live prompt for this order. Wait for its result. |
| 429 | payer_prompt_limit | That number has had 3 prompts in an hour, or 10 in 24 hours, across all Laces orders. Nothing was sent. Wait Retry-After, or, if no prompt is live, use another number. |
| 503 | service_unavailable | Payments only: temporarily unavailable, nothing was sent. Let the buyer try again shortly. |
| 409 | idempotency_in_progress | The same key is still being processed |
| 422 | idempotency_key_reuse | The key was used with a different order or number |
| 422 | payer_not_registered | Nothing was charged. The number was checked and isn’t registered for mobile money. Ask for another number. |
retry_safe: true means this failed attempt can’t charge the payer, so the
buyer may try again; false means read the order first. Never retry pay
automatically. Every pay response also has
failure_kind: null unless the attempt failed, otherwise
provider_not_reached (nothing was charged; the buyer can try again), timed_out,
declined or other. See
Why it failed.
Orders list and read
| HTTP | error_code | Meaning |
|---|---|---|
| 400 | validation_failed | limit outside 1–100, or an unknown status or order_type |
| 400 | invalid_cursor | The cursor is malformed |
| 404 | not_found | No such order or event, or another organization’s |
Everywhere
| HTTP | error_code | Meaning | What to do |
|---|---|---|---|
| 400 | invalid_json | The request body isn’t valid JSON. You get the normal JSON error envelope with an X-Request-Id, never an HTML page. | Fix the body. Send Content-Type: application/json. |
| 400 | invalid_request | The body couldn’t be read | Fix the request |
| 404 | not_found | The path doesn’t exist on the Partner API (check for a stray /partner segment or a wrong host). The old https://api.laces.run/v1/partner/… paths also answer 404 not_found, with an error that points you to connect.laces.run. | Use https://connect.laces.run/v1 |
| 405 | method_not_allowed | An HTTP method the API doesn’t support | Use the documented method |
| 413 | payload_too_large | The body is over 1 MB | Send a smaller body |
| 429 | rate_limited | Rate limited | Wait the Retry-After seconds. See Rate limits. |
| 500 | server_error | Unexpected failure | Retry with backoff, reusing the same Idempotency-Key. If it persists, email support@laces.run with the X-Request-Id. |
Token endpoint
POST /oauth/token answers in the OAuth shape
(RFC 6749 §5.2):
{ "error": "invalid_client", "error_description": "Client authentication failed" }.
| HTTP | error | Meaning |
|---|---|---|
| 400 | invalid_request | grant_type missing, both Basic and body credentials sent, an unreadable or oversized body, or the request carried an Origin header (a browser) |
| 400 | unsupported_grant_type | Anything other than client_credentials |
| 400 | invalid_scope | An unknown scope, or one the key doesn’t hold |
| 401 | invalid_client | Wrong client id or secret, or a revoked key |
| 429 | temporarily_unavailable | Rate limited. Retry after the Retry-After seconds. |
| 500 | server_error | Unexpected failure. Retry with backoff. |
Retrying safely
| Kind of error | Retry? |
|---|---|
400, 403, 404, 422 | No. Fix the request. |
401 invalid_token | Once, with a fresh token |
409 idempotency_in_progress on a create | Yes, after a short wait, with the same key |
Anything from pay (409, 429 payer_prompt_limit, 5xx, no answer) | Not automatically. When it succeeds it sends a new prompt, even with the same key. Read the order, and pay again only when the buyer asks. |
Other 409 | No. The state has changed; re-read and decide. |
429 rate_limited | Yes, after Retry-After |
500, 503, timeouts, network errors, except on pay | Yes, with backoff and the same Idempotency-Key |