Skip to main content
For Python services. Uses the well-maintained cryptography library. Full source (verbatim): docs/examples/webhook-receivers/python-fastapi/main.py

Dependencies

main.py

Run

Behind a TLS-terminating reverse proxy (Caddy, nginx). Or use uvicorn with --ssl-keyfile and --ssl-certfile for direct TLS.

Async work pattern

The reference above ACKs synchronously. For production, return 202 and process in the background:
ACK within ~100ms, do real work async.

Production tips

Read body before parsing. await request.body() gives you the original bytes — sign over those exact bytes. Do not let FastAPI’s automatic JSON parsing intercept. Persist alert_id for idempotency. Use Redis (SET with TTL = 86400) or your DB. Without idempotency a retry can double-act. Worker count. With multiple uvicorn workers, any in-memory dedup set becomes per-worker — leaks deliveries. Move to Redis before scaling. Hardcode the key allowlist. The example uses one key. During rotation, support two:

Test locally

The dashboard’s “Send test event” button delivers to your registered URL with a known payload. To test fully offline:
test.py
Add the generated public key as the receiver’s PEGANA_PUB_KEY_B64 env, hit your endpoint with curl, verify the 200.

Next

TypeScript example

Web Crypto API for edge.

Rust example

ed25519-dalek strict mode.