---
title: "Overwrite document body"
method: PUT
path: "/api/v1/documents/{id}/body"
tags: ["Documents"]
---

# Overwrite document body

`PUT /api/v1/documents/{id}/body`

## Request

- Base URL: `https://mdflow.cz`
- URL: `https://mdflow.cz/api/v1/documents/{id}/body`
- Auth: HTTP bearer

Replaces the markdown body of one document owned by the authenticated user while preserving metadata.

## Path parameters

- `id` string, uuid, required

## Request body

- UpdateDocumentBodyInput
  - `body` string, required: Markdown document body. UTF-8 encoded content must not exceed 512000 bytes.
  - `confirmEmpty` boolean: Must be true when body is an empty string. An empty body is otherwise refused with 400, so a client with a cleared or unloaded buffer cannot wipe a document silently.

## Response `200`

Updated document.

- Document
  - `id` string, uuid, required
  - `title` string, required
  - `folder_id` string, uuid, required
  - `is_public` boolean, required
  - `workspace_id` string, uuid, required: The workspace this document belongs to (via its folder).
  - `path` PathSegment[], required: Full path from the workspace root down to this document, workspace first, document last.
    - `id` string, uuid, required
    - `name` string, required
    - `type` 'workspace' | 'folder' | 'document', required
  - `path_string` string, required: Path segment names joined by " / ".
  - `body` string, required: Markdown document body.
  - `compounded_description` string, required: Labeled cascade of descriptions from the workspace down through each ancestor folder to this document's folder. Empty string when nothing in the chain has a description.
  - `created_at` string, date-time, required
  - `updated_at` string, date-time, required

## Other responses

- `400`: Request body was malformed or failed validation.
- `401`: Missing, malformed, invalid, or revoked bearer token. The body includes a `message` field with guidance for authenticating, and the response carries a `WWW-Authenticate` challenge.
- `403`: The bearer token is valid but its owner cannot use the API. Agent control (REST + MCP) requires an MDflow Pro plan, so a token owned by a non-Pro account returns 403 on every endpoint. POST /api/v1/documents additionally returns 403 when the account reaches its document limit. The body includes a `message` field with guidance.
- `404`: Document was not found or is not owned by the authenticated user.
- `429`: The token or authenticated user exceeded a 60 requests per minute rate limit.
- `500`: Unexpected server error.

---

[API](https://skmtc.dev/mdflow/apis/mdflow-public-api.md) · [All operations](https://skmtc.dev/mdflow/apis/mdflow-public-api/llms.txt) · [OpenAPI document](https://skmtc.dev/mdflow/apis/mdflow-public-api/revisions/3691fc5d1688?raw)
