Skip to main content

Module idempotency

Module idempotency 

Source
Expand description

Idempotency keys, as the PHP package’s Idempotency middleware handles them: a POST, PATCH or DELETE with an Idempotency-Key runs once, and retries with the same key get the stored response with Idempotent-Replayed: true. A retry must be the same request (the same version, query and body), or it gets a 422 idempotency_key_mismatch. While the first request runs, retries get a 409 idempotency_in_progress.

Keys are scoped to the API client. A request without one is a guest’s, scoped to the address it came from, as guest rate limits are, so guests at one address share their keys. A user signed in through Laravel’s own guards rather than as a client has no scope of their own, and the framework says only that someone is signed in, not who. Such a request runs without its key: it is neither replayed a response from a guest scope nor stored in one, so a retry runs again. This sees only a user signed in before the FusionStack middleware runs.

Constants§

HEADER
The request header that carries the key.
REPLAYED_HEADER
The response header that marks a replay.