Guides

Webhooks

Know the moment a job finishes: we POST a signed event to your server, and retry over more than eight hours until it answers.

webhookUrl per request, or endpoints set once

There are two ways to receive webhooks, and you can use both:

  • Per request. Pass webhookUrl on any create. We POST that job's events to it, signed with your account's webhook secret: GET /v1/webhook-secret returns it, as does webhooks.secret() in the SDKs.
  • Endpoints. Add an endpoint once, in the console or with POST /v1/webhook-endpoints (a key with the all permission), and choose its events, or every event. It receives every matching event on your account, signed with its own whsec_… secret.

Webhook URLs must be public https addresses. Private, local and internal addresses are refused.

Events

EventSent when
job.succeededA job finished. data is the job, with fresh output links.
job.failedA job failed. data.error says why. Failed jobs are never charged.
job.cancelledA queued job was cancelled.
balance.lowYour balance fell below $10 while auto-recharge is off.
balance.topped_upA top-up or an auto-recharge was added to your balance.
balance.recharge_failedAn auto-recharge could not charge your card.

Every event has an id (evt_…), a type, a createdAt and data. Use the event id to skip a delivery you have already handled. The same events are listed by GET /v1/events. The console's test button sends a webhook.test event.

Verifying the Framera-Signature header

Every delivery carries a Framera-Signature header such as t=1764433473,v1=5f2b…. t is when we sent it, in Unix seconds; v1 is the hex HMAC-SHA256 of `${t}.${body}` made with your signing secret. To check it:

  1. Read the raw request body, before any JSON parsing.
  2. Split the header on commas and take t and v1.
  3. Compute the HMAC-SHA256 of t, a dot and the body with your secret, as hex, and compare it with v1 in constant time.
  4. Reject the request if they differ, or if t is more than five minutes from now.

The SDKs do all of this in one call: Framera.webhooks.verify(body, header, secret) in TypeScript and framera.webhooks.verify(body, header, secret, tolerance=300) in Python. Without an SDK:

import { createHmac, timingSafeEqual } from 'node:crypto';

function verify(body: string, header: string, secret: string): boolean {
  const parts = Object.fromEntries(header.split(',').map((p) => p.trim().split('=')));
  const t = Number(parts.t);
  if (!t || Math.abs(Date.now() / 1000 - t) > 300) return false;
  const expected = createHmac('sha256', secret).update(`${t}.${body}`).digest('hex');
  const a = Buffer.from(expected, 'hex');
  const b = Buffer.from(parts.v1 ?? '', 'hex');
  return a.length === b.length && timingSafeEqual(a, b);
}

Retries and replaying events

Answer with any 2xx status within ten seconds to tell us you have the event, and do slow work after you answer. If your server answers anything else, or cannot be reached, we try again after 1 minute, 5 minutes, 30 minutes, 2 hours and 6 hours: six attempts in all. A failed delivery never changes the job itself.

The Webhooks page in the console lists every delivery with its response and timing. Press Resend on any of them to send it again, for example after fixing a bug in your handler.

Testing webhooks locally

Your laptop is not a public address, so use a tunnelling tool to give your local server a public https URL, and add that URL as an endpoint. Then press Send a test event on the endpoint in the console for a sample delivery straight away.