Skip to main content

Availability

For how webhooks work, refer to Webhooks. Each webhook delivery carries a signature in the X-Webhook-Signature header. Check it in your receiver before you process the event.

Verify the Signature

Each target has a signing secret. You get it when you create the target. The signature is an HMAC-SHA256 of the timestamp, a period, and the raw body, with the signing secret as the key. For all delivery headers, refer to Delivery Headers. To verify a delivery:
  1. Read the X-Webhook-Timestamp header and the raw request body.
  2. Calculate HMAC-SHA256(secret, timestamp + "." + body) and encode it as hexadecimal.
  3. Compare v1=<your value> with each comma-separated entry in X-Webhook-Signature. Use a constant-time comparison.
  4. Reject the request if no entry matches, or if the timestamp is older than a few minutes.
  5. Send a 2xx response.

Rotate the Signing Secret

When you select Rotate signing secret for a target, AI Studio makes a new secret and shows it one time. For a grace period, each delivery has two signatures: first with the new secret, then with the old secret. Update your receiver during this period. WEBHOOKS_SECRET_ROTATION_GRACE sets the length of the period.