Idempotency
Retry without duplicating or charging twice with the Idempotency-Key header.
If a request is cut off by the network, you do not know whether it arrived. With Idempotency-Key you can retry it without generating or charging twice. Use it on the POST requests that create work (create, correct, add sizes and locales, export, upload files); GET queries do not need it.
How it works
- Send
Idempotency-Keywith a unique text of up to200characters. A UUID works well. - Same key and same body: you receive the same response, with the
Idempotent-Replayed: trueheader. Nothing is generated or charged again. - Same key and different body:
422error (idempotency_mismatch). - Same key while the first request is still in progress:
409error (conflict). Wait a moment and retry. - Only successful responses are stored: if the request fails, the key is free again.
Example
curl -X POST https://app.bannermotion.com/api/v1/banners \
-H "Authorization: Bearer bm_live_..." \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 7f3c9a10-5b2e-4c1d-9a77-0e1f2a3b4c5d" \
-d '{
"prompt": "Banner for a high-altitude coffee",
"sizes": ["300x250", "728x90"],
"locales": ["es-CR", "en-US"]
}'If you repeat this same command, you receive the same response with Idempotent-Replayed: true, and nothing is charged again.
Remarque. The key is stored per API key. Two different API keys do not share idempotency.
Create a bannerCreates a concept in all the sizes and locales you ask for. Responds 202 with a job; check its status or wait for the webhook.Errors and limitsThe error format, each status code, and the requests-per-minute limit.
Cette page vous a-t-elle été utile ?