Webhooks
Events sent to your address as they happen: signed, retried, logged.
Okidoki can send what happens on your sites to an address of yours as it happens: a sale, a jump in traffic, a goal reached. Each event is a signed POST with JSON. Webhooks are part of Plus.
Prefer to ask instead of being told? GET /api/v1/sites/:site/events lists the same events, newest first, for 90 days. For Slack, Microsoft Teams or Discord, use chat channels instead: they need no code.
#Add a webhook
curl -X POST https://okidoki.sh/api/v1/webhooks \
-H "Authorization: Bearer oks_..." -H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"url":"https://example.com/hooks/okidoki","events":["sale","goal_reached"],"site":"mysite.com"}'The answer holds the webhook's secret (whsec_...). It is shown only this once: keep it where your receiver can read it. Leave out events to get every event, and site to get every site in the account. An account can have 10 webhooks, plus the ones automation apps like Zapier, Make and n8n make for themselves. An agent can do the same with the MCP tool add_webhook.
The address must be https:// and public. Send yourself a test event any time with POST /webhooks/:webhook/test.
#Events
| Type | When | In data |
|---|---|---|
traffic_spike | The last full hour had at least five times the usual visitors, and at least 50. At most once a day | visitors_last_hour, usual_hour |
quiet_day | No visitors for 24 hours, when the week before had some. Webhooks only, never a chat channel | visitors_last_24h, visitors_7_days_before |
sale | New orders from a connected shop or payment platform, checked every five minutes | orders, amount, currency |
goal_reached | A goal was reached today. Once a day per goal | goal_id, goal, day, count |
goal_quiet | A goal was not reached in 7 days, when it was in the 30 days before. Webhooks only, never a chat channel | goal_id, goal, days |
weekly_brief | The Monday check-in, the same as GET /sites/:site/brief | The numbers, changes and next steps |
site_down | The watch: the home page did not answer, or answered with a server error, twice in a row. Sent to every chat channel | kind, started_at, status, timezone |
site_up | The site answers again after site_down | kind, started_at, ended_at |
tracking_stopped | No visits have come in for longer than the site's own rhythm makes likely (at least 6 were expected). tag says whether the script is still on the home page | kind, started_at (the last visit), expected, tag |
tracking_back | Visits come in again after tracking_stopped | kind, started_at, ended_at |
goal_stopped | Nobody has reached a goal for longer than usual (at least 6 were expected). Checked every half hour | kind, goal, started_at (the last one), expected |
goal_back | The goal is reached again | kind, goal, started_at, ended_at |
sales_stopped | No orders from the connected shop for longer than usual (at least 6 were expected) | kind, started_at (the last order), expected |
sales_back | Orders come in again | kind, started_at, ended_at |
finding | The background agent noticed something worth knowing (at most once a day and three times a week), or its follow-up two weeks later. Sent to every chat channel. message is the plain text | finding, kind, direction, name, numbers, period, suggestion, approve_url, useful_url, not_useful_url; on a follow-up follow_up, verdict, values |
test | Only from the test button or POST /webhooks/:webhook/test | Nothing |
Events only ever hold numbers and plain sentences about a site: never a visitor, a customer, an email address or an IP address. New event types may be added; ignore types you do not know.
#What is sent
POST /hooks/okidoki HTTP/1.1
Content-Type: application/json
User-Agent: Okidoki-Webhooks/1.0 (+https://docs.okidoki.sh/webhooks)
Okidoki-Signature: t=1763107200,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd
Okidoki-Event: sale
Okidoki-Delivery: evt_1042
Okidoki-Webhook-Id: 0b7c3c9e-4f0e-4d8a-9a51-2f7f3c1d2e4b
Okidoki-Attempt: 1{
"id": "evt_1042",
"object": "event",
"api_version": "1",
"type": "sale",
"created_at": "2026-11-14T09:20:00.000Z",
"site": "mysite.com",
"message": "mysite.com made 2 sales: €98 together.",
"data": { "orders": 2, "amount": 98, "currency": "EUR" },
"open_url": "https://okidoki.sh/app/site?s=mysite.com"
}| Header | What it is |
|---|---|
Okidoki-Signature | t=<unix time>,v1=<signature>, see below |
Okidoki-Event | The event type, so you can route before parsing |
Okidoki-Delivery | The event id. The same on every attempt: use it to skip repeats |
Okidoki-Webhook-Id | Which of your webhooks this is |
Okidoki-Attempt | 1 the first time, 2 on the first retry, and so on |
message is written to be shown to a person as it is, like in the rest of the API.
#Check the signature
Always check the signature before you trust a request. v1 is the HMAC SHA-256, in hex, of the time, a dot and the raw body, with the webhook's secret as the key. Use the body exactly as it arrived: parsing and printing JSON again changes it.
- Split the header on
,and taketand everyv1. - Check that
tis within five minutes of now, so an old request cannot be sent again. - Compute
HMAC-SHA256(secret, t + "." + raw body)and compare it with eachv1in constant time. One match is enough.
import crypto from 'node:crypto';
import express from 'express';
const app = express();
app.post('/hooks/okidoki', express.raw({ type: 'application/json' }), (req, res) => {
const header = req.get('Okidoki-Signature') ?? '';
const parts = header.split(',').map((p) => p.split('='));
const t = Number(parts.find(([k]) => k === 't')?.[1]);
const sent = parts.filter(([k]) => k === 'v1').map(([, v]) => v);
const expected = crypto.createHmac('sha256', process.env.OKIDOKI_WEBHOOK_SECRET)
.update(`${t}.${req.body}`).digest('hex');
const fresh = Math.abs(Date.now() / 1000 - t) < 300;
const match = sent.some((v) => v.length === expected.length &&
crypto.timingSafeEqual(Buffer.from(v), Buffer.from(expected)));
if (!fresh || !match) return res.sendStatus(400);
const event = JSON.parse(req.body);
res.sendStatus(204); // answer first, then do the work
handle(event);
});import hashlib, hmac, os, time
from flask import Flask, request
app = Flask(__name__)
SECRET = os.environ["OKIDOKI_WEBHOOK_SECRET"].encode()
@app.post("/hooks/okidoki")
def okidoki():
raw = request.get_data()
parts = [p.split("=", 1) for p in request.headers.get("Okidoki-Signature", "").split(",")]
t = next((v for k, v in parts if k == "t"), "0")
sent = [v for k, v in parts if k == "v1"]
expected = hmac.new(SECRET, f"{t}.".encode() + raw, hashlib.sha256).hexdigest()
if abs(time.time() - int(t)) > 300 or not any(hmac.compare_digest(v, expected) for v in sent):
return "", 400
event = request.get_json()
# handle(event)
return "", 204#Answer fast, and only once
- Answer with any
2xxstatus within 8 seconds. Do slow work after you answer, or in a queue. - An event can arrive more than once, for example when your answer was lost. Keep the
idof events you have handled and skip one you have seen. - Events for one webhook arrive one at a time, oldest first. A failing event holds back the ones after it until it gets through, so nothing is skipped or comes out of order.
- Redirects are not followed. Give the final address.
#Retries
If your address does not answer 2xx in time, Okidoki tries the same event again, waiting longer each time: 5 minutes, 15 minutes, 30 minutes, 1 hour, 2 hours, 4 hours, 8 hours, 12 hours and then every 12 hours. That is about three days. After 12 failures in a row the webhook turns off, and the webhook list says so.
To turn it on again, fix the receiver and send a test (POST /webhooks/:webhook/test), or PATCH /webhooks/:webhook with {"on": true}. Either one starts sending at once, from the event that failed. Nothing is lost while it is off, as long as it is turned on within 90 days.
#The delivery log
Every attempt is in the log for 30 days: which event, which attempt, the status your address answered (or timeout or network), and how long it took. What your address answered is never stored.
curl -H "Authorization: Bearer oks_..." \
"https://okidoki.sh/api/v1/webhooks/0b7c3c9e-4f0e-4d8a-9a51-2f7f3c1d2e4b/deliveries?limit=20"{
"message": "3 attempts to send to https://example.com/hooks/okidoki, 1 failed. The log keeps 30 days.",
"data": {
"deliveries": [
{ "id": "whd_88", "event": "evt_1042", "type": "sale", "attempt": 2, "ok": true, "status": 204, "error": null, "duration_ms": 182, "created_at": "2026-11-14T09:25:01.000Z" },
{ "id": "whd_87", "event": "evt_1042", "type": "sale", "attempt": 1, "ok": false, "status": null, "error": "timeout", "duration_ms": 8001, "created_at": "2026-11-14T09:20:01.000Z" }
],
"next_cursor": "whd_87",
"has_more": true
}
}Send one again by hand with POST /webhooks/:webhook/deliveries/:delivery/retry, for example after fixing a bug in your receiver. Agents read the log with the MCP tool list_webhook_deliveries.
#Rotate the secret
POST /webhooks/:webhook/rotate-secret makes a new secret and shows it once. For the next 24 hours every event is signed with both the new and the old secret, as two v1 values, so your receiver keeps working while you switch it over. After that, only the new secret signs.
#Manage webhooks
| Method | Path | What it does |
|---|---|---|
GET | /webhooks | Your webhooks, and the events there are. Never the secret |
POST | /webhooks | Adds one, {"url", "events"?, "site"?, "label"?} |
GET | /webhooks/:webhook | One webhook, with when a failing event is tried next |
PATCH | /webhooks/:webhook | Changes url, events or label, or turns it on or off with on |
DELETE | /webhooks/:webhook | Stops sending |
POST | /webhooks/:webhook/test | Sends a test event now |
POST | /webhooks/:webhook/rotate-secret | A new secret; the old one works for 24 more hours |
GET | /webhooks/:webhook/deliveries | The delivery log, paged with limit and cursor |
POST | /webhooks/:webhook/deliveries/:delivery/retry | Sends that event again now |
GET | /sites/:site/events | The events of a site, newest first, with since, type, limit and cursor |
Changing needs a key that may read and change. A key for one site only sees and changes that site's webhooks.