Webhooks
Webhooks push real-time notifications to your server when things happen in Chronary — events created, updated, deleted, or agents modified. No polling required.
How it works
Section titled “How it works”- You register a webhook URL and choose which event types to listen for
- When a matching event occurs, Chronary sends an HTTP POST to your URL
- The request includes an HMAC-SHA256 signature for verification
- Failed deliveries are retried on a fixed schedule (see Retry behavior)
Create a webhook
Section titled “Create a webhook”curl -X POST https://api.chronary.ai/v1/webhooks \ -H "Authorization: Bearer chr_sk_your_key_here" \ -H "Content-Type: application/json" \ -d '{ "url": "https://your-server.com/webhooks/chronary", "events": ["event.created", "event.updated", "event.deleted"] }'chronary webhooks create \ --url "https://your-server.com/webhooks/chronary" \ --events "event.created, event.updated, event.deleted"# Created webhook whk_a1b2c3# URL: https://your-server.com/webhooks/chronary# Events: event.created, event.updated, event.deleted# Secret: whsec_abc123...# (Save this secret — it won't be shown again)const response = await fetch('https://api.chronary.ai/v1/webhooks', { method: 'POST', headers: { 'Authorization': 'Bearer chr_sk_your_key_here', 'Content-Type': 'application/json', }, body: JSON.stringify({ url: 'https://your-server.com/webhooks/chronary', events: ['event.created', 'event.updated', 'event.deleted'], }),});const webhook = await response.json();console.log(webhook.id); // "whk_a1b2c3"console.log(webhook.secret); // Save this — used for HMAC verificationfrom chronary import Chronary
client = Chronary()
webhook = client.webhooks.create( url="https://your-server.com/webhooks/chronary", events=["event.created", "event.updated", "event.deleted"],)print(webhook.secret) # Save this for HMAC verificationEvent types
Section titled “Event types”| Event type | Trigger |
|---|---|
event.created | A new event is added to any calendar |
event.updated | An event’s fields are modified |
event.deleted | An event is deleted |
agent.created | A new agent is created |
agent.updated | An agent’s fields are modified |
Webhook payload
Section titled “Webhook payload”Each delivery is an HTTP POST whose body is the raw event payload — there is no { id, type, timestamp, data } envelope. The event type travels in the X-Chronary-Event-Type header, the delivery ID in X-Delivery-Id, and the signing timestamp in X-Timestamp. The X-Signature-V2 signature covers those headers as well as the body, so once a delivery verifies you can trust them. For example, an event.created delivery body:
{ "calendar_id": "cal_x1y2z3", "event": { "id": "evt_m1n2o3", "calendarId": "cal_x1y2z3", "title": "Strategy sync with Acme Corp", "startTime": "2026-04-07T14:00:00Z", "endTime": "2026-04-07T14:30:00Z", "status": "confirmed" }}Each event type carries its own payload shape — see the event catalog in the API reference.
Verifying signatures
Section titled “Verifying signatures”Every delivery includes an X-Signature-V2 header: sha256=<hex>, an HMAC-SHA256 keyed with your webhook secret over the raw body and the X-Timestamp, X-Delivery-Id, X-Chronary-Event-Type, X-Chronary-Test and X-Chronary-Replay-Of headers (the exact message is in the API reference). Because those headers are signed, nobody holding a copy of a delivery can re-send it as another event type, with a new delivery ID, or with the test flag removed. Verify the signature against the raw request body before trusting the payload or any of those headers, and reject deliveries whose X-Timestamp is older than ~5 minutes to defend against replay. The SDKs do both for you:
import express from 'express';import { verifySignature } from '@chronary/sdk';
const app = express();
// express.raw() keeps the body as the exact bytes Chronary signed.// Register this route before any app-wide body parser such as// app.use(express.json()), or make that parser skip this path: once// the body has been parsed, the raw bytes are gone and every delivery// fails verification.app.post('/webhooks/chronary', express.raw({ type: 'application/json' }), async (req, res) => { let payload; try { // Pass the RAW body string and the request headers. // Throws on a bad/missing signature or a stale timestamp. const rawBody = req.body.toString('utf8'); await verifySignature(rawBody, req.headers, process.env.WEBHOOK_SECRET); payload = JSON.parse(rawBody); } catch { return res.status(401).send('Invalid signature'); } // ...handle the verified payload res.status(200).end();});import { verifySignature } from '@chronary/sdk';
// A Next.js route handler, for example app/webhooks/chronary/route.js.// Other fetch-style handlers read the raw body the same way. A framework// that hands your handler a context object (often named `c`) offers the// same call on its own request wrapper,// for example `await c.req.text()` with `c.req.raw.headers`.export async function POST(request) { const rawBody = await request.text(); try { // Throws on a bad/missing signature or a stale timestamp. await verifySignature(rawBody, request.headers, process.env.WEBHOOK_SECRET); } catch { return new Response('Invalid signature', { status: 401 }); } const payload = JSON.parse(rawBody); // ...handle the verified payload return new Response(null, { status: 200 });}import os
from flask import Flask, requestfrom chronary.webhook import verify_signature, SignatureVerificationError
app = Flask(__name__)
@app.post("/webhooks/chronary")def chronary_webhook(): try: verify_signature( payload=request.get_data(), # raw bytes, before any JSON parsing headers=request.headers, # reads X-Signature-V2 and the headers it covers secret=os.environ["WEBHOOK_SECRET"], ) except SignatureVerificationError: return "Invalid signature", 401 payload = request.get_json() # ...handle the verified payload return "", 200import jsonimport os
from fastapi import FastAPI, Request, Responsefrom chronary.webhook import verify_signature, SignatureVerificationError
app = FastAPI()
@app.post("/webhooks/chronary")async def chronary_webhook(request: Request): raw_body = await request.body() # raw bytes, before any JSON parsing try: verify_signature( payload=raw_body, headers=request.headers, # reads X-Signature-V2 and the headers it covers secret=os.environ["WEBHOOK_SECRET"], ) except SignatureVerificationError: return Response("Invalid signature", status_code=401) payload = json.loads(raw_body) # ...handle the verified payload return Response(status_code=200)Rotating the signing secret
Section titled “Rotating the signing secret”On the Developer or Pro plan you can replace an endpoint’s secret without dropping deliveries. Rotate it in the console (the endpoint’s Settings tab) or with POST /v1/webhooks/:id/secret/rotate, and choose when the old secret stops working: now, in 1 hour, in 24 hours (the default) or in 7 days. The new secret is shown once.
Until the old secret expires, each delivery carries two v2 signatures over the same message: X-Signature-V2 with the new secret and X-Signature-V2-Previous with the old one (and the v1 pair X-Signature / X-Signature-Previous). The SDK verifiers above accept the delivery if your secret matches either v2 header, so:
- Update the SDK first (SDK versions released before secret rotation check only one signature header). If you verify by hand, accept a match on either header.
- Rotate and store the new secret.
- Deploy the new secret to your receiver before the old one expires.
Rotating again before the old secret expires ends it at once: only the current secret and the one it replaced are ever valid. See Rotate the signing secret for the full reference.
The v1 signature (deprecated)
Section titled “The v1 signature (deprecated)”Deliveries also carry X-Signature (and, during a rotation, X-Signature-Previous): the v1 signature, an HMAC-SHA256 of `${X-Timestamp}.${rawBody}` only. It does not cover the event type, delivery ID, test flag or replay ID, so a receiver that checks only v1 must not trust those headers. v1 is deprecated and still sent, with no removal date. The current SDKs (@chronary/sdk 0.14.0, chronary 0.14.0 for Python, chronary-go 0.13.0) check X-Signature-V2 only and never fall back to v1; older SDK versions check v1. If you verify by hand, move to v2.
Retry behavior
Section titled “Retry behavior”Your endpoint has 10 seconds to respond with a 2xx status. A non-2xx status, a timeout or a network error counts as a failed attempt, and Chronary tries again on a fixed schedule:
| Attempt | Free | Developer | Pro |
|---|---|---|---|
| 1 | Immediately | Immediately | Immediately |
| 2 | +1 min | +1 min | +1 min |
| 3 | +5 min | +5 min | +5 min |
| 4 | +30 min | +30 min | +30 min |
| 5 | — | +1 h | +1 h |
| 6 | — | +2 h | +2 h |
| 7 | — | — | +6 h |
| 8 | — | — | +12 h |
Free makes 4 attempts, Developer makes 6 and Pro makes 8.
After the last attempt the delivery is marked failed.
An endpoint is disabled automatically (active: false) after 20 consecutive failed deliveries or 24 hours of continuous failures, whichever comes first. A webhook.deactivated event goes to your other active endpoints.
List webhooks
Section titled “List webhooks”curl https://api.chronary.ai/v1/webhooks \ -H "Authorization: Bearer chr_sk_your_key_here"Update a webhook
Section titled “Update a webhook”Change the URL, event types, or active status:
curl -X PATCH https://api.chronary.ai/v1/webhooks/whk_a1b2c3 \ -H "Authorization: Bearer chr_sk_your_key_here" \ -H "Content-Type: application/json" \ -d '{ "events": ["event.created", "event.updated"], "active": false }'Set active: false to temporarily pause deliveries without deleting the webhook.
Delete a webhook
Section titled “Delete a webhook”curl -X DELETE https://api.chronary.ai/v1/webhooks/whk_a1b2c3 \ -H "Authorization: Bearer chr_sk_your_key_here"Returns 204 No Content.
Best practices
Section titled “Best practices”- Always verify signatures — never trust a webhook payload without checking the HMAC
- Return 200 quickly — process the payload asynchronously if it takes more than a few seconds
- Handle duplicates — use the
X-Delivery-Idheader (signed byX-Signature-V2;event.deliveryId/delivery_id/DeliveryIDfrom the SDKs) to deduplicate, as retries reuse the same delivery ID