5xx response,
without creating a duplicate company, recipient, or payroll.
How it works
Include anIdempotency-Key header with a unique value in your write
requests.
- First request. Bitwage runs the operation and stores the response with a hash of the request payload.
- Same key, same payload. Bitwage returns the stored response with the original status code. It does not run the operation again, so it doesn’t repeat side effects such as provider calls or emails.
- Same key, different payload. Bitwage rejects the request with
idempotency-key-reused-with-different-payload.
Endpoints that use idempotency keys
A missing key returns400 with idempotency-key-required on these endpoints.
Other write endpoints, such as
POST /api/company/workers/invite,
POST /api/user/distribution, and PATCH and DELETE endpoints, don’t
accept idempotency keys. Retrying them can fail or repeat the action. See
Retrying safely for how to check state
before you retry.
Key scoping
Idempotency keys are scoped to your partner account and the endpoint. Using the same key on two different endpoints doesn’t conflict. Bitwage compares the request payload. It doesn’t compare headers or the order of JSON keys.Errors
What is stored
Only successful responses are stored. If a request fails, for example with a400 validation error or a 5xx, Bitwage doesn’t store a response for the
key, so you can fix the request and retry with the same key.
If a request times out and you don’t know whether it succeeded, retry with the
same key and the same payload. You get the original result if it succeeded,
or Bitwage runs it if it didn’t.
Best practices
- Generate a UUID for each logical operation.
- Store the key with the operation in your system before you send the request. Reuse it for every retry of that operation.
- Never reuse a key for a different payload on the same endpoint. Create a new key instead.
- For payrolls, also set
external_idso you can find the payroll later withGET /api/company/{company_id}/payrolls?external_id=.