# Webhooks reference

> Events, signature with ready-made code, retries, delivery log.

Source: https://flow-marketing.org/en/help/api-webhooks-reference · Question: How do I set up webhooks and verify the signature?

A webhook sends events such as video.ready to your server by POST. Every delivery is signed following the open “Standard Webhooks” spec. You verify the signature, answer with 2xx and do the work afterwards.

This page lists all endpoints, all events, the exact signature procedure with ready-made code for JavaScript and Python, the retries and the allowed addresses.

## Endpoints {#endpunkte}

Scope for all of them: `webhooks:manage`. Webhooks belong to one mode: a test key only sees and changes test webhooks, and test events only go to test webhooks. At most 10 webhooks per account (409 `too_many_webhooks`).

| Method and path | Purpose |
| --- | --- |
| `POST /webhooks` | create (201); the secret is returned only here |
| `GET /webhooks` | all webhooks of the mode |
| `GET /webhooks/{id}` | read one webhook |
| `PATCH /webhooks/{id}` | change `url`, `events`, `enabled`, `description` |
| `DELETE /webhooks/{id}` | delete; answer `{"id", "object": "webhook", "deleted": true}` |
| `POST /webhooks/{id}/rotate_secret` | new secret; the old one keeps signing for 24 hours |
| `POST /webhooks/{id}/test` | send `test.ping` now, result returned |
| `GET /webhooks/{id}/deliveries` | delivery log, newest first (`limit` 1–200, default 50) |
| `POST /webhooks/{id}/deliveries/{delivery_id}/retry` | send one delivery again now |

## Create a webhook {#anlegen}

The answer (201) contains `secret` (`whsec_…`) once. Store it right away, for example as `FLOW_WEBHOOK_SECRET`. The API never shows it again.

| Field | Meaning |
| --- | --- |
| `url` | required: public https address, up to 500 characters (rules in “Allowed addresses”) |
| `events` | list of up to 20 events or `["*"]` for all; default `["*"]` |
| `description` | up to 200 characters |

**curl**

```bash
curl -X POST https://flow-marketing.org/api/turbo/v1/webhooks \
  -H "Authorization: Bearer $FLOW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/flow-webhook", "events": ["video.ready", "video.failed"], "description": "Produktion"}'
```

**JavaScript**

```js
const res = await fetch('https://flow-marketing.org/api/turbo/v1/webhooks', {
  method: 'POST',
  headers: { Authorization: 'Bearer ' + process.env.FLOW_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({ url: 'https://example.com/flow-webhook', events: ['video.ready', 'video.failed'], description: 'Produktion' }),
})
const wh = await res.json()
// wh.secret (whsec_...) is shown ONLY here – store it as FLOW_WEBHOOK_SECRET
```

**Python**

```python
import os, requests

r = requests.post(
    "https://flow-marketing.org/api/turbo/v1/webhooks",
    headers={"Authorization": "Bearer " + os.environ["FLOW_API_KEY"]},
    json={"url": "https://example.com/flow-webhook", "events": ["video.ready", "video.failed"], "description": "Produktion"},
    timeout=30,
)
wh = r.json()
# wh["secret"] (whsec_...) is shown ONLY here – store it as FLOW_WEBHOOK_SECRET
```

**Response 201**

```json
{
  "id": "wh_3fGh7JkL9zXc1VbN5mQw",
  "object": "webhook",
  "url": "https://example.com/flow-webhook",
  "events": ["video.ready", "video.failed"],
  "mode": "test",
  "enabled": true,
  "paused_reason": null,
  "description": "Produktion",
  "success_rate_24h": null,
  "created_at": "2026-11-22T09:00:00.000Z",
  "secret": "whsec_q0Zt1n3G8oT4uJ8mVb2cW9xYzA1bC2dE"
}
```

## Events {#ereignisse}

You can subscribe to every name in the list. Today the ones marked “yes” are fired; the others are reserved for upcoming features and do not arrive yet.

| Event | When | Today |
| --- | --- | --- |
| `video.draft_ready` | video created or changed by PATCH, preview ready | yes |
| `video.rendering` | the render is running | yes |
| `video.ready` | video done, files available | yes |
| `video.failed` | still red after repairs | yes |
| `video.canceled` | render canceled | yes |
| `balance.low` | balance covers fewer than two 60-second videos (live only, only after a top-up) | yes |
| `spending_limit.warning` | 80 % of the monthly limit reached (live only) | yes |
| `spending_limit.reached` | 100 % of the monthly limit reached (live only) | yes |
| `speech.completed` | speech job done | yes, when “voice via the API” is on |
| `speech.failed` | speech job failed | yes, when “voice via the API” is on |
| `test.ping` | test via `POST /webhooks/{id}/test` | yes |
| `video.fill_failed` | reserved – fill errors come directly as 502 `fill_failed` today | no |
| `image.ready`, `image.failed` | reserved (images) | no |
| `brand.ready`, `brand.failed` | reserved (brand kits) | no |
| `asset.ready`, `asset.rejected` | reserved | no |
| `batch.completed` | reserved (batches) | no |
| `balance.topped_up` | reserved (top-ups) | no |
| `api_key.exposed` | reserved | no |

