{"object":"doc","slug":"api-conventions","title":"API conventions","summary":"Objects, lists, ids, integer amounts, request ids, and bounded idempotency conventions for the supported API.","tags":["guide","conventions","idempotency"],"body":"# API conventions\n\nBase path: `/v1`. JSON in, JSON out. Authenticate with `Authorization: Bearer zp_test_...`.\n\n## Objects\n\nEvery object carries `object` (its type, for example `platform`), `id`, `created` (unix seconds), and `livemode`. Objects that accept `metadata` take up to 50 string keys with string values, echoed back unchanged.\n\n## Card-number guard\n\nFree-text fields reject values that look like card numbers: payment and webhook `description`, terminal `label`, merchant `display_name`, `platform_reference`, and both `metadata` keys and values. Payment-reference search applies the guard too. A value is refused when it holds something shaped like a card number: an unbroken run of digits, or digit groups split the way a card is written (4-4-4-4, 4-4-4-4-3, 4-6-5, 4-6-4 or 4-4-5) by spaces, dashes, dots, slashes or underscores, that starts with a card brand's prefix at that brand's length and passes the Luhn check. Numeric chunks that merely add up to 13 to 19 digits, such as an order number and a date, a phone number or a date range, are not joined. A bare run of 13 to 19 digits is still refused when it happens to be card-shaped, and about 2.7% of random 16-digit numbers are (roughly one in 37; about 1% at 13 digits). The keyed `nonce` follows its own rule, because a genuine nonce must never be refused: any value holding a letter is accepted, and a value with no letters is rejected when its digits start with a card number, whatever separators or digit forms it is written in. Use opaque application identifiers; never put card data into an order reference or metadata. So do not use bare all-numeric 16-digit references: put a letter inside the number or use letters for the random part. A prefix such as `ORD-` in front of an unbroken 16-digit run does not help, because the run itself is what is read.\n\n## Ids\n\nIds are prefixed ULIDs: `plat_...` platforms, `key_...` API keys, `mch_...` merchants, `term_...` terminals, `pay_...` payments, `rfd_...` refunds, `evt_...` events, `whk_...` webhook endpoints, `dlv_...` deliveries, `cus_...` customers, `pm_...` payment methods (saved cards). Treat them as opaque strings up to 40 characters.\n\nA customer is named by the field `customer` everywhere on the wire: the save body, the `save_payment_method` object, the `GET /v1/payment_methods` filter, the payment method object, its events and the MCP tools. There is no `customer_id` field in any request or response; the payment that charged a saved card names it in `payment_method`.\n\n## References\n\n`platform_reference` is your own id for a payment, unique per merchant. References starting with `zp:` (in any case) are reserved for ZeroPoint: a payment request that sends one is refused with `400 parameter_invalid` (`param` `platform_reference`) before anything is read or sent. Listing payments by a `zp:` reference is allowed.\n\n## Amounts and currency\n\nAmounts are integers in the smallest currency unit (`1250` is $12.50). `currency` is lowercase ISO 4217 (`usd`).\n\n## Lists\n\nList endpoints accept `limit` (default 20, max 100) and `cursor`, and return:\n\n```json\n{ \"object\": \"list\", \"data\": [ ... ], \"has_more\": false, \"next_cursor\": null, \"url\": \"/v1/payments\" }\n```\n\nLists run newest first. To get the next page, pass `next_cursor` as `cursor`. `starting_after` is Stripe's name for the same parameter and works on every list: the id of the last object of the page you have. Send one of the two, not both (`400 parameter_invalid`). `ending_before` (paging backwards) is not offered and answers `400 parameter_unavailable` instead of being ignored, so a paging loop never fetches the first page forever. `url` is the list's path, as on Stripe's list object.\n\n## Request bodies\n\nBodies are JSON. The catalog, customer, payment method and payment routes (`/v1/products...`, `/v1/prices...`, `/v1/coupons...`, `/v1/promotion_codes...`, `/v1/customers...`, `/v1/payment_methods...`, `/v1/payments...`) also take `application/x-www-form-urlencoded` bodies with Stripe's bracket encoding, such as `metadata[app_user_id]=8841`, `consent[agreed_at]=1794700000` or `items[0][price]=...`, brackets sent as they are or percent-encoded. A form body is read into the same object a JSON body carries and checked by the same rules, and the same request sent once as JSON and once as a form is the same request for its `Idempotency-Key`. An empty form body on refund or void is the same request as a JSON call with no body. Other routes take JSON only.\n\nForm rules, each refused with `400 parameter_invalid`:\n\n- Values are text, and become a number or `true`/`false` only where the field is declared as one, and only from plain text: an integer is digits with an optional leading minus and no leading zeros (at most 18 digits); a decimal has at most 9 digits before the point and 2 after, with no sign or exponent; a boolean is exactly `true` or `false`. So `platform_reference=12345678` stays the text `12345678`, while `amount_cents=01250`, `amount_cents=12.50` or `terminal_options[tip]=yes` are refused. An empty value (`key=`) is null on a nullable text field and refused on a number or boolean field, so an empty `amount_cents` never means a full refund.\n- A field name is letters, digits and underscores, up to 64 characters, followed by at most 5 bracketed parts. A bracketed part is any text up to 64 characters without square brackets or control characters, so a metadata key reads the same as in JSON (`metadata[order-id]`, `metadata[a.b]`, `metadata[a b]`). A key shaped like a card number is refused, and no key or value is ever repeated in an error.\n- A key sent twice, a key sent both as a value and as an object, list indexes that skip a number, have leading zeros, go past 999 or mix with names, more than 1,000 fields, a field without `=`, and text that is not UTF-8 are refused.\n- A `charset` other than UTF-8 is refused. A JSON body sent with the form content type is refused with a hint to send `Content-Type: application/json`.\n\n## Expanding related objects\n\n`expand` replaces an id with the object it names, as on Stripe, on these routes only, each\nwith a fixed list of paths:\n\n- Reads: `GET /v1/subscriptions/{id}` and the list (`latest_invoice`,\n  `latest_invoice.payment_intent`, `customer`, `default_payment_method`,\n  `items.data.price.product`), `GET /v1/invoices/{id}` and the list (`customer`,\n  `subscription`, `payment_intent`), `GET /v1/prices/{id}` and the list (`product`),\n  `GET /v1/checkout/sessions/{id}` and the list (`line_items`, `customer`, `subscription`,\n  `invoice`, `payment_intent`). On a list, prefix the path with `data.`.\n- Writes: `POST /v1/subscriptions`, `POST /v1/subscriptions/{id}`,\n  `POST /v1/invoices/{id}/pay` and `POST /v1/checkout/sessions` take `expand` in the body\n  with the same paths as the object's read, for example\n  `{\"expand\": [\"latest_invoice.payment_intent\"]}` (a JSON list, or `expand[0]=...` in a form).\n\nAny other path, or a path your key may not read, is refused (`400 parameter_unavailable`\nnaming `expand[n]`, or `403`) before anything is written or charged. `expand` is not part of\nthe request hash: the same `Idempotency-Key` with and without it replays the same answer,\nand a replay is expanded from the objects as they are now, so the outer object and the\nexpanded ones can be from different moments. A write that succeeded is never answered with\nan error because an expansion could not be read afterwards: you get the plain answer, with\nids, and a `ZeroPoint-Expand-Dropped` header listing the paths that were not expanded.\nAfter a write, check whether a field is an object before reading inside it.\n\n## Query strings\n\nBracketed query names are read as Stripe means them: `lookup_keys[0]=a&lookup_keys[1]=b` is the repeated `lookup_keys`, and `name[part]=v` is the dotted name `name.part`. A query string without brackets is read exactly as before. On the catalog and customer lists (`/v1/products`, `/v1/prices`, `/v1/coupons`, `/v1/promotion_codes`, `/v1/customers`), a name the list does not take is refused for every caller with `400 parameter_unknown` naming it, never ignored, so a filter you rely on is never silently dropped. Their retrieves (`GET /v1/products/{product_id}` and the others) do the same: they take no query parameters except `expand` on a price (`expand[]=product`), so any other name is refused by name rather than answered without it.\n\n## Stripe SDK callers\n\nA request is treated as coming from a Stripe server SDK when it carries a `Stripe-Version` header, an `X-Stripe-Client-User-Agent` header, or a `User-Agent` starting `Stripe/v1 ` (any client may opt in by sending `Stripe-Version`). Only `/v1` requests are treated this way, and only these things change for them; success bodies are the same for every caller:\n\n- Errors use Stripe's shape: `type` is one of `invalid_request_error`, `idempotency_error`, `authentication_error`, `rate_limit_error`, `card_error`, `api_error`, with an HTTP status chosen so that both older and current Stripe SDKs raise the same error class; `param` is in bracket notation (`terminal_options[tip]`); `zeropoint_type`, `zeropoint_code` and `zeropoint_status` keep ours. A key reused with another body is `400 idempotency_error`; a state conflict is `400 invalid_request_error`; an outcome still unknown is `409 api_error`, never a card decline. `card_error` (HTTP 402) is used only for a proven decline: `card_declined`, `processor_rejected`, `card_not_saved` or `nonce_invalid`. `duplicate_transaction` (an identical charge was just made, so the first one may exist) and every other code are never a 402: look for that payment before charging again.\n- A query parameter the route does not take is refused with `400 parameter_unknown` naming it, instead of being ignored; `expand` outside the routes and paths listed in \"Expanding related objects\" is refused with `400 parameter_unavailable`.\n- Every answer echoes the request's `Idempotency-Key`. Errors carry `Stripe-Should-Retry`: `true` only for `idempotency_in_progress` and for `payment_in_progress` with `Retry-After: 2`, `false` otherwise and on every `5xx` of a POST or DELETE; on a `5xx` of a GET it is left out. The header is a courtesy: what makes a retry safe is that a retry with the same `Idempotency-Key` replays, waits, or resumes the same payment or refund, never a second one.\n- A Stripe resource ZeroPoint does not serve (SetupIntents, PaymentIntent creation, charges, Subscription Schedules, tax rates, search and others) answers `404` with a message naming what to use instead.\n- stripe-python: on a 429, 409 or 5xx answer it leaves `e.code` empty; our code is in `e.error.code` (and in `zeropoint_code`). After a connection cut mid-answer or a client timeout, the SDK can raise an error for a payment that succeeded: re-read the object, or retry with the same idempotency key, which replays the first answer and never charges again.\n- An SDK configured with `maxNetworkRetries: 0` may send no `Idempotency-Key` (stripe-node 17 does not); a write that needs one then answers `400 idempotency_key_required` and nothing is charged. Pass `idempotencyKey` in the request options, or upgrade the SDK.\n\n`ZeroPoint-Account` (or `Stripe-Account`) names the merchant a request acts on, on every `/v1` route. On a create without `merchant_id` it picks the merchant. On a route about one object (a read, update, delete, or an action such as a refund or a checkout expire) the object must be that merchant's: an object of another merchant answers `404 resource_missing`, the same answer as an id that does not exist, and nothing changes. A list is filtered by it, and a `merchant_id` query naming another merchant is a `400`. On a route where no merchant can apply (`/v1/me`, docs, the merchants list and create, webhooks and deliveries, test clocks) the header is refused with `400 parameter_unavailable` naming it, never ignored. Two headers that name different merchants, an `acct_...` value or an empty header are refused with `400`. `Stripe-Context` is refused with `400 parameter_unavailable` on every route. On `POST /v1/payments` they are checked for every method: a header that names another merchant than the body's `merchant_id` is `400 parameter_invalid`, before anything is created. A body or query `merchant_id` that disagrees with the header is always a `400`; a header naming a merchant that is not yours is `404 resource_missing` naming the header.\n\n## Metadata on update\n\nWhere an object can be updated, `metadata` merges key by key, as on Stripe: the keys you send are set, a key sent with an empty value (`\"\"`) is removed, `\"metadata\": \"\"` removes every key, and `{}` or no `metadata` changes nothing. The 50-key limit applies to the result. When a customer or a saved payment method is created, a key sent with `\"\"` is not stored, as on Stripe.\n\n## Request ids\n\nEvery response carries a `Request-Id` header (`req_...`). Error bodies repeat it as `request_id`. Quote it when you contact support.\n\n## Validation errors\n\nA request that fails validation (a missing or malformed parameter, header or body field, or a body that is not valid JSON) is answered `400` with the error envelope from the errors guide: type `invalid_request`, code `parameter_invalid`, and `param` naming the field when there is one. The API never answers `422` for validation and never sends a `detail` array. The only `422` is `idempotency_key_reused` on the idempotent routes below. The OpenAPI document says the same: `400` with the `ErrorResponse` schema on every operation whose input can fail validation (a body, or a query or header value; a bare id in the path cannot, and an unknown one is `404`), and `422` only on routes that take an `Idempotency-Key`. The other error statuses an operation answers (`401`, `402`, `403`, `404`, `409`, `413`, `429`, `502`, `503`) are listed on it with that same schema; `413 payload_too_large` is listed on every write (POST, PATCH, DELETE). `405 method_not_allowed` and `500 internal_error` can come from any route, so the document states them once in its description instead of on each operation.\n\n## Idempotency\n\nAn `Idempotency-Key` is required on these routes: `POST /v1/merchants`, `POST /v1/merchants/{merchant_id}/terminals`, `POST /v1/payments`, `POST /v1/payments/{payment_id}/cancel`, `POST /v1/payments/{payment_id}/refund`, `POST /v1/payments/{payment_id}/void`, `POST /v1/payment_methods`, `POST /v1/webhooks`, and `POST /v1/webhooks/{webhook_id}/rotate-secret`. On `POST /v1/customers`, `POST /v1/products`, `POST /v1/prices`, `POST /v1/coupons` and `POST /v1/promotion_codes`, which never reach the processor, it is optional, as on Stripe: sent, it works exactly as on the routes above; left out, the request runs once with no replay protection, so a retry creates a second object. Replays carry `Idempotent-Replayed: true`; a `5xx` releases the key so a retry with it re-executes and resumes the same pending payment or refund (same processor request id) rather than starting a new one.\n\nKeys are scoped per platform and mode: every API key of the same mode (test or live) belonging to a platform shares one key space, so the same key sent with two of your test keys replays the first request instead of starting a second one, while a test key and a live key never share a record. The OpenAPI document marks the `Idempotency-Key` header parameter as optional only because the requirement is enforced after authentication, not because it is optional in practice; it is required on every endpoint listed above.\n\n- Same key, same body, already completed: you get the stored response with header `Idempotent-Replayed: true`.\n- Same key, different body: `422` with code `idempotency_key_reused`, while the key's stored response or in-flight claim exists; a `5xx` answer releases the key, so a later retry with that key is judged on its own body (and a pending keyed payment then applies `payment_resume_mismatch`).\n- Same key, still in flight: `409` with code `idempotency_in_progress` and `Retry-After: 2`.\n- A refund or void blocked by an unresolved reversal returns `409 payment_not_refundable` with `Retry-After: 2`. This temporary response is not cached. Retry the original reversal with its original key; a new key cannot bypass an unknown processor outcome.\n- Missing key on an endpoint that requires it: `400` with code `idempotency_key_required`.\n\nThe REST response cache expires after 24 hours. Persist a key per logical operation and reuse the exact key and body for its authorized retries. Expiration is not permission to repeat an uncertain money action: inspect the existing payment/refund and ask the operator to resolve an unknown outcome. Do not invent a new key or reference to bypass that uncertainty. A cached response is historical; retrieve the object to learn its current state. Refunds and voids are stricter than the cache: a `succeeded` refund or void keeps answering for the key that made it after the 24 hours are up. The answer then comes from the refund itself, without the `Idempotent-Replayed` header, and nothing is sent to the processor. Reusing an old refund key therefore never refunds a second time; a second, equal refund needs a new key.\n\nOne key binds to one body. A different card, nonce or amount is a new payment: give it a new `Idempotency-Key` and a new `platform_reference`, and never present it as a retry. While a keyed payment is still `pending`, retry it only with its original key and original body, nonce included. A call with a new key and the same `platform_reference` resumes that pending payment only when its body matches the first attempt: same `amount_cents` and the same nonce, checked against a SHA-256 fingerprint stored at creation (the nonce itself is never stored). A different nonce or amount answers `409 payment_resume_mismatch` before any processor call, and the payment stays `pending` under its original request id. ZeroPoint therefore never presents a changed body under a used processor request id. Processor behaviour, VERIFIED 10/28/2026 on the sandbox: a used request id re-sent 1.5 seconds after a capture with a different card, or with the same card and a different amount, was refused with HTTP 400 `REQUEST_ID_DUPLICATE` and created no transaction. The second card was one the sandbox declines and no decline came back, so the processor checks the request id before it processes the card. That refusal says only that the id was used, never whether the first request captured.\n\nA replay marked `Idempotent-Replayed: true` comes from ZeroPoint's stored response, not from the processor. Processor behaviour, VERIFIED 10/04 and 10/05/2026 on the sandbox: the identical body re-sent under the same processor request id 0.2 seconds later replayed the original transaction, and the same re-send 24 hours later was refused with `REQUEST_ID_DUPLICATE` and moved no money. Where the replay stops between those two points is unmeasured, so a late retry that resumes a pending payment or refund can meet that refusal. ZeroPoint meets it with bounded read-back of the processor's own feed (the errors guide has the table); when read-back cannot name exactly one matching transaction the answer is `502 processor_unavailable` and the row stays `pending` under its original identity. `REQUEST_IN_PROGRESS` gets no read-back and the same `502`. So does a keyed sale answered with HTTP 408, 429, 401, 403, 404 or a redirect: that answer is not a decision on the sale, the payment stays `pending`, and the same key and body resume it. Neither answer permits a new key or a new `platform_reference` for the same money.\n\n`POST /v1/webhooks/{id}/test`, `POST /v1/webhooks/{id}/verify`, `POST /v1/deliveries/{id}/redeliver`, `POST /v1/sandbox/terminals/{id}/simulate`, `POST /v1/merchants/{id}/terminals/discover`, and `POST /v1/terminals/{id}/ping` do not use the REST idempotency cache. They are not interchangeable with pure reads: testing/verifying/redelivering sends webhook traffic, simulation changes sandbox payment state, and discovery/ping can contact the processor. Each call is a fresh operation and still needs the documented permission and caller authorization.\n\nMCP tools derive their own keys: `create_payment` uses `mcp:payment:{merchant_id}:{platform_reference}`, `refund_payment` uses `mcp:refund:{payment_id}:{amount or \"remaining\"}`, `void_payment` uses `mcp:void:{payment_id}`, `save_payment_method` uses `mcp:payment_method:{merchant_id}:{nonce fingerprint}` (a hash, never the nonce), and `create_customer` uses a hash of its arguments, so the same arguments return the same customer for 24 hours. Calling the same tool again with the same arguments therefore resumes a pending refund or void (same processor request id) instead of starting a second one, and returns the refund it already made if that one succeeded; a repeated `create_payment` for a `platform_reference` that already ended answers `platform_reference_in_use`, and one for a `platform_reference` still pending resumes that payment the way a REST retry with the same `Idempotency-Key` does; a repeat with a different nonce or amount answers `payment_resume_mismatch`. To make a second, equal partial refund, use REST with a different `Idempotency-Key`.\n\n## Modes\n\nThe authenticated key's stored mode limits which resources it may access; `livemode` is derived from each object's persisted ownership, not rewritten to match the caller. `zp_test_` keys see only sandbox resources. Protected operations also require their documented scopes; `full` does not bypass platform/mode isolation. Live writes run only on a connected merchant's own account; the going-live guide lists what live supports and what stays test-only.","updated":1795275945}