Platform guarantees
OpenFiskal publishes these current platform targets for the fiscalization API:Idempotency and concurrency per endpoint
The table below shows which endpoints requireIdempotency-Key and If-Match (ETag). Endpoints not listed here (all GET, DELETE, and POST /registers/{id}/fiscalize) require neither header.
PATCH endpoints for merchants, registers, and locations do not require If-Match or Idempotency-Key. These endpoints apply a last-writer-wins strategy — concurrency control is not enforced on resource metadata updates.
Idempotency rules
Idempotency-Key is required on every mutating operation request (POST /operations, POST /operations/{id}/complete, POST /operations/{id}/void). A request without it returns 400 idempotency_key_required. Use a fresh unique value, such as a UUID, for each new request, and send the same value again when you retry that request.
On POST /merchants, POST /locations and POST /registers the header is optional. Without it, every request creates a new resource, so a retried create after a lost response leaves a duplicate. Send a key whenever you may retry, for example one derived from your own id for the record you are provisioning, and the rules below apply in the same way. Merchant keys are scoped to the tenant, since the merchant does not exist yet.
- A key is 1 to 255 printable ASCII characters. Anything else returns
400 invalid_request. - Keys are scoped per endpoint, merchant, and authenticated tenant, and retained for 30 days.
- Sending a key again with the same request returns the result of the first request instead of running it again. The response carries
Idempotent-Replayed: trueand shows the operation as it is now, with its currentETag, not a stored copy of the first response. A replayedPOST /operationstherefore returns201withstatus: completedif the operation was completed in the meantime: read the state from the response rather than assumingopen. - Sending a key again with a different request (a different body, or a different operation id in the path) returns
409 idempotency_key_conflict, with the resource the key already belongs to indetails:operation_idon the operation endpoints,merchant_id,location_idorregister_idon the creates. If you meant to retry, resend the original request unchanged; do not switch to a new key, which forPOST /operationscreates a second operation. - If the first request with a key is still running, the retry waits up to 5 seconds for it and then returns its result. If it is still running after that, the retry returns
409 idempotency_key_in_progresswithretryable: trueand aRetry-Afterheader. Retry with the same key after that delay. - A key is remembered only once its request has taken effect. A request that fails validation, or fails before the operation is written, leaves no trace, so its retry runs normally.
- A retried
completeorvoidthat already went through returns the original result, even though itsIf-Matchvalue is now stale. The idempotency check runs before theIf-Matchcheck.
Retrying safely
Store each outgoing request together with its key before you send it, and on retry resend it unchanged: same body, sameIf-Match, same key. Do not rebuild the request. Fields your code fills with “now”, such as completed_at or processed_at, change between attempts, and the retry is then a different request that returns 409 idempotency_key_conflict instead of the original result.
session_open and session_cash_adjustment are recorded before they are signed. If one of them fails with a TSE signing error, the operation already exists: retry with the same Idempotency-Key, and the replay signs it. A new key would post a second adjustment, or fail with 409 session_invalid_state for an open.
A complete that was signed on the TSE before it failed stays bound to the amounts it signed. Completing it again with a different cash or non-cash total, under any key, returns 409 operation_already_signed.
This also covers an offline queue that replays its outbox after reconnecting. Replaying a create and then its complete, both with their stored keys, If-Match, and bodies, returns the existing operation twice, even if both requests already went through before the connection dropped.
Concurrency rules
Operation mutation endpoints (POST /operations/{id}/complete, POST /operations/{id}/void) require If-Match with the latest operation ETag. Omit it and the API returns 428 precondition_required. Send a stale value and the API returns 412 precondition_failed; the expected and current versions are included in message (e.g. "Resource version mismatch. Expected 1, current is 2."). The If-Match header value must be a quoted positive integer (e.g. "1"); a malformed value returns 400 invalid_request.
PATCH endpoints on merchants, registers, and locations accept updates without If-Match. These are metadata-only mutations where last-writer-wins is acceptable.
Request tracing
Every response includes anX-Request-Id header (e.g. req_a1b2c3d4e5f60718293a). Persist it in your logs and attach it to support cases.