---
docId: doc_2a389b2b950140978885bbbe06f55c2a
title: Create a file
description: Create a file from text, a web page or a document up to 1 MiB, and optionally connect it to an agent. It is processed in the background.
api:
  group: archivos
  auth: bearer
  operations:
    - operationId: createFile
      method: POST
      path: '/v1/files'
      postmanName: Create a file
---

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

# Create a file

Add content by sending `type` and the fields for that type: **text**, a **web page** or a **base64 document** up to 1 MiB. For larger documents, use [Upload a file](/api-reference/files/upload).

With `attachment.agentId` the file is connected to that agent and activates by itself when its content is ready. Without `attachment`, it stays in the workspace with no agents.

## Example

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

```bash
curl -X POST "https://api.platic.ai/v1/files" \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "type": "text",
  "text": "We ship in five business days."
}'
```

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

```ts
await platic.files.createText({ text: "We ship in five business days." });
```

</Ways.Way>
</Ways>

## Request body

From text, connected to an agent:

```json
{
  "type": "text",
  "title": "Service hours",
  "text": "We are open Monday to Friday from 9:00 to 18:00 and on Saturdays from 10:00 to 14:00.",
  "attachment": { "agentId": "Xq8mTe2LwP4kZ1aB9cDf" }
}
```

From a web page, without a title (Platica sets one with AI) and checking it every day:

```json
{
  "type": "url",
  "url": "https://acme.com/policies/returns",
  "refresh": { "intervalHours": 24 },
  "attachment": { "agentId": "Xq8mTe2LwP4kZ1aB9cDf" }
}
```

From a small document:

```json
{
  "type": "file",
  "title": "Price list",
  "fileName": "prices.pdf",
  "contentType": "application/pdf",
  "contentBase64": "JVBERi0xLjcKJcfsj6IK..."
}
```

| Field | Type | Description | Required |
|-------|------|-------------|----------|
| `type` | string | `text`, `url` or `file` | ✓ |
| `title` | string | 1 to 200 characters. Without it, Platica sets a provisional one and then one with AI (see [automatic names](/api-reference/files#automatic-names)). | - |
| `description` | string | Up to 1024 characters: what it is about and when to consult it. Empty or omitted, it is generated with AI. | - |
| `text` | string | With `text`: the content, up to 1 MiB. | * |
| `url` | string | With `url`: the page, public, `http` or `https`, up to 4096 characters. | * |
| `refresh` | object \| null | With `url`: `{ "intervalHours": 24 }` re-reads it every that many hours (6, 12, 24, 48, 72, 168, 336 or 720). Without it, it does not update by itself. | - |
| `fileName` | string | With `file`: the name with extension, for example `prices.pdf`. | * |
| `contentType` | string | With `file`: the type, for example `application/pdf`. | * |
| `contentBase64` | string | With `file`: the bytes in base64, up to 1 MiB. | * |
| `attachment` | object | `{ "agentId": "..." }` connects the file to that agent. | - |
| `attachment.activateOnReady` | boolean | If you send it, `true`. The connection always activates when processing finishes; `false` answers `422`. | - |

\* Depending on `type`, only its fields go and all of them are required: sending fields of another type answers `400`.

## Response

`202 Accepted`. Processing continues in the background:

```json
{
  "status": "success",
  "data": {
    "accepted": true,
    "fileId": "fH3kL9mQ2xR7",
    "uploadId": "up_4Tn8Vb2Kc1",
    "link": {
      "agentId": "Xq8mTe2LwP4kZ1aB9cDf",
      "fileId": "fH3kL9mQ2xR7",
      "state": "paused",
      "attachedAt": "2026-11-01T10:00:00.000Z",
      "activateOnReady": true,
      "schedule": null
    },
    "statusUrl": "/v1/agents/Xq8mTe2LwP4kZ1aB9cDf/files/fH3kL9mQ2xR7/jobs/up_4Tn8Vb2Kc1"
  }
}
```

## Response fields

| Field | Type | Description |
|-------|------|-------------|
| `accepted` | boolean | Always `true`: the request was accepted. It does not say it is already processed. |
| `fileId` | string | The new file. |
| `uploadId` | string | This processing. |
| `link` | object \| null | With `attachment`: the connection just created, paused, with the fields of [List agent files](/api-reference/agents/files/list#connection-fields-link). Without `attachment`, `null`. |
| `statusUrl` | string | Where to read the processing: the agent's route with `attachment`, the file's route without it. |

## Afterwards

1. Read the [processing](/api-reference/files/processing) (or the `statusUrl`) every few seconds until `terminal` is `true`.
2. With `status: "ready"` the content is ready and, if you connected it to an agent, the connection is already active.
3. With `status: "failed"`, `error` says why. The connection stays paused; fix the source and [replace it](/api-reference/files/update#replace-the-content) or [retry](/api-reference/files/reprocess).

## Errors

| Status | `details.code` | When |
|--------|----------------|------|
| `400` | `INVALID_INPUT` | A field is missing, one of another type is extra or a value is not valid; for example, a text or a base64 over 1 MiB. `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` | The request is too large. For documents over 1 MiB, use [Upload a file](/api-reference/files/upload). |
| `422` | `ACTIVATION_POLICY_MISMATCH` | You sent `attachment.activateOnReady: false`. |
| `422` | `INVALID_CONTENT_TYPE` | The type is not supported or does not match the document. |
| `429` | `QUOTA_EXCEEDED` | There are already 30 open processings in the workspace. Wait a few minutes. |
| `429` | `STORAGE_LIMIT_EXCEEDED` | The workspace reached its file or storage limit. |

The ones that apply to all operations are in [common errors](/api-reference/files#common-errors).

## Notes

- In the [SDK](/sdk) there is one method per type: `platic.files.createText(...)`, `platic.files.createUrl(...)` and `platic.files.createFile(...)` (the last one also handles documents over 1 MiB automatically).
- If you send the `Idempotency-Key` header and repeat the same request after a network cut, the API returns the same `fileId` and `uploadId` without duplicating the file.

<Note type="note">

A file created with `attachment` lives in the workspace: other agents can use it with [Connect a file](/api-reference/agents/files/connect), and changing it changes it for all of them.

</Note>
