For AI agents: the complete documentation index is available at /docs/llms.txt, the full documentation bundle is available at /docs/llms-full.txt, and this page is available as Markdown at /docs/recipes/receivers.md.

Receive signed webhooks

These are receivers you host yourself. No SDK or framework is needed. Create an endpoint on the form, subscribe to submission.created, and store its signing secret as WEBHOOK_SECRET. Do not use a submission API key here.

Production destinations need public HTTPS. Put these loopback listeners behind your HTTPS reverse proxy. Local development permits sandbox HTTP loopback destinations. Other private destinations are rejected.

Verify before parsing

The worker sends Content-Type: application/cloudevents+json and three signature headers:

  • webhook-id: the stable event ID.
  • webhook-timestamp: Unix seconds for this delivery attempt.
  • webhook-signature: space-separated v1,<base64> signatures.

Remove whsec_ from the secret and base64-decode the rest. Compute HMAC-SHA256 over webhook-id + "." + webhook-timestamp + "." + raw body. Compare the base64 signature in constant time. Accept any matching v1 signature; rotation sends both secrets' signatures for 24 hours.

The installed Standard Webhooks verifier allows 300 seconds in either direction. These examples use that same tolerance and require an integer timestamp. Keep your clock synchronized. Never parse and reserialize JSON before checking its signature.

Node receiver

Save as receiver.mjs and run node receiver.mjs. Set WEBHOOK_SECRET to your signing secret. Optional PORT defaults to 9000; INBOX defaults to ./inbox.

import { createServer } from 'node:http';
import { createHmac, timingSafeEqual, randomUUID } from 'node:crypto';
import { mkdirSync, openSync, writeFileSync, fsyncSync, closeSync,
  linkSync, unlinkSync } from 'node:fs';
import { join } from 'node:path';

const secret = process.env.WEBHOOK_SECRET;
if (!secret?.startsWith('whsec_')) throw new Error('Set WEBHOOK_SECRET');
const key = Buffer.from(secret.slice(6), 'base64');
const inbox = process.env.INBOX || './inbox';
mkdirSync(inbox, { recursive: true, mode: 0o700 });

createServer(async (req, res) => {
  const answer = (status) => res.writeHead(status).end();
  if (req.method !== 'POST' || req.url !== '/webhooks') return answer(404);
  try {
    const chunks = [];
    let size = 0;
    for await (const chunk of req) {
      size += chunk.length;
      if (size > 2 * 1024 * 1024) return answer(413);
      chunks.push(chunk);
    }
    const raw = Buffer.concat(chunks);
    const id = req.headers['webhook-id'];
    const stamp = req.headers['webhook-timestamp'];
    const signatures = req.headers['webhook-signature'];
    if (typeof id !== 'string' || !/^evt_[A-Za-z0-9_-]+$/.test(id) ||
        typeof stamp !== 'string' || !/^\d+$/.test(stamp) ||
        typeof signatures !== 'string' ||
        Math.abs(Math.floor(Date.now() / 1000) - Number(stamp)) > 300) {
      return answer(401);
    }
    const expected = Buffer.from(createHmac('sha256', key)
      .update(`${id}.${stamp}.`).update(raw).digest('base64'));
    const valid = signatures.split(' ').some((part) => {
      const [version, signature] = part.split(',');
      if (version !== 'v1' || !signature) return false;
      const candidate = Buffer.from(signature);
      return candidate.length === expected.length && timingSafeEqual(candidate, expected);
    });
    if (!valid) return answer(401);
    let event;
    try { event = JSON.parse(raw.toString('utf8')); } catch { return answer(400); }
    if (event?.id !== id) return answer(400);

    // Publish a complete, flushed inbox file atomically; its name deduplicates retries.
    const temp = join(inbox, `${randomUUID()}.tmp`);
    const fd = openSync(temp, 'wx', 0o600);
    try { writeFileSync(fd, raw); fsyncSync(fd); } finally { closeSync(fd); }
    try {
      try { linkSync(temp, join(inbox, `${id}.json`)); }
      catch (error) { if (error.code !== 'EEXIST') throw error; }
    } finally { unlinkSync(temp); }
    const directory = openSync(inbox, 'r');
    try { fsyncSync(directory); } finally { closeSync(directory); }
    answer(204);
  } catch {
    if (!res.headersSent) answer(503);
  }
}).listen(Number(process.env.PORT || 9000), '127.0.0.1');

Python receiver

Save as receiver.py and run python3 receiver.py. It uses the same environment variables and inbox format.

import base64
import hashlib
import hmac
import json
import os
import re
import tempfile
import time
from http.server import BaseHTTPRequestHandler, HTTPServer
from pathlib import Path