> **Note:** Flow Marketing checks balance and limit every 15 minutes. `spending_limit.*` arrives at most once per month, `balance.low` at most once in 24 hours.

## Structure of an event {#ereignis-koerper}

| Field | Meaning |
| --- | --- |
| `id` | `evt_…`, equal to the `webhook-id` header – for deduplication |
| `object` | `event` |
| `type` | name of the event |
| `mode` | `test` or `live` |
| `api_version` | `2026-11-20` |
| `created` | time in Unix seconds |
| `request_id` | the request that triggered the event, otherwise `null` |
| `data.object` | `video.*`: the video with `latest_render`; `balance.low` and `spending_limit.*`: `available_cents`, `reserved_cents`, `month_spent_cents`, `monthly_limit_cents`; `speech.*`: the speech job; `test.ping`: `{"object": "ping", "message"}` |

**Sample video.ready (shortened)**

```json
{
  "id": "evt_5pN2kLm8QwRt6Yu1Io3P",
  "object": "event",
  "type": "video.ready",
  "mode": "live",
  "api_version": "2026-11-20",
  "created": 1795305600,
  "request_id": null,
  "data": {
    "object": {
      "id": "vid_7Hq2LmN0pQrS3tUv4WxY",
      "object": "video",
      "status": "ready",
      "metadata": { "customer_id": "c_1042" },
      "latest_render": {
        "id": "rnd_9KpQ2wErT5yU7iO1aS3d",
        "status": "succeeded",
        "files": { "master_16x9": { "url": "https://...", "expires_at": "...", "content_type": "video/mp4" } },
        "charge": { "amount_cents": 260, "currency": "eur", "billable_seconds": 26, "source": "balance" }
      }
    }
  }
}
```

## Headers of a delivery {#kopfzeilen}

| Header | Content |
| --- | --- |
| `content-type` | `application/json` |
| `user-agent` | `FlowMarketing-Webhooks/1.0 (+https://flow-marketing.org/entwickler)` |
| `webhook-id` | id of the event (`evt_…`) |
| `webhook-timestamp` | Unix seconds of this delivery attempt |
| `webhook-signature` | `v1,<base64>`; during a rotation two signatures, separated by a space |
| `flow-event-type` | equal to `type` in the body |

## Verifying the signature {#signatur}

The procedure is the open “Standard Webhooks” spec. Instead of your own code you can use any Standard Webhooks library, for example the package `standardwebhooks` for JavaScript and Python.

1. Take the raw body – exactly the bytes that arrive. Do not parse and re-serialize first.
2. Read `webhook-timestamp`. If it differs from your clock by more than 5 minutes (300 seconds): reject.
3. Build the key: cut the prefix `whsec_` off the secret and Base64-decode the rest.
4. Build the signed text: `<webhook-id>.<webhook-timestamp>.<raw-body>`.
5. Compute HMAC-SHA256 with the key, Base64-encode it and put `v1,` in front.
6. Compare with each signature in the `webhook-signature` header (separated by spaces), in constant time. If one matches, the message is genuine.

**JavaScript**

```js
// Express: the RAW body is required for the signature (express.raw)
import crypto from 'node:crypto'
import express from 'express'

function verifyFlowWebhook(secret, headers, rawBody) {
  const id = headers['webhook-id']
  const ts = headers['webhook-timestamp']
  const sigHeader = headers['webhook-signature'] || ''
  const t = Number(ts)
  if (!id || !Number.isInteger(t)) return false
  if (Math.abs(Math.floor(Date.now() / 1000) - t) > 300) return false // older than 5 minutes
  const key = Buffer.from(secret.startsWith('whsec_') ? secret.slice(6) : secret, 'base64')
  const expected = Buffer.from('v1,' + crypto.createHmac('sha256', key).update(id + '.' + ts + '.' + rawBody).digest('base64'))
  // during a secret rotation the header carries two signatures, separated by a space
  return sigHeader.split(' ').filter(Boolean).some((s) => {
    const b = Buffer.from(s)
    return b.length === expected.length && crypto.timingSafeEqual(b, expected)
  })
}

const seen = new Set() // use a database in production
const app = express()
app.post('/flow-webhook', express.raw({ type: 'application/json' }), (req, res) => {
  const raw = req.body.toString('utf8')
  if (!verifyFlowWebhook(process.env.FLOW_WEBHOOK_SECRET, req.headers, raw)) return res.sendStatus(400)
  const event = JSON.parse(raw)
  res.sendStatus(200) // answer within 10 s, work afterwards
  if (seen.has(event.id)) return // webhook-id = event.id: deduplicate
  seen.add(event.id)
  if (event.type === 'video.ready') console.log('ready', event.data.object.id)
})
app.listen(3000)
```

