# Edit File Text (/docs/api-reference/update_file_content)

`PATCH /v1/files/{file_id}/content` · operation `update_file_content`

Saves a new version of a text File from content (the whole new text) or edits (exact old_text to new_text replacements, in order; each old_text must match one place). Needs edit access and the current revision. If people have it open, it lands live for them. Every Room with the File shows the new version.

**Sign-in:** a signed-in person's access token (`Authorization: Bearer …`), which AI apps get through MCP sign-in; or a Workspace API key in the `X-SMB-API-Key` header.

### Path parameters

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `file_id` | string | yes | Stable File ID. |

### Headers

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `SMB-Workspace-Id` | string (uuid) | yes | Workspace where this operation runs. Required for user tokens and Workspace API keys. |
| `Idempotency-Key` | string | yes |  |

### Request body (JSON)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `expected_revision` | integer | yes |  |
| `content` | string | no | The whole new text, up to 1 MiB. Or use edits. |
| `edits` | array of object | no | Applied in order. Copy old_text exactly, including spaces and line breaks. |
| `edits[].old_text` | string | yes |  |
| `edits[].new_text` | string | yes |  |
| `summary` | string | no | Optional: what changed, in a few words. Shown with the version and in Room activity. |

Send exactly one of these shapes:

1. Send `content`.
2. Send `edits`.

### Response

**200** Successful authorized response.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `file` | object | yes |  |
| `file.file_id` | string | yes | Stable File ID. |
| `file.business_id` | string or null | yes | Associated Business, or null for a Workspace File. |
| `file.name` | string | yes |  |
| `file.description` | string or null | yes |  |
| `file.classification` | one of `financial`, `legal`, `operational`, `marketing`, `other`, `null` | yes |  |
| `file.tags` | array of string | yes |  |
| `file.origin` | one of `upload`, `artifact`, `legacy_document` | yes |  |
| `file.lifecycle` | one of `active`, `archived` | yes |  |
| `file.current_version` | object or null | yes |  |
| `file.revision` | integer | yes |  |
| `file.created_at` | string (date-time) | yes |  |
| `file.updated_at` | string (date-time) | yes |  |
| `file.archived_at` | string (date-time) or null | yes |  |
| `file.access_level` | one of `view`, `edit`, `full_access` | yes |  |
| `new_version` | object | yes |  |
| `new_version.file_version_id` | string | yes | Immutable File version ID. |
| `new_version.version_number` | integer | yes |  |
| `new_version.content_type` | string | yes |  |
| `new_version.size_bytes` | integer | yes |  |
| `new_version.sha256` | string or null | yes |  |
| `new_version.processing_status` | one of `pending_upload`, `processing`, `ready`, `quarantined`, `failed` | yes |  |
| `new_version.processing_error` | string or null | no | Upload processing failure code, when available. |
| `new_version.summary` | string or null | no | What changed in this version, when the author said. |
| `new_version.created_by` | object | no |  |
| `new_version.created_at` | string (date-time) | yes |  |
| `new_version.ready_at` | string (date-time) or null | yes |  |
| `new_version.protection` | object or null | no | What SMB's check for private numbers found: state, reason, items (kind and page, never a number), hidden. Null if unchecked. |
| `new_version.redacted_from` | string or null | no | Copy's original version. |
| `new_version.redacted_copy` | string or null | no | Original's redacted copy. |
| `action_receipt` | object | yes |  |
| `action_receipt.receipt_id` | string (uuid) | yes |  |
| `action_receipt.command_id` | string (uuid) | yes |  |
| `action_receipt.operation` | string | yes |  |
| `action_receipt.workspace_id` | string (uuid) | yes |  |
| `idempotent_replay` | boolean | yes |  |
| `request_id` | string | yes |  |

### Errors

- `400` The request is invalid.
- `401` Authentication is required.
- `403` The caller is not authorized.
- `404` The resource was not found.
- `409` The resource revision or idempotency input conflicts.
- `413` The request body is too large.
- `415` The request must be JSON.
- `422` Required evidence is missing.
- `429` Rate limit reached; honor Retry-After.
- `500` The request could not be completed.
- `502` A dependency returned an invalid response.
- `503` The service is temporarily unavailable.

### Example

```bash
curl --request PATCH "https://api.smb.co/v1/files/$FILE_ID/content" \
  --header "Authorization: Bearer $ACCESS_TOKEN" \
  --header "SMB-Workspace-Id: $WORKSPACE_ID" \
  --header "Idempotency-Key: $IDEMPOTENCY_KEY" \
  --header "Content-Type: application/json" \
  --data '{"content":"…"}'
```