> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orq.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Webhooks for real-time notifications

> Subscribe to Orq.ai events and receive real-time HTTP POST notifications when agents, deployments, prompts, and other resources change.

Webhooks let you subscribe to events in **Orq.ai** and receive an HTTP `POST` request to your server whenever those events occur, with no polling required.

## Setting Up a Webhook

> [tab] AI Studio
>
> Navigate to **Settings** → **Project** → **Webhooks** and click <kbd> Webhook</kbd> to configure the following:
>
> * **Name**: a unique name to identify this webhook
> * **URL**: the endpoint on your server that will receive the HTTP POST requests
> * **Enable webhook**: controls whether this endpoint receives deliveries
> * **Event types**: choose which events should trigger this webhook
>
> Select **Create webhook** to create the endpoint.
>
> ![Create webhook endpoint sheet with Name, URL, Enable webhook, and Event types
> fields](https://mintcdn.com/orqai/mR6s_AJJ6QfYmhhA/images/webhook-create.png?fit=max\&auto=format\&n=mR6s_AJJ6QfYmhhA\&q=85\&s=15660e4196165c2a10881348057cf627)
>
> Create a webhook endpoint with a name, URL, the Enable webhook switch, and event types.
>
> When **deployment** events are selected, choose **Send me everything** or **Select individual deployments**. Both are stored in `events`, and `POST /v2/webhooks` takes the same form; there is no separate deployment field.
>
> | Option | Stored in `events` |
> | - | - |
> | **Send me everything** | `deployment.invoked` |
> | **Select individual deployments** | One `deployment.invoked.<deployment_id>` per selected deployment |
>
> For example, `["deployment.created", "deployment.invoked.01kkypj82sqrzg1s9t9v9p13jv"]` delivers invocations for that deployment only.
>
> > [!WARNING]
> >
> > After adding the webhook, a **Save your signing secret** dialog appears with
> > the secret, which is not shown again. To replace a lost secret, generate a
> > new one with `GET /v2/webhooks/secret` and send it in a
> > `PATCH /v2/webhooks/{id}` body. The webhook keeps its ID and event
> > subscriptions.

> [tab] API & SDK
>
> Create webhooks programmatically in two calls:
>
> 1. Generate a signing secret with [`GET /v2/webhooks/secret`](https://docs.orq.ai/reference/webhooks/generate-a-webhook-secret). The response returns the value in a `secret` field. The secret is not stored until a webhook is created with it.
> 2. Create the webhook with [`POST /v2/webhooks`](https://docs.orq.ai/reference/webhooks/create-a-webhook), sending that secret in the body.
>
> **Required fields**
>
> | Field | Description |
> | - | - |
> | `_id` | Client-generated webhook ID. |
> | `url` | HTTPS endpoint that receives deliveries. |
> | `content_type` | `application/json` or `application/x-www-form-urlencoded`. |
> | `display_name` | Human-readable webhook name. |
> | `events` | One or more event slugs from [Event Types](#event-types), for example `deployment.invoked`. |
> | `secret` | The signing secret from step 1. |
>
> `enabled` is optional. Omitting it leaves deliveries enabled.
>
> ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
> secret=$(curl -sS https://my.orq.ai/v2/webhooks/secret \
>   -H "Authorization: Bearer $ORQ_API_KEY" | jq -r '.secret')
>
> curl -sS -X POST https://my.orq.ai/v2/webhooks \
>   -H "Authorization: Bearer $ORQ_API_KEY" \
>   -H "Content-Type: application/json" \
>   -d "$(jq -n --arg secret "$secret" '{
>     _id: "webhook_production_alerts",
>     url: "https://example.com/orq-webhooks",
>     content_type: "application/json",
>     display_name: "Production alerts",
>     events: ["deployment.invoked", "llm.response"],
>     secret: $secret
>   }')"
> ```
>
> ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
> import { Orq } from "@orq-ai/node";
>
> const orq = new Orq({ apiKey: process.env["ORQ_API_KEY"] ?? "" });
>
> const { secret } = await orq.webhooks.generateSecret();
>
> await orq.webhooks.create({
>   id: "webhook_production_alerts",
>   url: "https://example.com/orq-webhooks",
>   contentType: "application/json",
>   displayName: "Production alerts",
>   events: ["deployment.invoked", "llm.response"],
>   secret,
> });
> ```
>
> ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
> import os
> from orq_ai_sdk import Orq
>
> with Orq(api_key=os.getenv("ORQ_API_KEY", "")) as orq:
>     secret = orq.webhooks.generate_secret().secret
>
>     orq.webhooks.create(
>         id="webhook_production_alerts",
>         url="https://example.com/orq-webhooks",
>         content_type="application/json",
>         display_name="Production alerts",
>         events=["deployment.invoked", "llm.response"],
>         secret=secret,
>     )
> ```

A webhook is scoped to the workspace: one webhook receives events from every project in the workspace.

Use the signing secret to [verify incoming requests](#security).

## Event Types

**Orq.ai** sends webhooks for the following events, grouped by resource:

| Group | Event |
| - | - |
| **Agent** | `agent.created` |
| | `agent.updated` |
| | `agent.deleted` |
| **Deployment** | `deployment.created` |
| | `deployment.updated` |
| | `deployment.deleted` |
| | `deployment.invoked` |
| **Prompt** | `prompt.created` |
| | `prompt.updated` |
| | `prompt.deleted` |
| **LLM** | `llm.chat_completion` |
| | `llm.response` |
| | `llm.embedding` |
| | `llm.rerank` |
| | `llm.evaluator` |

## Delivery

**Orq.ai** sends each matching event as an HTTP `POST` to the endpoint URL, with the event JSON as the body. A delivery succeeds when the endpoint responds with any `2xx` status within 15 seconds.

* **Timeout**: the request is abandoned after 15 seconds and the delivery counts as failed. Connecting to the endpoint allows 5 seconds, and response headers must arrive within 10 seconds.
* **Retries**: a failed delivery is attempted twice more, 5 seconds after the first failure and 10 seconds after the second, for three attempts in total. After the third failed attempt the event is not delivered again.
* **No retry**: `4xx` responses are permanent except `408`, `409`, `425`, and `429`. Those four, `5xx` responses, timeouts, and connection failures are retried.
* **Identical retries**: every attempt for the same event and endpoint sends the same body, the same `X-Orq-Signature`, and the same `Idempotency-Key` header.

### Failed deliveries

Each webhook carries `failure_count`, the number of consecutive failed attempts, and `enabled`, which turns delivery off.

| Event | Result |
| - | - |
| Any delivery succeeds | `failure_count` resets to `0` |
| An attempt fails | `failure_count` increases by 1, so one failed delivery adds up to 3 |
| The tenth consecutive failed attempt | The webhook is disabled |
| A `401` or `403` response | The webhook is disabled at once, because the endpoint rejected the credentials |
| A third failed attempt for one event | That event is dropped; later events still deliver |

Re-enable a disabled webhook by patching `enabled` to `true`, which also resets `failure_count` to `0`. Events dropped while it was disabled are not replayed.

### Replay Protection

The signature covers the request body only and includes no timestamp, so a captured request remains verifiable indefinitely when replayed to the endpoint. Defend on the receiver side:

* **Deduplicate**: store delivered event `id` values, or the `Idempotency-Key` header, and discard repeats. The `Idempotency-Key` value is stable for the same event and endpoint, so retries and replays of one delivery carry the same key. The event `id` is also sent as `X-Orq-Hook-ID`.
* **Reject stale events**: after verifying the signature, compare the `created` timestamp in the body with the current time and drop events older than the tolerated window.

## Create errors

| Case | Response |
| - | - |
| `_id` already exists | `409`, code `already_exists`, reason `WEBHOOK_ALREADY_EXISTS` |
| `url` is not an absolute `https://` URI | `400` field validation error on `url` |
| `events` is empty | `400` field validation error on `events` |
| An event slug that matches no event | Accepted and stored; it delivers only if an event carries that slug, as `deployment.invoked.<deployment_id>` does |

`_id` is a client-generated string of at least one character with no fixed format, and uniqueness is collection-wide, not per workspace.

## Delivery Metrics

![Webhooks dashboard showing delivery metrics, event deliveries chart,
response time chart, and endpoint list](https://mintcdn.com/orqai/_A_PSk641PTeogiZ/images/webhooks-dashboard.png?fit=max\&auto=format\&n=_A_PSk641PTeogiZ\&q=85\&s=415876b4682d1752bf34371c173475e5)

The Webhooks page showing delivery metrics and endpoint list.

The **Webhooks** page shows a **Delivery Metrics** dashboard with:

* **Total Deliveries**, **Successful**, **Failed**, and **Avg Duration** over a configurable time range
* An **Event deliveries** chart showing successful vs. failed deliveries over time
* A **Response time** chart showing min, avg, and max response times

Each webhook endpoint is listed with its name, URL, event types, and status, plus a truncated signing secret. The full secret is shown once, when the webhook is created.

## Payload Structure

The body is built when the event is recorded, not when it is delivered. An LLM event carries `gen_ai.input` and `gen_ai.output` exactly as they were recorded. Masking happens at ingest, before any sink runs, so a masked trace is delivered masked. An LLM event whose body exceeds 10,240,000 bytes (about 9.77 MiB) is not published and never reaches an endpoint.

Every event uses the same envelope. `request_id` identifies the originating API request and is absent for system-initiated events. `created` and `id` differ by group:

| Event group | `created` | `id` |
| - | - | - |
| Agent, Prompt, Deployment CRUD | Integer, Unix seconds | `evt_` + 26-character ULID |
| LLM | Integer, Unix seconds | `evt_` + 26-character hex |
| `deployment.invoked` | String, RFC 3339 with nanoseconds | `wk_log_` + 26-character ULID |

### Agent

> [accordion] agent.created
>
> ```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
> {
>   "id": "evt_<ulid>",
>   "object": "event",
>   "type": "agent.created",
>   "created": 1742123456,
>   "api_version": "1.0",
>   "workspace": "<workspace_id>",
>   "project": "<project_id>",
>   "correlation_id": "<correlation_id>",
>   "request_id": "req_<ulid>",
>   "data": {
>     "object": {
>       "id": "<agent_id>",
>       "key": "<agent_name>",
>       "version": "<version>"
>     }
>   }
> }
> ```

> [accordion] agent.updated
>
> ```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
> {
>   "id": "evt_<ulid>",
>   "object": "event",
>   "type": "agent.updated",
>   "created": 1742123456,
>   "api_version": "1.0",
>   "workspace": "<workspace_id>",
>   "project": "<project_id>",
>   "correlation_id": "<correlation_id>",
>   "data": {
>     "object": {
>       "id": "<agent_id>",
>       "key": "<agent_name>",
>       "version": "<version>"
>     }
>   }
> }
> ```

> [accordion] agent.deleted
>
> ```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
> {
>   "id": "evt_<ulid>",
>   "object": "event",
>   "type": "agent.deleted",
>   "created": 1742123456,
>   "api_version": "1.0",
>   "workspace": "<workspace_id>",
>   "project": "<project_id>",
>   "correlation_id": "<correlation_id>",
>   "data": {
>     "object": {
>       "id": "<agent_id>",
>       "key": "<agent_name>",
>       "version": "<version>"
>     }
>   }
> }
> ```

### Deployment

> [accordion] deployment.created
>
> ```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
> {
>   "id": "evt_<ulid>",
>   "object": "event",
>   "type": "deployment.created",
>   "created": 1742123456,
>   "api_version": "1.0",
>   "workspace": "<workspace_id>",
>   "project": "<project_id>",
>   "correlation_id": "<correlation_id>",
>   "data": {
>     "object": {
>       "id": "<deployment_id>",
>       "key": "<deployment_name>",
>       "version": "<version>"
>     }
>   }
> }
> ```

> [accordion] deployment.updated
>
> ```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
> {
>   "id": "evt_<ulid>",
>   "object": "event",
>   "type": "deployment.updated",
>   "created": 1742123456,
>   "api_version": "1.0",
>   "workspace": "<workspace_id>",
>   "project": "<project_id>",
>   "correlation_id": "<correlation_id>",
>   "data": {
>     "object": {
>       "id": "<deployment_id>",
>       "key": "<deployment_name>",
>       "version": "<version>"
>     }
>   }
> }
> ```

> [accordion] deployment.deleted
>
> ```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
> {
>   "id": "evt_<ulid>",
>   "object": "event",
>   "type": "deployment.deleted",
>   "created": 1742123456,
>   "api_version": "1.0",
>   "workspace": "<workspace_id>",
>   "project": "<project_id>",
>   "correlation_id": "<correlation_id>",
>   "data": {
>     "object": {
>       "id": "<deployment_id>",
>       "key": "<deployment_name>",
>       "version": "<version>"
>     }
>   }
> }
> ```

> [accordion] deployment.invoked
>
> > [!NOTE]
> >
> > Unlike CRUD events, `deployment.invoked` does not include `workspace`, `project`, `api_version`, or `correlation_id`. Deployment metadata is provided in a top-level `metadata` block instead of a nested `object`.
>
> ```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
> {
>   "id": "wk_log_01kkypj82sqrzg1s9t9v9p13jv",
>   "created": "2026-03-17T20:07:31.161517094Z",
>   "type": "deployment.invoked",
>   "metadata": {
>     "deployment_id": "<deployment_id>",
>     "deployment_key": "<deployment_name>",
>     "deployment_variant_id": "<variant_id>",
>     "deployment_variant_version": "<variant_version>",
>     "deployment_log_id": "<log_id>",
>     "deployment_url": "<deployment_url>",
>     "deployment_variant_url": "<variant_url>",
>     "deployment_log_url": "<log_url>"
>   },
>   "data": {
>     "contact_id": "<identity_ulid>",
>     "prompt_config": {
>       "messages": [
>         { "role": "system", "content": "<system_message>" },
>         { "role": "user", "content": "<user_message>", "id": "<message_id>" }
>       ],
>       "model": "gpt-5.4-mini",
>       "model_db_id": "<model_db_id>",
>       "model_parameters": {
>         "temperature": 0.2,
>         "maxTokens": 1000,
>         "topK": 5,
>         "topP": 0,
>         "frequencyPenalty": 0,
>         "presencePenalty": 0
>       },
>       "model_type": "chat",
>       "provider": "openai",
>       "stream": false
>     },
>     "choices": [
>       {
>         "finish_reason": "stop",
>         "index": 0,
>         "message": { "role": "assistant", "content": "<response>" }
>       }
>     ],
>     "variables": [
>       { "is_pii": false, "key": "<variable_key>", "value": "<variable_value>" }
>     ],
>     "performance": {
>       "first_time_to_token": 0,
>       "latency": 1125.2,
>       "tokens_per_second": 8.89
>     },
>     "usage": {
>       "completion_tokens": 10,
>       "completion_tokens_details": { "reasoning_tokens": 0 },
>       "prompt_tokens": 122,
>       "prompt_tokens_details": { "cached_tokens": 0 },
>       "total_tokens": 132
>     },
>     "billing": {
>       "billable": true,
>       "input_cost": 0.0000183,
>       "output_cost": 0.000006,
>       "total_cost": 0.0000243
>     },
>     "tools": [],
>     "metadata": {},
>     "thread": {
>       "id": "<thread_id>",
>       "tags": ["<tag1>", "<tag2>"]
>     },
>     "status": 200
>   }
> }
> ```
>
> > [!NOTE]
> >
> > `status` is always present. It contains the HTTP status code returned by the upstream model provider (e.g. `200`, `429`, `500`), useful for detecting partial failures without inspecting the full response.
> >
> > Several other fields are conditional and may be absent depending on the invocation:
> >
> > * `contact_id`: present when an [Identity](https://docs.orq.ai/ai-studio/observability/identities.md) is linked to the request
> > * `billing`: omitted when the response was served from [cache](https://docs.orq.ai/ai-gateway/features/cache.md)
> > * `cache_status`, `cache_key`, `cache_config`: present on cached responses
> > * `evals`: present when [Evaluators](https://docs.orq.ai/ai-studio/optimize/evaluators.md) are configured on the deployment
> > * `thread`: present when the invocation is part of a [thread](https://docs.orq.ai/ai-gateway/thread-management.md)

### Prompt

> [accordion] prompt.created
>
> ```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
> {
>   "id": "evt_<ulid>",
>   "object": "event",
>   "type": "prompt.created",
>   "created": 1742123456,
>   "api_version": "1.0",
>   "workspace": "<workspace_id>",
>   "project": "<project_id>",
>   "correlation_id": "<correlation_id>",
>   "data": {
>     "object": {
>       "id": "<prompt_id>",
>       "key": "<prompt_name>",
>       "version": "<version>"
>     }
>   }
> }
> ```

> [accordion] prompt.updated
>
> ```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
> {
>   "id": "evt_<ulid>",
>   "object": "event",
>   "type": "prompt.updated",
>   "created": 1742123456,
>   "api_version": "1.0",
>   "workspace": "<workspace_id>",
>   "project": "<project_id>",
>   "correlation_id": "<correlation_id>",
>   "data": {
>     "object": {
>       "id": "<prompt_id>",
>       "key": "<prompt_name>",
>       "version": "<version>"
>     }
>   }
> }
> ```

> [accordion] prompt.deleted
>
> ```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
> {
>   "id": "evt_<ulid>",
>   "object": "event",
>   "type": "prompt.deleted",
>   "created": 1742123456,
>   "api_version": "1.0",
>   "workspace": "<workspace_id>",
>   "project": "<project_id>",
>   "correlation_id": "<correlation_id>",
>   "data": {
>     "object": {
>       "id": "<prompt_id>",
>       "key": "<prompt_name>",
>       "version": "<version>"
>     }
>   }
> }
> ```

### LLM

LLM events fire after the gateway processes a chat completion, response, embedding, or rerank call. `llm.evaluator` fires when an **Evaluator** finishes running. The `data` block carries the OpenTelemetry GenAI semantic-convention span attributes so subscribers receive the full request and response payload inline. For the full list of `orq.*` attributes in the payload, see [Span Attributes](https://docs.orq.ai/ai-studio/observability/span-attributes.md).

The wire shape of `gen_ai.input` and `gen_ai.output` depends on which producer emitted the span:

* For Responses API spans (`llm.response`), the canonical input/output is on `openresponses.input` / `openresponses.output` and is delivered as a JSON-encoded string.
* For chat completion / embedding / rerank spans, the canonical fields follow OTEL GenAI semconv: `gen_ai.input.messages` / `gen_ai.output.messages` (chat), `gen_ai.rerank.query` / `gen_ai.rerank.results` (rerank).
* For evaluator spans (`llm.evaluator`), the evaluated data is on `orq.evaluation.input` and the result on `orq.evaluation.output`, both delivered as JSON-encoded strings.
* The envelope's top-level `project` field is omitted when the span has no associated project.

> [accordion] llm.chat\_completion
>
> ```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
> {
>   "id": "evt_a5a771765f4959ddf615093e39",
>   "object": "event",
>   "type": "llm.chat_completion",
>   "created": 1778437602,
>   "api_version": "1.0",
>   "workspace": "3de3a12f-6c52-46b5-a195-539bc40e99c9",
>   "correlation_id": "e98f5b18ddb209743950528b1f3a41a0",
>   "data": {
>     "span_id": "f3313eaecc8b24bc",
>     "trace_id": "e98f5b18ddb209743950528b1f3a41a0",
>     "parent_span_id": "f99eb9200abf32e6",
>     "span_type": "span.chat_completion",
>     "name": "chat gpt-5.4-mini",
>     "start_time": "2026-05-10T18:26:41.325945Z",
>     "end_time": "2026-05-10T18:26:41.327398792Z",
>     "duration_ns": 1453792,
>     "status": "OK",
>     "attributes": {
>       "gen_ai.input.messages": "[{\"role\":\"user\",\"parts\":[{\"_id\":\"text_01kr9j8e1dm0t92b2y2fxttc8w\",\"kind\":\"text\",\"text\":\"Hello\"}]}]",
>       "gen_ai.operation.name": "chat",
>       "gen_ai.output.messages": "[{\"role\":\"agent\",\"parts\":[{\"_id\":\"text_01kr9j8e1ft8xm3sstfh2wzbsm\",\"kind\":\"text\",\"text\":\"Hello! How can I assist you today?\"}]}]",
>       "gen_ai.provider.name": "openai",
>       "gen_ai.request.model": "gpt-5.4-mini",
>       "gen_ai.response.finish_reasons": ["stop"],
>       "gen_ai.response.model": "gpt-5.4-mini",
>       "gen_ai.system_instructions": "{\"role\":\"user\",\"parts\":[{\"_id\":\"text_01kr9j8e1dm0t92b2y2fxttc8w\",\"kind\":\"text\",\"text\":\"Hello\"}]}",
>       "gen_ai.usage.input_tokens": 8,
>       "gen_ai.usage.output_tokens": 9,
>       "gen_ai.usage.total_tokens": 17,
>       "orq.billing.billable": false,
>       "orq.billing.cache_read_cost": 0,
>       "orq.billing.cache_write_cost": 0,
>       "orq.billing.input_cost": 0.0000012,
>       "orq.billing.integration_id": "01KQ9Y9MS8ZHV99ZG60Q32C36E",
>       "orq.billing.output_cost": 0.0000054,
>       "orq.billing.pricing_tier": "standard",
>       "orq.billing.total_cost": 0.0000066,
>       "orq.model.id": "85b18e5b-76a0-48dc-99b5-5738c35c9c85",
>       "orq.model.is_private": false,
>       "orq.model.provider": "openai",
>       "orq.model.type": "chat",
>       "orq.organization_id": "55c3d968-8390-4e46-af01-e46857f37ced",
>       "orq.product": "router",
>       "orq.span_type": "span.chat_completion",
>       "orq.workspace_id": "3de3a12f-6c52-46b5-a195-539bc40e99c9",
>       "service.instance.id": "01KR9HSA5JCBQRN8ZFN9KJZ23G",
>       "service.name": "responses-api",
>       "service.version": "0.1.0",
>       "telemetry.sdk.language": "go",
>       "telemetry.sdk.name": "opentelemetry",
>       "telemetry.sdk.version": "1.43.0"
>     }
>   }
> }
> ```

> [accordion] llm.response
>
> ```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
> {
>   "id": "evt_23c9e52b6b1a38d64b9d034791",
>   "object": "event",
>   "type": "llm.response",
>   "created": 1778437600,
>   "api_version": "1.0",
>   "workspace": "3de3a12f-6c52-46b5-a195-539bc40e99c9",
>   "project": "<project_ulid>",
>   "correlation_id": "b12335e85a37ed3ce191a5268fa87111",
>   "data": {
>     "span_id": "6b2508f591d1b112",
>     "trace_id": "b12335e85a37ed3ce191a5268fa87111",
>     "parent_span_id": "f7fdfb8e41c2d9e1",
>     "span_type": "span.responses",
>     "name": "chat gpt-5.4-mini",
>     "start_time": "2026-05-10T18:26:39.414839Z",
>     "end_time": "2026-05-10T18:26:39.422535042Z",
>     "duration_ns": 7696042,
>     "status": "OK",
>     "attributes": {
>       "gen_ai.operation.name": "responses",
>       "gen_ai.provider.name": "openai",
>       "gen_ai.request.model": "gpt-5.4-mini",
>       "gen_ai.response.finish_reasons": ["stop"],
>       "gen_ai.response.id": "resp_0608254bd32f043b016a00b1642dfc81a4a1f3c41bec5cf70a",
>       "gen_ai.response.model": "gpt-5.4-mini",
>       "gen_ai.usage.input_tokens": 15,
>       "gen_ai.usage.output_tokens": 15,
>       "gen_ai.usage.total_tokens": 30,
>       "openresponses.background": false,
>       "openresponses.completed_at": "1778430310",
>       "openresponses.created_at": 1778430308,
>       "openresponses.frequency_penalty": 0,
>       "openresponses.input": "[{\"content\":[{\"type\":\"input_text\",\"text\":\"Count from 1 to 5.\"}],\"id\":\"msg_01kr9j8c5p9v4y4xyhdqhg117n\",\"role\":\"user\",\"status\":\"completed\",\"type\":\"message\"}]",
>       "openresponses.input.items.count": 1,
>       "openresponses.object": "response",
>       "openresponses.output": "[{\"content\":[{\"type\":\"output_text\",\"text\":\"1, 2, 3, 4, 5.\",\"annotations\":[],\"logprobs\":[]}],\"id\":\"msg_0608254bd32f043b016a00b1668cb881a480fe34962427a227\",\"role\":\"assistant\",\"status\":\"completed\",\"type\":\"message\"}]",
>       "openresponses.output.items.count": 1,
>       "openresponses.parallel_tool_calls": true,
>       "openresponses.presence_penalty": 0,
>       "openresponses.service_tier": "default",
>       "openresponses.status": "completed",
>       "openresponses.store": true,
>       "openresponses.stream": false,
>       "openresponses.temperature": 1,
>       "openresponses.text": "{\"format\":{\"type\":\"text\"},\"verbosity\":\"medium\"}",
>       "openresponses.tool_choice": "\"auto\"",
>       "openresponses.tools.count": 0,
>       "openresponses.top_logprobs": 0,
>       "openresponses.top_p": 1,
>       "openresponses.truncation": "auto",
>       "orq.billing.billable": false,
>       "orq.billing.cache_read_cost": 0,
>       "orq.billing.cache_write_cost": 0,
>       "orq.billing.input_cost": 0.00000225,
>       "orq.billing.integration_id": "01KQ9Y9MS8ZHV99ZG60Q32C36E",
>       "orq.billing.output_cost": 0.000009,
>       "orq.billing.pricing_tier": "standard",
>       "orq.billing.total_cost": 0.00001125,
>       "orq.model.id": "85b18e5b-76a0-48dc-99b5-5738c35c9c85",
>       "orq.model.is_private": false,
>       "orq.model.provider": "openai",
>       "orq.model.type": "chat",
>       "orq.organization_id": "55c3d968-8390-4e46-af01-e46857f37ced",
>       "orq.product": "router",
>       "orq.span_type": "span.responses",
>       "orq.workspace_id": "3de3a12f-6c52-46b5-a195-539bc40e99c9",
>       "service.instance.id": "01KR9HSA5JCBQRN8ZFN9KJZ23G",
>       "service.name": "responses-api",
>       "service.version": "0.1.0",
>       "telemetry.sdk.language": "go",
>       "telemetry.sdk.name": "opentelemetry",
>       "telemetry.sdk.version": "1.43.0"
>     }
>   }
> }
> ```

> [accordion] llm.embedding
>
> ```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
> {
>   "id": "evt_48eeb9fad80359ed8a52342235",
>   "object": "event",
>   "type": "llm.embedding",
>   "created": 1778437604,
>   "api_version": "1.0",
>   "workspace": "3de3a12f-6c52-46b5-a195-539bc40e99c9",
>   "correlation_id": "8d8bad94ac9a97d14fe783daf34cb3e5",
>   "data": {
>     "span_id": "ac6e9de774652b62",
>     "trace_id": "8d8bad94ac9a97d14fe783daf34cb3e5",
>     "parent_span_id": "8ac42a0d3556cd44",
>     "span_type": "span.embedding",
>     "name": "embeddings text-embedding-3-small",
>     "start_time": "2026-05-10T18:26:43.638991Z",
>     "end_time": "2026-05-10T18:26:43.6414215Z",
>     "duration_ns": 2430500,
>     "status": "OK",
>     "attributes": {
>       "gen_ai.input.messages": "[{\"role\":\"user\",\"parts\":[{\"type\":\"text\",\"content\":\"Hello\"}]}]",
>       "gen_ai.operation.name": "embeddings",
>       "gen_ai.output.count": 1,
>       "gen_ai.output.dimensions": 1536,
>       "gen_ai.output.object": "list",
>       "gen_ai.provider.name": "openai",
>       "gen_ai.request.model": "text-embedding-3-small",
>       "gen_ai.response.model": "text-embedding-3-small",
>       "gen_ai.usage.input_tokens": 1,
>       "gen_ai.usage.total_tokens": 1,
>       "http.response.status_code": 200,
>       "orq.billing.billable": false,
>       "orq.billing.input_cost": 2e-8,
>       "orq.billing.integration_id": "01KQ9Y9MS8ZHV99ZG60Q32C36E",
>       "orq.billing.pricing_tier": "standard",
>       "orq.billing.total_cost": 2e-8,
>       "orq.model.id": "679a4486-1936-4287-bcdd-f6dc0df8389c",
>       "orq.model.is_private": false,
>       "orq.model.provider": "openai",
>       "orq.model.type": "embedding",
>       "orq.organization_id": "55c3d968-8390-4e46-af01-e46857f37ced",
>       "orq.product": "router",
>       "orq.span_type": "span.embedding",
>       "orq.workspace_id": "3de3a12f-6c52-46b5-a195-539bc40e99c9",
>       "service.instance.id": "01KR9HSA5JCBQRN8ZFN9KJZ23G",
>       "service.name": "responses-api",
>       "service.version": "0.1.0",
>       "telemetry.sdk.language": "go",
>       "telemetry.sdk.name": "opentelemetry",
>       "telemetry.sdk.version": "1.43.0"
>     }
>   }
> }
> ```

> [accordion] llm.rerank
>
> ```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
> {
>   "id": "evt_194c87ee3cee419a20ccd730a7",
>   "object": "event",
>   "type": "llm.rerank",
>   "created": 1778437606,
>   "api_version": "1.0",
>   "workspace": "3de3a12f-6c52-46b5-a195-539bc40e99c9",
>   "correlation_id": "1c1aa12dad4675fbdf673dfcd41c53d1",
>   "data": {
>     "span_id": "919ab2e33d8e838e",
>     "trace_id": "1c1aa12dad4675fbdf673dfcd41c53d1",
>     "parent_span_id": "c40e7f287a267c29",
>     "span_type": "span.rerank",
>     "name": "rerank jina-reranker-v2-base-multilingual",
>     "start_time": "2026-05-10T18:26:45.708812Z",
>     "end_time": "2026-05-10T18:26:45.710460167Z",
>     "duration_ns": 1648167,
>     "status": "OK",
>     "attributes": {
>       "gen_ai.operation.name": "rerank",
>       "gen_ai.output.count": 3,
>       "gen_ai.provider.name": "jina",
>       "gen_ai.request.model": "jina-reranker-v2-base-multilingual",
>       "gen_ai.request.top_n": 3,
>       "gen_ai.rerank.documents": "[\"Organic skincare for sensitive skin with aloe vera and chamomile: Imagine the soothing embrace of nature with our organic skincare range, crafted specifically for sensitive skin. Infused with the calming properties of aloe vera and chamomile, each product provides gentle nourishment and protection. Say goodbye to irritation and hello to a glowing, healthy complexion.\",\"New makeup trends focus on bold colors and innovative techniques: Step into the world of cutting-edge beauty with this seasons makeup trends. Bold, vibrant colors and groundbreaking techniques are redefining the art of makeup. From neon eyeliners to holographic highlighters, unleash your creativity and make a statement with every look.\",\"Bio-Hautpflege für empfindliche Haut mit Aloe Vera und Kamille: Erleben Sie die wohltuende Wirkung unserer Bio-Hautpflege, speziell für empfindliche Haut entwickelt. Mit den beruhigenden Eigenschaften von Aloe Vera und Kamille pflegen und schützen unsere Produkte Ihre Haut auf natürliche Weise. Verabschieden Sie sich von Hautirritationen und genießen Sie einen strahlenden Teint.\",\"Neue Make-up-Trends setzen auf kräftige Farben und innovative Techniken: Tauchen Sie ein in die Welt der modernen Schönheit mit den neuesten Make-up-Trends. Kräftige, lebendige Farben und innovative Techniken setzen neue Maßstäbe. Von auffälligen Eyelinern bis hin zu holografischen Highlightern – lassen Sie Ihrer Kreativität freien Lauf und setzen Sie jedes Mal ein Statement.\",\"Cuidado de la piel orgánico para piel sensible con aloe vera y manzanilla: Descubre el poder de la naturaleza con nuestra línea de cuidado de la piel orgánico, diseñada especialmente para pieles sensibles. Enriquecidos con aloe vera y manzanilla, estos productos ofrecen una hidratación y protección suave. Despídete de las irritaciones y saluda a una piel radiante y saludable.\",\"Las nuevas tendencias de maquillaje se centran en colores vivos y técnicas innovadoras: Entra en el fascinante mundo del maquillaje con las tendencias más actuales. Colores vivos y técnicas innovadoras están revolucionando el arte del maquillaje. Desde delineadores neón hasta iluminadores holográficos, desata tu creatividad y destaca en cada look.\",\"针对敏感肌专门设计的天然有机护肤产品：体验由芦荟和洋甘菊提取物带来的自然呵护。我们的护肤产品特别为敏感肌设计，温和滋润，保护您的肌肤不受刺激。让您的肌肤告别不适，迎来健康光彩。\",\"新的化妆趋势注重鲜艳的颜色和创新的技巧：进入化妆艺术的新纪元，本季的化妆趋势以大胆的颜色和创新的技巧为主。无论是霓虹眼线还是全息高光，每一款妆容都能让您脱颖而出，展现独特魅力。\",\"敏感肌のために特別に設計された天然有機スキンケア製品: アロエベラとカモミールのやさしい力で、自然の抱擁を感じてください。敏感肌用に特別に設計された私たちのスキンケア製品は、肌に優しく栄養を与え、保護します。肌トラブルにさようなら、輝く健康な肌にこんにちは。\",\"新しいメイクのトレンドは鮮やかな色と革新的な技術に焦点を当てています: 今シーズンのメイクアップトレンドは、大胆な色彩と革新的な技術に注目しています。ネオンアイライナーからホログラフィックハイライターまで、クリエイティビティを解き放ち、毎回ユニークなルックを演出しましょう。\"]",
>       "gen_ai.rerank.documents.count": 10,
>       "gen_ai.rerank.query": "Organic skincare products for sensitive skin",
>       "gen_ai.rerank.results": "[{\"_id\":\"rerank_01kr9j8jae2zxygmftpz9880wc\",\"kind\":\"rerank\",\"index\":0,\"relevance_score\":0.87831426,\"document\":\"Organic skincare for sensitive skin with aloe vera and chamomile: Imagine the soothing embrace of nature with our organic skincare range, crafted specifically for sensitive skin. Infused with the calming properties of aloe vera and chamomile, each product provides gentle nourishment and protection. Say goodbye to irritation and hello to a glowing, healthy complexion.\"},{\"_id\":\"rerank_01kr9j8jae611fg8mqn8dm08y5\",\"kind\":\"rerank\",\"index\":6,\"relevance_score\":0.87747681,\"document\":\"针对敏感肌专门设计的天然有机护肤产品：体验由芦荟和洋甘菊提取物带来的自然呵护。我们的护肤产品特别为敏感肌设计，温和滋润，保护您的肌肤不受刺激。让您的肌肤告别不适，迎来健康光彩。\"},{\"_id\":\"rerank_01kr9j8jaetc7rzkrqkjse3pbh\",\"kind\":\"rerank\",\"index\":4,\"relevance_score\":0.86246759,\"document\":\"Cuidado de la piel orgánico para piel sensible con aloe vera y manzanilla: Descubre el poder de la naturaleza con nuestra línea de cuidado de la piel orgánico, diseñada especialmente para pieles sensibles. Enriquecidos con aloe vera y manzanilla, estos productos ofrecen una hidratación y protección suave. Despídete de las irritaciones y saluda a una piel radiante y saludable.\"}]",
>       "gen_ai.response.model": "jina-reranker-v2-base-multilingual",
>       "gen_ai.usage.input_tokens": 896,
>       "gen_ai.usage.total_tokens": 896,
>       "orq.billing.billable": true,
>       "orq.billing.input_cost": 0.00001613,
>       "orq.billing.pricing_tier": "standard",
>       "orq.billing.total_cost": 0.00001613,
>       "orq.model.id": "4666d24e-ae9c-11ef-9414-325096b39f47",
>       "orq.model.is_private": false,
>       "orq.model.provider": "jina",
>       "orq.model.type": "rerank",
>       "orq.organization_id": "55c3d968-8390-4e46-af01-e46857f37ced",
>       "orq.product": "router",
>       "orq.span_type": "span.rerank",
>       "orq.workspace_id": "3de3a12f-6c52-46b5-a195-539bc40e99c9",
>       "service.instance.id": "01KR9HSA5JCBQRN8ZFN9KJZ23G",
>       "service.name": "responses-api",
>       "service.version": "0.1.0",
>       "telemetry.sdk.language": "go",
>       "telemetry.sdk.name": "opentelemetry",
>       "telemetry.sdk.version": "1.43.0"
>     }
>   }
> }
> ```

> [accordion] llm.evaluator
>
> ```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
> {
>   "id": "evt_e76a17d7aadc69e8680f1d0a9d",
>   "object": "event",
>   "type": "llm.evaluator",
>   "created": 1789981534,
>   "api_version": "1.0",
>   "workspace": "3de3a12f-6c52-46b5-a195-539bc40e99c9",
>   "correlation_id": "56f452e187bd004959b4f6599a5ae804",
>   "data": {
>     "span_id": "6a72de4144176e25",
>     "trace_id": "56f452e187bd004959b4f6599a5ae804",
>     "span_type": "span.evaluator",
>     "name": "mentions_orq",
>     "start_time": "2026-09-21T09:05:33.704792Z",
>     "end_time": "2026-09-21T09:05:33.816403041Z",
>     "duration_ns": 111611041,
>     "status": "OK",
>     "attributes": {
>       "gen_ai.evaluation.config": "{\"_id\":\"01K5R7ZD3QW8H2N6T9V4XB1CJM\",\"code\":\"def evaluate(log):\\n    return \\\"orq\\\" in log[\\\"output\\\"].lower()\",\"created\":\"2026-09-21T09:04:55.759Z\",\"created_by_id\":\"\",\"description\":\"\",\"display_name\":\"mentions_orq\",\"domain_id\":\"\",\"enabled\":true,\"metadata\":{\"supported_on_input_type\":true,\"supported_on_output_type\":true},\"output_type\":\"boolean\",\"owner\":\"3de3a12f-6c52-46b5-a195-539bc40e99c9\",\"type\":\"python_eval\",\"updated\":\"2026-09-21T09:04:55.759Z\",\"updated_by_id\":\"\"}",
>       "gen_ai.evaluation.explanation": "true",
>       "gen_ai.evaluation.name": "mentions_orq",
>       "gen_ai.evaluation.passed": true,
>       "gen_ai.evaluation.score.label": "pass",
>       "gen_ai.evaluation.score.value": 1,
>       "orq.evaluation.input": "{\"log\":{\"output\":\"This is the orq.ai platform.\"}}",
>       "orq.evaluation.outcome": "passed",
>       "orq.evaluation.output": "{\"passed\":true,\"type\":\"boolean\",\"value\":true}",
>       "orq.evaluation.stage": "output",
>       "orq.evaluator.code": "def evaluate(log):\n    return \"orq\" in log[\"output\"].lower()",
>       "orq.evaluator.id": "01K5R7ZD3QW8H2N6T9V4XB1CJM",
>       "orq.evaluator.output_type": "boolean",
>       "orq.evaluator.type": "python_eval",
>       "orq.guardrail.enabled": false,
>       "orq.span_type": "span.evaluator",
>       "orq.workspace_id": "3de3a12f-6c52-46b5-a195-539bc40e99c9",
>       "service.instance.id": "01M31KCR7ED0RT53Z5RP8GYCDX",
>       "service.name": "graders-api",
>       "service.version": "0.1.0",
>       "telemetry.sdk.language": "go",
>       "telemetry.sdk.name": "opentelemetry",
>       "telemetry.sdk.version": "1.45.0"
>     }
>   }
> }
> ```

## Best Practices

* **Use HTTPS**: always use HTTPS for your webhook URL to ensure payloads are transmitted securely.
* **Verify signatures**: validate the `X-Orq-Signature` header on every request before processing the payload.
* **Respond quickly**: acknowledge receipt immediately with a `200` response. Offload any heavy processing to a background job.
* **Handle retries**: if your endpoint is temporarily unavailable, **Orq.ai** may retry delivery. Make your handler idempotent using the event `id` to avoid processing the same event twice.
* **Monitor delivery**: use the [Delivery Metrics](#delivery-metrics) dashboard to track failures and response times.

## Security

Every webhook request includes a signature you should verify before processing the payload.

### Headers

| Header | Description |
| - | - |
| `X-Orq-Signature` | HMAC-SHA256 hex digest of the request body |
| `X-Orq-Hook-ID` | The event ID |
| `X-Orq-Event` | The event type |
| `Idempotency-Key` | Stable for the same event and endpoint, so retries and replays carry the same value |
| `User-Agent` | `Orq-Webhook/2.0` |

### How the signature is computed

The signature is computed over the exact raw request body bytes sent by Orq.ai.
Verify the signature before parsing or modifying the body. Parsing and re-serializing
JSON can change whitespace, field order, or number formatting and produce an invalid
signature.

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "id": "evt_01kkyjd5d7drqxnmyzfxpracz3",
  "created": 1773773690,
  "type": "agent.updated"
}
```

This is signed with your webhook secret using HMAC-SHA256 and hex-encoded. Always use constant-time string comparison to prevent timing attacks.

### Verification examples

```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
import express, { Request, Response } from "express";
import crypto from "crypto";

const app = express();
const webhookSecret = "orq_wk_...";

function verifySignature(
  payload: string,
  signature: string,
  secret: string,
): boolean {
  const expected = crypto
    .createHmac("sha256", secret)
    .update(payload)
    .digest("hex");
  const a = Buffer.from(signature);
  const b = Buffer.from(expected);
  // timingSafeEqual throws if buffers differ in length; check first
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}

app.post("/webhooks", express.raw({ type: "application/json" }), (req: Request, res: Response) => {
  const signature = req.headers["x-orq-signature"] as string;
  const rawBody = req.body.toString("utf8");

  if (!verifySignature(rawBody, signature, webhookSecret)) {
    return res.status(400).send("Invalid signature");
  }

  res.json({ received: true });
});

app.listen(3000);
```

```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
import hmac
import hashlib
from fastapi import Request, FastAPI, HTTPException

webhook_secret = "orq_wk_..."
app = FastAPI()

def verify_signature(payload: str, signature: str, secret: str) -> bool:
    expected = hmac.new(
        secret.encode("utf-8"),
        payload.encode("utf-8"),
        hashlib.sha256
    ).hexdigest()
    return hmac.compare_digest(signature, expected)

@app.post("/webhooks")
async def handle_webhook(request: Request):
    body = await request.body()
    signature = request.headers.get("x-orq-signature", "")
    if not verify_signature(body.decode("utf-8"), signature, webhook_secret):
        raise HTTPException(status_code=400, detail="Invalid signature")
    return {"received": True}
```

```go Go theme={"theme":{"light":"github-light","dark":"github-dark"}}
package main

import (
  "crypto/hmac"
  "crypto/sha256"
  "encoding/hex"
  "io"
  "net/http"
)

var webhookSecret = "orq_wk_..."

func verifySignature(payload, signature, secret string) bool {
  mac := hmac.New(sha256.New, []byte(secret))
  mac.Write([]byte(payload))
  expected := hex.EncodeToString(mac.Sum(nil))
  return hmac.Equal([]byte(expected), []byte(signature))
}

func webhookHandler(w http.ResponseWriter, r *http.Request) {
  body, _ := io.ReadAll(r.Body)
  defer r.Body.Close()

  sig := r.Header.Get("X-Orq-Signature")

  if !verifySignature(string(body), sig, webhookSecret) {
    http.Error(w, "Invalid signature", http.StatusBadRequest)
    return
  }

  w.Header().Set("Content-Type", "application/json")
  w.Write([]byte(`{"received": true}`))
}

func main() {
  http.HandleFunc("/webhooks", webhookHandler)
  http.ListenAndServe(":3000", nil)
}
```

```php PHP theme={"theme":{"light":"github-light","dark":"github-dark"}}
<?php

$webhookSecret = 'orq_wk_...';
$body = file_get_contents('php://input');
$signature = $_SERVER['HTTP_X_ORQ_SIGNATURE'] ?? '';

$expected = hash_hmac('sha256', $body, $webhookSecret);

if (!hash_equals($expected, $signature)) {
    http_response_code(400);
    echo 'Invalid signature';
    exit;
}

header('Content-Type: application/json');
echo json_encode(['received' => true]);
```

```ruby Ruby theme={"theme":{"light":"github-light","dark":"github-dark"}}
require 'sinatra'
require 'json'
require 'openssl'

WEBHOOK_SECRET = 'orq_wk_...'

def verify_signature(payload, signature, secret)
  expected = OpenSSL::HMAC.hexdigest('SHA256', secret, payload)
  Rack::Utils.secure_compare(expected, signature)
end

post '/webhooks' do
  body = request.body.read
  signature = request.env['HTTP_X_ORQ_SIGNATURE'] || ''

  halt 400, 'Invalid signature' unless verify_signature(body, signature, WEBHOOK_SECRET)

  content_type :json
  { received: true }.to_json
end
```

```csharp C# theme={"theme":{"light":"github-light","dark":"github-dark"}}
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;

var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
var webhookSecret = "orq_wk_...";

static bool VerifySignature(string payload, string signature, string secret)
{
    using var hmac = new HMACSHA256(Encoding.UTF8.GetBytes(secret));
    var hash = hmac.ComputeHash(Encoding.UTF8.GetBytes(payload));
    var expected = Convert.ToHexStringLower(hash);
    return CryptographicOperations.FixedTimeEquals(
        Encoding.UTF8.GetBytes(expected),
        Encoding.UTF8.GetBytes(signature)
    );
}

app.MapPost("/webhooks", async (HttpContext context) =>
{
    using var reader = new StreamReader(context.Request.Body);
    var body = await reader.ReadToEndAsync();
    var signature = context.Request.Headers["X-Orq-Signature"].ToString();

    if (!VerifySignature(body, signature, webhookSecret))
        return Results.BadRequest("Invalid signature");

    return Results.Json(new { received = true });
});

app.Run("http://localhost:3000");
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.