Skip to main content

1. Webhook Subscription

Partners can subscribe to event notifications from AccessRC via the api/Event/Subscribe endpoint.

๐Ÿ’ก Example Requests

๐Ÿ”น No Authentication

{
  "eventType": "DELIVERY_CHANNEL_STATUS_UPDATED",
  "callbackUrl": "https://partner.example.com/webhook"
}

๐Ÿ”น API Key Authentication

{
  "eventType": "DELIVERY_CHANNEL_STATUS_UPDATED",
  "callbackUrl": "https://partner.example.com/webhook",
  "auth": {
    "type": "header",
    "headerName": "X-API-Key",
    "headerValue": "my-api-key"
  }
}

๐Ÿ”น Basic Authentication

{
  "eventType": "DELIVERY_CHANNEL_STATUS_UPDATED",
  "callbackUrl": "https://partner.example.com/webhook",
  "auth": {
    "type": "basic",
    "username": "webhook-user",
    "password": "s3cr3t"
  }
}

๐Ÿ”น HMAC Authentication

{
  "eventType": "DELIVERY_CHANNEL_STATUS_UPDATED",
  "callbackUrl": "https://partner.example.com/webhook",
  "auth": {
    "type": "hmac",
    "secret": "abcd1234"
  }
}

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 Keyx-api-keyx-api-key: my-api-key
BasicAuthorizationAuthorization: Basic bXl1c2VyOm15cGFzc3dvcmQ=
HMACx-signature x-signature: sha256=abcdef123456...

3. ๐Ÿงฎ Verifying HMAC Signatures

When using HMAC authentication, every webhook request includes an X-Signature header:
x-signature: sha256=3bdc5b07d7ef9b61b98ed5df4b1793e12fd...
This signature is generated using:
  • ๐Ÿงพ The raw HTTP request body (exact bytes, not parsed JSON)
  • ๐Ÿ”‘ The shared secret you provided in your subscription

โœ… Verification Steps

  1. Extract the Signature
    Read the x-signature header from the incoming request.
  2. Get the Raw Request Body
    Use the exact raw payload as received โ€” do not reformat or parse.
  3. Recompute the Signature
    Use HMAC-SHA256(secret, rawBody) to generate your own hash.
    Prefix it with "sha256=".
  4. 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:
  1. ๐ŸŒ Use a tool like ngrok or localtunnel to expose your local webhook endpoint publicly.
  2. ๐Ÿชต Log incoming request headers and the raw body for debugging.
  3. ๐Ÿ”‘ Simulate signature generation manually using your shared secret to validate your implementation.
  4. ๐Ÿงฉ Verify your signature verification logic before deploying to production.
  5. ๐Ÿ” 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 (usually 200 OK) when processing succeeds.
  • ๐Ÿ” Return 401 Unauthorized if 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.

๐Ÿ’ฌ Example Responses

โœ… Success

HTTP/1.1 200 OK
Content-Type: application/json

{
  "status": "success",
  "message": "Callback successfully received",
  "data": {}
}

โŒ Invalid Signature (HMAC)

HTTP/1.1 401 Unauthorized
Content-Type: application/json

{
  "status": "failed",
  "error": {
     "code": 401,
     "message": "Invalid Signature",
     "type": "Unauthorized"
  }
}

๐Ÿšซ Invalid API KEY

HTTP/1.1 401 Unauthorized
Content-Type: application/json

{
  "status": "failed",
  "error": {
     "code": 401,
     "message": "Invalid API KEY",
     "type": "Unauthorized"
  }
}

๐Ÿšซ Invalid Credentials

HTTP/1.1 401 Unauthorized
Content-Type: application/json

{
  "status": "failed",
  "error": {
     "code": 401,
     "message": "Invalid Credentials",
     "type": "Unauthorized"
  }
}