Security is critical when exposing webhook endpoints. Posthook provides tools to ensure that your communication is secure and authenticated.Documentation Index
Fetch the complete documentation index at: https://docs.posthook.io/llms.txt
Use this file to discover all available pages before exploring further.
Keys
API Key
The API Key is used to authenticate your requests to the Posthook API (e.g., when scheduling a hook viaPOST /hooks). This key grants full access to your project, so keep it secret.
- Usage: Set in the
X-API-Keyheader. - Exposure: Never expose this in client-side code (browsers, mobile apps). Store it securely in your backend environment variables.
Signing Key
The Signing Key is used to verify that incoming hooks to your endpoint actually came from Posthook.- Usage: Used to compute the
Posthook-SignatureandX-Ph-Signatureheaders included with every delivery. - Rotation: Posthook supports zero-downtime key rotation. During the grace period,
Posthook-Signatureincludes signatures for both the active and retiring keys. See Key Rotation. - Exposure: This key should also be kept secret on your backend.
Replay Attacks
To protect against replay attacks, where an attacker intercepts and resends a valid payload, verify the timestamp included with the delivery. You can use either:Posthook-Timestampheader (recommended) — Unix timestamp in seconds. This value is also part of the signed payload, so it cannot be tampered with.postedAtbody field — RFC 3339 timestamp.
Best Practice
Reject requests where the timestamp is too far from the current time (e.g., 5 minutes).SDK Verification (Recommended)
The official SDKs provide aparseDelivery() method that handles signature verification, timestamp validation, and replay protection in a single call. You will need your Signing Key, found in Project Settings in the Dashboard.
How It Works
Under the hood, the SDK verifies thePosthook-Signature header using HMAC-SHA256. Every webhook delivery includes three headers:
| Header | Example |
|---|---|
Posthook-Id | e5405623-2c1c-460e-9737-c884f7f59035 |
Posthook-Timestamp | 1700000000 |
Posthook-Signature | v1,abc123 v1,def456 |
- Build the signed payload:
{Posthook-Timestamp}.{raw_body}(dot-separated). - Compute HMAC-SHA256 using your project’s signing key.
- Hex-encode the result (lowercase, 64 characters).
- Prefix with
v1,.
Posthook-Signature contains two space-separated signatures (one per key). The SDK accepts the delivery if either signature matches.
Key Rotation
Posthook supports zero-downtime key rotation through a grace period:- Before rotation —
Posthook-Signaturehas onev1,entry using the active signing key. - After rotation (grace period) —
Posthook-Signatureincludes twov1,entries: one for the new active key and one for the retiring key. Accept the delivery if either matches. - After grace period expires — The retiring key is excluded.
Posthook-Signaturereturns to a singlev1,entry. - Revoke (optional) — You can revoke the retiring key early via the API or dashboard.
Legacy Header (X-Ph-Signature)
X-Ph-Signature is deprecated. Migrate to Posthook-Signature for dual-key support during key rotation. The SDK’s parseDelivery() verifies Posthook-Signature automatically.X-Ph-Signature contains a hex-encoded HMAC-SHA256 of the raw request body using the active project signing key.
Key difference: X-Ph-Signature uses only the active key. When you rotate your signing key, this header immediately switches to the new key — there is no grace period. If your consumer hasn’t updated yet, verification will fail until it starts using the new key.