Webhook Security

To ensure that your webhook implementation is secure, you can verify that the webhook notifications come from Ospree by computing the hmac-sha256 digest using your unique webhook secret. Each webhook URL has its own secret.

circle-info

This feature is currently in testing and will be available in production soon.

Finding your webhook secret

To get your webhook secret, first create a new webhook withConfigure Webhook or List Webhooks for existing webhooks. Then copy the webhook_secret field from the API response.

Signature Validation

Ospree webhook notifications contain x-ospree-signature and x-ospree-timestamp headers for signature validation. Your application should:

  1. Read the raw request body and the two headers before modifying the payload.

  2. Ensure x-ospree-timestamp is present and within 300 seconds (5 minutes) of the current UTC time to avoid replay attacks.

  3. Parse the JSON payload and confirm it includes a request_id.

  4. Build the signing string as <timestamp>.<request_id>.<raw_body>.

  5. Compute an HMAC-SHA256 digest of the signing string using your WEBHOOK_SECRET.

  6. Compare the computed digest with the hex value in x-ospree-signature (strip the hmac-sha256= prefix) using a constant-time comparison.

Example Request Headers

  'user-agent': 'Ospree-Webhook/2.0',
  'x-ospree-signature': 'hmac-sha256=4b562a267391cffb6f5847dd5978cca8e305fb21bf1d99dafeb565a05cae6b05',
  'x-ospree-timestamp': '1759839979'

Example Implementation

Last updated