Async & webhooks
For big PDFs, full-page screenshots, or high volume, render asynchronously: enqueue the job, get an id back immediately, then either poll or receive a signed webhook.
# Enqueue
Add async: true (or a webhookUrl) to any render or
screenshot request:
curl https://api.mostlyrender.com/v1/renders \
-H "Authorization: Bearer mr_live_…" \
-H "Content-Type: application/json" \
-d '{
"template": "tpl_abc",
"output": "pdf",
"async": true,
"webhookUrl": "https://your.app/hooks/mostlyrender"
}'
{ "id": "job_xyz789", "status": "queued" }
The response is 202 Accepted with a job id.
# Poll
curl https://api.mostlyrender.com/v1/renders/job_xyz789 \
-H "Authorization: Bearer mr_live_…"
{
"id": "job_xyz789",
"status": "done",
"kind": "render",
"result": { "id": "rnd_abc", "url": "https://img.mostlyrender.com/…/rnd_abc.pdf", "output": "pdf" },
"error": null
}
status moves queued → processing → done (or error). When done, result holds
the render { id, url, output }.
job = mr.render_async("tpl_abc", output="pdf", webhook_url="https://your.app/hooks/mostlyrender")
final = mr.wait_for_render(job["id"])
print(final["result"]["url"])
# Webhooks
If you pass a webhookUrl, MostlyRender POSTs the job result there when it finishes:
{
"id": "job_xyz789",
"status": "done",
"result": { "id": "rnd_abc", "url": "https://img.mostlyrender.com/…/rnd_abc.pdf", "output": "pdf" }
}
# Verify the signature
Each webhook carries an HMAC-SHA256 signature of the raw body in the
x-mostlyrender-signature header, prefixed sha256=. Recompute it with your signing
secret and compare in constant time:
import crypto from 'node:crypto';
function verify(rawBody, header, secret) {
const expected = 'sha256=' + crypto.createHmac('sha256', secret).update(rawBody).digest('hex');
return crypto.timingSafeEqual(Buffer.from(header), Buffer.from(expected));
}
Respond with any 2xx to acknowledge. Delivery is retried a few times on failure;
webhook targets are SSRF-guarded just like screenshot URLs.