# updatedocument: RAG – Update Document in Knowledge Base

> updatedocument (RAG – Update Document in Knowledge Base) is a 1001fx API function in the group Knowledge bases (RAG): POST https://api.1001fx.com/rag/updatedocument, 1 credit per 1,000 tokens (minimum 1). It works as a ready-made module in Make or as a plain HTTP call.

Changes a document of a knowledge base (404 if it does not exist). With file, fileUrl or text the content is read again (1 credit per 1,000 tokens, 0 if unchanged; a larger or smaller document changes the storage until the end of the month, result.storageCredits); without, only title, sourceUrl, lastModified, author and metadata change (0 credits). Metadata are merged by default (null removes a key); metadataMode replace sets exactly the given ones.

- Group: Knowledge bases (RAG)
- Endpoint: `POST https://api.1001fx.com/rag/updatedocument`
- Authentication: header `X-API-KEY: YOURSECRETAPIKEY`
- Content type: multipart/form-data
- Credits: 1 credit per 1,000 tokens (minimum 1)
- Ready-made in: Make
- Docs: https://1001fx.com/functions/updatedocument

## Parameters

- `knowledgeBase` (string, required) – Knowledge base: Name or ID of the knowledge base, e.g. "Support FAQ" or support-faq (same knowledge base). rag/adddocument creates it if it does not exist.
- `documentId` (string, required) – Document ID: ID of the document (as given when adding it).
- `file` (file, optional) – File: The new version of the document. Either file or fileUrl.
- `fileUrl` (string, optional) – File URL: Public URL of the document. Either file, fileUrl or text.
- `text` (string, optional) – Text: The content as text (or Markdown). Either file, fileUrl or text.
- `title` (string, optional) – Title: Shown in the sources of rag/ask. Default: the title of the file or its name.
- `sourceUrl` (string, optional) – Source URL: Link to the original, e.g. in Google Drive – returned with the sources.
- `lastModified` (string, optional) – Last modified: ISO 8601, e.g. modifiedTime of the Drive file. Default: from the file (Last-Modified header, PDF/Office properties) or now.
- `author` (string, optional) – Author: Default: from the file properties.
- `useOcr` (boolean, optional, default `false`) – Use OCR: For scans and images: reads the document with OCR (6 credits per page on top, at most 8 pages).
- `metadata` (any, optional) – Metadata: Own key-value pairs; merged with the stored ones (null removes a key). Object {"department": "support", "tags": ["billing"]} or array [{"key": "year", "value": "2026", "type": "number"}] (type text, number, boolean or date). At most 50 keys and 8 KB.
- `metadataMode` (enum, optional, one of `merge`, `replace`, default `merge`) – Metadata mode: merge (default) or replace.

## Example: RAG – Update Document in Knowledge Base

```bash
curl -X POST 'https://api.1001fx.com/rag/updatedocument' \
  -H 'X-API-KEY: YOURSECRETAPIKEY'
```
