> For the complete documentation index, see [llms.txt](https://docs.ibexa.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ibexa.ai/developers/rest-api/knowledge-base/update-document-content.md).

# Update Document Content

Replace a document node's body in the caller's organisation.

Only valid for `document` nodes (400 otherwise, and 404 if the node does not exist). `source_file_id`, when given, must reference an existing file in the caller's organisation (400 otherwise). Returns the updated document.

```json
{"openapi":"3.1.0","info":{"title":"Ibexa Agentic Marketing Platform","version":"0.1.0"},"security":[{"OAuth2PasswordBearer":[]}],"components":{"securitySchemes":{"OAuth2PasswordBearer":{"type":"oauth2","flows":{"password":{"scopes":{},"tokenUrl":"/api/v1/login/access-token"}}}},"schemas":{"UpdateDocumentContentPayloadSchema":{"properties":{"markdown":{"type":"string","title":"Markdown","default":""},"source_file_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Source File Id"}},"type":"object","title":"UpdateDocumentContentPayloadSchema","description":"Request schema for replacing a document's body.\n\nPUT semantics — the body is replaced wholesale; an empty payload clears it\n(an empty document is allowed). Only valid for `document` nodes."},"KnowledgeDocumentResponseSchema":{"properties":{"id":{"type":"integer","title":"Id"},"organisation_id":{"type":"integer","title":"Organisation Id"},"name":{"type":"string","title":"Name"},"slug":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Slug"},"parent_id":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Parent Id"},"path":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Path"},"summary":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Summary"},"citation_count":{"type":"integer","title":"Citation Count"},"metadata":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Metadata"},"markdown":{"type":"string","title":"Markdown"},"source_file_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Source File Id"},"parse_status":{"$ref":"#/components/schemas/DocumentParseStatus"},"parse_error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Parse Error"},"publish_error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Publish Error"},"published_version_id":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Published Version Id"},"version_number":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Version Number"},"status":{"anyOf":[{"$ref":"#/components/schemas/VersionStatus"},{"type":"null"}]},"embedding_status":{"anyOf":[{"$ref":"#/components/schemas/EmbeddingStatus"},{"type":"null"}]},"created_by":{"anyOf":[{"$ref":"#/components/schemas/KnowledgeNodeUserSchema"},{"type":"null"}]},"updated_by":{"anyOf":[{"$ref":"#/components/schemas/KnowledgeNodeUserSchema"},{"type":"null"}]},"created_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Created At"},"updated_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Updated At"}},"type":"object","required":["id","organisation_id","name","slug","parent_id","path","summary","citation_count","metadata","markdown","source_file_id","parse_status","parse_error","publish_error","published_version_id","version_number","status","embedding_status","created_by","updated_by","created_at","updated_at"],"title":"KnowledgeDocumentResponseSchema","description":"Response schema for a document's full view (node metadata + body).\n\nThe body shown is the published version's, or the latest draft's when nothing\nis published yet. `published_version_id` names the live version (null for a\ndraft-only document); `version_number`/`status`/`embedding_status` describe\nthe version whose body is returned, so a client can tell live from draft.\n`publish_error` is set when that version's last publish was abandoned and it\nwas returned to an editable state — null whenever the last attempt succeeded\nor none has been made."},"DocumentParseStatus":{"type":"string","enum":["pending","processing","completed","failed"],"title":"DocumentParseStatus","description":"Lifecycle of a file-uploaded document's Markdown conversion.\n\nInline-authored documents are `COMPLETED` on creation (nothing to parse).\nA file upload starts `PENDING`, moves to `PROCESSING` when the background\ntask picks it up, then to a terminal `COMPLETED` or `FAILED`."},"VersionStatus":{"type":"string","enum":["draft","publishing","published","archived"],"title":"VersionStatus","description":"Publication state of a single knowledge-document version.\n\nA version is created `DRAFT` (editable, not live). Requesting publication\nmoves it to `PUBLISHING` (edit-locked) while its chunks are embedded; once\nthe embeddings are ready the pointer flip marks it `PUBLISHED` and the\npreviously published version becomes `ARCHIVED`. A rollback re-publishes an\n`ARCHIVED` version through the same `PUBLISHING` state. A failed go-live\nreturns the version to its pre-attempt state: a failed publish reverts to\n`DRAFT`, a failed rollback reverts to `ARCHIVED` (see `PublishOrigin`).\n\nLegal transitions are enforced by the `KnowledgeDocumentVersion` entity (its\nstatus setter is a state machine); this enum only names the states. Only\n`knowledge_document.published_version_id` decides what retrieval serves —\nthe status is descriptive history metadata for the UI."},"EmbeddingStatus":{"type":"string","enum":["pending","ready","failed"],"title":"EmbeddingStatus","description":"Progress of embedding a version's chunks under the org's current model.\n\nInformational only: retrieval never depends on it (search joins the actual\nembedding rows, so an unembedded version simply yields no hits). `PENDING`\nuntil a publish embeds the version, `READY` once every chunk is embedded,\n`FAILED` if embedding gave up (the version then reverts to draft)."},"KnowledgeNodeUserSchema":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"email":{"type":"string","title":"Email"},"full_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Full Name"},"avatar_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Avatar Url"}},"type":"object","required":["id","email","full_name"],"title":"KnowledgeNodeUserSchema","description":"Basic info about a node's creator/updater."}}},"paths":{"/api/v1/knowledge-base/nodes/{node_id}/document":{"put":{"tags":["knowledge-base","public"],"summary":"Update Document Content","description":"Replace a document node's body in the caller's organisation.\n\nOnly valid for `document` nodes (400 otherwise, and 404 if the node does\nnot exist). `source_file_id`, when given, must reference an existing file\nin the caller's organisation (400 otherwise). Returns the updated document.","operationId":"knowledge-base-update_document_content","parameters":[{"name":"node_id","in":"path","required":true,"schema":{"type":"integer","title":"Node Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateDocumentContentPayloadSchema"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KnowledgeDocumentResponseSchema"}}}},"400":{"description":"Invalid request payload or parameters","content":{"application/json":{}}},"401":{"description":"User not authenticated","content":{"application/json":{}}},"403":{"description":"User lacks permission","content":{"application/json":{}}},"404":{"description":"Resource not found or user has no permission to access it","content":{"application/json":{}}}}}}}}
```
