Receive real-time HTTP notifications when events occur in your Lucitra project. Webhooks eliminate the need to poll for validation status and integrate directly with Slack and Microsoft Teams.
HMAC-SHA256 signing secret. Shown only once at creation time. Store it securely.
The secret value is only returned when you create the webhook. Store it immediately in a secure location like a secrets manager. There is no way to retrieve it later.
Every webhook delivery includes an X-Lucitra-Signature header containing an HMAC-SHA256 signature of the request body. Always verify this signature to ensure the payload was sent by Lucitra and has not been tampered with.The header format is:
import hmacimport hashlibdef verify_webhook(payload_bytes: bytes, signature_header: str, secret: str) -> bool: """Verify that a webhook payload was signed by Lucitra. Args: payload_bytes: The raw request body as bytes. signature_header: The value of the X-Lucitra-Signature header. secret: Your webhook signing secret (whsec_...). Returns: True if the signature is valid. """ if not signature_header.startswith("sha256="): return False expected_sig = signature_header.removeprefix("sha256=") computed_sig = hmac.new( secret.encode("utf-8"), payload_bytes, hashlib.sha256, ).hexdigest() return hmac.compare_digest(computed_sig, expected_sig)# Usage in a Flask handlerfrom flask import Flask, request, abortapp = Flask(__name__)WEBHOOK_SECRET = "whsec_abc123def456"@app.route("/webhooks/lucitra", methods=["POST"])def handle_webhook(): signature = request.headers.get("X-Lucitra-Signature", "") if not verify_webhook(request.data, signature, WEBHOOK_SECRET): abort(401, "Invalid signature") event = request.get_json() print(f"Received event: {event['event']}") return "", 200
Always use hmac.compare_digest (or equivalent constant-time comparison) instead of == to prevent timing attacks against the signature.
If you rotate your webhook secret, create a new webhook with the new secret and delete the old one. There is no update endpoint for secrets because they are only stored as hashed values.