Skip to content

Commit a78010f

Browse files
committed
Document HMAC signing
1 parent 0e1598c commit a78010f

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,30 @@ curl -X POST https://<your-worker>.workers.dev/capture \
8484
]'
8585
```
8686

87+
## HMAC signing (optional)
88+
89+
If `POSTHOG_SIGNING_SECRET` is set, requests must include a valid signature.
90+
91+
```bash
92+
payload='[
93+
{
94+
"api_key": "phc_example",
95+
"event": "purchase",
96+
"distinct_id": "user_12345",
97+
"properties": { "amount": 29.99 }
98+
}
99+
]'
100+
101+
signature=$(printf '%s' "$payload" | openssl dgst -sha256 -hmac "$POSTHOG_SIGNING_SECRET" | awk '{print $2}')
102+
103+
curl -X POST https://<your-worker>.workers.dev/capture \
104+
-H "Content-Type: application/json" \
105+
-H "X-POSTHOG-SIGNATURE: sha256=$signature" \
106+
-d "$payload"
107+
```
108+
109+
Note: `X-HUB-SIGNATURE` with `sha1=` is also accepted for GitHub-style webhook compatibility.
110+
87111
## PostHog SDK config
88112

89113
### Browser (posthog-js)

0 commit comments

Comments
 (0)