> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qontext.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Updating content

> Replace file content safely and handle concurrent edits and changes awaiting review.

Read the file before editing it, then send the full new content together with the version you read.

## Read the base version

Call [Get a file](/api-docs/files/get-file). Keep its `content` and `lastChangeId` together: they represent the version your edit starts from.

## Submit the new content

Replace the example IDs with values from your file:

```bash theme={null}
curl --fail-with-body -X PUT \
  https://api.qontext.ai/v1/files/doc_9f2k1x8b3m7q0v/content \
  -H "Authorization: Bearer $QONTEXT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "baseChangeId": "chg_7t4p2w9c1n6s8k",
    "content": "# Hello\n\nUpdated with the Qontext API."
  }'
```

`baseChangeId` must be the `lastChangeId` of the version you edited. Sending a newer ID with content based on an older read loses that relationship.

## Handle the outcome

| Status         | Meaning                                                                                                   | Next step                                                                          |
| -------------- | --------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| `200`          | The update was accepted. If another edit changed different sections, the versions may have been combined. | Keep the returned `content` and `file.lastChangeId` as the base for the next edit. |
| `202`          | The change is in review. The submitted content has not replaced the live file.                            | Record the change ID and resolve it in the app. Do not resubmit the same change.   |
| `4xx` or `5xx` | The request failed.                                                                                       | Inspect the error `code` and follow [Errors and limits](/api-docs/errors).         |

<Warning>
  A successful HTTP status does not always mean content was updated. Handle `202` separately from `200`.
</Warning>

A `202` response looks like this:

```json theme={null}
{
  "object": "change",
  "id": "chg_7t4p2w9c1n6s8k",
  "status": "in_review",
  "reason": "conflict",
  "fileIds": ["doc_9f2k1x8b3m7q0v"],
  "createdAt": "2026-08-01T14:03:00.000Z"
}
```

`reason` is `conflict` when edits cannot be combined automatically, or `protected` when protection requires review. `protected` takes precedence if both apply. See [Change reviews](/features/change-reviews) for resolving the change.

## Rename, move, or protect

Use [Update a file](/api-docs/files/update-file) for metadata changes. Send exactly one field per request: `name`, `parentId`, or `protected`. Content replacement uses its own endpoint.

Changing `protected` requires Full access. A key inheriting an owner’s or admin’s permissions can perform this operation. Directly assigned Can read or Can edit permissions do not allow it; use a permitted inheriting key or ask a member with Full access to change protection in the app. See [Access management](/features/access-management#access-controls-for-api-keys).

## Recover after an interrupted request

If the connection closes before a response arrives, the write may already have been processed. Inspect the live file and any changes in review before submitting again. The public API does not provide an idempotency-key parameter.
