Idempotency
Send an Idempotency-Key header on a public API POST so a retry returns the first successful response instead of running the request again.
The header is optional. If you leave it off, each POST runs as usual.
Send an idempotency key
Set the Idempotency-Key header on the first POST, and send that same header again when you retry. Use a new key for each distinct request. A version 4 UUID is a safe choice. n8n doesn't require that format.
The value must be from 1 to 128 visible ASCII characters: letters, digits, and symbols, with no spaces. n8n ignores spaces before and after the key. An empty value, or a value that's only spaces, is the same as leaving the header off.
curl -X POST \
'https://<your-instance>/api/v1/workflows' \
-H 'accept: application/json' \
-H 'X-N8N-API-KEY: <your-api-key>' \
-H 'Idempotency-Key: <idempotency-key>' \
-H 'Content-Type: application/json' \
-d '<workflow-json>'Replace <workflow-json> with the workflow body. Refer to Authentication for how to create the API key.
A key that's too long, or that contains a space or another disallowed character, returns 400 and doesn't create the resource. The message is Idempotency-Key must be 1 to 128 visible ASCII characters.
Requests that use the key
n8n uses the header on POST requests that create something or start work, such as creating a workflow or calling POST /api/v1/executions/<execution-id>/retry. The endpoint reference shows the header on each POST that accepts it.
n8n ignores the header for GET, PUT, PATCH, and DELETE.
How long n8n keeps the response
n8n keeps the first successful response for 12 hours from when you send the key. A retry inside that window returns that response and doesn't run the POST again.
After 12 hours, the same key runs the POST again and can create a duplicate. Send a new key for the next operation.
Keys belong to the user, not to one API key. Two API keys for the same user share stored responses. The same key from a different user is a separate request.
Retry the same request
Send the same key with the same path, query string, and body again, including the order of the JSON fields and any spaces. A match returns the same status code and JSON body as the first response.
A POST that returns a file isn't covered. Retrying it runs the request again.
Same key, different request
If the path, query string, or body differs, n8n returns 422 and doesn't run the POST:
Send a new key for the changed request. The first resource stays unchanged.
Request still in progress
If the first request hasn't finished, n8n returns 409:
Wait, then send the same key and the same request again. Two requests at the same time with one key don't create two resources. One request finishes the work. The other receives 409, or the first response if that request has already finished.
When the request fails
If the POST fails, n8n doesn't keep that response. A retry with the same key and the same request runs the POST again.
If the first POST returns 400 because the body is invalid, correct the body and send the same key again.
Limits of an idempotency key
The idempotency header applies only to public API endpoints at /api/v1.
Related resources
Last updated
Was this helpful?