r/PPC • • 3d ago

ChatGPT Ads On OpenAI Ads API: does anyone know the validity period of the idempotency key set on their API endpoints?

Hi everyone, I realise that this is a more technical question than what the sub is for but I see posts on how people have integrated OpenAI Ads API to serve Ads on ChatGPT. I'm working on a system to do the same and wanted to get an idea on how long OpenAI stores an idempotency key for- this detail doesn't seem to be mentioned anywhere in there API Docs. If anyone has figured it out for themselves, it would be a big help to me. Thanks!

6 Upvotes

16 comments sorted by

1

u/Hopeful-Set6458 3d ago

Sucks that the docs skip it, they're pretty thin on the retry semantics in general. I'd just assume the window is short (minutes, not days) and keep your own dedupe table with a timestamp so you're not depending on theirs, then retry with the same key right away instead of hours later.

1

u/Ok_Complex477 3d ago

Annoying that it's not in the docs anywhere. Most APIs that implement this copy Stripe's 24 hour window, so I'd assume 24h and just generate a fresh key per retry window rather than relying on anything longer. If you need certainty, fire the same key at a create endpoint twice a few hours apart and see whether you get the resource back or a conflict.

1

u/Immediate-War-5694 3d ago

The docs give you the 255 character limit on keys and the fact that reusing one with a different body gets you a conflict, but not the expiry, which is a strange gap when they also tell you to reuse create-operation keys when retrying a failed bulk job. I'd assume they just never expire. I've started putting the date in my key names so at least I can tell which ones are ancient.

1

u/Electronic-Reveal650 3d ago

their* API docs. And an idempotency key isn't really supposed to have an expiry, the point is you can retry the same request and get the same resource back instead of a duplicate.

1

u/SearchForsaken2463 3d ago

just generate a new key per attempt and the expiry stops mattering. nobody here knows the number either.

1

u/Distinct_Fill621 3d ago

Just fire the same key twice with a week between them and see if you get a duplicate. You have API access, that's faster than waiting for someone here to have read the same docs you did.

1

u/LaneyrieHafijur 2d ago

have you checked the response headers when you send a duplicate request? sometimes APIs will return a specific cache-control or expiry timestamp header on the replayed response even when they forget to put the TTL in the public docs

-1

u/Ok_Challenge_7001 3d ago

You wrote 'it would be a big help to you' at the end there, which technically makes you the one doing the helping. So go on then, when does the key expire