Skip to main content
AI agents and automated clients, such as CI jobs, scripts, and workers, can send the same request to the Laravel Cloud API more than once. Send an Idempotency-Key header with requests that create a resource or start an operation, and Cloud recognizes a repeated request and returns the original result instead of doing the work again.

Send an idempotency key

Generate a unique value for each operation, such as a UUID, and send it in the Idempotency-Key header. Replace ENDPOINT_PATH with the path of an endpoint that accepts the header:
Endpoints that accept the header list it in their API reference. Other endpoints ignore it.

Send a request again

When an agent retries a step, a CI job reruns, or your client times out before it reads the response, send the request with the same key and the same body. Use a new key for each new operation. Cloud stores the response to the first successful request with a key for 24 hours. Every repeated request with that key gets the same status code and body, with an Idempotent-Replayed: true header. Cloud scopes keys to the API token, so two tokens can use the same key without conflict. Cloud stores only successful responses. If a request fails with a 4xx or 5xx status code, fix the request and send it again with the same key.

Errors

Each error response has a message and a code:
400
The key is empty or longer than 255 characters. Send a key of 1 to 255 characters.
409
A request with the same key is still running. Retry after the number of seconds in the Retry-After header.
409
The first request succeeded, but Cloud could not store its response. Fetch the resource instead.
422
You sent the key with a different method, path, or body. Use a new key for the new request.