API Design Specification: Document Webhooks v2


1. Overview

The Webhooks v2 API lets workspaces subscribe to document lifecycle events (document.created, document.published, export.completed) with HMAC-SHA256 payload verification and automatic exponential backoff retries.


2. Delivery & Verification Sequence

[Diagram]

3. Data Model

[Diagram]

4. Endpoints

POST /v2/webhooks — Register Endpoint

Request Body

{
  "url": "https://hooks.customer.io/mdview",
  "events": ["document.published", "export.completed"],
  "description": "Production docs sync"
}

Response (201 Created)

{
  "id": "wh_01J8X9K2M4P5Q6R7S8T9",
  "url": "https://hooks.customer.io/mdview",
  "events": ["document.published", "export.completed"],
  "signing_secret": "whsec_live_9f8e7d6c5b4a3210",
  "is_active": true,
  "created_at": "2026-04-14T10:00:00Z"
}

[!WARNING] signing_secret is returned only once at creation time. Store it in your secrets manager immediately.

GET /v2/webhooks/:id/deliveries — List Delivery Attempts

Query Param Type Default Description
status string all Filter by succeeded, failed, or pending
limit integer 25 Page size (1–100)
cursor string null Opaque cursor from previous response next_cursor

5. Signature Verification

Every delivery includes two headers:

Reject requests where Math.abs(now - timestamp) > 300 to prevent replay attacks.


6. HTTP Status Codes & Error Contract

Status Error Code Retryable Meaning
200 — No Request succeeded
201 — No Webhook endpoint created
400 invalid_payload No Schema validation failed (see details[])
401 unauthorized No Missing, expired, or revoked Bearer token
403 insufficient_scope No Token lacks webhooks:write scope
404 endpoint_not_found No Endpoint ID does not exist in this workspace
429 rate_limited Yes Back off until Retry-After header
500 internal_error Yes Transient server error; safe to retry with idempotency key