---
search:
  tags:
    - Sessions
    - POST
seo:
  description: >-
    Include files in a session that already exists, each with whatever…
    Reference for the POST /v1/sessions/id/{session_id}/files endpoint in the
    Roboto REST API.
sidebar:
  label: Add files
  badge: POST
title: Add files
type: openapi-operation
---
Include files in a session that already exists, each with whatever topic data it declares.

Answers 200 once the request has been processed, even when the platform included only some of the files:
the response carries one element per declared file, in request order, holding either that file's membership in
the shape ``GET /v1/sessions/id/<session_id>/files`` reports it or the error that refused the entry.
The request runs in one transaction, and every entry's refusal is settled before anything is written,
so a refused entry leaves the others included; a failure the platform did not anticipate, such as the request's
deadline, includes none of them. A malformed request answers 400, and a file an entry declares, or a file a
listed representation names, that is not an ``Available`` file of the session's org answers 404;
both are settled before the first entry is written, so the session gains nothing.
A session deleted after the request loaded it answers 404, and none of the entries is written.

A client on an API version before 2026-10-05 sends the earlier request shape and receives the
session's record. Its request stands or falls whole: when the platform refuses one file it answers
with that refusal and includes none of the files, and a file named twice is included over its last
entry.

Every ``anchor_ns`` in the body is a time after the Unix epoch: an integer of nanoseconds since the
epoch, or any time ``roboto.time.to_epoch_nanoseconds`` reads, so a float or numeric string is seconds
and an ISO 8601 string is that instant.

The caller must be able to read every file the request names and to change every dataset the session's files
already sit in. Declaring topics on a file or anchoring it writes to that file and so requires edit access to it.
Naming a file in a listed representation writes nothing to that file and takes the access that declaring topics
on it does, because a read of the topic opens that file. Stating ``is_default_for_reads`` on a timeline source,
true or false, additionally requires topic edit access in the org: which source a schema's reads fall back to
is a property of the org's topics, not of any one file. Each denial answers 401 before any entry is prepared.

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

`POST /v1/sessions/id/{session_id}/files`

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

- `files` (SessionFile[], required)

Request body example:

```json
{
  "files": [
    {
      "file_id": "string",
      "data_range": null,
      "anchor_ns": null,
      "topics": [
        {
          "topic_name": "string",
          "topic_schema": {
            "name": null,
            "fields": [
              {
                "name": "",
                "path": [
                  "string"
                ],
                "data_type": "string",
                "canonical_data_type": "unknown",
                "unit": null,
                "element_names": null
              }
            ]
          },
          "timeline_sources": [
            {
              "min_file_timestamp_ns": -9223372036854776000,
              "max_file_timestamp_ns": -9223372036854776000,
              "is_default_for_reads": true,
              "kind": "field",
              "field_path": [
                "string"
              ]
            }
          ],
          "data_range": null,
          "representations": [
            {
              "file_id": "string",
              "storage_format": "mcap",
              "content_format": null,
              "transformations": [
                "string"
              ],
              "field_path": null
            }
          ]
        }
      ],
      "min_file_timestamp_ns": null,
      "max_file_timestamp_ns": null
    }
  ]
}
```

**Responses**

- `200` — OK
- `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, 200:

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