Contents and all reference pages
Send an Idempotency-Key with every POST and PATCH, such as a UUID or your order number. If you repeat the request with the same key and the same body, you get the stored answer and the header Idempotent-Replayed: true. Nothing runs twice.
The same key with a different body gives 409 idempotency_key_reused. If the first request is still running, you get 409 idempotency_in_progress – then retry after 2 seconds with the same key.
Why
If the connection drops, you do not know whether your request arrived. With an Idempotency-Key you may simply repeat it: if it arrived, you get the first answer again; if not, it runs now.
Rules
- Applies to POST and PATCH. On DELETE and PUT the header is not evaluated at the moment; a repeated DELETE answers 404 not_found the second time.
- Key: 1 to 200 characters, no control characters. Otherwise 400 invalid_parameter.
- A key is scoped to account and mode. Test and live have separate key spaces.
- Method, path and body are compared. Send exactly the same body on retries – the order of fields counts too.
- Only a successful answer is stored, with its status (such as 201 or 202). If the request ends with an error, nothing is stored: you may use the same key again afterwards.
- A replay returns the answer from back then, not the current state. Get the current state with GET.
- If a first request hangs for more than 2 minutes (for example after a restart on our side), the next request with the same key takes over.
Warning: Answers stay stored for 24 hours (clean-up runs hourly, so up to about 25 hours). After that, the same key runs the request again. So use a new key for every new action and the same key only for retries of that action.
Answers at a glance
| Situation | Answer | What you do |
|---|---|---|
| first call | normal answer | – |
| retry, first call succeeded | same status and body, header Idempotent-Replayed: true | use the answer |
| retry, first call still running | 409 idempotency_in_progress, Retry-After: 2 | retry after 2 s with the same key |
| same key, different request | 409 idempotency_key_reused | use a new key – or check why the body changed |
| first call ended with an error | the request runs again | fix the error first if it was caused by the request |
{
"type": "https://flow-marketing.org/entwickler/doku/fehler#idempotency_in_progress",
"title": "A request with this Idempotency-Key is still running.",
"status": 409,
"code": "idempotency_in_progress",
"detail": "The first request with this Idempotency-Key is still running. Nothing was executed twice – retry with the same key in 2 seconds.",
"request_id": "req_3xQ8wE1rT6yU0iO2",
"doc_url": "https://flow-marketing.org/entwickler/doku/fehler#idempotency_in_progress",
"retry_after_s": 2
}Example
curl -s -X POST https://flow-marketing.org/api/turbo/v1/videos \
-H "Authorization: Bearer $FLOW_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-4711-video" \
-d '{"template":"release-notes","brief":"Version 4.2 brings dark mode."}'
# Same call again (e.g. after a timeout): same key, same body
# → same answer, header "Idempotent-Replayed: true", no second videoimport { randomUUID } from 'node:crypto'
// Create the key ONCE per logical action and keep it for every retry of that action.
const key = randomUUID()
const body = JSON.stringify({ template: 'release-notes', brief: 'Version 4.2 brings dark mode.' })
async function createVideo() {
const res = await fetch('https://flow-marketing.org/api/turbo/v1/videos', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.FLOW_API_KEY}`,
'Content-Type': 'application/json',
'Idempotency-Key': key,
},
body, // byte-identical on every retry
})
if (res.headers.get('idempotent-replayed') === 'true') console.log('stored answer, nothing ran twice')
return { status: res.status, data: await res.json() }
}import os, uuid, requests
key = str(uuid.uuid4()) # once per logical action, reused for every retry
body = {"template": "release-notes", "brief": "Version 4.2 brings dark mode."}
def create_video():
r = requests.post(
"https://flow-marketing.org/api/turbo/v1/videos",
headers={"Authorization": f"Bearer {os.environ['FLOW_API_KEY']}", "Idempotency-Key": key},
json=body,
timeout=40,
)
if r.headers.get("Idempotent-Replayed") == "true":
print("stored answer, nothing ran twice")
return r.status_code, r.json()Protection even without a key
- A render starts only once per video: a second, concurrent start ends with 409 video_busy.
- Ledger entries carry unique ids internally. A render is never charged twice.
- Without a key, however, repeating POST /videos can create a second video. So: always send an Idempotency-Key.
In the MCP server
The writing MCP tools take an idempotency_key argument. It works like the header. After rate_limited or internal_error, repeat the same call with the same idempotency_key.
Did this help?