secret = os.environ['WEBHOOK_SECRET']
assert secret.startswith('whsec_')
key = base64.b64decode(secret[6:], validate=True)
inbox = Path(os.environ.get('INBOX', './inbox'))
inbox.mkdir(parents=True, exist_ok=True, mode=0o700)

class Receiver(BaseHTTPRequestHandler):
    def log_message(self, *args):
        pass

    def answer(self, status):
        self.send_response(status)
        self.end_headers()

    def do_POST(self):
        if self.path != '/webhooks':
            return self.answer(404)
        # This stdlib server requires Content-Length. Preserve it at the proxy.
        length = self.headers.get('Content-Length', '')
        if not length.isdecimal():
            return self.answer(411)
        if int(length) > 2 * 1024 * 1024:
            return self.answer(413)
        self.connection.settimeout(10)
        try:
            raw = self.rfile.read(int(length))
            if len(raw) != int(length):
                return self.answer(400)
            event_id = self.headers.get('webhook-id', '')
            stamp = self.headers.get('webhook-timestamp', '')
            signatures = self.headers.get('webhook-signature', '')
            if (not re.fullmatch(r'evt_[A-Za-z0-9_-]+', event_id)
                    or not re.fullmatch(r'[0-9]+', stamp)
                    or abs(int(time.time()) - int(stamp)) > 300):
                return self.answer(401)
            signed = (event_id + '.' + stamp + '.').encode() + raw
            expected = base64.b64encode(hmac.digest(key, signed, hashlib.sha256))
            valid = False
            for part in signatures.split(' '):
                version, _, signature = part.partition(',')
                if version == 'v1' and hmac.compare_digest(signature.encode(), expected):
                    valid = True
            if not valid:
                return self.answer(401)
            try:
                event = json.loads(raw)
            except (ValueError, UnicodeDecodeError):
                return self.answer(400)
            if not isinstance(event, dict) or event.get('id') != event_id:
                return self.answer(400)
            fd, temp = tempfile.mkstemp(dir=inbox, suffix='.tmp')
            try:
                with os.fdopen(fd, 'wb') as file:
                    file.write(raw)
                    file.flush()
                    os.fsync(file.fileno())
                try:
                    os.link(temp, inbox / (event_id + '.json'))
                except FileExistsError:
                    pass
            finally:
                os.unlink(temp)
            directory = os.open(inbox, os.O_RDONLY)
            try:
                os.fsync(directory)
            finally:
                os.close(directory)
            self.answer(204)
        except (OSError, ValueError):
            self.answer(503)

HTTPServer(('127.0.0.1', int(os.environ.get('PORT', '9000'))), Receiver).serve_forever()

These Linux examples acknowledge with 204 after saving the event, before any downstream request. Invalid signatures and stale timestamps get 401; receiver storage failures get 503. These are receiver choices, not submission API statuses. The 2 MiB body cap is also a receiver policy; adjust it to your form's payload needs. Keep inbox files private. Use persistent storage, monitor disk space, and retain event IDs when archiving processed payloads. Deleting an inbox file removes its deduplication record. Multiple hosts need a shared transactional inbox with a unique event ID.

Event fields

A creation event has specversion: "1.0", id, source: "/forms/<form ID>", type: "com.formroost.submission.created.v1", subject (receipt ID), time, datacontenttype: "application/json", and dataschema: "/docs/webhooks/schemas/submission.created.v1.json". Its data contains receiptId, environment, fields, and metadata (available origin and referrer). The signed header ID equals the envelope ID.

Delivery is at least once and unordered. Other event types do not all include fields. The forwarding examples process only creation events.

Failures, pause, and replay

Only 2xx succeeds. Redirects are not followed. Connection timeout is three seconds and total timeout is ten seconds. Automatic attempts are scheduled at offsets of 0, 60, 300, 1800, 7200, 21600, 43200, 86400, 172800, and 259200 seconds from event creation. After the tenth failed attempt the event is failed.

For 429 and 503, Retry-After may delay the next attempt. It is capped at 24 hours from now and 72 hours from event creation. Failures degrade the endpoint. At least 20 consecutive failures across at least five events open the circuit for 15 minutes; further failures increase the delay up to six hours. This is temporary backoff, not a manual pause.

Use Pause in the portal while repairing your receiver. The worker skips paused endpoints. Resume clears failure and circuit state and queues pending events. Failed or already delivered events require Replay from the event's delivery details. Replay preserves the event ID and payload, with a fresh timestamp and signature. A successfully saved event therefore remains deduplicated. Replay is disabled for paid-history retention archives.

Resume and replay are authenticated portal operations, not submission-key calls. Their routes are POST /api/v1/webhooks/:webhookId/resume and POST /api/v1/webhooks/:webhookId/events/:eventId/replay. See signed webhooks for delivery diagnostics and rotation.