knownprintDocs

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 pathPurposeSuccess
GET /v1/webhooksList the environment's webhooks200
POST /v1/webhooksCreate a webhook and get its secret201
PATCH /v1/webhooks/{id}Change a webhook's URL, event types, format or state200
DELETE /v1/webhooks/{id}Delete a webhook and its deliveries204
POST /v1/webhooks/{id}/testQueue a test delivery202
GET /v1/webhooks/{id}/deliveriesList a webhook's deliveries, newest first200
POST /v1/deliveries/{id}/replaySend a finished delivery again202

Conventions

  • Authentication. Every route takes a secret key with the webhooks:manage scope: Authorization: Bearer sk_live_... or sk_test_.... A key without the scope answers 403 forbidden_scope before 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 404 not_found, exactly as an unknown id does.
  • Ids. A webhook id is wh_ and a delivery id dl_, each followed by 26 characters from a to z and 2 to 7. A path id of the wrong shape answers 404.
  • Bodies. Request bodies are JSON with Content-Type: application/json and are checked strictly: a member the route does not take, a wrong type or a value out of range answers 422 validation_failed with the detail invalid_body. JSON that does not parse, or a body of another media type, answers 400 schema_mismatch. The routes without a body (DELETE, the test and the replay) take none: send them without a Content-Type header, since an empty body declared as application/json is refused the same way.
  • Idempotency. POST, PATCH and DELETE accept an Idempotency-Key header; a repeat with the same key and request within 24 hours answers the stored result with Idempotency-Replayed: true. See Idempotent writes.
  • Errors are application/problem+json (Errors); rate limits are the key's bucket (Rate limits).

The webhook object

FieldTypeMeaning
idstringThe webhook id, wh_...
urlstringThe endpoint deliveries are sent to, at most 2,048 characters
event_typesarray of stringsThe 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
formatstringstandard (the signed JSON envelope) or discord (a Discord message, see Discord format)
enabledbooleanfalse while the webhook is paused
created_atstringWhen it was created, RFC 3339 in UTC
secretstringOnly 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.

FieldTypeMeaning
idstringThe delivery id, dl_...; also the envelope's id and the webhook-id header
webhook_idstringThe webhook it belongs to
event_typestringThe event type, webhook.test included
statusstringpending while attempts remain, delivered after a 2xx answer, failed once the last attempt failed
attemptsintegerAttempts made so far, 0 to 8
created_atstringWhen the delivery was queued
first_attempt_atstring or nullThe first attempt's time; null before it. The retry schedule counts from it
last_attempt_atstring or nullThe latest attempt's time; null before the first
next_attempt_atstringWhile pending, the earliest time of the next attempt. Once the delivery is finished, the time it was last due
last_response_codeinteger or nullThe HTTP status of the latest attempt; 0 when no answer arrived; null before the first attempt
last_errorstring or nullnull after a success or before any attempt; otherwise the class of the latest failure: http_status, timeout, connect, tls, dns or url_rejected (meanings)
deadbooleantrue 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.

Shell
curl "$KNOWNPRINT_API/v1/webhooks" \
  -H "Authorization: Bearer $KNOWNPRINT_SECRET_KEY"

200:

JSON
{
  "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"
    }
  ]
}
StatusProblemWhen
401unauthorizedNo valid secret key
403forbidden_scopeThe key lacks webhooks:manage
429rate_limitedThe key's bucket is empty

POST /v1/webhooks

Creates a webhook, enabled, and answers it with its signing secret.

Body memberTypeRequiredMeaning
urlstringYesThe endpoint, at most 2,048 characters. It must use https, carry no user name or password, and resolve only to public addresses
event_typesarray of stringsYesOne to eight distinct subscribable event types
formatstringNostandard (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
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"]
  }'
Node
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:

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"
}

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.

StatusProblemWhen
400schema_mismatchThe body is not JSON
401unauthorizedNo valid secret key
403forbidden_scopeThe key lacks webhooks:manage
409idempotency_conflictThe Idempotency-Key was used for a different request (body_mismatch), or a request with it is still running (in_flight)
422validation_failedinvalid_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
429rate_limitedThe 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 memberTypeMeaning
urlstringA new endpoint. Checked like a new webhook's URL, unless it equals the current one
event_typesarray of stringsReplaces the whole list: one to eight distinct subscribable types
formatstringstandard or discord
enabledbooleanfalse pauses the webhook, true resumes it
Shell
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.
StatusProblemWhen
400schema_mismatchThe body is not JSON
401unauthorizedNo valid secret key
403forbidden_scopeThe key lacks webhooks:manage
404not_foundNo webhook with this id in the key's environment
409idempotency_conflictThe Idempotency-Key conflicts with another request
422validation_failedinvalid_body: an empty body, or a member unknown or invalid. url_rejected: the new URL is refused. idempotency_key: a malformed header
429rate_limitedThe 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.

Shell
curl -X DELETE "$KNOWNPRINT_API/v1/webhooks/wh_amg7qtxufogaunw7qawsqrgoxb" \
  -H "Authorization: Bearer $KNOWNPRINT_SECRET_KEY"

204 with no body.

StatusProblemWhen
401unauthorizedNo valid secret key
403forbidden_scopeThe key lacks webhooks:manage
404not_foundNo 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)
409idempotency_conflictThe Idempotency-Key conflicts with another request
422validation_failedidempotency_key: a malformed header
429rate_limitedThe 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.

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

202:

JSON
{
  "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.

StatusProblemWhen
401unauthorizedNo valid secret key
403forbidden_scopeThe key lacks webhooks:manage
404not_foundNo webhook with this id in the key's environment
409idempotency_conflictThe Idempotency-Key conflicts with another request
422validation_failedidempotency_key: a malformed header
429rate_limitedThe 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 parameterMeaning
limitPage size, 1 to 500, default 50. A decimal number without sign or leading zero
cursorThe next_cursor of the previous page; omit it for the first page

No other parameter is accepted. See Pagination.

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

200:

JSON
{
  "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.

StatusProblemWhen
401unauthorizedNo valid secret key
403forbidden_scopeThe key lacks webhooks:manage
404not_foundNo webhook with this id in the key's environment
422validation_failedinvalid_filter: an unknown or repeated parameter, or an invalid limit. invalid_cursor: a malformed cursor
429rate_limitedThe 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.

Shell
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:

JSON
{
  "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.

StatusProblemWhen
401unauthorizedNo valid secret key
403forbidden_scopeThe key lacks webhooks:manage
404not_foundNo delivery with this id in the key's environment, or it has left the log
409idempotency_conflictThe Idempotency-Key conflicts with another request
422validation_faileddelivery_pending: the delivery is still pending, so it is already being tried. idempotency_key: a malformed header
429rate_limitedThe key's bucket is empty

Error bodies

Every error is a problem document. For example, a URL that resolves to a private address:

HTTP
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 keydetail
invalid_bodyThe request body does not satisfy the schema of this route.
url_rejectedThe webhook URL is refused: it must use https and resolve only to public addresses.
invalid_filterA query parameter is unknown, repeated or has an invalid value.
invalid_cursorThe cursor is malformed.
delivery_pendingThe delivery is still pending, so it cannot be replayed.
idempotency_keyThe 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.