Webhooks
Subscribe an HTTPS endpoint to Coffee events. Deliveries are signed, and only include data the user who authorized your app can read.
Events
| Event | Fires when |
|---|---|
message.created | A new chat message is posted. |
task.activity | A task changes. |
Your app needs a scope that covers the event's data.
Manage subscriptions
| Method | Path | What it does |
|---|---|---|
POST | /webhook-subscriptions | Subscribe an HTTPS endpoint to events |
GET | /webhook-subscriptions | List this app's subscriptions in the workspace |
DELETE | /webhook-subscriptions/{webhook_hash} | Delete a subscription |
POST | /webhook-subscriptions/{webhook_hash}/ping | Send a signed test event |
The subscription's signing secret is returned only when you create it. Store it then.
An app can hold up to 10 subscriptions for one person in a workspace.
Payload
{
"id": "<delivery id>",
"type": "message.created",
"created_at": "2026-10-18T09:30:00.000Z",
"workspace": { "subdomain": "yourpractice" },
"data": { }
}
id is stable for an event and subscription. If you see the same id twice, it is a retry. Process it once.
Verify the signature
Every delivery has a Coffee-Signature header:
Coffee-Signature: t=<unix timestamp>,v1=<hex digest>
v1 is HMAC-SHA256 of <timestamp>.<raw request body>, keyed with the subscription secret.
import { createHmac, timingSafeEqual } from 'node:crypto';
export function verify(rawBody, header, secret) {
if (typeof header !== 'string') return false;
const parts = Object.fromEntries(header.split(',').map(p => p.trim().split('=')));
if (!/^\d+$/.test(parts.t ?? '') || !/^[a-f0-9]{64}$/.test(parts.v1 ?? '')) return false;
const timestamp = Number(parts.t);
if (!Number.isSafeInteger(timestamp) || Math.abs(Date.now() / 1000 - timestamp) > 300) return false;
const expected = createHmac('sha256', secret).update(`${parts.t}.${rawBody}`).digest('hex');
const a = Buffer.from(expected);
const b = Buffer.from(parts.v1 ?? '');
return a.length === b.length && timingSafeEqual(a, b);
}
Verify against the raw body, before parsing JSON. This example rejects timestamps more than five minutes away from the local clock. Keep your clock synchronized and deduplicate the stable delivery ID; signature verification alone does not stop repeated valid deliveries.
Failures
Each attempt has a 10-second timeout. Return a 2xx quickly and do the work afterwards. Failed deliveries have six attempts total, with exponential delays of approximately 30, 60, 120, 240 and 480 seconds between attempts; worker load can make them later. Each attempt is signed with its current timestamp. After 30 failed deliveries in a row, the subscription is turned off (is_active: false). A successful ping turns it back on. Each subscription reports consecutive_failures, last_status_code, last_error, last_success_at and last_failure_at.