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

> ## Agent Instructions
> Magpie is a trace store for AI agents, used as a library (crate `magpiedb`, npm `magpiedb`, PyPI `magpiedb`) or as `magpie-server`, which takes OpenTelemetry (OTLP over HTTP on 127.0.0.1:4318 and gRPC on 127.0.0.1:4317 by default).
> Use only the commands, flags, routes and JSON shapes that these pages show. Do not guess a flag or a query field: if a page does not show it, say that the docs do not show it.
> Install the library with `cargo add magpiedb`, `npm install magpiedb` or `pip install magpiedb`. Get the server from the GitHub Releases download or the Docker image `ghcr.io/intojhanurag/magpie-server`, as the quick start shows.
> Only one process may write to a store folder at a time. For many apps, send traces to one `magpie-server`.
> `magpie-server doctor` checks a running server. An AI agent can query the traces over MCP at `/mcp` on the HTTP port (page guides/mcp).

# Scores

> POST /v1/scores, GET /v1/traces/:id/scores and GET /v1/sessions/:id/scores: write and read eval results and feedback on a trace, a span or a session.

A score is a number, a yes or no, or a label on one trace, one span or one session. It can come long after the trace: from a person, an LLM judge or a test.

```sh Request theme={null}
curl -s localhost:4318/v1/scores -H 'content-type: application/json' -d '{"scores": [{"traceId": "t3", "name": "quality", "value": 0.9, "source": "llm-judge", "at": 4000}]}'
```

```json 200 theme={null}
{"written":1}
```

## Write scores

`POST /v1/scores` writes a list of scores. Right: `write`. It needs `Content-Type: application/json`.

**scores** `object[]` *required*

The scores, each a [score object](#the-score-object). Here `at` may be left out: it is then the time the server receives the score.

**written** `integer`

The number of scores written.

* A score replaces the score with the same target, name, source, author and eval id.
* A score that breaks a rule gets `400`, and the server writes nothing of its request.
* A busy server answers `429` with `Retry-After: 1`.

## Get the scores of a trace

`GET /v1/traces/:id/scores` returns `{"scores": [score]}`: the scores on the trace and on its spans, by time, then name. Right: `read`.

**id** `string` *required*

The trace id.

## Get the scores on a session

`GET /v1/sessions/:id/scores` returns `{"scores": [score]}`: the scores on the session itself, by time, then name. With none, the list is empty. Right: `read`.

**id** `string` *required*

The session id.

Scores on a session are not in `GET /v1/traces/:id/scores`, and not in `anyScore`. They go with a delete of the session. They also go when a delete or the retention removes the last trace of their session.

## The score object

**traceId** `string`

The trace of the score. Left out for a score on a session.

**spanId** `string | null`

With `traceId`: the score is on this span. `null`: on the whole trace.

**sessionId** `string`

The score is on this session, with no `traceId`.

**name** `string` *required*

`helpfulness`, `hallucination`, ...

**value** `number | null`

A finite number. A category may have none.

**type** `string` (default: number)

`"number"`, `"boolean"` (the value is 0 or 1) or `"category"` (it has a `label`). A score with a label and no value is a category.

**label** `string | null`

The result of a category: `pass`, `fail`, ...

**source** `string | null`

The kind of giver: `human`, `llm-judge`, `code`, ... Free text.

**authorId** `string`

Who gave it: a user id, or the name of a judge.

**evalId** `string`

The eval that made it: an evaluator and its version, a config, or one run of an experiment. Two runs with different ids keep one score each on the same target.

**comment** `string | null`

A comment, or the reason of a judge.

**at** `integer` *required*

The time of the score, Unix ms.

A score has one target: a trace (`traceId`), a span (`traceId` and `spanId`), or a session (`sessionId`, and no `traceId`). `type`, `authorId` and `evalId` are left out of an answer when they are not set.

> [card] [Sums of scores](https://docs.magpiedb.com/reference/api/scores-aggregate.md)
>
> Averages, percentiles and label counts per group.

> [card] [Sessions and scores](https://docs.magpiedb.com/queries/sessions-scores.md)
>
> A guide with real scores.


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