Your platform has 5,000 products and someone wants a personalized demo video for each one. By tomorrow.
You're not booking a studio. You're writing a loop. This post is that loop: a batch pipeline that queues thousands of template-based renders, verifies webhook callbacks, retries the flaky ones, and doesn't fall over at scale. Node.js throughout, with Python equivalents noted inline.
I'll skip the marketing case. Template rendering runs about $0.10 to $0.50 per video at volume against $1,000 to $7,000 a minute for agency footage, so the ROI was never the blocker. Production capacity was. Let's build.
What you're building
- Template-driven generation with a JSON
replacementspayload - Bulk processing for 1,000+ videos with batching and rate limits
- Webhook callbacks with HMAC signature verification
- Exponential-backoff retries and explicit error-code handling
Stack: Renderly (video API), Node.js, Promise.allSettled for concurrency, webhooks for completion. A queue like BullMQ on Redis helps once you're past ~10k, but you don't need it to start.
The API foundation
One endpoint, Bearer auth, JSON bodies. Base URL renderly.video/api/v1.
const RENDERLY_API_KEY = process.env.RENDERLY_API_KEY;
const API_BASE_URL = 'https://renderly.video/api/v1';
async function createRender(templateId, replacements) {
const res = await fetch(`${API_BASE_URL}/renders`, {
method: 'POST',
headers: {
Authorization: `Bearer ${RENDERLY_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ templateId, replacements }),
});
if (!res.ok) {
const err = await res.json();
throw new Error(`API ${res.status}: ${err.message}`);
}
return res.json(); // { id, status: 'pending', ... }
}
The template system: isDynamic, not {{ mustache }}
Most video API tutorials show {{ variable }} placeholders. Renderly is overlay-based instead, and this is the thing that trips people up on their first try.
Each overlay element carries an isDynamic flag. When it's true, that overlay's content becomes a named variable. Your request sends a replacements object keyed by overlay name, and the renderer matches by name to swap the value in. It replaces content for text and shape overlays, and src for image, video, and audio.
{
"overlays": [
{ "type": "text", "name": "product_name", "content": "Default", "isDynamic": true },
{ "type": "image", "name": "product_image", "src": "https://cdn.example.com/default.jpg", "isDynamic": true },
{ "type": "text", "name": "price", "content": "$0.00", "isDynamic": true },
{ "type": "text", "content": "Powered by Acme Co.", "isDynamic": false }
]
}
That last overlay (isDynamic: false) is the brand watermark. It stays identical across all 1,000 videos. Rendering one variation is a single call:
const job = await createRender('product-demo-v1', {
product_name: 'Premium Noise-Canceling Headphones',
product_image: 'https://cdn.example.com/headphones-sku-42.jpg',
price: '$149',
});
// { id: 'job_xyz', status: 'pending' }
One template, unlimited variations, zero per-video setup.
Bulk generation: batch, don't blast
Naive for…await is the first mistake. It turns a 20-minute run into 3 hours. Naive Promise.all is the second: one rejection kills 999 good renders. Bounded batches of Promise.allSettled avoid both:
async function generateInBatches(items, templateId, batchSize = 50) {
const results = { succeeded: [], failed: [] };
for (let i = 0; i < items.length; i += batchSize) {
const batch = items.slice(i, i + batchSize);
console.log(`Batch ${i / batchSize + 1} — ${batch.length} videos`);
const settled = await Promise.allSettled(
batch.map(p => createRender(templateId, {
product_name: p.name,
product_image: p.imageUrl,
price: p.price,
}))
);
for (const r of settled) {
if (r.status === 'fulfilled') results.succeeded.push(r.value);
else results.failed.push({ reason: r.reason.message });
}
// breathe between batches to stay under rate limits
if (i + batchSize < items.length) await new Promise(r => setTimeout(r, 2000));
}
return results;
}
Throughput is rarely the bottleneck. Hosted template APIs handle 10k to 100k+ renders a month. Your error strategy matters more than how fast you submit.
Tracking completion: webhooks over polling
Polling works for a handful of jobs. In production, register a webhook and let the API tell you when a render lands. Don't skip signature verification. It's one createHmac call standing between your endpoint and spoofed events:
import crypto from 'crypto';
app.post('/webhook/render-complete', express.json(), (req, res) => {
const expected = 'sha256=' + crypto
.createHmac('sha256', process.env.WEBHOOK_SECRET)
.update(JSON.stringify(req.body))
.digest('hex');
if (req.headers['x-renderly-signature'] !== expected) {
return res.status(401).json({ error: 'Invalid signature' });
}
const { jobId, status, outputUrl, error } = req.body;
if (status === 'completed') console.log(`✅ ${jobId}: ${outputUrl}`);
else if (status === 'failed') console.error(`❌ ${jobId}: ${error}`);
res.json({ received: true });
});
The full script
Loads data, retries with exponential backoff, batches, reports:
// generate-bulk-videos.js
import 'dotenv/config';
const API = 'https://renderly.video/api/v1';
const KEY = process.env.RENDERLY_API_KEY;
const TEMPLATE_ID = 'product-demo-v1';
const BATCH_SIZE = 50;
async function createRender(replacements) {
const res = await fetch(`${API}/renders`, {
method: 'POST',
headers: { Authorization: `Bearer ${KEY}`, 'Content-Type': 'application/json' },
body: JSON.stringify({ templateId: TEMPLATE_ID, replacements }),
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
return res.json();
}
async function withRetry(replacements, attempt = 0) {
try {
return await createRender(replacements);
} catch (err) {
if (attempt >= 3) throw err;
await new Promise(r => setTimeout(r, Math.min(1000 * 2 ** attempt, 30_000))); // 1s,2s,4s
return withRetry(replacements, attempt + 1);
}
}
async function run() {
// swap for your real source: DB query, CSV, upstream API
const products = Array.from({ length: 1000 }, (_, i) => ({
name: `Product ${i + 1}`,
imageUrl: `https://cdn.example.com/products/product-${i + 1}.jpg`,
price: `$${(10 + i * 0.5).toFixed(2)}`,
}));
let succeeded = 0, failed = 0;
for (let i = 0; i < products.length; i += BATCH_SIZE) {
const batch = products.slice(i, i + BATCH_SIZE);
const settled = await Promise.allSettled(
batch.map(p => withRetry({ product_name: p.name, product_image: p.imageUrl, price: p.price }))
);
succeeded += settled.filter(r => r.status === 'fulfilled').length;
failed += settled.filter(r => r.status === 'rejected').length;
if (i + BATCH_SIZE < products.length) await new Promise(r => setTimeout(r, 2000));
}
console.log(`Done: ${succeeded} queued, ${failed} failed`);
}
run().catch(console.error);
Error codes worth handling explicitly
-
401invalid or expired API key -
402credits exhausted. Check your balance before a big run, since it's a 402 and not a generic 500 -
404template ID not found -
429rate limited, which the backoff above already handles
Realistic numbers (from production, not marketing copy)
| Scale | Queue time | Render completion |
|---|---|---|
| 100 videos | ~2 min | ~10-15 min |
| 1,000 videos | ~15-20 min | ~1-2 hours |
| 10,000 videos | ~2-3 hours | ~12-24 hours |
Queueing is fast. Rendering happens server-side and concurrently, so wall-clock time tracks template complexity and resolution more than your submission speed. Lean templates (fewer overlays, compressed assets, shorter durations) are the single biggest throughput lever. If 10k jobs start hitting time limits, look at the template before you touch the code.
Three pitfalls that bite at scale
-
Sequential
awaitinstead ofPromise.allSettled. This is the 20-minute run that quietly becomes a 3-hour one. - No retry tracking. Persist failed job IDs to a list or table for a second pass. Log-and-forget loses those renders for good.
-
Missing
replacementsdefaults. An absent key falls back to the overlay's template default, so populate defaults in the template JSON.
Wrap-up
The pipeline above does 1,000 personalized videos in roughly 15 to 20 minutes of queue time, and it scales linearly. 10k is just more batches. Start with 10, confirm your template renders end-to-end, then turn up the volume.
The full version with the cost breakdown and the four production approaches lives here: How to Generate 1,000+ Personalized Videos with API Automation. Or grab an API key at renderly.video.
What's your current approach to bulk media generation? Queue-based, serverless fan-out, something else? Curious what's actually working for people.
Top comments (1)
At 1000 renders, webhooks and idempotency matter more than the render call itself. The API call is the easy part; the production problem is tracking jobs, retries, partial failures, and delivery status.
I would also store the template version with every render. Personalized video bugs are painful when you cannot tell which template or data snapshot produced a bad asset.