
Async Video API Pipeline: Never Lose a Result (Nov 2026)
How to persist generation results before the URL expires: idempotent submission, verified callbacks, an archive sweep, and storage tiers.
As of November 2026, every async media API we checked expires its result URL on a schedule, and the schedules range from one hour to a few months. The shape is the same everywhere: submit work, wait, receive a result URL. The pipeline you build around that shape decides whether a slow queue is an inconvenience or a paid incident.
This is the engineering companion to our retention research. It assumes you have already chosen a platform and now need the result to survive whatever your own system does — crashes, redeliveries, backlog, a deploy at the wrong moment. The examples use the i2v.ai REST API because its quoting and idempotency fields are documented, but the pattern applies to any provider with an async task model.
TL;DR
Persist the asset inside the completion handler, and make every step replayable. A result URL is a deadline, not a location.
- ✅ Use it if: you are wiring generation into a product, and a lost result means a refund, a support ticket, or a re-charge.
- ❌ Skip it if: you can regenerate freely and results are throwaway previews.
- ⚡ The three safeguards: a stable idempotency key, signature-verified callbacks with event deduplication, and a reconciliation sweep for whatever the callback missed.
What does the lifecycle of one generation actually look like?
Six states, and only one of them gives you a fresh URL. A generation moves from quote to submit, accepted, generating, completed and settled, and the window between completed and settled is the only moment when downloading is guaranteed to succeed. Every persistence bug in an async pipeline is a failure to act inside that window.
| State | What is true | What you must do |
|---|---|---|
| Quote | No task exists, no funds reserved | Read the maximum USD amount and keep the revision |
| Submit | A task may or may not have been created | Store the idempotency key before sending |
| Accepted | A task ID exists | Record it, and treat the key as spent |
| Generating | Upstream call in flight | Poll or wait for the callback; never resubmit |
| Completed | Output URLs are fresh | Download and store immediately |
| Settled | Billing captured or released | Reconcile the amount against your own ledger |
The mistake that causes most losses is treating "completed" as a state you can revisit later. It is not: the URL attached to it has its own clock, and the task record outliving the URL is exactly what makes the failure confusing in a UI.
How do you make the write path replayable?
Two operations carry every risk in an async media pipeline: the submission that creates a task, and the callback that announces its result. Both can be delivered more than once, and both must be safe when they are.
Send an idempotency key that is derived from the logical job, and persist it before the request leaves your process.
# 1. Quote first: no task, no reservation
curl --fail-with-body "https://api.i2v.ai/api/v1/jobs/quote" \
-H "Authorization: Bearer $I2V_API_KEY" \
-H "Content-Type: application/json" \
--data '{"model":"gpt-image-2","inputs":{"prompt":"A ceramic cup on a wooden desk"}}'
# 2. Submit with the quoted revision, an explicit ceiling, and a stable key
curl --fail-with-body "https://api.i2v.ai/api/v1/jobs/createTask" \
-H "Authorization: Bearer $I2V_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $JOB_KEY" \
--data '{"model":"gpt-image-2","inputs":{"prompt":"A ceramic cup on a wooden desk"},"maxCostUsd":"0.08","expectedRevision":7}'Three details carry the weight.
The ceiling is not decoration. maxCostUsd fails before a task exists when the quote exceeds it, which means a pricing change cannot silently enlarge your spend.
The revision ties you to the price you reviewed. If the model's published pricing changed between quote and submit, the submission is refused and you re-quote. That is the behaviour you want in a billing pipeline.
The key must be stable across retries and unique across jobs. A UUID generated inside the retry loop protects nothing. Persist it with the job row, write it to a receipt file, and reuse it verbatim. If a submission response is lost, do not resend blindly: look up the receipt with the original key.
// Retry-safe submission: the key is loaded, never regenerated
async function submitOnce(job, body) {
const response = await fetch(`${origin}/api/v1/jobs/createTask`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.I2V_API_KEY}`,
'Content-Type': 'application/json',
'Idempotency-Key': job.idempotencyKey, // persisted earlier
},
body: JSON.stringify(body),
});
if (response.status === 503) {
// callback_dns_unavailable: the callback host did not resolve.
// Retry the same body with the same key once DNS recovers.
throw new RetryLater(await response.json());
}
return response.json(); // { taskId }
}How do you handle callbacks so a redelivery cannot double-charge?
Treat the callback as a message that may arrive more than once, arrive late, or not arrive at all. Three rules follow.
Verify before parsing. Read X-I2V-Signature, X-I2V-Timestamp, X-I2V-Key-ID and X-I2V-Event-ID first. Compute HMAC-SHA256 over timestamp + '.' + rawBody with your signing secret, compare in constant time, and reject timestamps outside a few minutes.
Deduplicate before doing work. Store the event ID in a unique index. A second delivery of the same event should return 2xx immediately without re-running the download, because the download is idempotent only if you make it so.
Acknowledge quickly, then store. The API retries up to eight times with bounded backoff, so a slow handler is not fatal, but a handler that times out after the file is already stored should still return 2xx on the retry.
// Callback handler: verify, dedupe, then persist the asset immediately
export async function POST(request) {
const raw = await request.text();
const timestamp = request.headers.get('x-i2v-timestamp');
const signature = request.headers.get('x-i2v-signature');
const eventId = request.headers.get('x-i2v-event-id');
if (!verifyHmac(raw, timestamp, signature, process.env.I2V_WEBHOOK_SECRET)) {
return new Response('bad signature', { status: 401 });
}
const firstTime = await recordEventOnce(eventId); // unique index insert
if (!firstTime) return new Response(null, { status: 204 });
const event = JSON.parse(raw);
if (event.data?.status === 'success') {
// Download now: this is the freshest the URL will ever be.
await persistAsset(event.data.taskId, event.data.output);
}
return new Response(null, { status: 204 });
}The ordering matters. Persisting after acknowledging is how teams end up with an acknowledgement log and no files.

Three clocks run at once: the platform's retention window, your retry budget, and your user's patience. The pipeline only works when the first one is longer than the other two.
A useful way to size the handler is to compare the three windows explicitly. The platform's retention window is fixed and published. Your retry budget is a policy you choose. The time a human might take to look at a result is a product fact. If the first is not clearly longer than the other two, no amount of retry logic closes the gap, and the only correct move is to persist eagerly.
There is also an ordering subtlety in the callback itself. A delivery can arrive for a task you have already reconciled by sweep, which means the handler must tolerate a "already stored" state rather than treating it as an error. The idempotency here is at the storage layer: writing the same task ID twice should overwrite or no-op, never create a second asset row.
What does it take to persist an asset properly?
Persisting means the bytes are in storage you control, addressed by something stable, and discoverable from your own metadata. Four things to get right:
| Concern | Practical rule |
|---|---|
| Key | Derive from the task ID, not from a timestamp or a random slug |
| Content type | Store what the API returned; do not re-encode video to save space |
| Cache headers | Immutable objects keyed by task ID can be cached for a year |
| Metadata row | Task ID, model, prompt, parameters, provider, cost, stored-at |
Storing the prompt and parameters alongside the file is not optional if you ever need to reproduce or audit a result. Those fields are not recoverable from the file itself, and the upstream request record will age out faster than the media will.
For images, keep both a display derivative and the original: a WebP preview for lists and the delivered format for download. For video, keep the MP4 and generate a thumbnail at upload time rather than on every page render.
How do you catch what the callback missed?
Run a reconciliation sweep. It is a small job with a simple contract: for every task that is not in a terminal stored state and is older than a few minutes, query the task by ID and act on the answer.
curl "https://api.i2v.ai/api/v1/jobs/recordInfo?taskId=$TASK_ID" \
-H "Authorization: Bearer $I2V_API_KEY"| Observed status | Sweep action |
|---|---|
waiting / generating | Leave alone; back off and retry later |
success and not stored | Download now, then mark stored |
success and already stored | Mark the event as reconciled and stop |
fail | Record the error code and release any reserved credit |
| Record missing after a long delay | Escalate with the task ID; do not resubmit |
Run the sweep on a schedule that is much shorter than the platform's retention window. If you cannot, the sweep is not your safety net — the retention window is your deadline, and you need to shorten it.
The callback is the fast path. The sweep is what makes the pipeline survivable when the fast path fails.
How should you tier storage for generated media?
Retention promises and storage cost pull in opposite directions once volume grows. Tiering resolves the tension without weakening the promise to your own users.
| Tier | Age | Where | Why |
|---|---|---|---|
| Hot | 0–30 days | Primary object storage plus CDN | Active review, delivery, sharing |
| Warm | 30–90 days | Standard storage, no CDN warmth | Support, dispute handling, re-download |
| Cold | 90+ days | Archive class | Compliance and audit only |
The key discipline is that the metadata row never moves. A user searching their history should always see the asset listed; only the retrieval latency changes. Deleting the row when you archive the file is what turns an archive into a disappearance.
When should you stop retrying?
Retrying a failed download is different from retrying a failed submission, and mixing them is expensive.
A download failure is usually transient: a CDN hiccup, a socket timeout, a storage write that lost a connection. Retry it immediately, a few times, with backoff. Your worst case is a slightly delayed asset.
A submission failure is ambiguous. The task may exist even though you never saw a response. That is exactly what the idempotency key is for: reuse it, never generate a new one, and look up the receipt rather than resubmitting blindly. A retry with a fresh key is a second paid task, and the platform is not obliged to notice.
The rule that separates them: retry the write when you know it did not happen, look up the receipt when you do not.
What should you monitor so the pipeline stays honest?
A pipeline that silently drops results looks healthy from the outside: requests succeed, queues drain, the dashboard is green. Four metrics expose the gap between "a task completed" and "an asset exists".
| Metric | Why it catches what uptime does not |
|---|---|
| Stored-to-completed ratio | Below 1.0 means results are completing without ever being persisted |
| Callback coverage | Share of tasks whose terminal state arrived by callback rather than sweep |
| Sweep rescue count | Tasks the sweep had to rescue; a rising trend means the fast path is degrading |
| Download latency p95 | Time between completion and stored asset; compare it to the vendor's window |
The last one is the early warning. If your p95 download latency approaches the retention window, the pipeline is one slow deploy away from losing results, even though nothing has failed yet.
Alert on the ratio, not on individual task errors. One lost result is noise in a batch of five hundred; a ratio that slips from 0.999 to 0.97 is a systemic problem and usually means an exception is being swallowed in the download path.
What does a minimal version look like for a small team?
You do not need the full design on day one. This is the smallest version that removes the failure class:
- Persist the idempotency key with the job row before submitting.
- On completion, download inside the handler; never defer.
- Store the bytes under a key derived from the task ID, with immutable cache headers.
- Keep a metadata row with the prompt, model, parameters and cost.
- Run one hourly sweep for tasks stuck in a non-stored terminal state.
That is roughly one afternoon of work and it covers the overnight batch, the late retry, and most human-in-the-loop delays. Tiering, signing verification and cold storage can come later; the immediate download step cannot.

Five stages in order: submit, wait, reconcile, persist, confirm. Skipping the fourth is the failure class this article is about.
What We Don't Know Yet
This design assumes a provider that reports terminal states reliably and supports idempotent submission. Not every media API does. Some return only a polling endpoint and no callback; others accept a callback URL but do not sign deliveries, which makes verification impossible and pushes you back to polling for security-sensitive flows.
We have not benchmarked sweep frequency against real incident rates. The "shorter than the retention window" rule is a bound, not a measurement.
We also have not tested behaviour under provider-side outages longer than a few minutes. In that case both the callback and the polling path fail together, and the correct answer is to stop creating new work rather than to retry harder.
Use this pipeline if / Skip it if
| Your situation | Recommendation |
|---|---|
| Serial, low-volume, you can regenerate | A download step in the handler is enough |
| Fan-out batches overnight | Add the sweep and an archive queue |
| Client deliverables or paid outputs | Add idempotency, signed callbacks, and cold storage |
| Prototypes and internal tools | Skip the tiering; keep the idempotency key |
| Regulated or audited content | All of the above plus your own retention schedule |
Related Reading
- Why AI video result URLs expire in hours — the failure modes this pipeline is designed against.
- AI media API storage retention comparison — the published windows for eight platforms, with sources.
- Webhooks — signing secret setup, event envelope, and delivery retry behaviour.
- Media workflow: quote, upload, and task recovery — the quote, upload and receipt-lookup flow with runnable examples.
- Pricing — per-model USD rates, so you can price a regeneration.
Disclosure
API behaviour described here was taken from i2v.ai's public documentation on 2026-11-28: the quickstart, the media workflow guide, and the webhooks reference. Retention figures referenced in the companion articles were read from each vendor's first-party documentation on the same date. Code samples are illustrative patterns, not a published library, and have not been run against production credentials for this article.
الأسئلة الشائعة
كتب بواسطة
فئات المنشورات
مزيد من المقالات

AI Media API Storage Compared: 8 Platforms (November 2026)
How long each media API keeps your generated files, from first-party docs: Replicate 1 hour, Sora 1 hour, Runway 24-48h, up to 90 days.

Why AI Video Result URLs Expire in Hours (November 2026)
A generated media URL is a pickup ticket, not a file. Eight platforms compared: Replicate keeps API outputs 1 hour, Sora 1 hour, Runway 24-48h.

The Hidden Cost of Ephemeral Media URLs (November 2026)
A short-lived result URL is a recurring bill: regeneration, archive engineering and support load. How to model the real number before you sign.