Skip to main content
Webhooks let Agent Therapy push event notifications to your infrastructure the moment something significant happens — no polling required. When a subscribed event fires, Agent Therapy sends an HTTP POST request to the URL you register, with a JSON body describing the event. Use webhooks to trigger downstream workflows: escalating a critical finding to your on-call channel, automatically applying a pre-configured intervention, or updating your internal observability dashboard.
Return a 2xx response to Agent Therapy as quickly as possible — ideally within 5 seconds — and process the event asynchronously in a background job or queue. If your endpoint does not respond with a 2xx status within the timeout window, Agent Therapy will retry the delivery up to 3 times with exponential backoff (10 s, 30 s, 90 s).

Supported Events

Registering a Webhook

POST /webhooks

Register a new webhook endpoint and subscribe it to one or more events.

Request Body

string
required
The HTTPS URL that Agent Therapy should POST event payloads to. Must be publicly reachable and respond with a 2xx status. HTTP (non-TLS) URLs are not accepted.
array
required
An array of event name strings to subscribe to. You must subscribe to at least one event. Use ["*"] to subscribe to all current and future events. Valid values: session.completed, session.failed, finding.critical, health_score.threshold_breached, intervention.applied.
string
An optional secret string used to sign webhook payloads with HMAC-SHA256. Strongly recommended for production endpoints. If provided, every request will include an X-AgentTherapy-Signature header you can use to verify authenticity. See Verifying Webhook Signatures for details.

Response Fields

string
The unique identifier for this webhook registration. Prefixed with wh_.
string
The destination URL that was registered.
array
The list of events this webhook is subscribed to.
string
The webhook’s current status: active or inactive.
string
ISO 8601 timestamp indicating when the webhook was registered.

Example

Webhook Payload Format

When an event fires, Agent Therapy POSTs a JSON payload to your registered URL. Every payload follows the same envelope structure:

Verifying Webhook Signatures

If you provided a secret when registering your webhook, Agent Therapy signs each payload with HMAC-SHA256 and includes the signature in the X-AgentTherapy-Signature header. Always verify this signature before processing the event to ensure the payload came from Agent Therapy and was not tampered with. The signature is computed as:
The header value is prefixed with sha256=:
Here is a Python example showing how to verify the signature in a Flask webhook handler:
Always use hmac.compare_digest (or an equivalent constant-time comparison) when validating signatures. A standard string comparison (==) is vulnerable to timing attacks that can allow an attacker to forge a valid signature.

Managing Webhooks

GET /webhooks

List all webhook registrations for your account.

DELETE /webhooks/

Deactivate and remove a webhook registration. Agent Therapy will immediately stop sending events to the registered URL.
A successful delete returns an HTTP 204 No Content response with no body.