Skip to main content
PATCH
Update a file in a knowledge folder
Updates an existing file (attachment) in a Knowledge base by replacing it with a new version. The old file is removed and the new file is processed and embedded.

Before You Start

  • API key scope: Requires an API key with the KNOWLEDGE_FOLDER_API scope. The API key itself needs the Editor role on the Knowledge base. See Share Knowledge bases with the API for setup instructions.
  • Knowledge bases: The Knowledge Folder API manages resources that appear as Knowledge bases in the Library.

Base URL

Dedicated deploymentsReplace api.langdock.com with <your-deployment-url>/api/public in all requests.

Request Format

This endpoint accepts multipart/form-data requests with the file attached.

Path Parameters

Form Fields

File size limits depend on the file type: 10 MB for plain text, Markdown, JSON, and VTT files; 30 MB for XML files; and 256 MB for other supported document types. See the supported file types reference for supported formats.

Examples

Update with cURL

Update with JavaScript

Update with Source URL

Response Format

Success Response (200 OK)

Example Response

File Validation Response (400 Bad Request)

If the replacement file fails validation, the API returns the reason in message:

Error Handling

Processing Status

After updating, the new file is processed asynchronously. Use the Retrieve Files endpoint to check processing status. The syncStatus field indicates the current state:
  • UPLOADING - File is being uploaded
  • UPLOADED - File is uploaded and queued for processing
  • EXTRACTING - Text is being extracted from the file
  • EMBEDDING - Embeddings are being generated
  • SYNCED - File is ready for search
  • ACTION_FAILED, EXTRACTION_FAILED, EMBEDDING_FAILED, TIMEOUT - Processing failed
Langdock intentionally blocks browser-origin requests to protect your API key and ensure your applications remain secure. For more information, please see our guide on API Key Best Practices.

Authorizations

Authorization
string
header
required

API key as Bearer token. Format "Bearer YOUR_API_KEY"

Path Parameters

folderId
string
required

The ID of the knowledge folder

Body

multipart/form-data
file
file

The new file to upload

url
string

URL that is shown to the user if the file is used in an answer

attachmentId
string

The ID of the attachment to update

Response

Attachment updated successfully