Webhooks
Add a workspace endpoint and MCPDial POSTs the events you pick — finished calls and their structured results, bookings, automatic messages, contact changes, finished campaigns — to your server as they happen. Every delivery is signed with your workspace secret and retried until your server answers 2xx.
Endpoints
Add up to 10 endpoints in Settings → Webhooks or with POST /api/v1/webhooks (owners and admins, or an API key). Each one is a public https URL and a list of event types — or ["*"] for every event, including ones added later. Endpoint management is not available over MCP: pointing your workspace's events at a new URL is a decision for a person or your own backend, not an AI agent.
curl https://mcpdial.com/api/v1/webhooks \
-H "Authorization: Bearer $MCPDIAL_API_KEY" \
-H "content-type: application/json" \
-d '{"url":"https://crm.example.com/hooks/mcpdial","events":["call.result","booking.created"]}'If your workspace has no signing secret yet, the response carries it once as signing_secret (the dashboard shows it the same way). Then send POST /api/v1/webhooks/{id}/test — or Send test event in the dashboard — to check your receiver end to end.
The request
Every delivery is a JSON POST with the same envelope; only data depends on the event.
{
"id": "booking.created:3b9d0e1f-2a3b-4c5d-8e6f-7a8b9c0d1e2f",
"type": "booking.created",
"created_at": "2026-10-02T08:14:05.000Z",
"workspace_id": "25f5e409-0000-4000-8000-000000000000",
"data": {
"booking": {
"id": "3b9d0e1f-2a3b-4c5d-8e6f-7a8b9c0d1e2f",
"calendar_id": "0a1b2c3d-4e5f-4a6b-8c7d-8e9f0a1b2c3d",
"status": "confirmed",
"starts_at": "2026-10-14T12:30:00.000Z",
"ends_at": "2026-10-14T13:00:00.000Z",
"title": "Demo — Keller AG",
"attendee_name": "Anna Keller",
"attendee_email": "anna@keller.example",
"attendee_phone": "+41441234567",
"notes": null,
"call_id": "7d3f6c1e-2b4a-4c8e-9f10-5a6b7c8d9e0f",
"created_at": "2026-10-02T08:14:03.000Z"
},
"contact": {
"id": "6f1c2d3e-4a5b-4c6d-8e7f-901a2b3c4d5e",
"external_ref": "fr_lead_8812",
"name": "Anna Keller",
"phone": "+41441234567",
"email": "anna@keller.example"
}
}
}| Field | Description |
|---|---|
idstring | The event id. The same on every retry and replay — store it and ignore repeats (deliveries are at-least-once). |
typestring | One of the event types below (test.ping for test events). |
created_atISO 8601 | When the event happened. |
workspace_iduuid | The workspace it belongs to (useful when one receiver serves several workspaces). |
dataobject | Event-specific — see Events. |
| Header | Description |
|---|---|
x-mcpdial-signaturet=…,v1=… | HMAC-SHA256 signature — see Verifying the signature. |
x-mcpdial-event-idstring | Same as the body’s id. |
x-mcpdial-event-typestring | Same as the body’s type — route without parsing. |
x-mcpdial-delivery-iduuid | This delivery (one per endpoint and event), as listed in GET /api/v1/webhooks/{id}/deliveries. |
user-agentstring | MCPDial-Webhooks/1 |
import express from 'express';
import { verifyMcpdial } from './verify.mjs';
const app = express();
const seen = new Set(); // use your database in production
// Keep the RAW body: the signature covers the exact bytes we sent.
app.post('/webhooks/mcpdial', express.text({ type: 'application/json' }), (req, res) => {
if (!verifyMcpdial(req.body, req.get('x-mcpdial-signature'), process.env.MCPDIAL_WEBHOOK_SECRET)) {
return res.status(400).send('bad signature');
}
const event = JSON.parse(req.body);
if (seen.has(event.id)) return res.sendStatus(200); // a retry or replay
seen.add(event.id);
res.sendStatus(200); // answer first (10 s limit), then do the work
queueMicrotask(() => handle(event)); // e.g. switch (event.type) { case 'call.result': … }
});
app.listen(3000);Events
| Event | Description |
|---|---|
call.completedCalls | Every finished call — inbound, outbound, or a billable web call — answered or not, with its summary (result is null until extracted) and its settled cost (credits, usd, rate_credits_per_minute, usd_per_credit). The transcript is not included: GET /api/v1/calls/{id}. |
call.resultCalls | The call once its structured result (disposition, interest, next step, custom fields) was extracted — same data as call.completed with result set. |
booking.createdBookings | An appointment was confirmed — by the agent on a call, the API or the dashboard. |
booking.rescheduledBookings | A confirmed appointment moved to another time. |
booking.canceledBookings | A confirmed appointment was canceled. |
message.sentMessages | An automatic email or SMS (confirmation, reminder, call summary…) was handed to the provider. |
message.failedMessages | An automatic email or SMS could not be sent after its retries. |
message.receivedMessages | A text arrived on one of your numbers — a reply, or a keyword. keyword is "stop" (the number is already on the do-not-call list and the contact flagged), "start" (an opt-out made by text was lifted), "help", or null for an ordinary reply. contact is the matching contact, or null. |
contact.createdContacts | A new contact — from the API, an import, an inbound call or FounderReply. |
contact.updatedContacts | A contact’s details, brief or facts changed (data says which fact keys exist, not their values). |
contact.opted_outContacts | The contact asked not to be called again (on a call, by SMS, in the dashboard or via the API). Do-not-call is already applied. |
contact.mergedContacts | Two contacts turned out to be the same person and were merged; the merged-away id now resolves to the kept one. |
contact.erasedContacts | A contact was erased (GDPR / on request). Ids only — erase your copy of this person too. |
campaign.finishedCampaigns | A campaign called everyone in its queue, or was stopped. |
number.pending_reviewNumbers | A number was bought in a country whose carrier reviews the business details first: it is held (status pending) until the carrier decides — usually 1–3 business days. Then number.activated or number.rejected follows. |
number.activatedNumbers | A number went live (status active): right after the purchase, or once the carrier approved the business details of a held number. |
number.rejectedNumbers | A held number was cancelled — the carrier rejected the business details, or the number was taken meanwhile (reason "number_taken"). Its first month is refunded. Fix the details (PUT /api/v1/regulatory/profile, documents) and buy again. |
number.releasedNumbers | A number was released — by a person or the API, automatically after unpaid rent, or when the workspace was deleted. An imported number is only detached (it stays yours at your carrier). A held number released before activation gets its first month back. |
call.completed
Every finished call — inbound, outbound, or a billable web call — answered or not, with its summary (result is null until extracted) and its settled cost (credits, usd, rate_credits_per_minute, usd_per_credit). The transcript is not included: GET /api/v1/calls/{id}.
{
"call_id": "7d3f6c1e-2b4a-4c8e-9f10-5a6b7c8d9e0f",
"external_ref": "fr_conv_51",
"direction": "outbound",
"agent_id": "1c2d3e4f-5a6b-4c7d-8e9f-0a1b2c3d4e5f",
"campaign_id": null,
"from_number": "+41445550100",
"to_number": "+41441234567",
"contact": {
"id": "6f1c2d3e-4a5b-4c6d-8e7f-901a2b3c4d5e",
"external_ref": "fr_lead_8812",
"name": "Anna Keller",
"phone": "+41441234567",
"email": "anna@keller.example"
},
"status": "completed",
"outcome": "booked",
"answered": true,
"duration_seconds": 184,
"cost": {
"credits": 570,
"usd": 0.57,
"rate_credits_per_minute": 190,
"usd_per_credit": 0.001
},
"summary": "Anna agreed to a 30-minute demo on 14 October at 14:30.",
"result": null,
"has_recording": true,
"recording_status": "ready",
"started_at": "2026-10-02T08:11:00.000Z",
"ended_at": "2026-10-02T08:14:04.000Z"
}call.result
The call once its structured result (disposition, interest, next step, custom fields) was extracted — same data as call.completed with result set.
{
"call_id": "7d3f6c1e-2b4a-4c8e-9f10-5a6b7c8d9e0f",
"external_ref": "fr_conv_51",
"direction": "outbound",
"agent_id": "1c2d3e4f-5a6b-4c7d-8e9f-0a1b2c3d4e5f",
"campaign_id": null,
"from_number": "+41445550100",
"to_number": "+41441234567",
"contact": {
"id": "6f1c2d3e-4a5b-4c6d-8e7f-901a2b3c4d5e",
"external_ref": "fr_lead_8812",
"name": "Anna Keller",
"phone": "+41441234567",
"email": "anna@keller.example"
},
"status": "completed",
"outcome": "booked",
"answered": true,
"duration_seconds": 184,
"cost": {
"credits": 570,
"usd": 0.57,
"rate_credits_per_minute": 190,
"usd_per_credit": 0.001
},
"summary": "Anna agreed to a 30-minute demo on 14 October at 14:30.",
"result": {
"disposition": "booked",
"interest": 3,
"next_step": "Demo on 14 Oct 14:30; send the pricing PDF before.",
"callback_at": null,
"objections": [
"price"
],
"opt_out": false,
"fields": {
"team_size": 12
},
"summary": "Anna agreed to a 30-minute demo on 14 October at 14:30."
},
"has_recording": true,
"recording_status": "ready",
"started_at": "2026-10-02T08:11:00.000Z",
"ended_at": "2026-10-02T08:14:04.000Z"
}booking.created
An appointment was confirmed — by the agent on a call, the API or the dashboard.
{
"booking": {
"id": "3b9d0e1f-2a3b-4c5d-8e6f-7a8b9c0d1e2f",
"calendar_id": "0a1b2c3d-4e5f-4a6b-8c7d-8e9f0a1b2c3d",
"status": "confirmed",
"starts_at": "2026-10-14T12:30:00.000Z",
"ends_at": "2026-10-14T13:00:00.000Z",
"title": "Demo — Keller AG",
"attendee_name": "Anna Keller",
"attendee_email": "anna@keller.example",
"attendee_phone": "+41441234567",
"notes": null,
"call_id": "7d3f6c1e-2b4a-4c8e-9f10-5a6b7c8d9e0f",
"created_at": "2026-10-02T08:14:03.000Z"
},
"contact": {
"id": "6f1c2d3e-4a5b-4c6d-8e7f-901a2b3c4d5e",
"external_ref": "fr_lead_8812",
"name": "Anna Keller",
"phone": "+41441234567",
"email": "anna@keller.example"
}
}booking.rescheduled
A confirmed appointment moved to another time.
{
"booking": {
"id": "3b9d0e1f-2a3b-4c5d-8e6f-7a8b9c0d1e2f",
"calendar_id": "0a1b2c3d-4e5f-4a6b-8c7d-8e9f0a1b2c3d",
"status": "confirmed",
"starts_at": "2026-10-15T09:00:00.000Z",
"ends_at": "2026-10-15T09:30:00.000Z",
"title": "Demo — Keller AG",
"attendee_name": "Anna Keller",
"attendee_email": "anna@keller.example",
"attendee_phone": "+41441234567",
"notes": null,
"call_id": "7d3f6c1e-2b4a-4c8e-9f10-5a6b7c8d9e0f",
"created_at": "2026-10-02T08:14:03.000Z"
},
"contact": {
"id": "6f1c2d3e-4a5b-4c6d-8e7f-901a2b3c4d5e",
"external_ref": "fr_lead_8812",
"name": "Anna Keller",
"phone": "+41441234567",
"email": "anna@keller.example"
},
"previous_starts_at": "2026-10-14T12:30:00.000Z"
}booking.canceled
A confirmed appointment was canceled.
{
"booking": {
"id": "3b9d0e1f-2a3b-4c5d-8e6f-7a8b9c0d1e2f",
"calendar_id": "0a1b2c3d-4e5f-4a6b-8c7d-8e9f0a1b2c3d",
"status": "canceled",
"starts_at": "2026-10-14T12:30:00.000Z",
"ends_at": "2026-10-14T13:00:00.000Z",
"title": "Demo — Keller AG",
"attendee_name": "Anna Keller",
"attendee_email": "anna@keller.example",
"attendee_phone": "+41441234567",
"notes": null,
"call_id": "7d3f6c1e-2b4a-4c8e-9f10-5a6b7c8d9e0f",
"created_at": "2026-10-02T08:14:03.000Z"
},
"contact": {
"id": "6f1c2d3e-4a5b-4c6d-8e7f-901a2b3c4d5e",
"external_ref": "fr_lead_8812",
"name": "Anna Keller",
"phone": "+41441234567",
"email": "anna@keller.example"
}
}message.sent
An automatic email or SMS (confirmation, reminder, call summary…) was handed to the provider.
{
"message": {
"id": "9e8d7c6b-5a4f-4e3d-8c2b-1a0f9e8d7c6b",
"trigger": "booking_confirmed",
"audience": "caller",
"channel": "email",
"to": "anna@keller.example",
"subject": "Your demo on 14 October at 14:30",
"status": "sent",
"error": null,
"booking_id": "3b9d0e1f-2a3b-4c5d-8e6f-7a8b9c0d1e2f",
"call_id": "7d3f6c1e-2b4a-4c8e-9f10-5a6b7c8d9e0f",
"credits": 2,
"attempts": 1,
"created_at": "2026-10-02T08:14:04.000Z",
"sent_at": "2026-10-02T08:14:05.000Z"
}
}message.failed
An automatic email or SMS could not be sent after its retries.
{
"message": {
"id": "9e8d7c6b-5a4f-4e3d-8c2b-1a0f9e8d7c6b",
"trigger": "booking_confirmed",
"audience": "caller",
"channel": "email",
"to": "anna@keller.example",
"subject": "Your demo on 14 October at 14:30",
"status": "failed",
"error": "provider_error 422",
"booking_id": "3b9d0e1f-2a3b-4c5d-8e6f-7a8b9c0d1e2f",
"call_id": "7d3f6c1e-2b4a-4c8e-9f10-5a6b7c8d9e0f",
"credits": 0,
"attempts": 3,
"created_at": "2026-10-02T08:14:04.000Z",
"sent_at": null
}
}message.received
A text arrived on one of your numbers — a reply, or a keyword. keyword is "stop" (the number is already on the do-not-call list and the contact flagged), "start" (an opt-out made by text was lifted), "help", or null for an ordinary reply. contact is the matching contact, or null.
{
"message": {
"id": "3b2a1c0d-9e8f-4a7b-8c6d-5e4f3a2b1c0d",
"channel": "sms",
"direction": "inbound",
"from": "+41791234567",
"to": "+41445551234",
"body": "Yes, Thursday at 10 works for me.",
"keyword": null,
"segments": 1,
"received_at": "2026-10-04T08:12:00.000Z"
},
"contact": {
"id": "9f8e7d6c-5b4a-4c3d-9e2f-1a0b9c8d7e6f",
"external_ref": "fr_lead_8791"
}
}contact.created
A new contact — from the API, an import, an inbound call or FounderReply.
{
"contact": {
"id": "6f1c2d3e-4a5b-4c6d-8e7f-901a2b3c4d5e",
"external_ref": "fr_lead_8812",
"name": "Anna Keller",
"email": "anna@keller.example",
"phone": "+41441234567",
"dnc": false,
"facts_keys": [
"role",
"team_size"
],
"updated_at": "2026-10-02T08:15:00.000Z"
}
}contact.updated
A contact’s details, brief or facts changed (data says which fact keys exist, not their values).
{
"contact": {
"id": "6f1c2d3e-4a5b-4c6d-8e7f-901a2b3c4d5e",
"external_ref": "fr_lead_8812",
"name": "Anna Keller",
"email": "anna@keller.example",
"phone": "+41441234567",
"dnc": false,
"facts_keys": [
"role",
"team_size"
],
"updated_at": "2026-10-02T08:15:00.000Z"
}
}contact.opted_out
The contact asked not to be called again (on a call, by SMS, in the dashboard or via the API). Do-not-call is already applied.
{
"contact": {
"id": "6f1c2d3e-4a5b-4c6d-8e7f-901a2b3c4d5e",
"external_ref": "fr_lead_8812",
"name": "Anna Keller",
"email": "anna@keller.example",
"phone": "+41441234567",
"dnc": true,
"facts_keys": [
"role",
"team_size"
],
"updated_at": "2026-10-02T08:15:00.000Z"
}
}contact.merged
Two contacts turned out to be the same person and were merged; the merged-away id now resolves to the kept one.
{
"contact": {
"id": "6f1c2d3e-4a5b-4c6d-8e7f-901a2b3c4d5e",
"external_ref": "fr_lead_8812",
"name": "Anna Keller",
"email": "anna@keller.example",
"phone": "+41441234567",
"dnc": false,
"facts_keys": [
"role",
"team_size"
],
"updated_at": "2026-10-02T08:15:00.000Z"
},
"merged_ids": [
"5e4d3c2b-1a0f-4e9d-8c7b-6a5f4e3d2c1b"
],
"merged_external_refs": [
"fr_lead_8790"
]
}contact.erased
A contact was erased (GDPR / on request). Ids only — erase your copy of this person too.
{
"contact": {
"id": "9f8e7d6c-5b4a-4c3d-9e2f-1a0b9c8d7e6f",
"external_ref": "fr_lead_8791"
}
}campaign.finished
A campaign called everyone in its queue, or was stopped.
{
"campaign": {
"id": "8a7b6c5d-4e3f-4a2b-9c1d-0e9f8a7b6c5d",
"name": "October follow-ups",
"agent_id": "1c2d3e4f-5a6b-4c7d-8e9f-0a1b2c3d4e5f",
"status": "done",
"created_at": "2026-09-30T07:00:00.000Z"
},
"reason": "completed",
"finished_at": "2026-10-02T17:40:00.000Z",
"totals": {
"contacts": 120,
"done": 112,
"skipped": 8,
"outcomes": {
"completed": 61,
"booked": 9,
"no_answer": 30,
"voicemail": 12
}
}
}number.pending_review
A number was bought in a country whose carrier reviews the business details first: it is held (status pending) until the carrier decides — usually 1–3 business days. Then number.activated or number.rejected follows.
{
"number": {
"id": "2c3d4e5f-6a7b-4c8d-9e0f-1a2b3c4d5e6f",
"e164": "+41791234567",
"country": "CH",
"type": "mobile",
"status": "pending",
"agent_id": "1c2d3e4f-5a6b-4c7d-8e9f-0a1b2c3d4e5f"
}
}number.activated
A number went live (status active): right after the purchase, or once the carrier approved the business details of a held number.
{
"number": {
"id": "2c3d4e5f-6a7b-4c8d-9e0f-1a2b3c4d5e6f",
"e164": "+41791234567",
"country": "CH",
"type": "mobile",
"status": "active",
"agent_id": "1c2d3e4f-5a6b-4c7d-8e9f-0a1b2c3d4e5f"
}
}number.rejected
A held number was cancelled — the carrier rejected the business details, or the number was taken meanwhile (reason "number_taken"). Its first month is refunded. Fix the details (PUT /api/v1/regulatory/profile, documents) and buy again.
{
"number": {
"id": "2c3d4e5f-6a7b-4c8d-9e0f-1a2b3c4d5e6f",
"e164": "+41791234567",
"country": "CH",
"type": "mobile",
"status": "released",
"agent_id": null
},
"reason": "The commercial register excerpt does not show the business address."
}number.released
A number was released — by a person or the API, automatically after unpaid rent, or when the workspace was deleted. An imported number is only detached (it stays yours at your carrier). A held number released before activation gets its first month back.
{
"number": {
"id": "2c3d4e5f-6a7b-4c8d-9e0f-1a2b3c4d5e6f",
"e164": "+41791234567",
"country": "CH",
"type": "mobile",
"status": "released",
"agent_id": null
}
}Contact events identify the lead (id, your external_ref, name, email, phone) and list which facts exist — never the background text or fact values. Fetch the full contact with GET /api/v1/contacts/{id}. Erasing a contact also deletes its pending and logged deliveries.
Delivery and retries
Answer with any 2xx within 10 seconds; do the work after answering. Redirects are not followed (use the final URL). Anything else — a timeout, a network error, any non-2xx — is retried after 1 min, 5 min, 30 min, 1 h, 2 h, 6 h, 12 h (8 attempts, the last about 22 hours after the first, ±10 % jitter). Then the delivery is marked failed; replay it from the delivery log or with POST /api/v1/webhooks/{id}/deliveries/{deliveryId}/replay (same id, same body).
An endpoint that keeps failing — at least 10 failed attempts in a row over more than 24 hours — is turned off, and the workspace's owners and admins are notified. Fix the receiver, turn it back on and replay what it missed. Events are not guaranteed to arrive in order: use created_at and the objects' own timestamps. Deliveries are kept for 30 days.
Per-call callback_url
Independently of endpoints, pass a callback_url (a public https URL) when you place a call through the API: when that call ends, its result is POSTed there, signed the same way.
Callback payload
POST {callback_url}
content-type: application/json
x-mcpdial-event-id: 3f0c6c1e-9a0b-4d7e-8f43-0d3c2a1b9e77
x-mcpdial-signature: t=1791288161,v1=<hex HMAC-SHA256(secret, "t.rawBody")>
{
"event": "call.completed",
"call_id": "…",
"external_ref": "crm-8812",
"outcome": "booked",
"answered": true,
"duration_seconds": 143,
"summary": "Confirmed; moved to Tue 14:30.",
"transcript": [{ "direction": "out", "text": "…" }],
"actions": [{ "type": "book_appointment", "starts_at": "2026-10-06T12:30:00Z" }],
"cost_credits": 406,
"event_id": "3f0c6c1e-9a0b-4d7e-8f43-0d3c2a1b9e77",
"sent_at": "2026-10-06T12:02:41.518Z"
}| Field | Description |
|---|---|
event'call.completed' | Sent when a dialled call ends, answered or not. A call the compliance gate refused gets no callback — the 422 response already says why. |
call_iduuid | The call — GET /api/v1/calls/{id} returns the same record. |
external_refstring | null | Echo of the external_ref you sent. |
outcomestring | completed | booked | transferred | no_answer | voicemail | opted_out | failed | blocked |
answeredboolean | Whether the call was answered. |
duration_secondsnumber | Connected time. |
summarystring | null | A short summary of the conversation. |
transcript{ direction, text, at_ms? }[] | in = the other party, out = the agent. |
actions{ type, … }[] | Tool actions the agent took: bookings, notes, opt-outs, transfers. |
cost_creditsinteger | What the call cost (1 credit = $0.001). |
sent_atISO 8601 | When this delivery attempt was made. |
Callback delivery
Answer with any 2xx within 8 seconds. A timeout, network error, 5xx or 429 is retried — up to three attempts, a few seconds apart. Any other 4xx stops delivery. If every attempt fails, the result is still on the call: poll GET /api/v1/calls/{id}.
Each delivery carries x-mcpdial-event-id (also event_id in the body), the same on every retry — store it and ignore repeats.
Verifying the signature
Generate your workspace's signing secret in Settings → Webhooks (owners and admins) — adding the first endpoint creates it for you. It's shown once; keep it with your receiver. Every endpoint delivery and every callback carries:
x-mcpdial-signature: t=1791288161,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd| Field | Description |
|---|---|
tunix seconds | When we signed. Reject anything older than 5 minutes so a captured request can’t be replayed later. |
v1hex | HMAC-SHA256 of `${t}.${rawBody}` with your secret. Two v1 values appear for 24 hours after a rotation (new and previous secret) — accept if either matches. |
Use the raw body exactly as received (not re-serialised JSON) and compare in constant time. Use Send test event in Settings → Webhooks to check your receiver end to end. Endpoint deliveries are only ever signed with your workspace secret (never the legacy header below).
import crypto from 'node:crypto';
// rawBody: the request body exactly as received (a string, before JSON.parse).
// header: the x-mcpdial-signature request header.
// secret: your workspace signing secret (whsec_…) from Settings → Webhooks.
export function verifyMcpdial(rawBody, header, secret, toleranceSeconds = 300) {
const parts = String(header ?? '').split(',').map((p) => p.trim().split('='));
const t = Number(parts.find(([k]) => k === 't')?.[1]);
const sigs = parts.filter(([k]) => k === 'v1').map(([, v]) => v);
if (!Number.isInteger(t) || sigs.length === 0) return false;
if (Math.abs(Date.now() / 1000 - t) > toleranceSeconds) return false; // too old: replay
const expected = crypto.createHmac('sha256', secret).update(`${t}.${rawBody}`).digest();
// Two v1 values right after a rotation — accept either one.
return sigs.some((sig) => {
const got = Buffer.from(sig, 'hex');
return got.length === expected.length && crypto.timingSafeEqual(got, expected);
});
}import hashlib
import hmac
import time
def verify_mcpdial(raw_body: bytes, header: str, secret: str, tolerance: int = 300) -> bool:
"""raw_body: the request body bytes exactly as received.
header: the x-mcpdial-signature request header."""
t, sigs = None, []
for part in (header or "").split(","):
key, _, value = part.strip().partition("=")
if key == "t" and value.isdigit():
t = int(value)
elif key == "v1":
sigs.append(value)
if t is None or not sigs or abs(time.time() - t) > tolerance:
return False # malformed, or too old: replay
expected = hmac.new(secret.encode(), f"{t}.".encode() + raw_body, hashlib.sha256).hexdigest()
# Two v1 values right after a rotation — accept either one.
return any(hmac.compare_digest(expected, s) for s in sigs)Rotating the secret
Rotate in Settings → Webhooks. The new secret signs immediately; the previous one keeps signing alongside it for 24 hours, so you can deploy the new secret to your receiver without dropping a callback. If a secret leaked, rotate and then revoke the old one right away.
Legacy signature (deprecated)
Workspaces created before 1 October 2026 that haven't generated a secret yet still get x-cv-signature: a hex HMAC-SHA256 of the raw body with a key shared across the platform. It proves the request came through MCPDial, not which workspace it belongs to. It stops being sent as soon as you generate your own secret — switch your receiver to x-mcpdial-signature first.
Sunset: after 30 November 2026 callbacks are only sent to workspaces with their own secret; without one they are not delivered until you generate it (Settings → Webhooks shows the days left). Newer workspaces never receive the legacy header: a secret is created automatically on the first callback — generate or rotate it in Settings → Webhooks (or send a test event there) to see it.
// x-cv-signature: bare hex HMAC-SHA256 of the raw body, platform-wide key.
const expected = crypto.createHmac('sha256', legacySecret).update(rawBody).digest('hex');