Standard Webhooks library for verifying and signing webhooks from Python
Project Links
Meta
Author: Standard Webhooks Team
Requires Python: >=3.10
Classifiers
Intended Audience
- Developers
- Information Technology
License
- OSI Approved :: MIT License
Operating System
- OS Independent
Programming Language
- Python
- Python :: 3
- Python :: 3 :: Only
- Python :: 3.10
- Python :: 3.11
- Python :: 3.12
- Python :: 3.13
- Python :: 3.14
- Python :: 3.15
Topic
- Software Development
- Software Development :: Libraries
- Software Development :: Libraries :: Application Frameworks
- Software Development :: Libraries :: Python Modules
Typing
- Typed
Python library for Standard Webhooks
Example
Verifying a webhook payload:
from standardwebhooks.webhooks import Webhook
wh = Webhook(base64_secret)
wh.verify(webhook_payload, webhook_headers)
webhook_payload must be the raw request body exactly as received, before any JSON parsing.
Pass it as bytes to verify the bytes as sent, including bodies that aren't valid UTF-8. A
str is verified as its UTF-8 encoding.
Responding to endpoint verification:
challenge = webhook_headers.get("webhook-challenge")
if challenge:
response_headers["webhook-challenge-response"] = wh.endpoint_verification_response(challenge)
# Not a webhook delivery: respond (e.g. with 204 No Content) without processing the body
return
Verifying the response as a producer (raises WebhookVerificationError if it doesn't match):
wh.verify_endpoint_verification_response(challenge, response_headers["webhook-challenge-response"])
Development
Requirements
- python 3
Installing dependencies
python -m venv .venv
pip install -r requirements.txt && pip install -r requirements-dev.txt
Contributing
Before opening a PR be sure to format your code!
./scripts/format.sh
Running Tests
Simply run:
pytest
Wheel compatibility matrix
Files in release
No dependencies