AI UGC Review
Workflows and teams

Idempotency Keys in the Mantinea API: Retry Without Duplicate Jobs

API idempotency keys let you retry a timed-out video job without paying twice. How to generate, store and reuse them with Mantinea's API and webhooks.

A video render costs real money, so a duplicate job is a real bug. The classic case: your service sends "start a 30-second talking-actor ad", the connection times out, you retry, and now two jobs are rendering. Mantinea's API supports idempotency keys so the retry returns the original job instead of starting a second one.

API facts come from Mantinea's public docs; prices from its live price list of 24 November 2026. The exact header or field name and how long keys are remembered are in the OpenAPI 3.1 spec on the API and MCP help page. This post covers how to use them well.

Why this matters more for generative APIs

On a typical CRUD API, a duplicate write is an annoyance. On a generative API it's a charge. A standard 30-second talking-actor render is 15 credits per second, 450 credits, about $4.50 at list. A lip-sync route render is 1,200 credits. A retry storm in a batch job can double a day's spend before anyone notices.

Mantinea already protects you from some failure modes: failed or canceled jobs are refunded automatically, and a started job reserves its quote and charges what actually ran, never more than the reserve. Neither helps with a job that succeeded twice. That's the job of the idempotency key.

The rule

One key per logical job, reused on every retry of that job.

  • Same job, retried after a timeout: same key.
  • Same job, retried after a 5xx: same key.
  • A genuinely new job, even with identical parameters: new key.

The most common bug is generating a new key per attempt (for example, a fresh UUID inside the retry loop). That turns idempotency off.

Generating keys

Two good approaches:

1. Derive the key from your own job record. If your system has a row for "render ad 17 for client Acme, batch 2026-11-24", the key can be that row's id, or a hash of it. Retries naturally reuse it, and a second process picking up the same row also uses it.

key = "acme:batch-2026-11-24:ad-17:render"

2. Generate once, store, then send. Create a UUID, write it to your database with the job, and only then call the API. On retry, read it back.

Avoid deriving keys from the request body alone. Two legitimately separate jobs with the same parameters (say, the same script rendered twice for an A/B test) would collide.

A retry loop that's safe

Pseudocode:

job = db.get_or_create_job(client, batch, ad_index)
if job.idempotency_key is empty:
    job.idempotency_key = new_uuid()
    db.save(job)

for attempt in 1..5:
    response = POST start-job with idempotency key = job.idempotency_key
    if response is success:
        db.save(job.remote_id = response.job_id)
        break
    if response is a client error (4xx other than rate limit):
        stop and alert
    sleep(backoff(attempt))

Two details:

  • Rate limits. Mantinea allows 600 requests or 60 paid starts per minute per key. If you hit the limit, back off and retry with the same idempotency key.
  • Batches. You can send up to 50 jobs in a batch. Give each job in the batch its own key, so a partial retry doesn't duplicate the jobs that already started.

Pair it with estimate_only

Before the first start of a new job type, call it with estimate_only to get the credit price without running anything. If you're quoting a batch, sum the estimates and stop if they exceed your budget. Estimates and idempotency keys solve different problems: one prevents surprises in price, the other prevents surprises in count. See estimate_only explained.

The other side: webhooks retry too

Idempotency matters on the way back as well. Mantinea's webhooks are signed and cover a job or workflow run succeeding, failing or being canceled. If your endpoint doesn't acknowledge a delivery, it's retried at 1 min, 5 min, 30 min, 2 h, 6 h and 12 h.

So your webhook handler must be idempotent too:

  1. Verify the signature in the X-Autonomous-Signature header before doing anything ("Autonomous" is an older product name that still appears in developer surfaces).
  2. Deduplicate by event or job. Record which events you've processed; ignore repeats.
  3. Acknowledge fast, process later. Return success quickly and do the work in a queue, so slow processing doesn't trigger retries.

If you'd rather not run a webhook endpoint, the API supports long-poll waits of up to 50 seconds per request.

A checklist for production

  • Keys come from your job records, not from the retry loop.
  • Each job in a batch has its own key.
  • Retries on rate limits reuse keys and back off.
  • New job types are priced with estimate_only first.
  • Webhook handlers verify signatures and deduplicate.
  • Workspace spending caps (daily, weekly, monthly) are set as a last line of defense.
  • Keys are scoped: render workers use a generate key, dashboards a read key, and only admins hold admin.

Testing your retry logic

Don't wait for a real outage to find out whether retries are safe. In staging:

  1. Price first. Call the job with estimate_only so your test knows the expected credit cost.
  2. Simulate a timeout. Kill the connection after the request is sent but before the response arrives, then let your retry loop run.
  3. Check the count. You should see one job, not two, for that key.
  4. Check the balance. Credits should drop by one job's charge.
  5. Replay a webhook. Send the same signed event to your handler twice and confirm it processes once.

Use short, cheap jobs for this, such as a script (3 credits) or a short narrated clip at 3 credits per second, rather than a full talking-actor render.

New to the API? Start with the curl quickstart.

The AI UGC Review editors

We review AI UGC ad tools from their own pricing pages, docs and help centers, and we say who each one suits and who should skip it. We work from vendors' own pricing pages, docs and help centers, and date every price we quote. About us.