---
docId: doc_d6e36414b0a14b4dba1ef9e28cda33e3
title: Update a file
description: Change a file's title or description, turn on or off keeping a page up to date, or replace its content. It applies to all agents that use it.
api:
  group: archivos
  auth: bearer
  operations:
    - operationId: patchFile
      method: PATCH
      path: '/v1/files/{fileId}'
      postmanName: Update a file
---

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

# Update a file

Change a file’s title or description, refresh a page automatically or replace its content. Send at least one field. The change reaches **all agents** that use the file.

Before changing it, check which agents use it with [Get a file](/api-reference/files/get) and `include=affectedAgents`.

## Example

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

```bash
curl -X PATCH "https://api.platic.ai/v1/files/$FILE_ID" \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "title": "Prices 2027" }'
```

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

```ts
await platic.files.update("file_123", { title: "Prices 2027" });
```

</Ways.Way>
</Ways>

## Path parameters

| Parameter | Type | Description | Required |
|-----------|------|-------------|----------|
| `fileId` | string | The file | ✓ |

## Request body

Send at least one field. With `replacement` it is a replacement; without it, a data change.

### Rename

```json
{
  "title": "Return policies 2026",
  "description": "Deadlines, conditions and exceptions for returning a product. Use it when people ask about exchanges or refunds."
}
```

### Keep a page up to date

Only for `url` files. It re-reads the page every that many hours, for all the agents that use it:

```json
{ "refresh": { "intervalHours": 168 } }
```

To turn it off:

```json
{ "refresh": null }
```

### Replace the content

The new content is processed and, in the meantime, agents keep using the previous one. You can rename in the same change:

```json
{
  "title": "Service hours",
  "replacement": {
    "type": "text",
    "text": "We are open Monday to Saturday from 9:00 to 19:00."
  }
}
```

With another page:

```json
{ "replacement": { "type": "url", "url": "https://acme.com/help/returns" } }
```

With a document up to 1 MiB (`file`) or a larger one (`upload`, which answers with an address to upload it to, like [Upload a file](/api-reference/files/upload)):

```json
{
  "replacement": {
    "type": "upload",
    "fileName": "returns-manual-2026.pdf",
    "contentType": "application/pdf",
    "byteSize": 8126464
  }
}
```

| Field | Type | Description |
|-------|------|-------------|
| `title` | string | New name, 1 to 200 characters. |
| `description` | string | New description, up to 1024 characters. |
| `refresh` | object \| null | Only in `url` files, without `replacement`. `{ "intervalHours": N }` with N in 6, 12, 24, 48, 72, 168, 336 or 720; `null` turns it off. On another type it answers `422`. |
| `replacement` | object | The new content. A single type: |
| `replacement.type` | string | `text`, `url`, `file` (base64 up to 1 MiB) or `upload` (up to 50 MiB). |
| `replacement.text` | string | With `text`: up to 1 MiB. |
| `replacement.url` | string | With `url`: public, `http` or `https`. |
| `replacement.fileName`, `replacement.contentType` | string | With `file` and `upload`. |
| `replacement.contentBase64` | string | With `file`. |
| `replacement.byteSize` | integer | With `upload`: the exact size in bytes, from 1 to 52,428,800. |

Inside `replacement`, the fields of its type are required.

## Response

### Data change

`200 OK` with the file:

```json
{
  "status": "success",
  "data": {
    "fileId": "fH3kL9mQ2xR7",
    "title": "Return policies",
    "description": "Deadlines, conditions and exceptions for returning a product.",
    "kind": "url",
    "lifecycle": "available",
    "activeVersionId": "vr_2Lp9Qs",
    "pipelineStatus": "ready",
    "latestUploadId": "up_4Tn8Vb2Kc1",
    "attachmentCount": 2,
    "createdAt": "2026-10-30T16:02:11.000Z",
    "updatedAt": "2026-11-01T11:20:03.000Z",
    "sourceUrl": "https://acme.com/policies/returns",
    "refresh": {
      "intervalHours": 168,
      "nextRunAt": "2026-11-08T11:20:03.000Z",
      "lastRunAt": "2026-11-01T10:12:45.000Z",
      "lastResult": "unchanged",
      "lastError": null
    },
    "tags": [],
    "fileName": null,
    "contentType": null,
    "byteSize": 3420
  }
}
```

The fields are those of [Get a file](/api-reference/files/get#response-fields).

### Replacement

`202 Accepted`, like [Create a file](/api-reference/files/create#response-fields) but with `link: null` (connections do not change). With `upload` it also has `upload` next to `data`, like [Upload a file](/api-reference/files/upload#response-fields):

```json
{
  "status": "success",
  "data": {
    "accepted": true,
    "fileId": "fH3kL9mQ2xR7",
    "uploadId": "up_7Wc2Np4Lz8",
    "link": null,
    "statusUrl": "/v1/files/fH3kL9mQ2xR7/jobs/up_7Wc2Np4Lz8"
  }
}
```

Read the [processing](/api-reference/files/processing) until `terminal` is `true`. With `ready`, all agents that had the connection active use the new content. With `failed`, they keep the previous one.

## Errors

| Status | `details.code` | When |
|--------|----------------|------|
| `400` | `INVALID_INPUT` | You sent no field, mixed types in `replacement` or a value is not valid. |
| `403` | `RESOURCE_NOT_ACCESSIBLE` | You do not have Integrations nor can you edit all the agents that use it. |
| `409` | `FILE_JOB_IN_PROGRESS` | There is already an open processing on this file. Wait for it to finish. |
| `410` | `FILE_DELETED` | The file was already deleted. |
| `413` | `SIZE_LIMIT_EXCEEDED` | The replacement is over the limit (1 MiB inline or 50 MiB in `upload`). |
| `422` | `INVALID_INPUT` | `refresh` on a file that is not `url` (`details.fields: ["refresh"]`). |
| `422` | `INVALID_CONTENT_TYPE` | The replacement document's type is not supported or does not match. |
| `429` | `QUOTA_EXCEEDED` | Replacement with 30 open processings in the workspace. |
| `429` | `STORAGE_LIMIT_EXCEEDED` | The workspace reached its storage limit. |

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

## Notes

- **In the SDK:** use `platic.files.update(fileId, ...)` to change title, description or `refresh`, and `platic.files.replace(fileId, ...)` to replace content (if you pass a document over 1 MiB, the SDK opens the upload session automatically).
- **Replacing changes the type.** The file takes the type of the new content. Replacing it with another page (`url`) changes `sourceUrl` and keeps `refresh`. Replacing it with text or a document removes `sourceUrl` and `refresh`: it is no longer read from the page.
- **There is no history.** The previous content is discarded when the new one is ready. To go back, replace it again.
- A title or description you set replaces the AI-generated one and no longer changes by itself.
- To re-read the same page or the same document, without changing it, use [Reprocess a file](/api-reference/files/reprocess).
