---
title: "Update a document"
method: PATCH
path: "/knowledge-bases/{id}/documents/{documentId}"
tags: ["Knowledge Base"]
---

# Update a document

`PATCH /knowledge-bases/{id}/documents/{documentId}`

## Request

- Base URL: `https://api.markcopy.ai/api/v1`
- URL: `https://api.markcopy.ai/api/v1/knowledge-bases/{id}/documents/{documentId}`
- Auth: API key in header `X-API-Key`

Update metadata (`sourceUrl`, `name`, `tags`) of an existing document without re-uploading its content. At least one field must be provided. Updating `tags` replaces the document's existing tags with the provided set.

## Path parameters

- `id` string, required
- `documentId` string, required

## Request body

- object
  - `sourceUrl` string, uri: New source URL for the document, used as the citation source in retrieval. Must be a valid HTTP or HTTPS URL.
  - `name` string: New name for the document.
  - `tags` string[]: Replaces the document's tags with this set. Tags are created automatically if they don't exist.
  - `mimeType` 'text/markdown' | 'text/plain' | 'text/html' | 'application/json': New declared format for the document (markdown, plain text, HTML, or JSON).

## Response `200`

Document updated.

- UpdatedDocument
  - `id` string: Unique document ID (prefixed with `doc_`).
  - `name` string: The document name after the update.
  - `sourceUrl` string, uri: The new source URL, present only when `sourceUrl` was updated.
  - `tags` string[]: The document's tags after the update, present only when `tags` was updated.
  - `mimeType` 'text/markdown' | 'text/plain' | 'text/html' | 'application/json': The document's declared format after the update, present only when `mimeType` was updated.
  - `updatedAt` string, date-time: Timestamp of when the document was last updated.

## Other responses

- `400`: Invalid or missing parameters.
- `401`: API key is missing, invalid, or expired.
- `404`: Document not found or not accessible with this API key.

---

[API](https://skmtc.dev/markcopy/apis/mark-api.md) - [All operations](https://skmtc.dev/markcopy/apis/mark-api/llms.txt) - [OpenAPI document](https://skmtc.dev/markcopy/apis/mark-api/revisions/93323d1697ae?raw)
