Webhooks
Verification
Verify X-OuiPay-Signature on every webhook delivery.
Signature = hex HMAC-SHA256 of {timestamp}.{raw_body} using the subscription
signing secret.
Headers
| Header | Value |
|---|---|
X-OuiPay-Timestamp | Unix seconds |
X-OuiPay-Signature | Hex digest (no sha256= prefix) |
X-OuiPay-Delivery-Id | Unique delivery id |
Steps
- Read the raw request body bytes (do not re-serialize JSON first).
- Reject if the timestamp is too old (for example older than 5 minutes).
- Compute
HMAC_SHA256(secret, "{timestamp}.{body}")as lowercase hex. - Compare to
X-OuiPay-Signaturewith a constant-time equality check. - Deduplicate on
X-OuiPay-Delivery-Id.
Code
# Compute expected signature (hex) from timestamp + raw body file
printf '%s.' "$TIMESTAMP" | cat - ./body.json \
| openssl dgst -sha256 -hmac "$WEBHOOK_SECRET" \
| awk '{print $2}'