1. Webhook Subscription
Partners can subscribe to event notifications from AccessRC via theapi/Event/Subscribe endpoint.
๐ก Example Requests
๐น No Authentication
๐น API Key Authentication
๐น Basic Authentication
๐น HMAC Authentication
2. ๐ Webhook Request Authentication
AccessRC will send event callbacks to your registered callbackUrl. Each webhook request will include an authentication header according to your chosen subscription option:| ๐ธ Auth Type | ๐ Header | ๐งฉ Example |
|---|---|---|
| None | (no header) | โ |
| API Key | x-api-key | x-api-key: my-api-key |
| Basic | Authorization | Authorization: Basic bXl1c2VyOm15cGFzc3dvcmQ= |
| HMAC | x-signature | x-signature: sha256=abcdef123456... |
3. ๐งฎ Verifying HMAC Signatures
When using HMAC authentication, every webhook request includes anX-Signature header:
- ๐งพ The raw HTTP request body (exact bytes, not parsed JSON)
- ๐ The shared secret you provided in your subscription
โ Verification Steps
-
Extract the Signature
Read thex-signatureheader from the incoming request. -
Get the Raw Request Body
Use the exact raw payload as received โ do not reformat or parse. -
Recompute the Signature
UseHMAC-SHA256(secret, rawBody)to generate your own hash.
Prefix it with"sha256=". -
Compare Signatures
Compare your computed signature with the received one.
4. ๐ Security Best Practices
- ๐ซ Never log or expose the shared secret.
- โ Always verify signatures for HMAC webhooks.
- ๐ Reject any unsigned or invalid webhook requests.
- ๐ Always use HTTPS for your webhook endpoint.
- ๐งฑ Keep your secret in secure configuration storage (not in code or client apps).
5. ๐งช Testing Webhooks
To test locally and ensure your webhook integration works as expected:- ๐ Use a tool like ngrok or localtunnel to expose your local webhook endpoint publicly.
- ๐ชต Log incoming request headers and the raw body for debugging.
- ๐ Simulate signature generation manually using your shared secret to validate your implementation.
- ๐งฉ Verify your signature verification logic before deploying to production.
- ๐ Test retry scenarios by sending multiple requests and validating idempotency.
๐ก Tip: When testing, return different HTTP status codes (200, 401, 403) to confirm AccessRC handles each scenario as expected.
6. ๐ฌ Response Expectations
Your webhook endpoint should behave as follows:- โ
Return
HTTP 2xx(usually200 OK) when processing succeeds. - ๐ Return
401 Unauthorizedif signature or authentication validation fails. - โฑ๏ธ Respond quickly (within a few seconds) โ delayed responses may trigger retries.
- ๐งพ Include a short, plain-text or JSON response body if helpful for debugging, but itโs optional.
