Skip to main content
A copy-paste-runnable webhook receiver in Python + Flask. Around 80 lines. Demonstrates the four things you have to get right: raw-body capture, constant-time signature compare, idempotency on x-klikit-event-id, and fast 2xx acknowledgement.
The source also lives in the partner-api repo at examples/webhook-receiver/python so you can clone it directly.

Run it

Listens on :8080 and exposes POST /webhooks/klikit.

Source

server.py
requirements.txt

Hardening for production

The reference above runs as-is, but two things need real-world replacements before you put it in production:
  • _seen_event_ids is in-memory. Replace with Redis (SET key NX EX 86400) or a Postgres unique index. An in-memory set evaporates on every restart, letting duplicates back in.
  • threading.Thread is a single-process worker. For real throughput, push to a durable queue (SQS, Celery, RQ) and process from a separate worker so an OOM in your processor can’t drop events.
  • Use a real WSGI server (gunicorn, uvicorn with an ASGI shim, etc.) in production. Flask’s dev server is not suitable for live traffic.