Docs
API · webhooks

Create a webhook

Register an endpoint that receives signed event deliveries as email moves through the pipeline. The HMAC signing secret is returned once, on this call only.

POST/v1/webhooks

01 Body

urlstringRequired
HTTPS endpoint that receives the event POSTs. Each delivery is signed with the secret returned below.
eventTypesstring[]Required
Events to subscribe to. One or more of accepted, queued, sending, sent, delivery, bounce, complaint, open, click, delivery_delayed, rejected, rendering_failure, failed, inbound_received, inbound_rejected.
The secret is shown oncesigningSecret is returned only on this response and is redacted on every later read. Store it now. If you lose it, delete the endpoint and create a new one.

02 Request

curl https://api.drin.run/v1/webhooks \
  -H "Authorization: Bearer $DRIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/hooks/drin",
    "eventTypes": ["delivery", "bounce", "complaint"]
  }'

03 Response

Returns 201 Created with the endpoint. New endpoints start enabled.

201 Created
{
  "id": "wh_3kQ9p2",
  "url": "https://example.com/hooks/drin",
  "enabled": true,
  "eventTypes": ["delivery", "bounce", "complaint"],
  "signingSecret": "whsec_a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0"
}
Verify deliveriesThe SDK ships a constant-time verifier: drin.webhooks.verify(rawBody, header, signingSecret) checks the Drin-Signature header and returns the parsed payload. See Webhooks.