<!-- Generated from the operation definitions by `pnpm docs:reference`. Do not edit by hand. -->

# Upload a file: `upload_file`

Takes a file (PDF, Word, ODT, RTF, plain text, Markdown, HTML, JPG or PNG, up to 10 MB) as base64 and returns an id to use in quote_letter or check_letter pages. Kept for 24 hours unless a letter uses it. Free. For a letter you write yourself, pass text in the quote instead.

| | |
|---|---|
| MCP tool | `upload_file` |
| REST | `POST /v1/files` |
| CLI | `atomside upload-file` |
| Key needs | Quote (`letters:quote`) |
| Changes anything | Yes. |
| Idempotency key | Not used. |

## Example

A real call and its real answer, made against the API in test mode. A test runs it again and fails if the answer changes. Ids, keys and links are replaced with stand-ins.

### A call that works

REST:

```sh
curl -X POST https://api.atomside.com/v1/files \
  -H "Authorization: Bearer $ATOMSIDE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "rent-review.txt",
  "content_base64": "RGVhciBNcyBTYW1wbGUsCgpZb3VyIHJlbnQgc3RheXMgdGhlIHNhbWUuCg=="
}'
```

MCP:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "upload_file",
    "arguments": {
      "name": "rent-review.txt",
      "content_base64": "RGVhciBNcyBTYW1wbGUsCgpZb3VyIHJlbnQgc3RheXMgdGhlIHNhbWUuCg=="
    }
  }
}
```

CLI:

```sh
atomside upload-file \
  --name rent-review.txt \
  --content-base64 'RGVhciBNcyBTYW1wbGUsCgpZb3VyIHJlbnQgc3RheXMgdGhlIHNhbWUuCg=='
```

The answer (HTTP 200; over MCP, the same JSON is the result's `structuredContent`):

```json
{
  "file": "file_example000000001",
  "name": "rent-review.txt",
  "kind": "text",
  "size_bytes": 43,
  "sha256": "e10ae3aca4d6138ec91d6d76721b9b0b211bcff571a6be14c53fd94651fa0e36",
  "pages": null,
  "expires": "2026-11-17T09:30:00.000Z",
  "next": "Use { \"file\": \"file_example000000001\" } in the pages of check_letter or quote_letter."
}
```

## Input

Over REST, fields in the path go in the path, GET fields in the query string, and POST fields in the JSON body. Over MCP, every field is an argument of the tool.

```json
{
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200,
      "description": "The file name, with its extension."
    },
    "content_base64": {
      "type": "string",
      "maxLength": 13981016,
      "format": "base64",
      "contentEncoding": "base64",
      "pattern": "^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$",
      "description": "The file, base64 encoded."
    },
    "media_type": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    }
  },
  "required": [
    "name",
    "content_base64"
  ],
  "additionalProperties": false
}
```

## Output

```json
{
  "type": "object",
  "properties": {
    "file": {
      "type": "string",
      "description": "Use this in a quote: { \"file\": \"file_…\" }."
    },
    "name": {
      "type": "string"
    },
    "kind": {
      "type": "string",
      "enum": [
        "text",
        "markdown",
        "html",
        "pdf",
        "docx",
        "odt",
        "rtf",
        "png",
        "jpg"
      ]
    },
    "size_bytes": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991
    },
    "sha256": {
      "type": "string"
    },
    "pages": {
      "anyOf": [
        {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        {
          "type": "null"
        }
      ],
      "description": "For a PDF, how many pages it has: choose some with \"pages\" in a quote. Else null."
    },
    "expires": {
      "type": "string",
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
      "description": "Kept until then unless a letter uses it."
    },
    "next": {
      "type": "string"
    }
  },
  "required": [
    "file",
    "name",
    "kind",
    "size_bytes",
    "sha256",
    "pages",
    "expires",
    "next"
  ],
  "additionalProperties": false
}
```

## Refusals

Every refusal has the same shape. Branch on `code`, `answer` and `retry`; repeat `say` to your person.

| Code | Answer | Retry | HTTP | What to do next |
|---|---|---|---|---|
| [`key_missing`](../refusals.md#key_missing) | no | after_fix | 401 | Send the key as "Authorization: Bearer as_test_…". Ask your person if you have none. |
| [`key_not_valid`](../refusals.md#key_not_valid) | no | never | 401 | Ask your person for a new key. There is no link: we cannot say whose it was. |
| [`scope_missing`](../refusals.md#scope_missing) | no | after_person | 403 | Ask your person to give the key that permission. |
| [`invalid_request`](../refusals.md#invalid_request) | no | after_fix | 400 | Fix the field named in details.field. The same idempotency key is fine. |
| [`rate_limited`](../refusals.md#rate_limited) | no | at_time | 429 | Wait. The same idempotency key never sends twice. |
| [`try_again_shortly`](../refusals.md#try_again_shortly) | no | at_time | 503 | Try again after retry_after with the same idempotency key. |
| [`account_expired`](../refusals.md#account_expired) | no | never | 401 | Start again with start_account if your person still wants this. |
| [`connection_ended`](../refusals.md#connection_ended) | no | after_person | 401 | Tell your person. To carry on, they connect Atomside again in your assistant. |
| [`file_not_usable`](../refusals.md#file_not_usable) | no | after_fix | 422 | details.problem says which page and what is wrong. |
| [`not_found`](../refusals.md#not_found) | no | after_fix | 404 | Check the name against the tool list or /v1/openapi.json. |
