Most developers integrating an async video API start the same way. They kick off a render, then write a while True loop that hits the status endpoint every two seconds until the MP4 URL shows up. That's fine in a local demo with one clip. Then an agency runs 30 client variants at once, and the loop eats request quota, fills the logs and slows down everything else sharing the API key.
Mantinea's public REST API (https://app.mantinea.com/api/v1) has two cleaner ways to wait for finished ads: signed webhooks, and a long polling api wait parameter of up to 50 seconds per request.
Facts below come from Mantinea's public documentation and OpenAPI 3.1 spec (checked November 2026). Verify the exact query parameter names in the live spec on the API and MCP help page before writing production code.
Why tight polling breaks down at agency scale
A video render takes far longer than a database write; Mantinea's FAQ says generations usually take a few minutes as background jobs. Poll every 2 seconds for a 3-minute render and one job burns 90 status requests. Do that across a Variations run of 4 hooks x 3 actors x 2 formats (24 jobs) and the script sends more than 2,100 status requests for a single batch.
Mantinea's rate limit is 600 requests per minute (and 60 paid starts per minute) per API key, so tight polling across concurrent batches soon produces 429 errors you caused yourself. It also wastes compute on serverless workers or CI runners that bill per execution cycle while they sit in sleep(2) loops.
How Mantinea's 50-second long-poll works
A long-poll request asks the server to hold the connection open for up to 50 seconds while it waits for the job to reach a terminal state (succeeded, failed or canceled), instead of returning "status": "running" straight away.
- If the job finishes at second 18: the server responds at second 18 with the completed payload.
- If the job is still rendering at second 50: the server returns the current status, and your client opens the next wait call. That's roughly 1 request every 50 seconds, against 25 to 30 requests a minute with a tight loop.
The 50-second cap also fits under the 60-second idle timeout that many load balancers, reverse proxies and serverless HTTP clients use, so the request ends cleanly before a gateway can drop it with a 504.
Pseudocode: replacing a tight loop with a 50-second wait
Check the exact status route and wait parameter name in Mantinea's OpenAPI 3.1 spec (shown here as <GET_JOB_PATH> and <WAIT_PARAM>):
import time
import requests
API_BASE = "https://app.mantinea.com/api/v1"
HEADERS = {"<AUTH_HEADER>": MANTINEA_READ_KEY}
def wait_for_job(job_id: str, timeout_seconds: int = 600) -> dict:
deadline = time.monotonic() + timeout_seconds
while time.monotonic() < deadline:
# Read-only status polling can use a scoped 'read' key
resp = requests.get(
f"{API_BASE}/<GET_JOB_PATH>/{job_id}",
headers=HEADERS,
params={"<WAIT_PARAM>": 50},
timeout=60, # Must exceed the 50s server wait
)
if resp.status_code == 429:
time.sleep(5)
continue
resp.raise_for_status()
data = resp.json()
if data["status"] in ("succeeded", "failed", "canceled"):
return data
raise TimeoutError(f"Job {job_id} did not finish within {timeout_seconds}s")
Two details in that snippet are easy to miss:
- Client HTTP timeout > 50 seconds. If your HTTP client defaults to a 30-second read timeout, it will drop the connection before Mantinea is done holding it, and you'll get pointless retries. Set client read timeouts to at least 60 to 65 seconds.
- Use a
read-scoped key for status waits. Mantinea keys come in read, generate and admin scopes. Running status checks on areadkey keeps polling out of yourgeneratekey's 600-request/min pool, and it gives the poller only the access it needs.
If you haven't set up your first API key and job call yet, do the curl quickstart first.
Long-polling vs. webhooks: which fits your workflow?
Agencies usually run two kinds of automation: interactive or CLI workflows, and unattended background pipelines.
| Pattern | Best for | Pros | Trade-offs |
|---|---|---|---|
| 50s Long-Poll | CLI scripts, CI jobs, local tools, MCP-to-API prototypes, behind-NAT workers | No public URL or TLS endpoint needed; linear code flow | Holds an HTTP worker/thread open while waiting |
| Signed Webhooks | SaaS backends, product-feed pipelines, Slack/email notifications, large batches | Zero idle connections; automatic retries (1m, 5m, 30m, 2h, 6h, 12h) | Needs a public HTTPS endpoint and signature check (X-Autonomous-Signature) |
For a one-off script on your laptop that makes five ads for a client pitch, setting up a public webhook receiver with ngrok or a cloud queue is overkill, and long-polling is simpler. When a Shopify product feed or a Notion brief kicks off 40 localized ads overnight, use webhooks: they keep your worker pool free, and Mantinea's retry schedule covers you if your server restarts.
The hybrid pattern
Plenty of production teams use both:
- Webhooks as the main notification to ingest finished renders, trigger Brand finish or Resize calls, and post review links into Slack or client approval queues.
- Long-poll as a fallback when a job's expected window passes with no webhook (during a brief firewall change on your receiver, for instance), or inside synchronous internal tools where an account manager clicks "Generate preview" and waits on one request.
Watch idempotency on the starting call too. If you retry a timed-out job creation request before you ever reach the status step, reuse the same idempotency key so you don't render and pay for the same 30-second ad ($4.50 at 15 credits/s on the standard talking actor) twice. Idempotency keys in the Mantinea API has the full retry pattern.
Before you push to production
The public REST API, long-poll status waits, scoped keys and signed webhooks are on every Mantinea plan from Starter ($29/mo for 2,900 credits), and on the 14-day no-card trial (1,000 credits). Failed or canceled jobs are refunded automatically. Check the OpenAPI 3.1 spec on https://mantinea.com/help/api-mcp for the exact parameter name, set your HTTP client timeout above 50 seconds, and delete the 2-second polling loop.