Skip to main content
SMS, WhatsApp, and mobile data delivery receipts are signed with HMAC-SHA256 using your API client secret. You can also restrict your endpoint to Belio’s outbound IPs. If receipts stop arriving, the URL may have tripped the circuit breaker.

HMAC signing

Each signed callback includes two extra HTTP headers:

How the signature is computed

The signature is computed over the timestamp and the raw request body: HMAC-SHA256(api_client_secret, "{X-Timestamp}.{body}")\text{HMAC-SHA256}(\text{api\_client\_secret},\ \texttt{"\{X\text{-}Timestamp\}.\{body\}"}) body is the exact JSON string of the request body. Do not reformat or change whitespace.

Verify the signature

1

Read the headers

Extract the X-Timestamp and X-Signature headers from the incoming request.
2

Check the timestamp

Reject the request if X-Timestamp is more than 5 minutes off from your clock. That limits replay of a captured request.
3

Recompute the signature

Using your API client secret (UTF-8 encoded), compute:
Use the raw request body bytes. Do not parse and re-serialize the JSON.
4

Compare

Base64-encode your computed HMAC, then compare it against the value in X-Signature after stripping the sha256= prefix. If they match, handle the receipt. If they don’t, reject it with 401 Unauthorized.
After you regenerate your API client secret, signed callbacks may still use the previous secret for up to 5 minutes. During that window, verify against both secrets.

Code examples

Compare signatures with a timing-safe function such as crypto.timingSafeEqual, hmac.compare_digest, or hash_equals. Ordinary string equality can leak whether the first bytes matched.

IP whitelisting

You can reject requests that do not come from these addresses, at the network or in your handler. The same IPs send USSD callbacks.