---
docId: doc_f5de52659fff4f38ac4eac591fc9fc69
title: Upload a file
description: "Uploads documents up to 50 MiB through a private session and processes their content."
api:
  group: archivos
  auth: bearer
  operations:
    - operationId: createUpload
      method: POST
      path: '/v1/files/upload'
      postmanName: Upload a file
---

<script>
  import { Ways, Note } from '$lib/components';
</script>

# Upload a file

Upload a document up to 50 MiB: first send `fileName`, `contentType` and `byteSize` to get `upload.sessionUri`, then send the bytes to that private URL with `PUT`. For documents up to 1 MiB, text or web pages, use [Create a file](/api-reference/files/create).

## Example

<Ways tabs="api,sdk">
<Ways.Way name="api">

```bash
curl -X POST "https://api.platic.ai/v1/files/upload" \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "title": "Returns manual",
  "fileName": "returns-manual.pdf",
  "contentType": "application/pdf",
  "byteSize": 7340032
}'
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
await platic.files.createFile({ data: new Uint8Array(2_000_000), fileName: "catalog.pdf" });
```

</Ways.Way>
</Ways>

## Request body

```json
{
  "title": "Returns manual",
  "fileName": "returns-manual.pdf",
  "contentType": "application/pdf",
  "byteSize": 7340032,
  "attachment": { "agentId": "Xq8mTe2LwP4kZ1aB9cDf" }
}
```

| Field | Type | Description | Required |
|-------|------|-------------|----------|
| `fileName` | string | The name with extension (see [formats](/api-reference/files#limits)). | ✓ |
| `contentType` | string | The type, for example `application/pdf`. | ✓ |
| `byteSize` | integer | The exact size in bytes, from 1 to 52,428,800 (50 MiB). | ✓ |
| `title` | string | 1 to 200 characters. Without it, it starts with the document's name and then takes one with AI. | - |
| `description` | string | Up to 1024 characters. Empty or omitted, it is generated with AI. | - |
| `attachment` | object | `{ "agentId": "..." }` connects the file to that agent; the connection activates by itself when it finishes. | - |

## Response

`202 Accepted`. It has `upload` next to `data`:

```json
{
  "status": "success",
  "data": {
    "accepted": true,
    "fileId": "kP7wQ2sN5tY1",
    "uploadId": "up_9Rf3Jd6Hx2",
    "link": {
      "agentId": "Xq8mTe2LwP4kZ1aB9cDf",
      "fileId": "kP7wQ2sN5tY1",
      "state": "paused",
      "attachedAt": "2026-11-01T10:00:00.000Z",
      "activateOnReady": true,
      "schedule": null
    },
    "statusUrl": "/v1/agents/Xq8mTe2LwP4kZ1aB9cDf/files/kP7wQ2sN5tY1/jobs/up_9Rf3Jd6Hx2"
  },
  "upload": {
    "method": "PUT",
    "sessionUri": "https://storage.googleapis.com/upload/storage/v1/b/...",
    "admissionExpiresAt": "2026-11-01T11:00:00.000Z"
  }
}
```

## Response fields

`data` has the fields of [Create a file](/api-reference/files/create#response-fields). Also:

| Field | Type | Description |
|-------|------|-------------|
| `upload.method` | string | Always `PUT`. |
| `upload.sessionUri` | string | The private address you send the bytes to. It is a secret: do not store it in logs or share it. |
| `upload.admissionExpiresAt` | string | Until when you can send the bytes: one hour. After that, processing fails with `UPLOAD_EXPIRED`. |

## Send the bytes

```bash
curl -X PUT "$SESSION_URI" \
  -H "Content-Type: application/pdf" \
  --data-binary @returns-manual.pdf
```

- **Without** `Authorization`: the address already grants permission. Do not send your API key to another server.
- Use the same `Content-Type` you declared when opening the upload.
- It answers `200` or `201` when everything arrived. Then the processing moves from `awaiting_upload` to `queued`.
- If the upload is interrupted, resume it using the same URL (Google Cloud Storage resumable upload). Check how many bytes arrived with an empty `PUT` and `Content-Range: bytes */TOTAL`, then continue from that point.

Then, read the [processing](/api-reference/files/processing) until `terminal` is `true`.

<Note type="warning">

`upload` only comes in this response. Keep `sessionUri` until you finish uploading.

</Note>

## Errors

| Status | `details.code` | When |
|--------|----------------|------|
| `400` | `INVALID_INPUT` | A field is missing or a value is not valid. `details.fields` names them. |
| `403` | `RESOURCE_NOT_ACCESSIBLE` | Without `attachment`: Integrations is missing. With `attachment`: you cannot edit that agent. |
| `404` | `AGENT_NOT_FOUND` | The agent in `attachment` does not exist. |
| `413` | `SIZE_LIMIT_EXCEEDED` | `byteSize` is over 50 MiB. |
| `422` | `INVALID_CONTENT_TYPE` | The extension or the type is not supported. |
| `429` | `QUOTA_EXCEEDED` | There are already 30 open processings in the workspace. |
| `429` | `STORAGE_LIMIT_EXCEEDED` | The workspace reached its file or storage limit. |
| `503` | `ACCEPTANCE_INCOMPLETE` | The upload could not finish opening. Repeat the request. |

If the bytes do not match what you declared (another size, another type), the request was already accepted: the processing fails with its reason in `error`. The errors that apply to all operations are in [common errors](/api-reference/files#common-errors).

## Notes

- With the [SDK](/sdk) you do not have to open the session manually: `platic.files.createFile({ data, fileName })` decides by itself whether to send inline (up to 1 MiB) or open an upload session (1 to 50 MiB) and upload the bytes.
- If you repeat this call with the same `Idempotency-Key`, the second response has `upload: null`: the `sessionUri` address is only delivered once.
- This operation is not in Platica's MCP: over MCP a file goes in base64 inside [`create_file`](/mcp/tools#files), up to 1 MB.
- To replace a file's content with another large document, use [Update a file](/api-reference/files/update#replace-the-content) with `replacement.type: "upload"`: it answers the same way, with `upload`.
