Developers / Webhooks and events
Webhooks and events
ANOMA tells your systems the moment something happens: someone joins, time off is approved, a month is locked for payroll. Every delivery is signed, so you know it came from ANOMA.
How delivery works
Add an endpoint with POST /v1/webhooks: an https:// address and the events it wants, or ["*"] for all of them. ANOMA shows the endpoint’s signing secret once, in that response. Keep it on your server.
When something happens, ANOMA saves an event and sends it to every endpoint that wants it, as a POST with a JSON body. Answer with any 2xx status within 15 seconds. Do slow work after you answer.
The same events are kept for 30 days at GET /v1/events, so you can catch up after downtime.
The request
| Header | What it holds |
|---|---|
content-type | application/json |
user-agent | ANOMA-Webhooks/1 |
x-anoma-event | The event type, such as leave.approved |
x-anoma-delivery | This delivery’s id. A retry has the same event id in the body, so use the body’s id to ignore repeats. |
x-anoma-signature | t=<unix seconds>,v1=<hex>: the HMAC-SHA256 of <t>.<raw body>, keyed with the endpoint’s secret |
{
"id": "evt_2b7f0c41d9a3e8f1c6b0a2d4",
"type": "leave.approved",
"created_at": "2026-11-24T10:02:11.482Z",
"workspace": "acme",
"api_version": "2026-11-24",
"data": {
"id": 88,
"employee_id": 12,
"employee_name": "Sneha Iyer",
"type": {
"id": 1,
"name": "Casual leave"
},
"start_date": "2026-12-08",
"end_date": "2026-12-09",
"days": 2,
"half_day": false,
"reason": "Family function",
"status": "pending",
"stage": "Waiting for their manager",
"created_at": "2026-11-24T09:12:00Z"
}
}Check the signature
Work it out from the raw body exactly as it arrived, before you parse it. Compare in constant time, and refuse a timestamp more than five minutes old so a captured request cannot be replayed. Neither example needs a library.
import { createServer } from 'node:http';
import { createHmac, timingSafeEqual } from 'node:crypto';
const SECRET = process.env.ANOMA_WEBHOOK_SECRET; // whsec_…, shown once when you add the endpoint
// header looks like: t=1764000000,v1=5f2b… (v1 = HMAC-SHA256 of "<t>.<raw body>", in hex)
function verify(rawBody, header, secret, toleranceSeconds = 300) {
const parts = Object.fromEntries(header.split(',').map(p => [p.slice(0, p.indexOf('=')), p.slice(p.indexOf('=') + 1)]));
const t = Number(parts.t);
if (!t || Math.abs(Date.now() / 1000 - t) > toleranceSeconds) return false; // too old: maybe replayed
const expected = createHmac('sha256', secret).update(`${t}.${rawBody}`).digest();
const given = Buffer.from(parts.v1 || '', 'hex');
return given.length === expected.length && timingSafeEqual(given, expected);
}
createServer((req, res) => {
let raw = '';
req.setEncoding('utf8');
req.on('data', chunk => (raw += chunk));
req.on('end', () => {
if (!verify(raw, req.headers['x-anoma-signature'] || '', SECRET)) return res.writeHead(400).end('Bad signature');
const event = JSON.parse(raw); // parse only after checking the raw text
console.log(req.headers['x-anoma-delivery'], event.type, event.data);
res.writeHead(200).end('OK'); // answer 2xx within 15 seconds; do slow work afterwards
});
}).listen(3000);import hashlib
import hmac
import json
import os
import time
from http.server import BaseHTTPRequestHandler, HTTPServer
SECRET = os.environ["ANOMA_WEBHOOK_SECRET"] # whsec_..., shown once when you add the endpoint
def verify(raw: bytes, header: str, secret: str, tolerance: int = 300) -> bool:
# header looks like: t=1764000000,v1=5f2b... (v1 = HMAC-SHA256 of "<t>.<raw body>", in hex)
parts = dict(p.split("=", 1) for p in header.split(",") if "=" in p)
try:
t = int(parts["t"])
except (KeyError, ValueError):
return False
if abs(time.time() - t) > tolerance: # too old: maybe replayed
return False
expected = hmac.new(secret.encode(), f"{t}.".encode() + raw, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, parts.get("v1", ""))
class Hook(BaseHTTPRequestHandler):
def do_POST(self):
raw = self.rfile.read(int(self.headers.get("content-length", 0)))
if not verify(raw, self.headers.get("x-anoma-signature", ""), SECRET):
self.send_response(400)
self.end_headers()
return
event = json.loads(raw) # parse only after checking the raw bytes
print(self.headers.get("x-anoma-delivery"), event["type"], event["data"])
self.send_response(200) # answer 2xx within 15 seconds; do slow work afterwards
self.end_headers()
HTTPServer(("", 3000), Hook).serve_forever()Try a signature
Paste what your server received. The check runs in your browser with WebCrypto, step by step; nothing is sent anywhere.
Retries and the inbox
If your server does not answer 2xx, ANOMA tries again with growing gaps (1, 2, 4, 8 minutes and so on), up to 8 times over about a day, then marks the delivery failed. GET /v1/webhooks/deliveries shows what your server answered, and redeliver sends one again.
An endpoint whose address is inbox keeps its deliveries inside ANOMA instead of sending them anywhere. Every sandbox has one subscribed to all events, which is what the live inspector shows.
Every event
| Event | When | data |
|---|---|---|
employee.created | Someone was added | A person |
employee.updated | Someone’s details changed | A person |
employee.exited | Someone left the company | A person |
leave.submitted | Time off was requested | A time-off request |
leave.approved | Time off was approved | A time-off request |
leave.rejected | Time off was declined | A time-off request |
leave.cancelled | Time off was cancelled | A time-off request |
attendance.checked_in | Someone checked in | A day’s attendance |
attendance.checked_out | Someone checked out | A day’s attendance |
training.completed | Someone completed a course | training |
correction.submitted | An attendance fix was asked for | A request and where it stands |
correction.approved | An attendance fix was approved | A request and where it stands |
correction.rejected | An attendance fix was declined | A request and where it stands |
expense.submitted | An expense claim was submitted | A request and where it stands |
expense.approved | An expense claim was approved | A request and where it stands |
expense.rejected | An expense claim was declined | A request and where it stands |
comp_off.submitted | Comp-off was claimed | A request and where it stands |
comp_off.approved | Comp-off was approved | A request and where it stands |
comp_off.rejected | Comp-off was declined | A request and where it stands |
profile.submitted | Someone asked to change their details | A request and where it stands |
profile.approved | A change to someone’s details was approved | A request and where it stands |
profile.rejected | A change to someone’s details was declined | A request and where it stands |
resignation.submitted | Someone resigned | A request and where it stands |
resignation.approved | A resignation was accepted | A request and where it stands |
resignation.rejected | A resignation was not accepted | A request and where it stands |
letter.submitted | Someone asked for a letter | A request and where it stands |
letter.approved | A letter was approved | A request and where it stands |
letter.rejected | A letter was declined | A request and where it stands |
loan.submitted | Someone asked for a loan or advance | A request and where it stands |
loan.approved | A loan or advance was approved | A request and where it stands |
loan.rejected | A loan or advance was declined | A request and where it stands |
approval.requested | A request is waiting for someone | A request and where it stands |
payroll.month.locked | HR locked a month for payroll | A locked month |
ping | A test from the Developers screen | A short message |
What data holds
A person · employee.created employee.updated employee.exited
{
"id": 12,
"emp_code": "E0012",
"first_name": "Sneha",
"last_name": "Iyer",
"name": "Sneha Iyer",
"email": "sneha@acme.in",
"phone": "+919876543210",
"department": {
"id": 3,
"name": "Engineering"
},
"designation": "Backend engineer",
"manager_id": 4,
"employment_type": "full_time",
"join_date": "2024-04-01",
"status": "active",
"exit_date": null
}A time-off request · leave.submitted leave.approved leave.rejected leave.cancelled
{
"id": 88,
"employee_id": 12,
"employee_name": "Sneha Iyer",
"type": {
"id": 1,
"name": "Casual leave"
},
"start_date": "2026-12-08",
"end_date": "2026-12-09",
"days": 2,
"half_day": false,
"reason": "Family function",
"status": "pending",
"stage": "Waiting for their manager",
"created_at": "2026-11-24T09:12:00Z"
}A day’s attendance · attendance.checked_in attendance.checked_out
{
"employee_id": 12,
"date": "2026-11-24",
"status": "present",
"check_in": "09:12",
"check_out": "18:40",
"work_min": 568,
"late_min": 0,
"source": "device",
"employee_name": "Sneha Iyer"
}training · training.completed
{}A request and where it stands · correction.submitted correction.approved correction.rejected expense.submitted expense.approved expense.rejected comp_off.submitted comp_off.approved comp_off.rejected profile.submitted profile.approved profile.rejected resignation.submitted resignation.approved resignation.rejected letter.submitted letter.approved letter.rejected loan.submitted loan.approved loan.rejected approval.requested
{
"kind": "leave",
"ref_id": 88,
"kind_label": "Time off",
"employee_id": 12,
"employee_name": "Sneha Iyer",
"summary": "2 days of casual leave, 8 Dec 2026 to 9 Dec 2026",
"reason": "Family function",
"stage": "Waiting for their manager",
"status": "pending"
}A locked month · payroll.month.locked
{
"month": "2026-10",
"status": "locked",
"people": 48,
"locked_at": "2026-11-02T10:00:00Z",
"hash": "9c1e…"
}A short message · ping
{
"message": "Hello from ANOMA. If you can read this, your endpoint works."
}