# Webhooks

URL: https://qrdx.dev/docs/webhooks
Source: https://github.com/qrdxinc/qrdx/blob/main/apps/docs/content/docs/webhooks.mdx

Signed HTTPS requests to your endpoint when QR codes are scanned, created or changed, or forms are sent, with retries. Verify them, or use Zapier, Make or n8n.

By the end of this page, a URL you control receives a signed `POST` within a few minutes of every event you picked, your server verifies that each request came from QRdx, and you know how retries, duplicates and the delivery log behave.

Webhooks push events from a workspace to your server as they happen: update a CRM when someone fills in a form, post to an internal tool when a code passes 1,000 scans, or keep your own copy of scan data.

**Business plan**

Webhooks, Zapier and Make hooks and Slack and Discord alerts are part of the **Business** plan. Email alerts and the weekly digest are part of Pro; see [Notifications](https://qrdx.dev/docs/notifications). Compare the plans on [Plans and limits](https://qrdx.dev/docs/plans-and-limits).

## Before you start [#before-you-start]

- A public `https://` URL that answers `POST` requests. IP addresses, `localhost` and host names that resolve to private networks are refused, and redirects are not followed. For local development, use a tunnel that gives you a public host name.
- Owner or admin role in the workspace. Members can see endpoints and their delivery logs, not add or change them.

## 1. Add an endpoint [#1-add-an-endpoint]

1. Open [Settings → Webhooks](https://qrdx.dev/dashboard?to=settings/webhooks) in the workspace whose events you want. The link opens the workspace you last used; pick another one in the workspace switcher and you stay on the same page.
2. Choose **Add endpoint**, enter the **Endpoint URL** and tick the **Events** you want, then choose **Add endpoint** in the dialog. QRdx asks you to [confirm it's you](https://qrdx.dev/docs/help/privacy-and-security/two-step-verification#confirm-its-you) first, and again whenever you change an endpoint's URL; changing its events or disabling it doesn't ask.
3. Copy the **Signing secret** shown after saving. Owners and admins can show it again, or rotate it, from the endpoint's **Deliveries** page.
4. Choose **Send test**. QRdx sends a signed `ping` event and shows the response status in the delivery log.

![The Add webhook endpoint dialog with an Endpoint URL typed in and the five events ticked: scans, scan milestones, new codes, code changes and form submissions.](https://qrdx.dev/docs-static/shots/add-endpoint-dialog.light.webp)

![The Endpoint added dialog right after an endpoint is saved: the signing secret that verifies every delivery, with a copy button, a note about the X-QRdx-Signature header, and Done.](https://qrdx.dev/docs-static/shots/webhook-signing-secret.light.webp)

A workspace can have up to 20 endpoints and hooks together.

## 2. Pick the events [#2-pick-the-events]

| Event | When | Notes |
| --- | --- | --- |
| `scan.created` | A dynamic code is scanned | Batched: at most one request a minute per endpoint, with up to 100 scans and the exact `count` |
| `scan.milestone` | A code's 1st scan, then 10, 100, 500, 1,000, 5,000, 10,000, 50,000, 100,000, 500,000 and 1,000,000 scans, then every million | Fires once per milestone |
| `code.created` | A dynamic code is created, in the dashboard or through the API | One event per code, also for bulk creation |
| `code.updated` | A code's destination, title, design or short-link domain changes | `changes` lists the fields |
| `form.submitted` | Someone submits a form on a hosted page | Includes the answers |
| `ping` | You choose **Send test** | |

Scans by bots, link previews and prefetchers, and rapid repeats from one visitor, are not counted and don't trigger events, exactly as in [scan analytics](https://qrdx.dev/docs/dynamic-qr-codes#scan-analytics).

## 3. Read the payload [#payloads]

Every request is a `POST` with a JSON body and these headers:

| Header | Value |
| --- | --- |
| `Content-Type` | `application/json` |
| `User-Agent` | `QRdx-Webhooks/1.0 (+https://qrdx.dev/docs/webhooks)` |
| `X-QRdx-Event` | The event type, such as `code.created` |
| `X-QRdx-Delivery` | Delivery id: the same on every retry, so you can ignore duplicates |
| `X-QRdx-Timestamp` | Unix seconds when this attempt was signed |
| `X-QRdx-Signature` | `t=<timestamp>,v1=<hex HMAC-SHA256>` |

The body is always an envelope with `id`, `type`, `created_at` and `data`:

```json title="code.created"
{
  "id": "evt_cm3x8c1a20001",
  "type": "code.created",
  "created_at": "2026-10-31T09:30:00.000Z",
  "data": {
    "code": {
      "id": "cm3x7q2l40000",
      "slug": "aB3dE5f",
      "title": "Spring menu",
      "short_link": "https://qrdx.dev/q/aB3dE5f",
      "destination_url": "https://example.com/menu",
      "status": "active",
      "scan_count": 0,
      "created_at": "2026-10-31T09:30:00.000Z",
      "updated_at": "2026-10-31T09:30:00.000Z"
    },
    "actor_id": "user_123"
  }
}
```

A `scan.created` batch:

```json title="scan.created"
{
  "id": "evt_cm3x9d0b10002",
  "type": "scan.created",
  "created_at": "2026-10-31T09:31:00.000Z",
  "data": {
    "window_started_at": "2026-10-31T09:31:00.000Z",
    "window_seconds": 60,
    "count": 2,
    "scans": [
      {
        "scan_id": "cm3x9d0b00001",
        "code": { "id": "cm3x7q2l40000", "slug": "aB3dE5f", "title": "Spring menu" },
        "scanned_at": "2026-10-31T09:31:00.000Z",
        "country": "DE",
        "region": "BE",
        "city": "Berlin",
        "device_type": "mobile",
        "os": "iOS",
        "browser": "Safari",
        "referer": null,
        "source": "qr"
      }
    ]
  }
}
```

When more than 100 scans arrive in one minute, `scans` holds the first 100 and `count` the exact total. `source` is `nfc` for a tap on an [NFC tag](https://qrdx.dev/docs/nfc) and `qr` for a QR scan. Scan payloads never include IP addresses or visitor hashes.

The other events carry:

- `scan.milestone`: `milestone`, `code` (`id`, `slug`, `title`, `scan_count`) and the `scan` that reached it.
- `code.updated`: like `code.created`, plus `changes`, such as `["destination_url"]`.
- `form.submitted`: `response_id`, `page` (`id`, `title`), `code` (`id`, `slug`, or `null`), `fields` (`name`, `label`, `value` as text) and `submitted_at`.

To see a payload of each event built from your own data before the first real one arrives, call [Get sample events](https://qrdx.dev/docs/developers/api/get-hook-samples):

```bash title="Terminal"
curl "https://api.qrdx.dev/v1/hooks/sample?event=scan.created" \
  -H "Authorization: Bearer $QRDX_API_KEY"
```

## 4. Verify signatures [#verify-signatures]

Compute an HMAC-SHA256 of `<timestamp>.<raw body>` with your signing secret and compare it with `v1` in `X-QRdx-Signature`. Use the raw request body, before any JSON parsing, and reject timestamps older than five minutes.

```ts title="lib/qrdx-webhook.ts"
import { createHmac, timingSafeEqual } from "node:crypto";

export function isFromQRdx(rawBody: string, header: string, secret: string) {
  const parts = Object.fromEntries(
    header.split(",").map((part) => part.trim().split("=", 2)),
  );
  const timestamp = Number(parts.t);
  if (!timestamp || Math.abs(Date.now() / 1000 - timestamp) > 300) return false;

  const expected = createHmac("sha256", secret)
    .update(`${timestamp}.${rawBody}`)
    .digest("hex");
  const received = Buffer.from(parts.v1 ?? "");
  return (
    received.length === expected.length &&
    timingSafeEqual(received, Buffer.from(expected))
  );
}
```

```python title="qrdx_webhook.py"
import hmac
import hashlib
import time


def is_from_qrdx(raw_body: bytes, header: str, secret: str) -> bool:
    parts = dict(part.strip().split("=", 1) for part in header.split(","))
    timestamp = int(parts.get("t", "0"))
    if not timestamp or abs(time.time() - timestamp) > 300:
        return False
    expected = hmac.new(
        secret.encode(), f"{timestamp}.".encode() + raw_body, hashlib.sha256
    ).hexdigest()
    return hmac.compare_digest(parts.get("v1", ""), expected)
```

Rotating the secret takes effect immediately: the old secret stops verifying, so update your server right after rotating.

## 5. Respond, and handle retries [#5-respond-and-handle-retries]

Respond with any `2xx` status within 10 seconds. Anything else (an error status, a redirect, a timeout, an unreachable host) counts as a failure, and QRdx retries with growing waits of about 1 minute, 4 minutes, 16 minutes, 1 hour, 4 hours, 17 hours and 24 hours. Each retry goes out within a few minutes of its wait ending. That's 8 attempts over roughly two days, after which the delivery is marked failed.

Deliveries can arrive more than once (a retry after a slow response, a manual retry) and out of order. Use `X-QRdx-Delivery` or the envelope `id` to ignore duplicates, and do your work after you have answered `2xx` if it takes longer than a few seconds.

## Change it later [#change-it-later]

Each endpoint's **Deliveries** page lists the last 50 deliveries with their event, status, attempts and payload. **Retry now** re-sends a failed or pending delivery at once; **Send again** re-sends a delivered one. Deliveries are kept for 30 days.

![The deliveries page of a webhook endpoint: its signing secret (hidden, with Reveal and Rotate), and recent deliveries with their event, status, attempts and a Retry now button on a failed one.](https://qrdx.dev/docs-static/shots/webhook-deliveries.light.webp)

From an endpoint's menu you can **Edit** its URL and events, **Disable endpoint** (new deliveries stop; **Enable endpoint** resumes them), show or **Rotate** its **Signing secret**, and **Delete** it, which also deletes its log. If a workspace's plan no longer includes webhooks, endpoints are kept but nothing is sent until it is on Business again. Your QR codes keep working either way.

## Zapier, Make and n8n (REST Hooks) [#zapier-make-and-n8n-rest-hooks]

Automation tools can subscribe and unsubscribe on their own through the REST Hooks API. Authenticate with an [API key](https://qrdx.dev/docs/developers/api-keys) or an OAuth access token: `codes:write` to subscribe or unsubscribe, `codes:read` to list. Hook URLs are often secret, so with `codes:read` alone `target_url` shows only the host (`https://hooks.zapier.com`). Token requests act on your own workspace; a key acts on the workspace it was created in. Subscribing with your signed-in browser session instead asks you to [confirm it's you](https://qrdx.dev/docs/help/privacy-and-security/two-step-verification#confirm-its-you) first, and answers `403 CONFIRMATION_REQUIRED` until you have in the last 10 minutes. Subscriptions are ordinary endpoints: they appear in **Settings → Webhooks**, where you can also remove them.

| Method | Path | Description |
| --- | --- | --- |
| `POST` | `/v1/hooks` | Subscribe. Body: `target_url` (or Zapier's `hookUrl`) and `event` (or an `events` array). Returns `201` with the subscription `id` and its `secret` |
| `DELETE` | `/v1/hooks/{id}` | Unsubscribe (`204`) |
| `GET` | `/v1/hooks` | List subscriptions and endpoints |
| `GET` | `/v1/hooks/{id}` | One subscription |
| `GET` | `/v1/hooks/sample?event=<event>` | Recent example payloads for `event`, as an array (Zapier's "perform list") |

```bash title="Terminal"
curl https://api.qrdx.dev/v1/hooks \
  -H "Authorization: Bearer $QRDX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"target_url": "https://hooks.zapier.com/hooks/standard/123/abc/", "event": "form.submitted"}'
```

```json title="201 Created (fields)"
{
  "id": "<hook id>",
  "target_url": "https://hooks.zapier.com/hooks/standard/123/abc/",
  "events": ["form.submitted"],
  "event": "form.submitted",
  "active": true,
  "created_at": "<ISO 8601 time>",
  "secret": "whsec_<shown only here>"
}
```

Without Business the subscribe call returns `402`:

```json title="402 Payment Required"
{"code":"PLAN_REQUIRED","message":"Webhooks and Zapier/Make hooks are part of the Business plan.","status":402}
```

A `scan.created` delivery is one batch, so in Zapier use the `data.scans` line items to act on each scan. In n8n, the QRdx Trigger node from the [QRdx nodes for n8n](https://qrdx.dev/docs/developers/n8n) makes these calls for you and checks each signature; a plain Webhook node works too, set up like any other endpoint. The reference pages are [Subscribe to events](https://qrdx.dev/docs/developers/api/create-hook), [List hooks](https://qrdx.dev/docs/developers/api/list-hooks) and [Unsubscribe](https://qrdx.dev/docs/developers/api/delete-hook).

## If something goes wrong [#if-something-goes-wrong]

### The endpoint URL is refused [#the-endpoint-url-is-refused]

Only public `https://` host names are accepted: no `http://`, no IP addresses, no `localhost`, no names that resolve to a private network. Use a tunnel with a public host name while developing.

### Every delivery shows a failed status [#every-delivery-shows-a-failed-status]

Your server answered something other than `2xx` within 10 seconds, redirected, or didn't answer. Open the delivery's details for the exact HTTP status or error, fix it, then choose **Retry now**. Answer `2xx` first and process afterwards if your handler is slow.

### Signatures don't verify [#signatures-dont-verify]

Make sure you hash the raw request body, not a re-serialized JSON object, and that your server uses the current secret: rotating it invalidates the old one at once. Check your server's clock too, since the timestamp check allows five minutes.

### Events stopped arriving [#events-stopped-arriving]

The workspace left the Business plan (endpoints are kept but paused), the endpoint is **Disabled**, or the Zap, scenario or workflow that created the subscription was turned off and unsubscribed. Check **Settings → Webhooks**.

### `403 CONFIRMATION_REQUIRED` from `POST /v1/hooks` [#403-confirmation_required-from-post-v1hooks]

You subscribed with a browser session. Confirm it's you in QRdx and retry within 10 minutes, or subscribe with an API key from your server.

## Self-hosting [#self-hosting]

Deliveries are sent right away; retries and scan batches whose minute has ended are sent by a scheduled job. QRdx runs it every 5 minutes from a GitHub Actions workflow, which works on Vercel's free Hobby plan, and `apps/app/vercel.json` also runs it in full once a day. GitHub can start scheduled runs late, so expect retries within a few minutes rather than to the minute.

To do the same, copy `.github/workflows/webhook-worker.yml`, add your `CRON_SECRET` as an Actions secret and your job URL as the `WEBHOOK_WORKER_URL` variable. Or call the job from any scheduler with the `CRON_SECRET` you set in the environment:

```bash title="crontab (every 1 to 5 minutes)"
curl -H "Authorization: Bearer $CRON_SECRET" https://your-host/api/cron/webhooks
```

With `?source=github` added to the URL, the job first checks a small marker in Upstash Redis and returns `{"skipped": true}` without querying the database when nothing is due, so a database that scales to zero can stay asleep (without Upstash, it always runs the full job). Keep one call a day without it: that run always does the full job and repairs the marker. The other scheduled jobs are listed under [Self-hosting](https://qrdx.dev/docs/self-hosting#scheduled-jobs).

## Related [#related]

- [Subscribe to events](https://qrdx.dev/docs/developers/api/create-hook): the REST Hooks endpoint with a Try it panel
- [n8n](https://qrdx.dev/docs/developers/n8n): the QRdx Trigger node that subscribes and verifies for you
- [Notifications](https://qrdx.dev/docs/notifications): email, Slack and Discord alerts for the same events, without code
- [Build an integration](https://qrdx.dev/docs/developers/build-an-integration): subscribe on behalf of the people who connect your app
