For the complete documentation index, see llms.txt. This page is also available as Markdown.

Authentication

Cuoral uses HMAC-SHA256 signatures to authenticate webhook requests and ensure that webhook events are coming from Cuoral.

Every webhook request includes a signature in the X-Cuoral-Webhook-Signature header.

Your webhook endpoint should verify this signature before processing the request.

Signature Header

The signature is provided in the following request header:

X-Cuoral-Webhook-Signature: <signature>

The signature is generated using:

  • Algorithm: HMAC-SHA256

  • Secret: Your organization's api_key

  • Payload: The webhook request payload serialized as JSON with sorted keys

How Verification Works

When Cuoral sends a webhook, it:

  1. Serializes the webhook payload as JSON with keys sorted alphabetically.

  2. Uses your organization's api_key as the HMAC secret.

  3. Generates an HMAC-SHA256 hash.

  4. Sends the resulting hexadecimal signature in the X-Cuoral-Webhook-Signature header.

Your application should perform the same calculation and compare the generated signature with the value provided in the request header.

If the signatures match, the webhook can be considered authentic.

Node.js

Python

Important: Verify the Raw Payload

For maximum reliability, webhook signature verification should be performed against the raw request body before your framework parses or transforms the JSON.

Re-serializing JSON can produce a different string due to differences in whitespace, escaping, or key ordering.

If your framework provides access to the raw request body, use it when calculating the HMAC.

Security Recommendations

  • Always verify the X-Cuoral-Webhook-Signature header before processing a webhook.

  • Keep your organization's api_key secret.

  • Use HTTPS for your webhook endpoint.

  • Use a constant-time comparison when comparing signatures.

  • Return a successful HTTP status only after the webhook has been accepted and validated.

Last updated