# Traces API

## GET /api/v1/admin/otlp-ingest/settings

`GET /api/v1/admin/otlp-ingest/settings` · operation `otlpIngestSettings`

OTLP ingest settings (T186.016). Requires otlp_ingest and config:read. The policy in force, the stored override or null, the YAML base with defaults, the source of each setting (default, yaml or console), the issue codes the ingest records (code, attribute, effect, fix), the app span sub-kinds, and the current control version for an update. Applies from the next upload, no restart.

**Authentication:** `adminSession`

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Effective settings and their sources; no-store. | `application/json`: object |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `503` | Configuration storage unavailable. | — |

Response `200` fields:

- `application/json`: object
  - `version` (integer, required, min 0)
  - `otlp_ingest` ([OTLPIngestPolicy](/docs/api/schemas/o/#otlpingestpolicy), required)
  - `override` ([OTLPIngestPolicy](/docs/api/schemas/o/#otlpingestpolicy) or null, required)
    - Any of (1): [OTLPIngestPolicy](/docs/api/schemas/o/#otlpingestpolicy)
    - Any of (2): null
  - `yaml` ([OTLPIngestPolicy](/docs/api/schemas/o/#otlpingestpolicy), required)
  - `sources` (object, required)
    - any other key: string
  - `endpoint` (`"/v1/traces"`, required)
  - `encodings` (array of string, required)
  - `subkinds` (array of string, required)
  - `issue_codes` (array of [OTLPIngestIssue](/docs/api/schemas/o/#otlpingestissue), required)
  - `transcript_ingest` (boolean, required)
  - `restart_required` (`false`, required)
  - `applies_to` (`"next_request"`, required)


## PUT /api/v1/admin/otlp-ingest/settings

`PUT /api/v1/admin/otlp-ingest/settings` · operation `setOTLPIngestSettings`

Replaces the OTLP ingest policy as a whole at the configuration version read (T186.016). Requires otlp_ingest, features:manage and CSRF; audited (otlp_ingest.set).

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: object
  - `version` (integer, required, min 0)
  - `otlp_ingest` ([OTLPIngestPolicy](/docs/api/schemas/o/#otlpingestpolicy), required)

**Responses**

| Status | Description | Body |
|---|---|---|
| `204` | Stored and applied. | — |
| `400` | invalid_otlp_ingest_settings | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `409` | version_conflict | — |
| `503` | configuration_unavailable, storage_unavailable or configuration_sync_pending | — |


## DELETE /api/v1/admin/otlp-ingest/settings

`DELETE /api/v1/admin/otlp-ingest/settings` · operation `revertOTLPIngestSettings`

Removes the override: the YAML block applies again (T186.016). Requires otlp_ingest, features:manage and CSRF; audited (otlp_ingest.revert).

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: object
  - `version` (integer, required, min 0)

**Responses**

| Status | Description | Body |
|---|---|---|
| `204` | Reverted. | — |
| `400` | invalid_otlp_ingest_settings | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | feature_disabled or not_found (no override) | — |
| `409` | version_conflict | — |
| `503` | configuration_unavailable, storage_unavailable or configuration_sync_pending | — |


## GET /v1/traces

`GET /v1/traces` · operation `listPublicTraces`

Public trace read (T186.016). Requires public_trace_api (tenant flag; under plan entitlements the team plan must include it) and span_store, and key scope traces:read on a key of a team. The key's team's traces (scope traces, one row per trace summary) or spans (scope spans) whose activity falls in [from, to) (default the last 24 hours, at most 92 days), matching q in the query language (the same fields as the trace explorer; evaluation terms need evaluations:read; no full-text terms), newest first, cursor-paginated. The team filter (and the team's current organization) is applied in the query before the page bound. fields groups: core (always), cost (default; with usage_valuation), evaluations (needs evaluations:read: each row's results), attributes (scope spans only: attributes, events and links). A key is never a content reader: tool names, price entries and capture IDs are left out. Counts in the key's requests-per-minute policies.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `scope` | query | string, one of `"traces"`, `"spans"`, default `"traces"` |  |
| `q` | query | string, max length 2000 |  |
| `from` | query | string | RFC 3339 time, or a negative duration such as -15m |
| `to` | query | string (date-time) |  |
| `limit` | query | integer, default `50`, min 1, max 200 |  |
| `cursor` | query | string, max length 2048 |  |
| `fields` | query | string | Comma-separated: core, cost, evaluations, attributes (spans) |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | A page of traces or spans. | `application/json`: object |
| `400` | invalid_request, invalid_range or invalid_query | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | scope_forbidden (no traces:read, or fields=evaluations without evaluations:read), team_required or entitlement_forbidden | — |
| `404` | public_trace_api or span_store disabled (feature_disabled) | — |
| `429` | rate_limit_exceeded | — |
| `503` | storage_unavailable or analytics_store_unavailable | — |

Response `200` fields:

- `application/json`: object
  - `scope` (string, required, one of `"traces"`, `"spans"`)
  - `from` (string (date-time), required)
  - `to` (string (date-time), required)
  - `query` (string)
  - `cost_shown` (boolean)
  - `data` (array of object, required, max items 200)
  - `has_more` (boolean, required)
  - `next_cursor` (string)


## POST /v1/traces

`POST /v1/traces` · operation `ingestTraces`

OTLP/HTTP trace ingest. Key scope traces:write on a key of a team; the caller is checked before the flags (401 without a key, 403 without the scope), and only a key that holds the scope is told feature_disabled. With otlp_ingest (operator control, T186.016; requires span_store) the route stores an application's OpenTelemetry spans: OTLP protobuf (application/x-protobuf) or JSON (application/json), optionally Content-Encoding gzip; hex or base64 IDs in JSON. Spans with OpenTelemetry GenAI (gen_ai.*, 1.37+) or OpenInference (openinference.span.kind) attributes become spans of kind app with a sub-kind (agent, workflow, llm, embedding, tool, retrieval, guardrail, evaluator, task, untyped), under the trace and span IDs the application gave them, in the key's team and organization, so they join the gateway's own spans of the same trace in one tree; with otlp_ingest.keep genai_and_ancestors (default) the non-GenAI spans that connect them (or that a stored gateway span names as its parent) are kept as sub-kind connector with no attributes, and other non-GenAI spans are left out. Attributes come from an allowlist; other gen_ai.* attributes are kept cut to 256 characters, the rest are counted (dropped_attributes); message content is stored encrypted only when the team's content capture policy has the app_spans purpose, otherwise discarded (content: not_captured). Instrumentation problems are stored on the span as attributes.issues (code, attribute, effect, fix) and are searchable with issue:&lt;code&gt;. A model span's cost column is unknown (the gateway's ledger holds no line for a call it did not make); its price-book estimate is the attribute estimated_cost_usd with cost_source price_book_estimate (unknown without a price or a token count, never zero), which no list, chart or total adds. A tool span is named execute_tool. A span repeated by an exporter is stored once; reads of every team filter by team first, so naming another team's trace ID adds spans only its own team sees. Bounded by otlp_ingest.max_request_bytes (after decompression too), max_spans_per_request, max_traces_per_request and max_concurrent_uploads (503 ingest_busy with Retry-After), by spans.max_spans_per_trace, and by the key's requests-per-minute policies (429 before the body is read). Without otlp_ingest, or with X-Gateway-Ingest: transcript, the route is the agent transcript ingest (T186.019): JSON only, requires agent_transcript_ingest, agent_recognition, agent_sessions, session_tracking and span_store (and, under plan entitlements, the agent_sessions and agent_recognition rights); its spans join the run named by gen_ai.conversation.id under keyed digests of the uploaded IDs, message content is discarded. The write is synchronous: a 200 means the spans are stored.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-Gateway-Ingest` | header | string, one of `"transcript"` | With otlp_ingest on, routes the upload to the agent transcript ingest |

**Request body** (required)

- `application/json`: [OTLPTraceExport](/docs/api/schemas/o/#otlptraceexport)
- `application/x-protobuf`: string (binary) — An OTLP ExportTraceServiceRequest

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | OTLP ExportTraceServiceResponse in the upload's encoding: empty (protobuf) or {} (JSON) when every span was stored or was already stored, partial_success otherwise with the count and the reasons (invalid_id, invalid_time, out_of_window, non_genai, trace_full) | `application/json`: object<br/>`application/x-protobuf`: string (binary) |
| `400` | invalid_request: the body is not gzip, could not be read, or is not an OTLP/HTTP trace export (transcript: more than 16 traces) | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | scope_forbidden (key without traces:write), team_required (key without a team) or entitlement_forbidden | — |
| `404` | feature_disabled: otlp_ingest without span_store, or the transcript ingest's flags off; answered only to a key that holds traces:write | — |
| `413` | request_too_large (otlp_ingest.max_request_bytes, before or after decompression), too_many_spans (max_spans_per_request), too_many_traces (max_traces_per_request), too_many_values (more than 256 attribute values per span on average, counted while decoding), or for a transcript agent_recognition.transcript_ingest bounds and trace_too_large. Nothing of the upload was stored. | — |
| `415` | unsupported_media_type: Content-Type other than application/x-protobuf or application/json (a transcript: JSON only), or Content-Encoding other than gzip | — |
| `429` | rate_limit_exceeded: a requests-per-minute policy of the key, its team, its organization or its end user is spent; Retry-After says when to send again. Nothing was stored. | — |
| `503` | ingest_busy (otlp_ingest.max_concurrent_uploads reached; Retry-After), storage_unavailable (nothing of the upload was stored; send it again) or rate_limit_unavailable | — |

Response `200` fields:

- `application/json`: object
  - `partialSuccess` (object)
    - `rejectedSpans` (string, required) — Number of spans not stored, as a decimal string (OTLP JSON writes 64-bit integers as strings)
    - `errorMessage` (string, required)
- `application/x-protobuf`: string (binary)


## GET /v1/traces/{trace_id}

`GET /v1/traces/{trace_id}` · operation `getPublicTrace`

One trace of the key's team (T186.016). Requires public_trace_api and span_store, and key scope traces:read. The team's spans of the trace (at most 2,000; truncated says when more exist) oldest first, application spans (kind app) and the gateway's own in one tree, with the summary and app_totals: the tokens and estimated cost of the application's model spans that the gateway did not serve (a call the gateway served counts once, in its request span). fields groups: core, cost (default), attributes (default: attributes, events, links and an app span's issues), evaluations (needs evaluations:read: the trace's results, also on the span each judged; reasoning is never returned). Another team's spans of the same trace ID are never returned or counted; a trace the team has no span of answers 404.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `trace_id` | path | string, required, pattern `^[0-9a-f]{32}$` |  |
| `fields` | query | string | Comma-separated: core, cost, attributes, evaluations |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | The trace. | `application/json`: object |
| `400` | invalid_trace_id or invalid_request | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | scope_forbidden, team_required or entitlement_forbidden | — |
| `404` | trace_not_found, or feature_disabled | — |
| `429` | rate_limit_exceeded | — |
| `503` | storage_unavailable | — |

Response `200` fields:

- `application/json`: object
  - `trace_id` (string, required)
  - `summary` (object)
  - `spans` (array of object, required, max items 2000)
  - `truncated` (boolean, required)
  - `cost_shown` (boolean)
  - `app_totals` ([AppTraceTotals](/docs/api/schemas/a/#apptracetotals))
  - `evaluations` (array of [PublicEvaluation](/docs/api/schemas/p/#publicevaluation))


## GET /v1/evaluations

`GET /v1/evaluations` · operation `listPublicEvaluations`

Public evaluation result read (T186.016). Requires public_trace_api, span_store, evals and evaluation_results, and key scope evaluations:read. The key's team's results, newest first, cursor-paginated, narrowed by q (space-separated key:value terms) or the same keys as parameters: name, source, assessment, status, evaluator (ID), metric_type, trace_id, span_id, request_id, session, run; from and to bound the creation time. A result never carries the judge's reasoning (reasoning_state withheld when one exists), the console user who wrote it or a comment.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `q` | query | string, max length 2000 |  |
| `limit` | query | integer, default `50`, min 1, max 200 |  |
| `cursor` | query | string |  |
| `from` | query | string |  |
| `to` | query | string (date-time) |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | A page of results. | `application/json`: object |
| `400` | invalid_query or invalid_request | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | scope_forbidden, team_required or entitlement_forbidden | — |
| `404` | feature_disabled | — |
| `429` | rate_limit_exceeded | — |
| `503` | storage_unavailable or analytics_store_unavailable | — |

Response `200` fields:

- `application/json`: object
  - `data` (array of [PublicEvaluation](/docs/api/schemas/p/#publicevaluation), required, max items 200)
  - `has_more` (boolean, required)
  - `next_cursor` (string)


## GET /v1/evaluators

`GET /v1/evaluators` · operation `listPublicEvaluators`

The key's team's evaluators (T186.016), every type (LLM judge, decision model, rule, code), with their live configuration, status and published version. Requires public_trace_api, span_store and evals, and key scope evaluators:read or evaluators:write.

**Authentication:** `bearerAuth`

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | The evaluators | `application/json`: object |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | scope_forbidden, team_required or entitlement_forbidden | — |
| `404` | feature_disabled | — |
| `429` | rate_limit_exceeded | — |
| `503` | storage_unavailable | — |

Response `200` fields:

- `application/json`: object
  - `data` (array of object, required)


## POST /v1/evaluators

`POST /v1/evaluators` · operation `createPublicEvaluator`

Creates an evaluator of the key's team from CI (T186.016): the body is an evaluator definition with its name (as PUT /v1/evaluators/{name}); 409 evaluator_exists when the team already has one with that name. Requires public_trace_api, span_store, evals and the evaluators flags (evaluators, eval_capture, trace_query, evaluation_tracing), and key scope evaluators:write. The first version is a draft; audited with the key as the actor.

**Authentication:** `bearerAuth`

**Request body** (required)

- `application/json`: object

**Responses**

| Status | Description | Body |
|---|---|---|
| `201` | Created | `application/json`: object |
| `400` | invalid_evaluator | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | scope_forbidden, team_required, team_forbidden or entitlement_forbidden | — |
| `404` | feature_disabled | — |
| `409` | evaluator_exists, or the evaluator is declared in the YAML (managed_by yaml) | — |
| `429` | rate_limit_exceeded | — |
| `503` | storage_unavailable | — |


## GET /v1/evaluators/{name}

`GET /v1/evaluators/{name}` · operation `getPublicEvaluator`

One evaluator of the key's team by name, with its definition (scope, filter, sample rate, route, output, criteria, status, version, published version, managed_by, updated_by). Key scope evaluators:read or evaluators:write.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `name` | path | string, required, min length 1, max length 80 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | The evaluator | `application/json`: object |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | scope_forbidden, team_required or entitlement_forbidden | — |
| `404` | evaluator_not_found or feature_disabled | — |
| `429` | rate_limit_exceeded | — |


## PUT /v1/evaluators/{name}

`PUT /v1/evaluators/{name}` · operation `putPublicEvaluator`

Evaluators as code from CI (T186.016): saves the definition as a new draft version of the team's evaluator with this name, created when there is none (201) or updated (200). Live traffic keeps the published version until POST .../publish. The same validation as the console's save (judge route, prompt paths, output, filter, code evaluators under their plan right); a team_id in the body must be the key's team. Requires the evaluator flags and key scope evaluators:write; audited (evaluator events) with key:&lt;id&gt; as the actor.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `name` | path | string, required, min length 1, max length 80 |  |

**Request body** (required)

- `application/json`: object

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | A new version | `application/json`: object |
| `201` | Created | `application/json`: object |
| `400` | invalid_evaluator | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | scope_forbidden, team_required, team_forbidden or entitlement_forbidden | — |
| `404` | feature_disabled | — |
| `409` | The evaluator is declared in the YAML (managed_by yaml) | — |
| `429` | rate_limit_exceeded | — |
| `503` | storage_unavailable | — |


## POST /v1/evaluators/{name}/publish

`POST /v1/evaluators/{name}/publish` · operation `publishPublicEvaluator`

Publishes a version (body {version}, default the latest) of the team's evaluator: live traffic runs it from the next span. The checks of the console's publish (a filter for a judge that calls a model, a priced route for a daily ceiling, no template placeholder). Key scope evaluators:write; audited with key:&lt;id&gt; as the actor.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `name` | path | string, required, min length 1, max length 80 |  |

**Request body**

- `application/json`: object
  - `version` (integer, min 1)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Published | `application/json`: object |
| `400` | invalid_request or invalid_evaluator | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | scope_forbidden, team_required or entitlement_forbidden | — |
| `404` | evaluator_not_found, version not found or feature_disabled | — |
| `409` | The evaluator is declared in the YAML | — |
| `422` | filter_required, ceiling_needs_price or placeholder_unfilled | — |
| `429` | rate_limit_exceeded | — |


## GET /v1/review-queues

`GET /v1/review-queues` · operation `listPublicReviewQueues`

The key's team's review queues (T186.016b). Requires public_trace_api, span_store and evals, and key scope reviews:read or reviews:write. A queue assigned to named people says assigned and can_annotate false: a key reviews only queues assigned to nobody.

**Authentication:** `bearerAuth`

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | The queues | `application/json`: object |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | scope_forbidden, team_required or entitlement_forbidden | — |
| `404` | feature_disabled | — |
| `429` | rate_limit_exceeded | — |

Response `200` fields:

- `application/json`: object
  - `data` (array of [PublicReviewQueue](/docs/api/schemas/p/#publicreviewqueue), required, max items 1000)


## GET /v1/review-queues/{id}

`GET /v1/review-queues/{id}` · operation `getPublicReviewQueue`

One review queue of the key's team (T186.016b): its fields, required fields, annotators_per_item, lock timeout and counts. Key scope reviews:read or reviews:write; another team's queue is 404.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, min length 1, max length 128 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | The queue | `application/json`: [PublicReviewQueue](/docs/api/schemas/p/#publicreviewqueue) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | scope_forbidden, team_required or entitlement_forbidden | — |
| `404` | not_found or feature_disabled | — |
| `429` | rate_limit_exceeded | — |


## GET /v1/review-queues/{id}/items

`GET /v1/review-queues/{id}/items` · operation `listPublicReviewItems`

The queue's items (T186.016b): each with its target, status, the reviews it needs and has. The key's own review is whole (answers, lock); another reviewer's shows its status only, never who it is; finals are not shown. status narrows to pending or completed; mine=true lists the pending items the key has not reviewed. Key scope reviews:read or reviews:write.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, min length 1, max length 128 |  |
| `status` | query | string, one of `"pending"`, `"completed"` |  |
| `mine` | query | boolean |  |
| `limit` | query | integer, min 1, max 500 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | The items | `application/json`: object |
| `400` | invalid_request | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | scope_forbidden, team_required or entitlement_forbidden | — |
| `404` | not_found or feature_disabled | — |
| `429` | rate_limit_exceeded | — |

Response `200` fields:

- `application/json`: object
  - `data` (array of [PublicReviewItem](/docs/api/schemas/p/#publicreviewitem), required, max items 500)


## POST /v1/review-queues/{id}/items

`POST /v1/review-queues/{id}/items` · operation `addPublicReviewItems`

Adds 1-500 targets of the key's team to the queue (T186.016b): request (with a capture), session, run_item (&lt;run&gt;/&lt;item&gt;), trace or span (&lt;trace_id&gt;/&lt;span_id&gt;; with review_multi_annotator and evaluation_results). The target's content is not read here. A target already queued counts as a duplicate. Key scope reviews:write; the item records key:&lt;id&gt; as who added it.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, min length 1, max length 128 |  |

**Request body** (required)

- `application/json`: object
  - `targets` (array of object, required, min items 1, max items 500)
    - `type` (string, required, one of `"request"`, `"session"`, `"run_item"`, `"trace"`, `"span"`)
    - `id` (string, required, min length 1, max length 256)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Added | `application/json`: object |
| `400` | invalid_request or invalid_target | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | scope_forbidden, team_required or entitlement_forbidden | — |
| `404` | not_found or feature_disabled | — |
| `429` | rate_limit_exceeded | — |

Response `200` fields:

- `application/json`: object
  - `added` (integer, required, min 0)
  - `duplicates` (integer, required, min 0)


## POST /v1/review-queues/{id}/next

`POST /v1/review-queues/{id}/next` · operation `nextPublicReviewItem`

Takes a seat on the next item for the key (T186.016b), with the console's semantics: one seat per reviewer, held for the queue's lock_timeout_seconds, at most annotators_per_item reviewers per item, never an item assigned to named people. item is null when nothing is left for the key. Key scope reviews:write.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, min length 1, max length 128 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | The item, or null | `application/json`: object |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | scope_forbidden, team_required, entitlement_forbidden or not_assigned | — |
| `404` | not_found or feature_disabled | — |
| `409` | item_locked | — |
| `429` | rate_limit_exceeded | — |

Response `200` fields:

- `application/json`: object
  - `item` ([PublicReviewItem](/docs/api/schemas/p/#publicreviewitem) or null, required)
    - One of (1): [PublicReviewItem](/docs/api/schemas/p/#publicreviewitem)
    - One of (2): null


## POST /v1/review-queues/{id}/annotations

`POST /v1/review-queues/{id}/annotations` · operation `annotatePublicReviewItem`

Stores the key's review of an item and completes it (T186.016b): each score is one of the queue's fields and passes its score config, every required field is given, and the form is all or nothing. On an item several reviewers review, the item completes with the last review; the final values and disagreement are computed as for the console. A second review by the same key is 409. Key scope reviews:write; the results are written with key:&lt;id&gt; as their author.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, min length 1, max length 128 |  |

**Request body** (required)

- `application/json`: object
  - `target_type` (string, required, one of `"request"`, `"session"`, `"run_item"`, `"trace"`, `"span"`)
  - `target_id` (string, required, min length 1, max length 256)
  - `scores` (array of object, required, max items 50)
    - `name` (string, required, min length 1, max length 80)
    - `data_type` (string)
    - `value` (number)
    - `string_value` (string, max length 500)
    - `comment` (string, max length 3000)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Stored | `application/json`: object |
| `400` | invalid_score or required_field | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | scope_forbidden, team_required, entitlement_forbidden or not_assigned | — |
| `404` | not_found or feature_disabled | — |
| `409` | item_locked or invalid_state | — |
| `429` | rate_limit_exceeded | — |

Response `200` fields:

- `application/json`: object
  - `stored` (integer, required, min 0)
  - `item_status` (string, required, one of `"pending"`, `"completed"`)
  - `disagreement` (boolean)
  - `unresolved` (boolean)


## GET /v1/comments

`GET /v1/comments` · operation `listPublicComments`

The comment thread on a target of the key's team (T186.016b): a request, a session or a run item, oldest first, at most 200. A key's comment names its key; a person's says person. Key scope reviews:read or reviews:write.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `target_type` | query | string, required, one of `"request"`, `"session"`, `"run_item"` |  |
| `target_id` | query | string, required, min length 1, max length 256 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | The thread | `application/json`: object |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | scope_forbidden, team_required or entitlement_forbidden | — |
| `404` | not_found or feature_disabled | — |
| `429` | rate_limit_exceeded | — |

Response `200` fields:

- `application/json`: object
  - `data` (array of [PublicComment](/docs/api/schemas/p/#publiccomment), required, max items 200)


## POST /v1/comments

`POST /v1/comments` · operation `createPublicComment`

Comments on a request, a session or a run item of the key's team (T186.016b), as key:&lt;id&gt;; audited. A key mentions nobody. Key scope reviews:write.

**Authentication:** `bearerAuth`

**Request body** (required)

- `application/json`: object
  - `target_type` (string, required, one of `"request"`, `"session"`, `"run_item"`)
  - `target_id` (string, required, min length 1, max length 256)
  - `content` (string, required, min length 1, max length 3000)

**Responses**

| Status | Description | Body |
|---|---|---|
| `201` | The comment | `application/json`: [PublicComment](/docs/api/schemas/p/#publiccomment) |
| `400` | invalid_comment | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | scope_forbidden, team_required or entitlement_forbidden | — |
| `404` | feature_disabled | — |
| `429` | rate_limit_exceeded | — |

