Webhooks¶
A tenant can have one webhook. It receives alerts about the identities the tenant enrolled.
Register¶
curl -s -X PUT http://127.0.0.1:7620/v1/webhook -H "Authorization: Bearer <api key>" -d '{"url":"https://example.org/hooks/keri"}'
The answer contains a secret. Registering again replaces the address and the secret. DELETE /v1/webhook removes it with all pending deliveries.
The address must use HTTPS and contain no credentials. Plain HTTP and private addresses are accepted only with ALLOW_PRIVATE=true.
Delivery¶
POST /hooks/keri
Content-Type: application/json
X-Timestamp: 1796118688
X-Signature: <hex>
{"payload":"...","aid":"<watcher>","sig":"..."}
Answer with a 2xx status within ten seconds. Otherwise the delivery is repeated up to 12 times, with a delay that doubles from one second up to an hour.
Verify¶
X-Signatureis the HMAC-SHA256 of<X-Timestamp>.<body>with the secret.- Reject old timestamps.
- Verify the envelope with the watcher's identifier.
import hashlib, hmac, time
def valid(secret, headers, body):
ts = headers["X-Timestamp"]
want = hmac.new(secret.encode(), ts.encode() + b"." + body, hashlib.sha256).hexdigest()
return hmac.compare_digest(want, headers["X-Signature"]) and abs(time.time() - int(ts)) < 300
Deliveries can repeat, so use the alert's id to recognize one you have processed.