---
search:
  tags:
    - Metrics
    - POST
seo:
  description: >-
    Record many metric values against one session in a single call. Reference
    for the POST /v1/metrics endpoint in the Roboto REST API.
sidebar:
  label: Publish metrics
  badge: POST
title: Publish metrics
type: openapi-operation
---
Record many metric values against one session in a single call.

Answers 201 once the request has been processed, even when the platform refused every value: the
response carries one element per submitted metric, in request order, holding either the metric it
recorded or the error that refused it. A caller on an API version before 2026-10-05 gets the older
shape instead, a ``succeeded`` list of stored records beside a ``failed`` list of named errors.

Three cases are settled before anything is recorded: a session that does not exist in this org answers
404, a malformed request answers 400, and so does one that omits ``device_id`` for a session without
exactly one device attached, since there is then no single attached device to record the values against.

A publication that runs out of time answers 504, under ``RobotoServiceTimeoutException`` when the
invocation's own deadline expired and ``RobotoOperationTimeoutException`` when a statement's budget did.
Either one rolls the publication back, the definitions it created along with the values.

#### Access control
 - requires_org
 - Restricted tokens need the API scope `api.everything_else`

`POST /v1/metrics`

**Request body** (`application/json`, required)

- `session_id` (string, required)
- `device_id` (string | null)
- `metrics` (MetricEntry[], required)

Request body example:

```json
{
  "session_id": "string",
  "device_id": {},
  "metrics": [
    {
      "name": "string",
      "value": 0
    }
  ]
}
```

**Responses**

- `201` — CREATED
- `400` — A conversation with Roboto's AI is longer than the AI model can read at once. The conversation's messages and tool results, together with the AI's instructions, exceed the model's context window. The exception does not carry the token count or the model's limit.
- `401` — The caller's token is expired or malformed.
- `403` — The request would take the user or organization past a limit on a resource, such as AI credits.
- `404` — The request names an API route Roboto does not serve.
- `409` — The request conflicts with an existing resource, such as by giving a name another resource already has.
- `410` — The resource the request names is missing or has expired.
- `500` — Roboto reported an error that this release of the SDK cannot match to a specific exception class. Reported for an element of a :py:class:\`\~roboto.http.BatchResponse\` whose error names a code this release defines no class for, or that arrived without a code, without a message, or as text that is not an error envelope at all. It carries whatever code and message Roboto sent, so a caller handling the failure still learns what went wrong; when no message could be read, the message is the error's raw text. :py:meth:\`\~roboto.domain.devices.Device.create\_session\` raises it, and :py:meth:\`\~roboto.domain.devices.Device.create\_sessions\` lists it in the batch's :py:attr:\`\~roboto.http.BatchResponse.failed\`. The error envelope carries no status code, so \`\`http\_status\_code\`\` reports the 500 inherited from \`\`RobotoDomainException\`\` rather than the status the failure had.
- `501` — The request asks for an operation this deployment of Roboto does not provide.
- `503` — Roboto could not accept the request, such as under heavy load. Retrying later may succeed.
- `504` — Roboto ran out of time while processing the request. Retrying may succeed.
- `507` — The response to the request is larger than Roboto can send. Retrying the same request fails the same way; request less data at a time.

Response example, 201:

```json
{
  "data": {
    "responses": [
      {
        "data": null,
        "error": null
      }
    ]
  }
}
```
