Skip to main content

Wait for exports with webhooks

A video can take minutes to render. Instead of asking for its state every few seconds, let heycreo send a request to your server the moment the file is ready.

You need a server reachable over HTTPS and a design to export: Create and export a design shows how to make one.

1. Create the webhook​

Webhook endpoints belong to a service account: it decides what the deliveries may contain. In heycreo, open the service account under Settings → Developers → Service accounts and add an endpoint on its Webhooks tab:

  • URL: your receiver, for example https://example.com/heycreo/webhooks.
  • Events: export.completed and export.failed.

Copy the signing secret (whsec_…) right away; it is shown only once. Then send a Test ping from the same page to check that your server is reached.

2. Receive the events​

A minimal receiver in Node.js with Express. It checks the signature, answers at once and does the work afterwards:

receiver.js
import express from 'express'
import { createHmac, timingSafeEqual } from 'crypto'

const SECRET = process.env.HEYCREO_WEBHOOK_SECRET
const seen = new Set() // in production: a table with a unique key

function verify(rawBody, header) {
const parts = Object.fromEntries(
header.split(',').map((p) => p.trim().split('=')),
)
if (Math.abs(Date.now() / 1000 - Number(parts.t)) > 300) return false

const expected = createHmac('sha256', SECRET)
.update(`${parts.t}.${rawBody}`)
.digest('hex')
if (parts.v1?.length !== expected.length) return false
return timingSafeEqual(Buffer.from(parts.v1), Buffer.from(expected))
}

const app = express()

// The signature covers the raw body: read it unparsed.
app.post('/heycreo/webhooks', express.raw({ type: 'application/json' }), (req, res) => {
if (!verify(req.body.toString('utf8'), req.get('heycreo-signature') ?? '')) {
return res.sendStatus(401)
}
res.sendStatus(204)

const event = JSON.parse(req.body.toString('utf8'))
if (seen.has(event.id)) return // a retry of an event already handled
seen.add(event.id)

if (event.type === 'export.completed') {
const { id, postId, videoUrl, imageUrl, pdfUrl } = event.data.export
const file = videoUrl ?? imageUrl ?? pdfUrl
console.log(`Export ${id} of design ${postId} is ready: ${file}`)
// Fetch the file and pass it on: to your CMS, your DAM, a customer.
}
if (event.type === 'export.failed') {
console.error(`Export ${event.data.export.id} failed:`, event.data.export.error)
}
})

app.listen(3000)
  • Answer within 10 seconds. Store the event and do the work afterwards; a slow answer counts as a failed delivery.
  • Deduplicate on the event's id (heycreo-event-id). A failed delivery is retried with the same id, up to six attempts in all.
  • Reject old timestamps. The check above refuses signatures older than five minutes, so a captured request cannot be replayed.

Webhooks describes the signature, retries and every event type in full.

3. Start the export​

POST /api/organizations/{organizationId}/posts/{postId}/exports
curl "https://app.heycreo.io/api/organizations/$ORGANIZATION_ID/posts/$POST_ID/exports" \
-H "Authorization: Bearer $HEYCREO_API_KEY" \
--json '{}' | jq '.[] | {id, templateSizeId, status}'

Keep the export IDs from the response. Each export ends in exactly one event, export.completed or export.failed, with the same ID in data.export.id; that is how you match an event to the request that started it.

What arrives​

export.completed
{
"id": "evt_…",
"type": "export.completed",
"createdAt": "2026-11-26T10:04:12.000Z",
"organization": { "id": "…", "slug": "…" },
"data": {
"export": {
"id": "…",
"postId": "…",
"status": "completed",
"mediaType": "video",
"templateSizeId": "instagram-story",
"videoUrl": "https://…",
"width": 1080,
"height": 1920,
"renderTimeMs": 84210
}
}
}

A video export carries its file in videoUrl, an image in imageUrl, a print export in pdfUrl. A carousel lists its pages in carouselImageUrls.

See also​