Webhooks
Subscribe to what happens to artifacts, and get a signed POST for each event. Delivery is a port (ADR 0003): the reference sender is in-process, and Svix/Hookdeck/Convoy replace it without changing the event catalogue, the payload, or the outbox.
POST /api/webhooks { "url": "https://example.com/hooks", "kinds": ["artifact.version.published"] }
→ 201 { "subscription": { "id": "sub_…", "secret": "whsec_…", … } } // secret shown once
The events
| kind | when |
|---|---|
artifact.created | a new artifact |
artifact.updated | a version was added |
artifact.deleted | deleted |
artifact.version.published | a body row was attached (the domain event artifact.published) |
artifact.share.created / artifact.share.revoked | the public link changed |
artifact.viewed | a page was served — { version, channel }, one per GET, never for HEAD |
artifact.state.changed | a state key was written — { scope, key, bytes }, never the value |
comment.thread.created / comment.thread.resolved / comment.created | threads and replies |
kinds empty means every kind; artifactIds empty means every artifact the subscriber owns. A
body never travels in an event — the payload says what changed and gives the id, and the consumer
fetches the thing if it needs it.
The delivery
POST https://example.com/hooks
content-type: application/json
x-artifactkit-event: artifact.version.published
x-artifactkit-delivery: evt_ab12cd34_812
x-artifactkit-seq: 812
x-artifactkit-timestamp: 1795842019
x-artifactkit-signature: sha256=<hex hmac of `${timestamp}.${body}` with your secret>
{ "id": "evt_ab12cd34_812", "kind": "…", "seq": 812, "artifactId": "art_…",
"createdAt": "…", "data": { …domain event… } }
Verify by recomputing the HMAC over the timestamp and the raw body, and reject a timestamp older
than a few minutes — that is what stops a captured request being replayed. Dedupe on
x-artifactkit-delivery: delivery is at-least-once, and a retry carries the same id.
Retries
- 5s timeout,
redirect: 'manual'(a redirect to169.254.169.254is the SSRF the URL check cannot catch, because the check happens at subscription time). - Backoff between attempts: 10s, 60s, 5m, 30m, 2h, then 2h. Six attempts by default.
- Exhausted attempts become a dead letter (
GET /api/webhooks/{id}/dead-letters, with the count and the last error) and only then does the cursor move past the event. - 20 consecutive dead letters disables the subscription — a bad URL or a revoked secret would otherwise burn every drain forever.
- The retry schedule lives on the subscription (
pending.attempts,pending.nextAttemptAt), not in a worker's memory, so a restart resumes it instead of starting over.
Draining
Nothing here runs a timer. A cron, a queue consumer, or you:
POST /api/webhooks/drain → { delivered, retrying, deadLettered, subscriptions }
POST /api/webhooks/drain { "all": true } // deployment-level: every active subscription
Each call does bounded work (one page of the outbox per subscription, stopping at the first failure so ordering per artifact holds). On a serverless host, point a scheduled function at it.
Swapping in Svix
import { createSvixSender } from '@artifactkitdev/core/adapters/webhook/svix';
const webhooks = createWebhookService({
subscriptions, log, runtime,
sender: createSvixSender({ apiKey: process.env.SVIX_API_KEY! }),
});
They take over the endpoint registry, retries, the signing scheme, the delivery log and the replay
UI. Ours stay: the catalogue, the payload, and the outbox cursor — the drain only advances after
Svix accepts the message, and the message's eventId is our deliveryId, so their dedupe and ours
agree on what "the same delivery" means.
SSRF
A subscription URL must be https, may not carry credentials, and may not resolve to a literal
private/loopback/link-local host or *.internal/*.local. That is a string check at subscription
time; the redirect rule above is the other half, because a public URL can redirect anywhere.