AI Ad Reviews
Automation and teams

What a Duplicate Render Costs: Idempotency Keys in a Video Ad API

One retry storm on a 50-job batch can add $225 to $600 of duplicate renders. How Mantinea's idempotency keys stop it, and how to test that cheaply.

A batch of 50 thirty-second talking-actor ads costs 22,500 credits on Mantinea, $225 at list. If a network blip makes your worker retry every job once, and each retry starts a new job, the batch costs $450. On the lip-sync route the same mistake adds $600. Mantinea's refunds cover failed and canceled jobs, and its reserve rule caps each job's charge at the quote, but neither helps when the same job succeeds twice. Idempotency keys do. Send the same key on a retry and the API returns the original job. API behavior here is from Mantinea's public docs and prices from its 24 November 2026 list; the exact header name and how long keys are remembered are in the OpenAPI 3.1 spec on the API and MCP help page.

The price of one duplicate

JobCreditsDuplicate cost50-job batch, every job duplicated
30 s standard or Pro actor (15/s)450$4.50$225
30 s lip-sync route (40/s)1,200$12.00$600
30 s narrated (3/s)90$0.90$45
30 s lip-synced dub, one language280$2.80$140
3 s new hook (12/s)36$0.36$18

On a CRUD API a duplicate write is a cleanup job. On a generative API it is a charge, and a retry storm can double a day's spend before anyone looks at the balance.

The one rule

Use one key per logical job and reuse it on every retry of that job. A retry after a timeout uses the same key, and so does a retry after a 5xx or a rate-limit response. A new job with identical parameters, such as the same script rendered twice for an A/B test, gets a new key.

The bug that turns all of this off is generating the key inside the retry loop. A fresh UUID per attempt means every attempt is a new job.

Where keys should come from

The safest key is built from your own job record:

shop-12:campaign-bfcm:variant-c:render

Any worker that picks up variant C of that campaign sends the same key, so two processes racing on the same row still produce one job. The alternative is to generate a UUID once, write it to the job row, and only then call the API; retries read it back.

Do not derive the key from the request body alone. Two separate jobs with the same parameters would collide, and you would get one render where you paid for a plan that needed two.

A safe retry loop

job = jobs.find_or_create(shop, campaign, variant)
if not job.idem_key:
    job.idem_key = uuid()
    jobs.save(job)

for attempt in 1..5:
    r = start_job(params, idempotency_key = job.idem_key)
    if r.ok:
        jobs.save(job.remote_id = r.job_id); break
    if r.status is 4xx and not rate_limited:
        alert(); break
    wait(backoff(attempt))

Rate limits are 600 requests or 60 paid starts per minute per key. When you hit one, back off and retry with the same key. Batches take up to 50 jobs; give each job in the batch its own key, so retrying a half-accepted batch does not duplicate the half that already started.

Two different safeguards

ProblemSafeguard
The price is higher than expectedestimate_only on the call before starting it
The same job runs twiceIdempotency key reused on retries
A job fails or is canceledAutomatic refund
A job uses more than quotedThe charge never exceeds the reserve
Everything else goes wrong at onceWorkspace spending caps, daily, weekly or monthly

Estimates prevent surprises in price and keys prevent surprises in count. You want both. More on the first in estimate_only explained.

The return path retries too

Mantinea's webhooks are signed and fire when a job or workflow run succeeds, fails or is canceled. An unacknowledged delivery is retried at 1 min, 5 min, 30 min, 2 h, 6 h and 12 h, so your handler will see repeats. If the handler starts paid work, such as dubbing a finished render, a repeat event can start that work twice, and a 30-second lip-synced dub in five languages is 1,400 credits each time.

  1. Verify X-Autonomous-Signature before anything else ("Autonomous" is an older product name in developer surfaces).
  2. Record processed events and skip repeats.
  3. Return success fast and do the work from a queue, so slow processing does not trigger a retry.
  4. Use an idempotency key on any paid call the handler makes, built from the event's job id.

If you would rather not run an endpoint, long-poll waits up to 50 seconds per request.

Testing it for under $2

Test retry safety in staging with cheap jobs. A script costs 3 credits and a 10-second narrated clip costs 30 (3 a second), so five full test runs cost at most 150 credits, $1.50.

  • Price the test job with estimate_only so you know the expected charge
  • Cut the connection after the request is sent and before the response arrives; let the loop retry
  • Confirm one job exists for that key
  • Confirm the balance dropped by one job's charge
  • Send the same signed webhook event twice and confirm it is processed once
  • Repeat with a batch of three jobs where the second call partially fails

Production checklist

  • Keys built from job records, never inside the retry loop
  • One key per job in every batch
  • Rate-limit retries back off and reuse keys
  • New job types priced with estimate_only first
  • Webhook handlers verify, deduplicate and key their own paid calls
  • Workspace caps set as the last line
  • Scoped keys: generate for render workers, read for dashboards, admin for admins only

New to the API? The curl quickstart shows the first call end to end.

The AI Ad Reviews editors

We turn AI ad tool pricing into dollars per ad, so you can compare plans without a spreadsheet of your own. We work from vendors' own pricing pages, docs and help centers, and date every price we quote. About us.