**Python**

```python
# Flask: request.get_data() is the raw body
import base64, hashlib, hmac, json, os, time
from flask import Flask, request

def verify_flow_webhook(secret: str, headers, raw_body: bytes) -> bool:
    msg_id = headers.get("webhook-id", "")
    ts = headers.get("webhook-timestamp", "")
    sig_header = headers.get("webhook-signature", "")
    try:
        t = int(ts)
    except ValueError:
        return False
    if not msg_id or abs(int(time.time()) - t) > 300:  # older than 5 minutes
        return False
    key = base64.b64decode(secret[6:] if secret.startswith("whsec_") else secret)
    signed = msg_id.encode() + b"." + ts.encode() + b"." + raw_body
    expected = "v1," + base64.b64encode(hmac.new(key, signed, hashlib.sha256).digest()).decode()
    # during a secret rotation the header carries two signatures, separated by a space
    return any(hmac.compare_digest(s, expected) for s in sig_header.split(" ") if s)

app = Flask(__name__)
seen = set()  # use a database in production

@app.post("/flow-webhook")
def flow_webhook():
    raw = request.get_data()
    if not verify_flow_webhook(os.environ["FLOW_WEBHOOK_SECRET"], request.headers, raw):
        return "", 400
    event = json.loads(raw)
    if event["id"] in seen:  # webhook-id = event id: deduplicate
        return "", 200
    seen.add(event["id"])
    if event["type"] == "video.ready":
        print("ready", event["data"]["object"]["id"])
    return "", 200
```

> **Warning:** Answer 2xx only after verifying. Answer a message without a valid signature or with an old timestamp with 400 and do not process it.

## Delivery, timeout and retries {#zustellung}

- Answer within 10 seconds with a status from 200 to 299. The response body is ignored; the log keeps its first 500 characters.
- Redirects (3xx) are not followed and count as a failure.
- Any other answer, a timeout or a connection error leads to a retry: after 1, 5, 15, 60, 120, 240, 480 and 480 minutes – 8 retries over about 23.4 hours. After that the delivery is `failed`.
- Sending runs every minute. So up to about one minute can pass between the event and the first delivery.
- Paused webhooks (`enabled: false`) receive no new events. Retries already scheduled wait and continue once you switch it on again.
- Order is not guaranteed. Decide by `data.object.status` and `created`, not by arrival.
- The same event can arrive more than once (retry, send again). Deduplicate by `webhook-id`.
- File links in the body are valid 24 hours from the event. If a retry arrives late, fetch fresh links with `GET /renders/{id}`.
- Finished deliveries (delivered or given up) stay in the log for 30 days.

> **Note:** Unlike the OpenAPI description says, there is currently no random jitter on retries, no e-mail when a delivery is given up, no automatic pause after three days of failures and no `GET /events` endpoint.

## Allowed addresses {#erlaubte-adressen}

If a URL breaks these rules, `POST` and `PATCH` answer 422 `webhook_url_not_allowed`. If a name later points to a private network, the delivery fails (log: “Ziel-Adresse gesperrt”, target address blocked).

- Only `https://`, port 443 or no port.
- No credentials in the URL (`user:pass@`).
- No internal names: `localhost`, names without a dot and endings like `.local`, `.internal`, `.lan`, `.home`, `.intern`, `.localhost`.
- No private or reserved IP addresses. The name is resolved and checked again before every send; the connection goes to exactly the checked address.

## Test, log, send again, change the secret {#verwalten}

`POST /webhooks/{id}/test` sends a `test.ping` right away and returns the delivery with status code and response excerpt. The call counts as expensive for rate limiting, and so does `retry`.

`GET /webhooks/{id}/deliveries` lists deliveries with `status` (`pending`, `delivered`, `failed`), `attempts`, `next_attempt_at`, `last_status_code`, `last_response_excerpt` and `last_duration_ms`. `retry` resets one delivery and sends it at once.

