API reference
Webhooks API
Reference for the webhook routes of the knownprint API: list, create, update and delete webhooks, send a test delivery, list deliveries and replay one.
These routes manage the webhooks of an environment and their deliveries. What a delivery contains, how it is retried and how to handle it are on Webhooks; how to check its signature is on Verify a webhook.
| Method and path | Purpose | Success |
|---|---|---|
GET /v1/webhooks | List the environment's webhooks | 200 |
POST /v1/webhooks | Create a webhook and get its secret | 201 |
PATCH /v1/webhooks/{id} | Change a webhook's URL, event types, format or state | 200 |
DELETE /v1/webhooks/{id} | Delete a webhook and its deliveries | 204 |
POST /v1/webhooks/{id}/test | Queue a test delivery | 202 |
GET /v1/webhooks/{id}/deliveries | List a webhook's deliveries, newest first | 200 |
POST /v1/deliveries/{id}/replay | Send a finished delivery again | 202 |
Conventions
- Authentication. Every route takes a secret key with the
webhooks:managescope:Authorization: Bearer sk_live_...orsk_test_.... A key without the scope answers403forbidden_scopebefore anything is looked up. See Authentication. - Environment. A webhook belongs to the environment of the key that created it. Each route sees only that environment: an id from another environment answers
404not_found, exactly as an unknown id does. - Ids. A webhook id is
wh_and a delivery iddl_, each followed by 26 characters fromatozand2to7. A path id of the wrong shape answers404. - Bodies. Request bodies are JSON with
Content-Type: application/jsonand are checked strictly: a member the route does not take, a wrong type or a value out of range answers422validation_failedwith the detailinvalid_body. JSON that does not parse, or a body of another media type, answers400schema_mismatch. The routes without a body (DELETE, the test and the replay) take none: send them without aContent-Typeheader, since an empty body declared asapplication/jsonis refused the same way. - Idempotency.
POST,PATCHandDELETEaccept anIdempotency-Keyheader; a repeat with the same key and request within 24 hours answers the stored result withIdempotency-Replayed: true. See Idempotent writes. - Errors are
application/problem+json(Errors); rate limits are the key's bucket (Rate limits).
The webhook object
| Field | Type | Meaning |
|---|---|---|
id | string | The webhook id, wh_... |
url | string | The endpoint deliveries are sent to, at most 2,048 characters |
event_types | array of strings | The event types the webhook receives: one to eight distinct values from event.identified, account.linked, account.related_found, visitor.merged, visitor.unmerged, visitor.split, visitor.suggested and visitor.deleted |
format | string | standard (the signed JSON envelope) or discord (a Discord message, see Discord format) |
enabled | boolean | false while the webhook is paused |
created_at | string | When it was created, RFC 3339 in UTC |
secret | string | Only in the answer of POST /v1/webhooks: the signing secret, whsec_ and 32 base64 characters |
No route returns secret after the create.
The delivery object
A delivery is one event sent to one webhook, with its attempt state. The body that was sent is not part of it.
| Field | Type | Meaning |
|---|---|---|
id | string | The delivery id, dl_...; also the envelope's id and the webhook-id header |
webhook_id | string | The webhook it belongs to |
event_type | string | The event type, webhook.test included |
status | string | pending while attempts remain, delivered after a 2xx answer, failed once the last attempt failed |
attempts | integer | Attempts made so far, 0 to 8 |
created_at | string | When the delivery was queued |
first_attempt_at | string or null | The first attempt's time; null before it. The retry schedule counts from it |
last_attempt_at | string or null | The latest attempt's time; null before the first |
next_attempt_at | string | While pending, the earliest time of the next attempt. Once the delivery is finished, the time it was last due |
last_response_code | integer or null | The HTTP status of the latest attempt; 0 when no answer arrived; null before the first attempt |
last_error | string or null | null after a success or before any attempt; otherwise the class of the latest failure: http_status, timeout, connect, tls, dns or url_rejected (meanings) |
dead | boolean | true once every attempt has failed and knownprint has stopped trying; false again after a replay |
Timestamps are RFC 3339 in UTC with milliseconds. Deliveries are kept for 30 days after their last attempt (The deliveries log).
GET /v1/webhooks
Lists every webhook of the environment, enabled or not, oldest first. The list is not paged and takes no query parameters.
curl "$KNOWNPRINT_API/v1/webhooks" \
-H "Authorization: Bearer $KNOWNPRINT_SECRET_KEY"200:
{
"data": [
{
"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"
}
]
}| Status | Problem | When |
|---|---|---|
401 | unauthorized | No valid secret key |
403 | forbidden_scope | The key lacks webhooks:manage |
429 | rate_limited | The key's bucket is empty |
POST /v1/webhooks
Creates a webhook, enabled, and answers it with its signing secret.
| Body member | Type | Required | Meaning |
|---|---|---|---|
url | string | Yes | The endpoint, at most 2,048 characters. It must use https, carry no user name or password, and resolve only to public addresses |
event_types | array of strings | Yes | One to eight distinct subscribable event types |
format | string | No | standard (default) or discord |
The URL is checked when you create the webhook: its host name is resolved, and every address it resolves to must be a public one. A URL that fails the check and a host name that does not resolve in time both answer 422 with the detail url_rejected. The same check runs again at every delivery attempt.
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"]
}'const res = await fetch(`${process.env.KNOWNPRINT_API}/v1/webhooks`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.KNOWNPRINT_SECRET_KEY}`,
'Content-Type': 'application/json',
'Idempotency-Key': 'create-webhook-backend-1',
},
body: JSON.stringify({
url: 'https://example.com/webhooks/knownprint',
event_types: ['event.identified', 'account.related_found', 'visitor.merged'],
}),
});
if (res.status !== 201) throw new Error(`webhook create failed: ${res.status}`);
const webhook = await res.json();
// Store webhook.secret now: it is never returned again.201:
{
"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"
}Send an Idempotency-Key with the create. If the answer is lost, repeat the request with the same key and body within 24 hours: you get the same webhook and the same secret, with Idempotency-Replayed: true, instead of a second webhook whose secret you never saw. knownprint stores that answer encrypted.
An error answer below 500 (other than 429) is stored under the key as well: if the create was refused, for example with url_rejected, fix the request and send it with a new Idempotency-Key.
| Status | Problem | When |
|---|---|---|
400 | schema_mismatch | The body is not JSON |
401 | unauthorized | No valid secret key |
403 | forbidden_scope | The key lacks webhooks:manage |
409 | idempotency_conflict | The Idempotency-Key was used for a different request (body_mismatch), or a request with it is still running (in_flight) |
422 | validation_failed | invalid_body: a member is missing, unknown or invalid (an unknown or repeated event type, webhook.test, more than eight types, a URL not starting with http:// or https://). url_rejected: the URL is refused. idempotency_key: the header is not 1 to 255 visible ASCII characters |
429 | rate_limited | The key's bucket is empty |
PATCH /v1/webhooks/{id}
Changes a webhook. Send at least one member; a member you leave out keeps its value.
| Body member | Type | Meaning |
|---|---|---|
url | string | A new endpoint. Checked like a new webhook's URL, unless it equals the current one |
event_types | array of strings | Replaces the whole list: one to eight distinct subscribable types |
format | string | standard or discord |
enabled | boolean | false pauses the webhook, true resumes it |
curl -X PATCH "$KNOWNPRINT_API/v1/webhooks/wh_amg7qtxufogaunw7qawsqrgoxb" \
-H "Authorization: Bearer $KNOWNPRINT_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{ "event_types": ["event.identified", "visitor.merged", "visitor.unmerged", "visitor.split"] }'200 with the updated webhook object, without its secret.
How the changes take effect:
- New event types apply to changes recorded after the update, on every server within a few seconds.
- A new URL or format applies to every attempt from then on, including retries of deliveries already queued.
- While a webhook is disabled, no deliveries are queued for it, so the changes of that period are never sent to it. Deliveries queued before you disabled it wait, and are attempted again once you enable it.
| Status | Problem | When |
|---|---|---|
400 | schema_mismatch | The body is not JSON |
401 | unauthorized | No valid secret key |
403 | forbidden_scope | The key lacks webhooks:manage |
404 | not_found | No webhook with this id in the key's environment |
409 | idempotency_conflict | The Idempotency-Key conflicts with another request |
422 | validation_failed | invalid_body: an empty body, or a member unknown or invalid. url_rejected: the new URL is refused. idempotency_key: a malformed header |
429 | rate_limited | The key's bucket is empty |
DELETE /v1/webhooks/{id}
Deletes a webhook and every one of its deliveries, queued and logged. Nothing more is sent to it. This cannot be undone.
curl -X DELETE "$KNOWNPRINT_API/v1/webhooks/wh_amg7qtxufogaunw7qawsqrgoxb" \
-H "Authorization: Bearer $KNOWNPRINT_SECRET_KEY"204 with no body.
| Status | Problem | When |
|---|---|---|
401 | unauthorized | No valid secret key |
403 | forbidden_scope | The key lacks webhooks:manage |
404 | not_found | No webhook with this id in the key's environment (a repeat of a delete that succeeded answers 404, unless it carries the same Idempotency-Key) |
409 | idempotency_conflict | The Idempotency-Key conflicts with another request |
422 | validation_failed | idempotency_key: a malformed header |
429 | rate_limited | The key's bucket is empty |
POST /v1/webhooks/{id}/test
Queues a webhook.test delivery to the webhook, whatever its event types. The request has no body. The answer is the new delivery, pending, with no attempt yet; the attempt follows within seconds.
curl -X POST "$KNOWNPRINT_API/v1/webhooks/wh_amg7qtxufogaunw7qawsqrgoxb/test" \
-H "Authorization: Bearer $KNOWNPRINT_SECRET_KEY"202:
{
"id": "dl_v7k75veqcqpzq4kzfy4w6cc7zu",
"webhook_id": "wh_amg7qtxufogaunw7qawsqrgoxb",
"event_type": "webhook.test",
"status": "pending",
"attempts": 0,
"created_at": "2026-12-02T12:00:00.000Z",
"first_attempt_at": null,
"last_attempt_at": null,
"next_attempt_at": "2026-12-02T12:00:00.000Z",
"last_response_code": null,
"last_error": null,
"dead": false
}The body your endpoint receives is a signed envelope with type webhook.test, visitor_id null and data { "webhook_id": "wh_..." }. A test delivery gets a single attempt: if it fails, it is failed and dead at once, with no retries. Read the result with GET /v1/webhooks/{id}/deliveries. A test sent to a disabled webhook stays pending until the webhook is enabled.
Each call queues a new test delivery. With an Idempotency-Key, a repeat within 24 hours answers the first delivery as it stood when it was queued, instead of queuing another; read the deliveries log for its current state.
| Status | Problem | When |
|---|---|---|
401 | unauthorized | No valid secret key |
403 | forbidden_scope | The key lacks webhooks:manage |
404 | not_found | No webhook with this id in the key's environment |
409 | idempotency_conflict | The Idempotency-Key conflicts with another request |
422 | validation_failed | idempotency_key: a malformed header |
429 | rate_limited | The key's bucket is empty |
GET /v1/webhooks/{id}/deliveries
Lists the webhook's deliveries, newest first (by created_at, then id), test deliveries included.
| Query parameter | Meaning |
|---|---|
limit | Page size, 1 to 500, default 50. A decimal number without sign or leading zero |
cursor | The next_cursor of the previous page; omit it for the first page |
No other parameter is accepted. See Pagination.
curl "$KNOWNPRINT_API/v1/webhooks/wh_amg7qtxufogaunw7qawsqrgoxb/deliveries?limit=2" \
-H "Authorization: Bearer $KNOWNPRINT_SECRET_KEY"200:
{
"data": [
{
"id": "dl_oh26kwfbvskdjleostefx3pzkk",
"webhook_id": "wh_amg7qtxufogaunw7qawsqrgoxb",
"event_type": "event.identified",
"status": "delivered",
"attempts": 1,
"created_at": "2026-12-02T12:10:00.000Z",
"first_attempt_at": "2026-12-02T12:10:00.395Z",
"last_attempt_at": "2026-12-02T12:10:00.395Z",
"next_attempt_at": "2026-12-02T12:10:00.000Z",
"last_response_code": 204,
"last_error": null,
"dead": false
},
{
"id": "dl_v7k75veqcqpzq4kzfy4w6cc7zu",
"webhook_id": "wh_amg7qtxufogaunw7qawsqrgoxb",
"event_type": "webhook.test",
"status": "failed",
"attempts": 1,
"created_at": "2026-12-02T12:00:00.000Z",
"first_attempt_at": "2026-12-02T12:00:00.410Z",
"last_attempt_at": "2026-12-02T12:00:00.410Z",
"next_attempt_at": "2026-12-02T12:00:00.000Z",
"last_response_code": 401,
"last_error": "http_status",
"dead": true
}
],
"next_cursor": "eyJjIjoiMjAyNi0xMi0wMlQxMjowMDowMC4wMDAwMDBaIiwiciI6ImRsX3Y3azc1dmVxY3FwenE0a3pmeTR3NmNjN3p1In0"
}next_cursor is null on the last page.
| Status | Problem | When |
|---|---|---|
401 | unauthorized | No valid secret key |
403 | forbidden_scope | The key lacks webhooks:manage |
404 | not_found | No webhook with this id in the key's environment |
422 | validation_failed | invalid_filter: an unknown or repeated parameter, or an invalid limit. invalid_cursor: a malformed cursor |
429 | rate_limited | The key's bucket is empty |
POST /v1/deliveries/{id}/replay
Sends a finished delivery again. The request has no body. The delivery must be delivered or failed; it goes back to pending with attempts 0, first_attempt_at, last_attempt_at, last_response_code and last_error cleared, dead false, and next_attempt_at now. It then gets a fresh retry schedule of eight attempts (one for a webhook.test delivery).
The replay sends the stored body unchanged, with the same delivery id and so the same webhook-id header, to the webhook's current URL in its current format. If the webhook is disabled, the delivery waits until it is enabled.
curl -X POST "$KNOWNPRINT_API/v1/deliveries/dl_v7k75veqcqpzq4kzfy4w6cc7zu/replay" \
-H "Authorization: Bearer $KNOWNPRINT_SECRET_KEY" \
-H "Idempotency-Key: replay-dl_v7k75veqcqpzq4kzfy4w6cc7zu-1"202 with the delivery as it now stands:
{
"id": "dl_v7k75veqcqpzq4kzfy4w6cc7zu",
"webhook_id": "wh_amg7qtxufogaunw7qawsqrgoxb",
"event_type": "webhook.test",
"status": "pending",
"attempts": 0,
"created_at": "2026-12-02T12:00:00.000Z",
"first_attempt_at": null,
"last_attempt_at": null,
"next_attempt_at": "2026-12-02T12:20:00.000Z",
"last_response_code": null,
"last_error": null,
"dead": false
}A delivery is replayable while it is in the log: 30 days after its last attempt. If your endpoint deduplicates on webhook-id, remember that a replay carries an id it may have seen; see Ordering and duplicates.
| Status | Problem | When |
|---|---|---|
401 | unauthorized | No valid secret key |
403 | forbidden_scope | The key lacks webhooks:manage |
404 | not_found | No delivery with this id in the key's environment, or it has left the log |
409 | idempotency_conflict | The Idempotency-Key conflicts with another request |
422 | validation_failed | delivery_pending: the delivery is still pending, so it is already being tried. idempotency_key: a malformed header |
429 | rate_limited | The key's bucket is empty |
Error bodies
Every error is a problem document. For example, a URL that resolves to a private address:
HTTP/1.1 422 Unprocessable Entity
Content-Type: application/problem+json; charset=utf-8
Cache-Control: no-store
{
"type": "https://knownprint.dev/problems/validation_failed",
"title": "Validation failed",
"status": 422,
"detail": "The webhook URL is refused: it must use https and resolve only to public addresses.",
"request_id": "evt_fih672iilexbhuijjplt6yjas5"
}The detail sentence is fixed for each detail key:
| Detail key | detail |
|---|---|
invalid_body | The request body does not satisfy the schema of this route. |
url_rejected | The webhook URL is refused: it must use https and resolve only to public addresses. |
invalid_filter | A query parameter is unknown, repeated or has an invalid value. |
invalid_cursor | The cursor is malformed. |
delivery_pending | The delivery is still pending, so it cannot be replayed. |
idempotency_key | The Idempotency-Key header must be 1 to 255 visible ASCII characters. |
request_id identifies the API request; quote it to your knownprint contact. Every problem type is listed on Errors.