Skip to main content
Project Webhooks send signed event notifications to your configured HTTPS endpoint after changes to resources in your project are committed. You can use these notifications to update business state, process follow-up work, or respond to failures. Notifications carry resource identities and essential state fields rather than complete resource snapshots. After receiving a notification, query the resource API for details and the latest state. Webhooks are not a durable event log—record the full change history separately if you need it, and query the resource API whenever you need to reconcile the latest business state. If you need detailed real-time output from a session, use the Event Stream. If you only need notifications for scheduled trigger runs, use the trigger’s notification configuration; see Run Agents with Triggers. These three notification mechanisms are independent of one another.

Register an endpoint

Use a project API key to manage Webhooks. Session work tokens and environment work keys cannot be used to manage Webhooks, and queries return only configurations belonging to the current project.

Create a Webhook

Call POST /v1/webhooks with the receiver URL and the events to subscribe to:
New configurations are disabled by default. The full signing secret is returned only in this creation response, so save it immediately; later queries do not return it. Each project can store up to 32 Webhooks, including disabled configurations, and multiple Webhooks in the same project can use the same URL.

Prepare the receiver and enable the Webhook

The receiver must be an absolute HTTPS URL with a non-empty hostname. The default port is 443, and an explicit port must be between 1 and 65535. Domain names, IPv4/IPv6 literals, paths, and query parameters are supported. Userinfo, fragments, and IPv6 zone IDs are not accepted. Public targets are allowed by default, while loopback, link-local, cloud provider metadata, and other special-purpose addresses are rejected. The platform performs standard TLS certificate validation and does not follow redirects. Once your receiver is ready, call PATCH /v1/webhooks/{id} to explicitly enable the Webhook:
The platform delivers an event only to configurations that were enabled and subscribed to that event type when the event occurred. Adding, enabling, or modifying a subscription later does not backfill earlier events.

Verify the signature

Every HTTPS POST includes the following headers:
The signature scheme and whsec_<base64> secret format follow the Standard Webhooks specification. To verify a signature, strip the whsec_ prefix and decode the standard Base64 value to recover the 32-byte key. Use that key to compute HMAC-SHA256 over event ID + "." + timestamp + "." + raw request body bytes. The example below shows a Node.js receiver with no web framework dependencies:
The example uses an in-memory set to demonstrate deduplication. In production, use persistent deduplication storage and return a 2xx response only after reliably storing or queueing the event. When multiple consumers share deduplication storage, scope deduplication keys by consumer.

Handle events

The notification envelope contains the fixed type: event, a unique event id, the occurrence time created_at, and the resource payload data:
The top-level id identifies the event, while data.id identifies the resource that changed. Different changes to the same resource produce different event IDs. project_id identifies the project that persistently owns the resource. Receivers should process notifications in this order:
  1. Verify the signature and timestamp against the raw request body before parsing the JSON.
  2. Deduplicate by the top-level event id.
  3. Return any 2xx response once the event is reliably received, and handle time-consuming business logic asynchronously.
  4. Query the latest resource state using data.type and data.id before updating business data. Late historical notifications must not overwrite newer resource state; treat a deletion notification as the final signal that the resource was permanently deleted.

Supported event types

When creating a Webhook, specify the events to subscribe to in event_types. Each configuration must subscribe to at least one event type, without duplicates. For complete payload fields, see the Webhooks group and the Send a Webhook event callback in the API reference.
Session events describe the state of the whole session, while child thread events describe an individual child thread. The resource ID in a child thread event is the child thread ID, and session_id identifies the parent session.The initial idle state at session creation does not send a separate notification. session.status_idled and session.thread_idled carry a stop reason of end_turn, canceled, internal_error, or requires_action; writes without an explicit reason do not emit these events.When a session is archived, separate notifications are sent for the session and for each child thread that actually terminates, but no event is sent for the coordinator thread. A single property-update transaction emits session.updated only once. An automatic title emits this event only when the previous title was empty and the title was written successfully. The deletion event retains the session ID and project ownership from before deletion as the final signal that the session was permanently deleted.
Project ownership is determined by the resource’s persistent owner. Official resources and changes without project ownership do not produce project Webhooks; changes made by an administrator to project resources still emit events according to the resource’s project ownership.

Delivery behavior

  • Duplicate deliveries: The same event may arrive more than once. All targets and retries for an event share the same top-level id, which also matches Webhook-Id.
  • Subscription scope: Each delivery task is created after the resource change is committed and captures the target’s URL and signing secret at that moment. Later configuration changes do not affect tasks that have already been created.
  • Delivery order: Events are not guaranteed to arrive in the order they occurred. Drive business logic from the latest state returned by the resource API rather than relying on arrival order.
  • Retries: Each event-target combination is attempted at most 3 times in total (including the initial attempt), with a 10-second timeout per request. Any 2xx response counts as success; non-2xx responses, temporary DNS or connection failures, and request timeouts are retried while attempts remain.
  • Retry-After: Parsed only for 429 and 503 responses. A valid value of up to 120 seconds sets the lower bound for the backoff delay; a value above 120 seconds stops retries and ends the task as a final delivery failure. Empty, malformed, zero-second, or expired values fall back to the standard backoff.
  • Redirects and rejected addresses: 3xx responses are never followed and are treated as ordinary non-2xx responses. If the address policy rejects the target, the current task ends immediately without retries and does not count toward receiver failures.
  • Timestamps: Webhook-Timestamp is generated when each delivery attempt is signed and is updated on retries; use the payload’s created_at for the event occurrence time.
  • Lost notifications: Platform failures, publication timeouts, or queue anomalies can cause notifications to be lost. Query the resource API when you need to reconcile business state; do not treat Webhooks as a complete change log.
The platform tracks delivery tasks that end in a final failure separately for each configuration; intermediate retries are not counted. The first final failure opens a fixed 24-hour window, and any 2xx success clears the failure record. If the number of final delivery failures within the window exceeds 20, the platform automatically disables the Webhook and sets disabled_reason to delivery_failures. An actual URL change, signing secret rotation, or explicit enable resets the failure record for the new configuration; changing only the name or subscription list preserves the existing record. Automatic disabling only stops capturing new events; tasks that have already been created continue executing. Once you fix the receiver, you can re-enable the Webhook, but events that occurred while it was disabled are not replayed.

Manage Webhooks

Creation and signing-secret rotation responses additionally include signing_secret and carry Cache-Control: no-store. For request fields, response fields, and error definitions, see the Webhook API reference. The update endpoint modifies only fields present in the request body; an empty request body, explicit null, empty URL, empty event list, or duplicate or unknown event types all return 400. Changing the URL, rotating the signing secret, disabling, or deleting a Webhook affects only subsequent new events. Delivery tasks that have already been created, including their retries, continue using the original URL and secret. After rotating a secret, receivers should support verification with both the old and new secrets until in-flight tasks from the old configuration have drained. Deleting a configuration does not cancel delivery tasks that have already been created.

Next steps

View the Event Stream

Receive detailed real-time output from sessions and threads.

Configure scheduled tasks

Learn about triggers and their independent scheduled-run notifications.

Explore the API reference

View management endpoints, callbacks, and complete event schemas.