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

# Annotations

> Record human review decisions on documents, such as approved or rejected, query them as a review queue, and read the judgment set at a past instant.

Record a reviewer's decision on a document, such as `approved`, `rejected` or `deferred`, with a confidence, the reasoning and any structured data your workflow needs. Annotations turn retriever results into verified decisions: medical coding review, brand infringement triage, content moderation, duplicate confirmation. They are stored apart from the documents and never change document data. For implicit signals such as clicks and dwell time, use [interactions](https://docs.mixpeek.com/docs/retrieve/relevance.md#record-interactions) instead.

**Prerequisites:** a namespace with a collection of documents, and usually a [retriever](https://docs.mixpeek.com/docs/retrieve/retrievers.md) whose results people review.

## Record a decision

**1. Create the annotation**

`document_id` and `label` are required. Labels are free-form strings; the rest is optional.

```bash cURL theme={null}
curl -X POST "https://api.mixpeek.com/v1/annotations" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "X-Namespace: $NAMESPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{
    "document_id": "'"$DOCUMENT_ID"'",
    "collection_id": "'"$COLLECTION_ID"'",
    "label": "approved",
    "confidence": 0.95,
    "reasoning": "Note documents peripheral neuropathy with supporting lab values.",
    "payload": { "codes_approved": ["E11.40", "E11.65"], "raf_impact": 0.42 },
    "metadata": { "reviewer_team": "hcc-west" },
    "retriever_id": "'"$RETRIEVER_ID"'",
    "execution_id": "'"$EXECUTION_ID"'"
  }'
```

```python Python theme={null}
import os
import requests

resp = requests.post(
    "https://api.mixpeek.com/v1/annotations",
    headers={
        "Authorization": f"Bearer {os.environ['MIXPEEK_API_KEY']}",
        "X-Namespace": os.environ["NAMESPACE_ID"],
    },
    json={
        "document_id": os.environ["DOCUMENT_ID"],
        "collection_id": os.environ["COLLECTION_ID"],
        "label": "approved",
        "confidence": 0.95,
        "reasoning": "Note documents peripheral neuropathy with supporting lab values.",
        "payload": {"codes_approved": ["E11.40", "E11.65"], "raf_impact": 0.42},
        "metadata": {"reviewer_team": "hcc-west"},
        "retriever_id": os.environ["RETRIEVER_ID"],
        "execution_id": os.environ["EXECUTION_ID"],
    },
)
print(resp.json()["annotation_id"])
```

```javascript JavaScript theme={null}
const resp = await fetch("https://api.mixpeek.com/v1/annotations", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MIXPEEK_API_KEY}`,
    "X-Namespace": process.env.NAMESPACE_ID,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    document_id: process.env.DOCUMENT_ID,
    collection_id: process.env.COLLECTION_ID,
    label: "approved",
    confidence: 0.95,
    reasoning: "Note documents peripheral neuropathy with supporting lab values.",
    payload: { codes_approved: ["E11.40", "E11.65"], raf_impact: 0.42 },
    metadata: { reviewer_team: "hcc-west" },
    retriever_id: process.env.RETRIEVER_ID,
    execution_id: process.env.EXECUTION_ID,
  }),
});
console.log((await resp.json()).annotation_id);
```

**2. Build a review queue**

List annotations with any combination of `document_id`, `collection_id`, `label`, `actor_id`, `retriever_id`, `target_kind` and `as_of` in the body. `skip` and `limit` are query parameters.

```bash cURL theme={null}
curl -X POST "https://api.mixpeek.com/v1/annotations/list" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "X-Namespace: $NAMESPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{ "collection_id": "'"$COLLECTION_ID"'", "label": "deferred" }'
```

**3. Update a decision when it is revisited**

```bash cURL theme={null}
curl -X PATCH "https://api.mixpeek.com/v1/annotations/$ANNOTATION_ID" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "X-Namespace: $NAMESPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{
    "label": "approved",
    "confidence": 0.88,
    "reasoning": "Clinical review confirmed peripheral neuropathy."
  }'