`rotate_secret` creates a new secret (`secret` in the answer) and states in `previous_secret_valid_until` until when the old one still signs: for 24 hours every delivery carries two signatures. Switch your server over in that time.

**curl**

```bash
# send a test.ping now
curl -X POST https://flow-marketing.org/api/turbo/v1/webhooks/wh_3fGh7JkL9zXc1VbN5mQw/test \
  -H "Authorization: Bearer $FLOW_API_KEY"

# delivery log (newest first)
curl "https://flow-marketing.org/api/turbo/v1/webhooks/wh_3fGh7JkL9zXc1VbN5mQw/deliveries?limit=20" \
  -H "Authorization: Bearer $FLOW_API_KEY"

# send one delivery again
curl -X POST https://flow-marketing.org/api/turbo/v1/webhooks/wh_3fGh7JkL9zXc1VbN5mQw/deliveries/whd_1aS3dF5gH7jK9lZ1xC3v/retry \
  -H "Authorization: Bearer $FLOW_API_KEY"

# new secret – the old one keeps signing for 24 h
curl -X POST https://flow-marketing.org/api/turbo/v1/webhooks/wh_3fGh7JkL9zXc1VbN5mQw/rotate_secret \
  -H "Authorization: Bearer $FLOW_API_KEY"

# pause / resume
curl -X PATCH https://flow-marketing.org/api/turbo/v1/webhooks/wh_3fGh7JkL9zXc1VbN5mQw \
  -H "Authorization: Bearer $FLOW_API_KEY" -H "Content-Type: application/json" \
  -d '{"enabled": false}'
```

**JavaScript**

```js
const BASE = 'https://flow-marketing.org/api/turbo/v1/webhooks/' + webhookId
const H = { Authorization: 'Bearer ' + process.env.FLOW_API_KEY, 'Content-Type': 'application/json' }

const ping = await (await fetch(BASE + '/test', { method: 'POST', headers: H })).json()
console.log(ping.status, ping.last_status_code, ping.last_response_excerpt)

const log = await (await fetch(BASE + '/deliveries?limit=20', { headers: H })).json()
for (const d of log.data.filter((x) => x.status === 'failed')) {
  await fetch(BASE + '/deliveries/' + d.id + '/retry', { method: 'POST', headers: H })
}

const rot = await (await fetch(BASE + '/rotate_secret', { method: 'POST', headers: H })).json()
console.log(rot.secret, rot.previous_secret_valid_until)
```

**Python**

```python
import os, requests

BASE = "https://flow-marketing.org/api/turbo/v1/webhooks/" + webhook_id
H = {"Authorization": "Bearer " + os.environ["FLOW_API_KEY"]}

ping = requests.post(BASE + "/test", headers=H, timeout=30).json()
print(ping["status"], ping["last_status_code"], ping["last_response_excerpt"])

log = requests.get(BASE + "/deliveries", params={"limit": 20}, headers=H, timeout=30).json()
for d in log["data"]:
    if d["status"] == "failed":
        requests.post(BASE + "/deliveries/" + d["id"] + "/retry", headers=H, timeout=30)

rot = requests.post(BASE + "/rotate_secret", headers=H, timeout=30).json()
print(rot["secret"], rot["previous_secret_valid_until"])
```

**Delivery**

```json
{
  "id": "whd_1aS3dF5gH7jK9lZ1xC3v",
  "object": "delivery",
  "webhook_id": "wh_3fGh7JkL9zXc1VbN5mQw",
  "event_id": "evt_5pN2kLm8QwRt6Yu1Io3P",
  "event_type": "video.ready",
  "status": "pending",
  "attempts": 2,
  "next_attempt_at": "2026-11-22T09:21:00.000Z",
  "last_status_code": 503,
  "last_response_excerpt": "Service Unavailable",
  "last_duration_ms": 412,
  "delivered_at": null,
  "created_at": "2026-11-22T09:00:00.000Z"
}
```

## The webhook object {#webhook-objekt}

| Field | Meaning |
| --- | --- |
| `id` | `wh_` plus 20 characters |
| `url`, `events`, `description` | as created |
| `mode` | `test` or `live` |
| `enabled` | `false` = paused |
| `paused_reason` | `manual` when `enabled: false`, otherwise `null` |
| `success_rate_24h` | always `null` today |
| `created_at` | timestamp (ISO 8601, UTC) |
| `secret` | only in the answer to create and rotate |

## See also

- [Webhooks in short](https://flow-marketing.org/en/help/webhooks)
- [Renders and status](https://flow-marketing.org/en/help/api-renders-and-status)
- [Troubleshooting](https://flow-marketing.org/en/help/api-troubleshooting)
