Batch operations let you generate hundreds or thousands of images efficiently from a single API call. Perfect for bulk social cards, certificates, personalized content, and data-driven graphics.
The poll endpoint does not return rendered URLs. getBatchResults reports per-item { index, success, variables } (plus error on failures). Final image URLs are delivered via the render.completed webhook — subscribe to webhooks to collect batch output (see below).
const status = await pictify.getBatchResults(job.batchId);for (const item of status.results) { if (item.success) { console.log(`Item ${item.index} rendered (vars: ${item.variables.join(', ')})`); } else { console.error(`Item ${item.index} failed: ${item.error}`); }}
Webhooks are how you collect the rendered image URLs from a batch. Configure a webhook subscription in the dashboard (Settings > Webhooks) or via the webhook API, then handle two event types:
render.completed — fired once per rendered image, and carries the url. This is where you collect output.
batch.completed — fired once when the whole job finishes, with success/failure counts.
async function retryFailedItems(templateId: string, batchId: string) { const status = await pictify.getBatchResults(batchId); const failed = status.results.filter(item => !item.success); if (failed.length === 0) { console.log('No failed items to retry'); return; } // The poll response reports the variable names per item, not the original // values — look the failed sets back up from your own records. const failedVariableSets = failed.map(item => originalVariableSets[item.index]); // Start a new batch with just the failed items const retryJob = await pictify.renderBatch({ templateId, variableSets: failedVariableSets, }); console.log(`Retry batch started: ${retryJob.batchId}`);}