```

Every value-changing edit creates a new version that records who changed which fields and when.

## Fields

| Field | What it holds |
| - | - |
| `document_id`, `collection_id` | What was reviewed |
| `label` | The decision, such as `approved`. Stats group by exact string, so keep one vocabulary per workflow |
| `confidence` | The reviewer's confidence, 0.0 to 1.0 |
| `reasoning` | The justification, kept for audits and disputes |
| `payload` | Structured content of the judgment: codes, scores, amounts. Keep it out of `label` |
| `metadata` | Anything to carry alongside, stored and returned as-is |
| `retriever_id`, `execution_id`, `stage_name` | How the document was found, so you can evaluate the retriever that surfaced it |
| `target` | Which part of the result is judged (below). Absent means the whole document |
| `actor_id`, `actor_type` | Who decided: a user, an API key or the system. Set by Mixpeek |

### Judge part of a result

`target` narrows a judgment:

| `target` field | Judges |
| - | - |
| `object_id` | The object the document came from, the entity a search should return |
| `span` | One time range, such as "right result, wrong moment" |
| `region` | One area of a page or image |
| `rank` | The 1-based position the result was shown at |
| `expected: true` | A relevant result that did not come back, named by `document_id` or `object_id` |

Filter on the kind with `target_kind`: `document`, `execution`, `object`, `span`, `region`, `rank` or `expected`.

## Check it worked

Label counts power progress bars and dashboards:

```bash cURL theme={null}
curl "https://api.mixpeek.com/v1/annotations/stats?collection_id=$COLLECTION_ID" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "X-Namespace: $NAMESPACE_ID"
```

```json Response theme={null}
{ "total": 142, "by_label": { "approved": 89, "rejected": 31, "deferred": 22 } }
```

`GET /v1/annotations/{annotation_id}/versions` lists an annotation's edits; `/versions/{version}` returns the full state at one version. Every create, update and delete also emits a [webhook event](https://docs.mixpeek.com/docs/enrich/alerts-and-triggers.md#events) (`annotation.created`, `annotation.updated`, `annotation.deleted`) and an entry in the [audit log](https://docs.mixpeek.com/docs/api-reference/organization-audit/list-audit-logs.md).

## Read the judgment set at a past instant

Pass `as_of` to list annotations as they stood at that moment. Annotations created later are left out, and each remaining one is rewound to its state at that time. An evaluation that pins one `as_of` reads the identical judgment set weeks later, after reviewers have added and revised decisions.

```bash cURL theme={null}
curl -X POST "https://api.mixpeek.com/v1/annotations/list" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "X-Namespace: $NAMESPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{ "collection_id": "'"$COLLECTION_ID"'", "as_of": "2026-08-01T00:00:00Z" }'
```

A rewound annotation reports the `version` it held at that instant, and its `revisions` contain only earlier versions. Compare `version` across two `as_of` reads to see which decisions moved.

> [!WARNING]
>
> The boundary is inclusive. An annotation created at exactly `as_of` is returned, and an edit at exactly `as_of` is kept. To exclude a record created at a known time, pass an earlier `as_of`.

## Bulk changes

`POST /v1/annotations/bulk` takes up to 1,000 creates, updates and deletes in one call. Each operation is independent, so one failure does not roll back the rest; the response has `created_count`, `updated_count`, `deleted_count`, `failed_count` and a per-operation `results` list to retry from.

```bash cURL theme={null}
curl -X POST "https://api.mixpeek.com/v1/annotations/bulk" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "X-Namespace: $NAMESPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{
    "create": [
      { "document_id": "doc_001", "collection_id": "col_notes", "label": "approved", "confidence": 0.95 },
      { "document_id": "doc_003", "collection_id": "col_notes", "label": "rejected", "reasoning": "Insufficient documentation" }
    ],
    "update": [ { "annotation_id": "ann_abc123", "label": "approved", "confidence": 0.88 } ],
    "delete": ["ann_def456"]
  }'
```

## What goes wrong

| Symptom | Cause |
| - | - |
| Stats split one decision across several labels | Labels differ in case or spelling; stats match exact strings |
| `metadata` lost keys after an update | `PATCH` replaces `metadata` whole. Send the full object; omit it or send `null` to keep it, send `{}` to clear it |
| `metadata` missing from the system collection | Mixpeek mirrors `metadata` onto the annotation's row in the `mxp_document_annotations` [system collection](https://docs.mixpeek.com/docs/manage/vector-store.md) on a best-effort basis; the write still succeeds if the mirror fails. The annotation record is the source of truth |
| An `as_of` read includes a record you meant to exclude | The boundary is inclusive; use an earlier instant |

## Related

* [Relevance and evaluation](https://docs.mixpeek.com/docs/retrieve/relevance.md): use judgments to measure retriever quality
* [Alerts, triggers and webhooks](https://docs.mixpeek.com/docs/enrich/alerts-and-triggers.md): act on annotation events
* [Create annotation](https://docs.mixpeek.com/docs/api-reference/annotations/create-annotation.md) and [List annotations](https://docs.mixpeek.com/docs/api-reference/annotations/list-annotations.md) in the API reference


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