Skip to main content
SpherePay signs every webhook delivery so you can confirm it genuinely came from SpherePay and was not tampered with in transit. SpherePay never sends an unsigned delivery. Always verify the signature before processing a payload, and reject anything that fails verification with a non-2xx response.

Delivery headers

Every delivery attempt carries these headers: Headers describe the delivery attempt; the body describes the event. On a replay, Sphere-Timestamp and Sphere-Signature are freshly generated — so the same verification code path handles originals and replays — while the body remains byte-for-byte identical to the original.

How the signature is computed

The signature is an HMAC-SHA256 digest, hex-encoded:
  • secret — the endpoint’s signing secret (whsec_...), returned once when you created the endpoint.
  • timestamp — the value of the Sphere-Timestamp header.
  • rawBody — the raw HTTP request body bytes, exactly as transmitted.
To verify: compute the same digest yourself and compare it to Sphere-Signature using a constant-time comparison.
Verify against the raw request body, not a re-serialized version. Parsing the JSON and re-encoding it can reorder keys or change whitespace, which changes the bytes and breaks verification. Most web frameworks require explicit configuration to expose the raw body — capture it before any JSON middleware runs.

Guard against replay attacks

To prevent captured deliveries from being re-sent by a third party, reject deliveries whose Sphere-Timestamp is more than 5 minutes old. Manual replays get a fresh timestamp and signature, so legitimate replays always pass this check.

Reference implementations

Each snippet takes the raw body bytes, the two headers, and your endpoint secret, and returns whether the delivery is authentic.

When verification fails

Respond with a non-2xx status code (for example 401) and do not process the payload. The delivery is recorded as failed on SpherePay’s side, giving you an audit trail in the Events API.
If you registered the same receiver URL under multiple SpherePay applications, each application’s endpoint has its own secret. Use the applicationId in the payload to select the correct secret — see Event payloads. If you cannot parse the body before verifying, try each of your known secrets.
Last modified on August 11, 2026