Idempotency-Key header: a
value you choose, 1 to 255 characters, that ties retries of the same request
to one job.
Send it on campaigns, photoshoots, moodboards, ChatGPT ad groups and ads,
listing images and videos. It is optional, but it is what makes a retry after
a dropped connection safe: with the same key and the same body, LocalAds
returns the original job instead of starting and charging for a second one.
Rules
- One key per logical request. A new request, even an identical body submitted deliberately again, gets a new key.
- The key is matched against the request body. The same key with a different
body returns
409 idempotency_conflict. - While the first request with a key is still running, a retry with the same
key and body returns
409 idempotency_in_progress. Wait and retry shortly; you get the original job when it finishes. - A key can be any unique string: a UUID, or a stable value you derive per
request such as
quick-shoot-1042.
After an ambiguous failure
A network timeout or a dropped connection leaves you not knowing whether the job started. This is exactly the case the key exists for:- Send an
Idempotency-Keyon every request that spends credits, before you need it. - On an ambiguous failure, retry the identical request with the identical key.
- Interpret the response:
- the original job’s resource, if it was accepted;
409 idempotency_in_progress, if it is still running: retry shortly;- the job freshly accepted, if the first attempt never arrived.
Where it is accepted
See Errors and retries for the two
409 codes.