---

title: Webhooks
description: Receive signed HTTPS calls from knownprint when a browser is identified, an account shows up on a new browser, or a visitor is merged, split or deleted, with retries, a deliveries log and replay.
---

A webhook is an HTTPS endpoint on your side that knownprint calls when something happens in your environment: a browser is identified, one of your accounts turns up on another browser, two visitor ids turn out to be one, a visitor is deleted. Instead of polling the API, your backend receives a signed JSON body within seconds and acts on it.

Every delivery is signed, so your endpoint can prove it came from knownprint ([Verify a webhook](/webhooks/verify)). A delivery that fails is retried, up to eight attempts in all over 72 hours, every attempt is recorded in a deliveries log you can read, and any finished delivery can be sent again on request.

This page explains what you receive and how delivery behaves. The routes that manage webhooks are documented in the [Webhooks API](/api/webhooks) reference.

## Set up an endpoint

You need a secret key with the `webhooks:manage` scope ([Keys](/api/keys#post-v1-keys)). Webhooks are managed through the API; each one belongs to the environment of the key that created it.

1. **Build the receiver.** Add a route to your backend that accepts `POST` with a JSON body, reads the body as raw bytes, verifies the signature, and answers `2xx` quickly. [Verify a webhook](/webhooks/verify) has complete receivers in Node, Python and Go.

2. **Register it.** Create the webhook with the URL and the event types you want:

   ```bash
   curl "$KNOWNPRINT_API/v1/webhooks" \
     -H "Authorization: Bearer $KNOWNPRINT_SECRET_KEY" \
     -H "Content-Type: application/json" \
     -H "Idempotency-Key: create-webhook-backend-1" \
     -d '{
       "url": "https://example.com/webhooks/knownprint",
       "event_types": ["event.identified", "account.related_found", "visitor.merged"]
     }'
   ```

   The answer is `201` with the webhook and its signing secret:

   ```json
   {
     "id": "wh_amg7qtxufogaunw7qawsqrgoxb",
     "url": "https://example.com/webhooks/knownprint",
     "event_types": ["event.identified", "account.related_found", "visitor.merged"],
     "format": "standard",
     "enabled": true,
     "created_at": "2026-12-02T12:00:00.000Z",
     "secret": "whsec_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
   }
   ```

3. **Store the secret.** `secret` is returned once, by this answer, and never again: no route reads it back. Put it in your secrets manager or environment (for example `KNOWNPRINT_WEBHOOK_SECRET`). If you retry the create with the same `Idempotency-Key` and the same body within 24 hours, you get the same webhook and the same secret back instead of a second webhook.

4. **Send a test.** Ask knownprint to send a `webhook.test` delivery to the new endpoint, then read the deliveries log to see how it went:

   ```bash
   curl -X POST "$KNOWNPRINT_API/v1/webhooks/wh_amg7qtxufogaunw7qawsqrgoxb/test" \
     -H "Authorization: Bearer $KNOWNPRINT_SECRET_KEY"

   curl "$KNOWNPRINT_API/v1/webhooks/wh_amg7qtxufogaunw7qawsqrgoxb/deliveries?limit=5" \
     -H "Authorization: Bearer $KNOWNPRINT_SECRET_KEY"
   ```

   A delivery with `"status": "delivered"` means your endpoint answered `2xx`. See [Test deliveries](#test-deliveries).

The URL must use `https`, carry no user name or password, and resolve only to public internet addresses. The URL is checked when you register it: one that points at a private, loopback, link-local or otherwise reserved address, or whose host name does not resolve, is refused with `422` `validation_failed` and the detail `url_rejected`. The same check runs again at every delivery attempt, so a host name that later resolves to a reserved address fails the attempt with `url_rejected` (or `dns` when it no longer resolves) in the [deliveries log](#the-deliveries-log). To receive webhooks on a development machine, expose it through a public HTTPS tunnel and register the tunnel's address.

:::tip One endpoint or several
An environment can have several webhooks, each with its own URL, secret and event types. Each change is queued for every enabled webhook subscribed to its type, as a separate delivery with its own id.
:::

## Event types

A webhook subscribes to one to eight of these types (`event_types`). `webhook.test` is not subscribable: only a [test delivery](#test-deliveries) carries it.

| Type                                              | Fires when                                                                                | Envelope `visitor_id` |
| ------------------------------------------------- | ----------------------------------------------------------------------------------------- | --------------------- |
| [`event.identified`](#event-identified)           | A browser is identified and a new event is recorded                                       | The event's visitor   |
| [`account.linked`](#account-linked)               | A visitor carries one of your linked ids for the first time                               | The visitor           |
| [`account.related_found`](#account-related-found) | That new pair means a linked id now has several visitors, or a visitor several linked ids | The visitor           |
| [`visitor.merged`](#visitor-merged)               | Two visitor ids are found to be one browser and are merged                                | The surviving visitor |
| [`visitor.unmerged`](#visitor-unmerged)           | A merge is undone                                                                         | The restored visitor  |
| [`visitor.split`](#visitor-split)                 | Part of a visitor is moved to a new visitor id                                            | The new visitor       |
| [`visitor.suggested`](#visitor-suggested)         | A past visitor may be another visitor; no id changes                                      | The past visitor      |
| [`visitor.deleted`](#visitor-deleted)             | A visitor's data has been deleted                                                         | The deleted visitor   |
| [`webhook.test`](#webhook-test)                   | You asked for a test delivery                                                             | `null`                |

Every delivery has the same outer shape, the [envelope](#the-envelope). What differs by type is `data`, described below.

### event.identified

Fires once for each new event: each time the agent on your page identifies a browser and knownprint records the result. A replayed request does not produce a second delivery.

`data` is the complete event, exactly the object [`GET /v1/events/{request_id}`](/api/events#get-v1-events-request-id) returns for it, as it stood at the moment of identification. Its fields (`request_id`, `visitor_id`, `confidence`, `anonymity_set_size`, `linked_id`, `tags`, the signals and the rest) are documented on [Events](/events).

```json title="event.identified (data abridged)"
{
  "v": 1,
  "id": "dl_oh26kwfbvskdjleostefx3pzkk",
  "type": "event.identified",
  "created_at": "2026-12-02T12:00:00.000Z",
  "environment_id": "env_wczpaxppqdzxap2fhelv6asokc",
  "visitor_id": "v_gx4osuthsfn5i6evdwyvuzxd2z",
  "data": {
    "request_id": "evt_fih672iilexbhuijjplt6yjas5",
    "environment_id": "env_wczpaxppqdzxap2fhelv6asokc",
    "visitor_id": "v_gx4osuthsfn5i6evdwyvuzxd2z",
    "match_type": "token",
    "confidence": 0.99,
    "anonymity_set_size": 1,
    "linked_id": "account-1842",
    "url_path": "/login"
  }
}
```

The delivery is a copy taken when the event was recorded. Incognito and the suspect score can be refined within about ten seconds of the identification, and the bot verdict can turn `bad` for up to 30 minutes after it; those updates, and changes you make later (tags or a linked id set with [`PATCH /v1/events/{request_id}`](/api/events#patch-v1-events-request-id), feedback), are not sent again. When a decision depends on the event's current state, read it with `GET /v1/events/{request_id}` using `data.request_id` when the visitor acts.

### account.linked

Fires when a visitor is seen with one of your [linked ids](/concepts#linked-id) for the first time: the linked id was attached at identification or later with `PATCH /v1/events/{request_id}`, and that visitor had never carried it before. A pair already recorded fires nothing, however often it is seen again.

| Field        | Type   | Meaning                        |
| ------------ | ------ | ------------------------------ |
| `visitor_id` | string | The visitor, `v_...`           |
| `linked_id`  | string | Your linked id, as you sent it |

```json
{
  "v": 1,
  "id": "dl_v7k75veqcqpzq4kzfy4w6cc7zu",
  "type": "account.linked",
  "created_at": "2026-12-02T12:00:00.000Z",
  "environment_id": "env_wczpaxppqdzxap2fhelv6asokc",
  "visitor_id": "v_gx4osuthsfn5i6evdwyvuzxd2z",
  "data": {
    "visitor_id": "v_gx4osuthsfn5i6evdwyvuzxd2z",
    "linked_id": "account-1842"
  }
}
```

### account.related_found

Fires together with `account.linked` when the new pair means that the linked id is now carried by more than one visitor, or that the visitor now carries more than one linked id. This is the event to watch for shared, sold or duplicate accounts: one account on several browsers, or several accounts on one browser.

| Field        | Type    | Meaning                                                            |
| ------------ | ------- | ------------------------------------------------------------------ |
| `visitor_id` | string  | The visitor of the new pair                                        |
| `linked_id`  | string  | The linked id of the new pair                                      |
| `visitors`   | integer | How many visitors now carry `linked_id`, this one included         |
| `linked_ids` | integer | How many linked ids this visitor now carries, `linked_id` included |

```json
{
  "v": 1,
  "id": "dl_v7k75veqcqpzq4kzfy4w6cc7zu",
  "type": "account.related_found",
  "created_at": "2026-12-02T12:00:00.000Z",
  "environment_id": "env_wczpaxppqdzxap2fhelv6asokc",
  "visitor_id": "v_gx4osuthsfn5i6evdwyvuzxd2z",
  "data": {
    "visitor_id": "v_gx4osuthsfn5i6evdwyvuzxd2z",
    "linked_id": "account-1842",
    "visitors": 1,
    "linked_ids": 3
  }
}
```

To see which visitors and linked ids are involved, call [`GET /v1/visitors/{visitor_id}/related`](/api/visitors#get-v1-visitors-visitor-id-related) or [`GET /v1/linked/{linked_id}/related`](/api/linked#get-v1-linked-linked-id-related). [Accounts](/accounts) explains how to act on related accounts.

### visitor.merged

Fires when knownprint finds that two visitor ids are one browser and merges them. The older id survives; the other becomes its alias. From then on, every new event names the surviving id, and [`GET /v1/visitors/{visitor_id}`](/api/visitors#get-v1-visitors-visitor-id) answers the surviving visitor for either id. Events recorded before the merge keep the id they were answered with. [Visitors](/visitors) explains merges in full.

The envelope's `visitor_id` is the surviving visitor.

| Field            | Type           | Meaning                                                                                                                                                                                                     |
| ---------------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `alias_id`       | string         | The visitor merged away, from now on an alias of `canonical_id`                                                                                                                                             |
| `canonical_id`   | string         | The surviving visitor, equal to the envelope's `visitor_id`                                                                                                                                                 |
| `reason`         | string         | `two_tokens`, `reevaluation`, `chain` or `relink` (`relink` for a merge found when past visitors were looked at again). Informational; do not build rules on it. A merge with `two_tokens` cannot be undone |
| `linker_version` | string         | An opaque version string, for knownprint's own use; do not build rules on it                                                                                                                                |
| `posterior`      | number or null | For knownprint's own use; do not build rules on it. Read `probability`                                                                                                                                      |
| `probability`    | number or null | How likely the two visitors are one device, from 0 to 1; `null` when none was given                                                                                                                         |

```json
{
  "v": 1,
  "id": "dl_v7k75veqcqpzq4kzfy4w6cc7zu",
  "type": "visitor.merged",
  "created_at": "2026-12-02T12:00:00.000Z",
  "environment_id": "env_wczpaxppqdzxap2fhelv6asokc",
  "visitor_id": "v_gx4osuthsfn5i6evdwyvuzxd2z",
  "data": {
    "alias_id": "v_nnfdmplf52gttvrmtt5o36qneh",
    "canonical_id": "v_gx4osuthsfn5i6evdwyvuzxd2z",
    "reason": "relink",
    "linker_version": "v5.1",
    "posterior": 0.991,
    "probability": 0.984
  }
}
```

What to do: wherever you stored `alias_id` beside your own records (bans, claims, reviews), treat those records as belonging to `canonical_id` too. Keep the alias: it still resolves.

### visitor.unmerged

Fires when knownprint undoes a merge by hand, for example after you tell your knownprint contact that a merge was wrong. No API route undoes a merge. The former alias is its own visitor again, under its own id, and the events its browser made while the two were merged name it again. The two visitors are kept apart from then on.

The envelope's `visitor_id` is the restored visitor.

| Field            | Type    | Meaning                                             |
| ---------------- | ------- | --------------------------------------------------- |
| `visitor_id`     | string  | The restored visitor, the alias of the undone merge |
| `canonical_id`   | string  | The visitor it had been merged into                 |
| `reason`         | string  | Always `operator`: the merge was undone by hand     |
| `linker_version` | string  | An opaque version string, for knownprint's own use  |
| `moved_events`   | integer | How many events now name `visitor_id` again         |

What to do: move back any records you had attributed to `canonical_id` because of the merge, and re-read the restored visitor's events with [`GET /v1/events`](/api/events#get-v1-events) and its `visitor_id` filter.

### visitor.split

Fires when part of a visitor turns out to be a different device and is moved to a new visitor id, together with its events. The two are kept apart from then on; a split is not undone.

The envelope's `visitor_id` is the new visitor.

| Field            | Type    | Meaning                                                                                                                                                                                   |
| ---------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `visitor_id`     | string  | The new visitor                                                                                                                                                                           |
| `parent_id`      | string  | The visitor it was split from                                                                                                                                                             |
| `reason`         | string  | `operator` for a split knownprint made by hand, for example after you disputed a link; `audit` or `fleet` for a split knownprint made on its own. Informational; do not build rules on it |
| `linker_version` | string  | An opaque version string, for knownprint's own use                                                                                                                                        |
| `moved_events`   | integer | How many events moved to `visitor_id` and name it from now on                                                                                                                             |

What to do: re-read the new visitor's events with `GET /v1/events?visitor_id=...` and review any decision you took against `parent_id` that rested on those events.

### visitor.suggested

Fires when knownprint, looking at past visitors again, finds that one may be the same device as another, but does not merge them. No id changes. Treat it as a lead for review, not as a merge.

The envelope's `visitor_id` is the past visitor the suggestion is about.

| Field            | Type   | Meaning                                                                |
| ---------------- | ------ | ---------------------------------------------------------------------- |
| `visitor_id`     | string | The past visitor                                                       |
| `suggested_id`   | string | The visitor it may also be                                             |
| `posterior`      | number | For knownprint's own use; do not build rules on it. Read `probability` |
| `probability`    | number | How likely the two are the same device, from 0 to 1                    |
| `reason`         | string | Always `relink`                                                        |
| `linker_version` | string | An opaque version string, for knownprint's own use                     |

### visitor.deleted

Fires when a deletion of a visitor has run: after [`DELETE /v1/visitors/{visitor_id}`](/api/visitors#delete-v1-visitors-visitor-id), or when deleting a linked id with [`DELETE /v1/linked/{linked_id}`](/api/linked#delete-v1-linked-linked-id) leaves a visitor with no linked id and that visitor is deleted too. The delivery is queued in the same transaction as the deletion, so it is sent only once the data is gone. A visitor that expires through inactivity does not fire it.

| Field        | Type   | Meaning                                                                                                                                                                                                                                   |
| ------------ | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `visitor_id` | string | The deleted visitor. When you asked to delete an alias, this is the surviving visitor the alias resolved to                                                                                                                               |
| `job_id`     | string | The visitor's deletion job, `del_...`. For `DELETE /v1/visitors/{visitor_id}` it is the `job_id` that request answered. For a visitor deleted because of `DELETE /v1/linked/{linked_id}`, it is a job of its own, not the linked id's job |

Use it to confirm a deletion you requested, or to delete what your own systems hold about that visitor id.

### webhook.test

Sent only by [`POST /v1/webhooks/{id}/test`](/api/webhooks#post-v1-webhooks-id-test). `visitor_id` is `null` and `data` holds one field:

| Field        | Type   | Meaning                                    |
| ------------ | ------ | ------------------------------------------ |
| `webhook_id` | string | The webhook the test was sent to, `wh_...` |

## The envelope

Every delivery in the `standard` format is one JSON object with exactly these members:

| Field            | Type           | Meaning                                                                                                   |
| ---------------- | -------------- | --------------------------------------------------------------------------------------------------------- |
| `v`              | integer        | The envelope version, always `1`                                                                          |
| `id`             | string         | The delivery id, `dl_` and 26 characters. The same value is sent as the `webhook-id` header               |
| `type`           | string         | One of the [event types](#event-types)                                                                    |
| `created_at`     | string         | When the delivery was queued: the time of the change it reports, RFC 3339 in UTC with milliseconds        |
| `environment_id` | string         | The environment, `env_...`                                                                                |
| `visitor_id`     | string or null | The visitor the change concerns (see the table of [event types](#event-types)); `null` for `webhook.test` |
| `data`           | object         | The type's fields                                                                                         |

`created_at` is the time of the change, not of the attempt. A delivery that is retried keeps its body: every attempt carries the same `id`, `created_at` and `data`.

Write your parser to ignore fields it does not know inside `data`, and to accept values it does not know in fields such as `reason`, so that a new value never breaks your endpoint.

### Request headers

Each attempt is an HTTP `POST` with these headers:

| Header              | Value                                                                                                                 |
| ------------------- | --------------------------------------------------------------------------------------------------------------------- |
| `content-type`      | `application/json`                                                                                                    |
| `user-agent`        | `knownprint-webhooks/` followed by the API version (the `version` that [`GET /health`](/api/keys#get-health) reports) |
| `webhook-id`        | The delivery id, equal to the envelope's `id`                                                                         |
| `webhook-timestamp` | The attempt's time in Unix seconds                                                                                    |
| `webhook-signature` | `v1,` and the base64 HMAC-SHA256 signature of the attempt                                                             |

The signature follows the Standard Webhooks scheme. Each attempt is signed afresh with its own timestamp, so a retry carries a new `webhook-timestamp` and `webhook-signature` but the same `webhook-id`. [Verify a webhook](/webhooks/verify) gives the algorithm and the code.

## Delivery and retries

knownprint queues a delivery as soon as the change is recorded, and makes the first attempt within seconds.

**What counts as success.** An attempt succeeds when your endpoint answers with any `2xx` status within 10 seconds. The 10 seconds cover the whole attempt: resolving your host name, connecting, sending the body and receiving your answer. Anything else is a failure:

- a `3xx` answer (redirects are never followed, so register the final URL),
- a `4xx` or `5xx` answer,
- no complete answer within 10 seconds,
- a DNS, connection or TLS failure,
- a URL that no longer passes the address check (for example, your host name now resolves to a private address).

knownprint reads at most 64 KB of your answer's body and discards it. Answer with an empty body and `200` or `204`.

**The schedule.** A delivery gets eight attempts. Each retry is timed from the first attempt, not from the one before:

| Attempt | Earliest time after the first attempt |
| ------- | ------------------------------------- |
| 1       | Immediately                           |
| 2       | 1 minute                              |
| 3       | 5 minutes                             |
| 4       | 30 minutes                            |
| 5       | 2 hours                               |
| 6       | 12 hours                              |
| 7       | 24 hours                              |
| 8       | 72 hours                              |

After the eighth failure the delivery is `failed` with `dead` set to `true`, and knownprint stops trying. You can still send it again with a [replay](#replay-a-delivery).

A failed attempt is recorded with the HTTP status (`last_response_code`, `0` when there was no answer) and a class of failure (`last_error`):

| `last_error`   | Meaning                                                                    |
| -------------- | -------------------------------------------------------------------------- |
| `http_status`  | Your endpoint answered with a status other than `2xx`, a redirect included |
| `timeout`      | The attempt did not finish within 10 seconds                               |
| `connect`      | The connection failed or was dropped                                       |
| `tls`          | The TLS handshake or the certificate check failed                          |
| `dns`          | Your host name did not resolve                                             |
| `url_rejected` | The URL failed the address check at the attempt                            |

`last_error` is `null` after a successful attempt.

:::tip Answer first, work later
Verify the signature, store the envelope (or put it on your own queue), answer `2xx`, then do the work. An endpoint that calls other services before answering risks the 10 second limit, and a timed-out attempt is retried even if your side finished the work.
:::

## The deliveries log

Every delivery to a webhook is listed, newest first, by [`GET /v1/webhooks/{id}/deliveries`](/api/webhooks#get-v1-webhooks-id-deliveries). Each entry shows the delivery's state, not its body:

```json
{
  "data": [
    {
      "id": "dl_v7k75veqcqpzq4kzfy4w6cc7zu",
      "webhook_id": "wh_amg7qtxufogaunw7qawsqrgoxb",
      "event_type": "event.identified",
      "status": "pending",
      "attempts": 3,
      "created_at": "2026-12-02T12:00:00.000Z",
      "first_attempt_at": "2026-12-02T12:00:00.412Z",
      "last_attempt_at": "2026-12-02T12:05:00.902Z",
      "next_attempt_at": "2026-12-02T12:30:00.412Z",
      "last_response_code": 503,
      "last_error": "http_status",
      "dead": false
    }
  ],
  "next_cursor": null
}
```

`status` is `pending` while attempts remain, `delivered` after a `2xx`, and `failed` once the last attempt has failed. The [Webhooks API](/api/webhooks#the-delivery-object) describes every field.

Finished deliveries (`delivered` or `failed`) stay in the log for 30 days after their last attempt. A delivery that is still waiting, for example for a disabled webhook, is removed 30 days after it was last attempted or last due, whichever is later. After that, it can no longer be listed or replayed.

## Replay a delivery

[`POST /v1/deliveries/{id}/replay`](/api/webhooks#post-v1-deliveries-id-replay) sends a finished delivery again: one that was `delivered` or `failed`. The delivery returns to `pending` with its attempt count at zero and a fresh schedule of eight attempts (one for a test delivery), starting at once.

A replay sends the stored body unchanged, with the same delivery id and therefore the same `webhook-id`. It goes to the webhook's current URL in its current format, signed with its secret. A delivery that is still `pending` cannot be replayed (`422` `validation_failed`, detail `delivery_pending`): it is already being tried.

Use replay after an outage on your side: list the webhook's deliveries, pick those with `status` `failed`, and replay them once your endpoint is healthy again.

```bash
curl "$KNOWNPRINT_API/v1/webhooks/$WEBHOOK_ID/deliveries?limit=500" \
  -H "Authorization: Bearer $KNOWNPRINT_SECRET_KEY" \
| jq -r '.data[] | select(.status == "failed") | .id' \
| while read -r id; do
    curl -s -X POST "$KNOWNPRINT_API/v1/deliveries/$id/replay" \
      -H "Authorization: Bearer $KNOWNPRINT_SECRET_KEY" \
      -H "Idempotency-Key: replay-$id-$(date +%Y%m%d)" > /dev/null
  done
```

For more than 500 deliveries, follow `next_cursor` as described in [Pagination](/api#pagination).

## Test deliveries

[`POST /v1/webhooks/{id}/test`](/api/webhooks#post-v1-webhooks-id-test) queues a `webhook.test` delivery to that webhook, whatever event types it subscribes to. The answer is the new delivery, `pending`, and the attempt follows within seconds.

A test delivery gets one attempt and no retries: if it fails, it is `failed` and `dead` at once, so you see the result straight away in the deliveries log, with the status your endpoint answered and the class of failure. It is signed like any other delivery, so it is the right way to check your signature verification end to end. You can replay it like any other finished delivery.

A test sent to a disabled webhook waits, `pending`, until the webhook is enabled again.

## Change, pause or delete a webhook

With [`PATCH /v1/webhooks/{id}`](/api/webhooks#patch-v1-webhooks-id) you can change the URL, the event types, the format, or switch the webhook off and on:

- **Event types.** The new list replaces the old one. It applies to changes recorded after the update, everywhere within a few seconds.
- **URL and format.** They apply to every attempt from then on, including the retries of deliveries already queued. A new URL is checked like a new webhook's.
- **`enabled: false`.** Pauses the webhook. No new deliveries are queued for it while it is disabled: changes that happen in that time are **not** delivered later. Deliveries already queued wait and resume when you enable it again, as long as they are still within the log's 30 days.

[`DELETE /v1/webhooks/{id}`](/api/webhooks#delete-v1-webhooks-id) removes the webhook together with all of its deliveries, queued and logged. It cannot be undone.

The signing secret never changes. To replace it, see [Rotate the secret](/webhooks/verify#rotate-the-secret).

## Discord format

A webhook created with `"format": "discord"` sends a Discord message instead of the envelope, so you can point it at a Discord channel's webhook URL and watch activity in a channel:

```bash
curl "$KNOWNPRINT_API/v1/webhooks" \
  -H "Authorization: Bearer $KNOWNPRINT_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://discord.com/api/webhooks/000000000000000000/xxxxxxxxxxxxxxxx",
    "event_types": ["visitor.merged", "account.related_found"],
    "format": "discord"
  }'
```

Each delivery is one embed titled `knownprint:` and the event type. It holds the visitor id; for `event.identified`, the match type, confidence and lookalike count; for `visitor.merged`, `visitor.unmerged`, `visitor.split` and `visitor.suggested`, the other visitor id, and the reason for all but `visitor.suggested`. It never carries a linked id, your tags, an IP address or any other value from the event, so it is safe for a shared channel. Retries, the deliveries log, replay and test deliveries work the same way, and the signature headers are still sent.

A Discord-format webhook is for people to read. For code that acts on events, use the `standard` format.

## Ordering and duplicates

Delivery is at least once and in no guaranteed order. Design your endpoint for both:

- **Duplicates.** If your endpoint does the work but its answer is lost or late, the attempt counts as failed and is retried. A replay also sends a delivery again. Every copy carries the same `webhook-id`. Record each `webhook-id` you have processed and skip one you have seen; record it only after the work succeeded, so a failed attempt is processed again. Keep the ids for at least the 72 hours of the retry schedule, and for 30 days if you replay deliveries.
- **One event, several webhooks.** Each webhook gets its own delivery with its own id. If two of your webhooks lead to the same handler, deduplicate on the content instead, such as `data.request_id` for `event.identified`.
- **Order.** Retries, and attempts made in parallel, mean a later change can arrive before an earlier one: a `visitor.merged` before the `event.identified` that preceded it, for example. Use the envelope's `created_at` to order changes, and make each handler correct on its own: write upserts keyed on the ids in `data`, not increments.
- **Current state.** A delivery describes one change at one moment. When you act on a visitor, resolve it with [`GET /v1/visitors/{visitor_id}`](/api/visitors#get-v1-visitors-visitor-id), which always answers the visitor that holds the id now, merges included.

```js title="handler.js"
// After verifying the signature (see /webhooks/verify):
export async function handleDelivery(envelope, db) {
  if (await db.processedWebhookIds.has(envelope.id)) return; // a duplicate: already done

  switch (envelope.type) {
    case 'event.identified':
      await db.events.upsert(envelope.data.request_id, envelope.data);
      break;
    case 'account.related_found':
      await db.reviews.open({
        linkedId: envelope.data.linked_id,
        visitorId: envelope.data.visitor_id,
        visitors: envelope.data.visitors,
        linkedIds: envelope.data.linked_ids,
      });
      break;
    case 'visitor.merged':
      await db.visitorAliases.upsert(envelope.data.alias_id, envelope.data.canonical_id);
      break;
    case 'visitor.deleted':
      await db.visitorData.deleteFor(envelope.data.visitor_id);
      break;
    default:
      break; // a type this handler does not use
  }

  await db.processedWebhookIds.add(envelope.id, { ttlDays: 30 });
}
```

## Privacy and retention

A `standard` delivery carries personal data: an `event.identified` delivery is the whole event, including the visitor's IP address, your linked id and your tags. Serve your endpoint over HTTPS only (knownprint will not deliver to anything else), keep what you store from deliveries under the same rules as your other personal data, and delete it when you delete the visitor.

knownprint keeps a delivery, body included, for 30 days after its last attempt (see [The deliveries log](#the-deliveries-log)). When a visitor is deleted, every delivery that names it, as the envelope's visitor or as the other visitor of a merge, unmerge, split or suggestion, is deleted in the same step, queued ones included, so it is never sent afterwards. The only delivery that names it from then on is the `visitor.deleted` delivery itself. When you delete a linked id, every delivery whose data names that linked id is deleted too. [Privacy](/privacy) covers deletion and retention across knownprint.

## Related pages

- [Verify a webhook](/webhooks/verify): the signature algorithm and receivers in Node, Python and Go.
- [Webhooks API](/api/webhooks): every route, parameter, answer and error.
- [Visitors](/visitors): visitor ids, aliases and merges.
- [Accounts](/accounts): linked ids and related accounts.
- [Limits](/limits): rate limits for the API routes that manage webhooks.
