Receive webhooks
Dockt sends signed HTTP requests to your backend when a Decision is created or a document finishes processing. This guide registers an endpoint, verifies each delivery, and handles every event type.
Prerequisites
Section titled “Prerequisites”You need:
- A public HTTPS endpoint on port 443 that can read the raw request body.
- An API credential with
account:write. - A secret manager for the one-time signing secret.
curlandjqfor the API examples.
Set the API base URL and token:
export DOCKT_API_BASE_URL='https://api.dockt.com'export DOCKT_API_TOKEN='REPLACE_WITH_BEARER_TOKEN'1. Register the endpoint
Section titled “1. Register the endpoint”Create a notification destination with the URL and the event types it receives. Replace https://example.com/webhooks/dockt with your receiver’s URL:
destination_response="$( curl --fail-with-body --silent --show-error \ -X POST "$DOCKT_API_BASE_URL/v1/notification-destinations" \ -H "Authorization: Bearer $DOCKT_API_TOKEN" \ -H 'Content-Type: application/json' \ -H 'Idempotency-Key: notification-destination-production' \ --data '{ "url": "https://example.com/webhooks/dockt", "event_types": ["decision.created", "document.processed", "document.failed"] }')"
export DOCKT_NOTIFICATION_DESTINATION_ID="$(printf '%s' "$destination_response" | jq -r '.data.id')"printf '%s' "$destination_response" | jq '.data | {id, url, event_types, enabled, signing_secret}'Store data.signing_secret right away. Dockt returns it only in this response and when you rotate it.
The URL must use HTTPS on port 443 with a public DNS hostname, and no credentials or fragment. Dockt doesn’t follow redirects; register the final URL.
2. Read the raw request
Section titled “2. Read the raw request”Dockt sends an HTTP POST with Content-Type: application/json and these headers:
X-Dockt-Event-IdX-Dockt-Event-TypeX-Dockt-TimestampX-Dockt-Signature
Read the exact body bytes before parsing JSON. Re-serializing parsed JSON changes the signed message, and the signature check then fails.
3. Verify the signature
Section titled “3. Verify the signature”The signed message is <timestamp>.<raw body>. The signature is a lowercase hexadecimal HMAC-SHA256 digest, prefixed with v1=, the signature scheme’s version.
This Web Crypto implementation rejects malformed timestamps, requests outside the five-minute replay window, and invalid signatures:
export const verifyDocktWebhook = async (input: { body: string; secret: string; signature: string; timestamp: string; now?: Date;}) => { const signedAt = Date.parse(input.timestamp); const now = input.now?.getTime() ?? Date.now(); if (!Number.isFinite(signedAt) || Math.abs(now - signedAt) > 5 * 60 * 1000) { return false; }
const encoder = new TextEncoder(); const key = await crypto.subtle.importKey( 'raw', encoder.encode(input.secret), { name: 'HMAC', hash: 'SHA-256' }, false, ['sign'] ); const digest = await crypto.subtle.sign( 'HMAC', key, encoder.encode(`${input.timestamp}.${input.body}`) ); const expected = `v1=${Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, '0')).join('')}`;
if (expected.length !== input.signature.length) return false;
let mismatch = 0; for (let index = 0; index < expected.length; index += 1) { mismatch |= expected.charCodeAt(index) ^ input.signature.charCodeAt(index); } return mismatch === 0;};Use your platform’s constant-time comparison function when it has one.
4. Connect verification to your HTTP handler
Section titled “4. Connect verification to your HTTP handler”Pass verified events to a function that stores the event ID and queues your application’s work:
type AcceptEvent = (input: { eventId: string; event: unknown;}) => Promise<'stored' | 'duplicate'>;
export const receiveDocktWebhook = async ( request: Request, secret: string, acceptEvent: AcceptEvent) => { const eventId = request.headers.get('x-dockt-event-id'); const signature = request.headers.get('x-dockt-signature'); const timestamp = request.headers.get('x-dockt-timestamp');
if (!eventId || !signature || !timestamp) { return new Response('Missing webhook headers', { status: 400 }); }
const body = await request.text(); const valid = await verifyDocktWebhook({ body, secret, signature, timestamp }); if (!valid) return new Response('Invalid signature', { status: 401 });
let event: unknown; try { event = JSON.parse(body); } catch { return new Response('Invalid JSON', { status: 400 }); }
if ( typeof event !== 'object' || event === null || !('id' in event) || event.id !== eventId || !('type' in event) || typeof event.type !== 'string' || event.type !== request.headers.get('x-dockt-event-type') ) { return new Response('Event headers do not match the signed body', { status: 400 }); }
await acceptEvent({ eventId: event.id, event }); return new Response(null, { status: 204 });};Implement acceptEvent so it inserts eventId with a unique constraint and durably stores or queues the event in the same operation. Return duplicate when the ID already exists. A duplicate still gets 204, because your application already accepted it. The handler also checks that the ID and type headers match the signed body; use that verified ID for deduplication. Validate the event’s data before applying your application’s changes.
5. Deduplicate before side effects
Section titled “5. Deduplicate before side effects”Delivery is at least once and unordered. Store X-Dockt-Event-Id with a unique constraint before you apply a side effect. A retry uses the same event ID and body.
Don’t assume that document.processed arrives before the decision.created it caused, or that two decision.created events for the same Assignment arrive in order. Before applying an important change, fetch the Assignment or Engagement and compare the event’s Decision ID with its latest_decision.id. Fetching an older Decision alone does not establish that it is still current.
6. Acknowledge after durable acceptance
Section titled “6. Acknowledge after durable acceptance”Return any 2xx response after you have stored the event or queued durable work. Dockt retries other responses and timeouts with exponential backoff: 30 seconds, doubling up to one hour between attempts, for up to 24 hours after the event. Each attempt times out after 10 seconds.
Keep request handling short. Move long-running work out of the HTTP request.
7. Handle each event
Section titled “7. Handle each event”The body is an event envelope:
{ "id": "evt_9Qa2", "type": "decision.created", "created_at": "2026-11-02T09:00:05Z", "data": { "decision": { "id": "dec_91Kp", "result": "incomplete", "summary": "1 requirement missing: Dimona registration." }, "target": { "type": "assignment", "id": "asg_6Pw3", "external_ref": "preannouncement-9031" }, "workplace": { "id": "wpl_8Tn1", "external_ref": "plant-antwerp" }, "person": { "id": "per_7Hq2", "external_ref": "worker-4821" }, "company": { "id": "cmp_3Lp9", "external_ref": "comp-77" }, "changed_requirements": ["employment_registration"], "changed_findings": [] }}decision.created: route bydata.target.type(assignmentorengagement) and your references. FetchGET /v1/decisions/{decisionId}for requirements, findings and input requests. For an Engagement,personisnullandcompanyis the engaged Company.document.processed: a Document finished processing. Update your upload’s status. Its effect on work arrives asdecision.created.document.failed: processing failed.data.document.errorsays why. Ask for a clearer copy, or declare the document type so a reviewer can confirm it.notification_destination.test: confirm signature verification, deduplication and acknowledgement without changing product state.
8. Send a test event
Section titled “8. Send a test event”Queue a signed notification_destination.test delivery:
curl --fail-with-body --silent --show-error \ -X POST \ -H "Authorization: Bearer $DOCKT_API_TOKEN" \ "$DOCKT_API_BASE_URL/v1/notification-destinations/$DOCKT_NOTIFICATION_DESTINATION_ID/test"The API returns 202 Accepted when the delivery is queued. A disabled destination doesn’t receive it.
9. Rotate the signing secret
Section titled “9. Rotate the signing secret”POST /v1/notification-destinations/{id}/rotate-secret returns a new signing_secret once. Deliveries are signed with the new secret from then on. Deploy the new secret to your receiver as soon as you rotate; during the switch, accept either secret for a short time.
10. Recover from missed events
Section titled “10. Recover from missed events”Events are a signal; the API is the source of truth. If your endpoint was unavailable for longer than the retry window, or you suspect a gap:
- List both upcoming and open Assignments with
GET /v1/assignments?status=upcomingandGET /v1/assignments?status=open. Do the same for/v1/engagementsif you use company work. Follow pagination and compare eachlatest_decision.idwith the last Decision you processed. - Read a target’s history with
GET /v1/decisions?assignment={assignmentId}. - List the Person’s documents with
GET /v1/persons/{personId}/documents, or a Company’s withGET /v1/companies/{companyId}/documents, and compare their current statuses with your upload records. Filtering only onprocessingwould miss uploads that completed or failed while your endpoint was unavailable.
Pause deliveries with PATCH /v1/notification-destinations/{id} and "enabled": false. Events from while it is disabled are not sent later, so reconcile after you enable it again.