LedgerBee Developer
  • Getting started
  • Conventions
  • Products
  • Configuration
  • API Reference
ErrorsVersioning & DeprecationRate limitsIdempotency
Conventions

Idempotency

Idempotency lets you retry a request (after a timeout or network blip) without it being processed twice. The Public API provides it in three forms, depending on the endpoint.

Usage reporting — idempotency key required

Usage reporting (the Meters endpoint) requires an x-api-idempotency-key header on every submission. A missing key is rejected with 400.

TerminalCode
curl -X POST https://api.ledgerbee.com/api/v1/meters/report \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -H "x-api-idempotency-key: 3f9c1e2a-7b54-4e10-9a2b-8d1f6c0e4a77" \ -d '{ ... }'
  • Reuse the same key when retrying the same submission — the duplicate is acknowledged with status: "duplicate" instead of being recorded twice.
  • Keys are valid for at least 30 days. Expired keys are cleaned up shortly after the window ends; once a key is cleaned up, reusing it is treated as a new submission.
  • Keys can be up to 255 characters long.
  • Use a fresh key for each new submission. A UUID is a good key.
  • Keys are scoped per tenant, so two callers can never collide on the same key value.

Endpoints that require the key mark the header parameter as required in the API Reference.

Naturally idempotent endpoints

Some endpoints are idempotent by design through their identifiers rather than a header — for example, customer provisioning upserts by customer.customerNumber, so re-sending the same provision request resolves to the same customer instead of creating a duplicate. The endpoint descriptions in the API Reference call this out where it applies.

All other mutating endpoints — optional key

Every other mutating Public API endpoint (POST, PUT, PATCH, DELETE) accepts x-api-idempotency-key as an optional header. Send a fresh key with each new operation when you want retry protection, and reuse the same key only when retrying that same operation:

TerminalCode
curl -X POST https://api.ledgerbee.com/api/v1/customers \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -H "x-api-idempotency-key: 8b6f0a3d-2c41-47c9-b5d9-6e2a91c4f5b3" \ -d '{ ... }'

The first successful request runs normally. Retrying with the same key does not repeat the operation — the replay response carries the original status code, the header x-idempotent-replay: true, and a minimal body identifying what was created:

Code
{ "idempotentReplay": true, "id": "0197b2e4-51c6-7e88-a344-9f0b6c1d2e3f" }

id is the created resource's id, or null when the operation didn't create a single addressable resource (batch endpoints, action endpoints) — fetch the full object with a GET if you need it. A replay of a 204 No Content response returns 204 with the replay header and no body.

Failure states

SituationResponseWhat to do
The original request failed with 4xx/5xxThe key is not burnedRetry with the same key — the operation runs again
A duplicate arrives while the original is still in progress409 with code IDEMPOTENT_REQUEST_IN_PROGRESSWait briefly, then retry with the same key
The key was already used on a different endpoint422 with code IDEMPOTENCY_KEY_REUSEDUse a fresh key — one key maps to one operation. This includes a usage-report key reused elsewhere
The key exceeds 255 characters400 with code IDEMPOTENCY_KEY_TOO_LONGShorten the key — a UUID is a good key

Keys are tenant-scoped, retained for at least 30 days, and can be up to 255 characters long — the same window and cap as usage reporting.

Protocol endpoints (OAuth token and revocation, SCIM, MCP, and the portal SSO handoff and session endpoints) manage their own request semantics and don't accept the key. The API Reference shows the header parameter on every endpoint that does.

Last modified on July 30, 2026
Rate limits
On this page
  • Usage reporting — idempotency key required
  • Naturally idempotent endpoints
  • All other mutating endpoints — optional key
    • Failure states
JSON