On this page
documents.upload
Upload a knowledge document
Request
POST /api/v1/documents
- MCP:
documents_upload - SDK:
client.documents.upload(SDK path arguments usepath; MCP usesparams). - Minimum API key role: member.
- Idempotency: required_header. Send an
Idempotency-Keyheader; MCP usesidempotency_key. Reuse it after an unknown outcome.
Use the request schema below. Read IDs from earlier operation results.
Input schema
json
{
"parameters": [
{
"name": "Idempotency-Key",
"in": "header",
"required": true,
"schema": {
"type": "string",
"minLength": 1,
"maxLength": 256
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/DocumentsUploadRequest"
}
}
}
}
}
Responses
json
{
"201": {
"description": "Upload a knowledge document",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Document"
}
}
}
},
"4XX": {
"description": "Typed error (ApiError)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiError"
}
}
}
},
"5XX": {
"description": "Typed error (ApiError)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiError"
}
}
}
}
}
Referenced schemas
json
{
"components": {
"schemas": {
"DocumentsUploadRequest": {
"type": "object",
"properties": {
"title": {
"type": "string",
"minLength": 1,
"maxLength": 512
},
"source_name": {
"type": "string",
"minLength": 1,
"maxLength": 512
},
"media_type": {
"type": "string",
"enum": [
"text/plain",
"text/markdown",
"text/html",
"application/pdf"
]
},
"content": {
"anyOf": [
{
"type": "object",
"properties": {
"encoding": {
"type": "string",
"enum": [
"utf8"
]
},
"text": {
"type": "string",
"minLength": 1,
"maxLength": 2000000
}
},
"required": [
"encoding",
"text"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"encoding": {
"type": "string",
"enum": [
"base64"
]
},
"data": {
"type": "string",
"minLength": 4,
"maxLength": 14000000,
"pattern": "^[A-Za-z0-9+/]+={0,2}$"
}
},
"required": [
"encoding",
"data"
],
"additionalProperties": false
}
]
}
},
"required": [
"title",
"source_name",
"media_type",
"content"
],
"additionalProperties": false
},
"Document": {
"type": "object",
"properties": {
"document_id": {
"type": "string",
"format": "uuid"
},
"title": {
"type": "string",
"minLength": 1,
"maxLength": 512
},
"source_name": {
"type": "string",
"minLength": 1,
"maxLength": 512
},
"media_type": {
"type": "string",
"enum": [
"text/plain",
"text/markdown",
"text/html",
"application/pdf"
]
},
"byte_size": {
"type": "integer",
"minimum": 0
},
"sha256": {
"type": "string",
"pattern": "^[a-f0-9]{64}$"
},
"state": {
"type": "string",
"enum": [
"uploaded",
"indexing",
"ready",
"failed",
"deleting"
]
},
"created_at": {
"type": "string",
"format": "date-time"
},
"expires_at": {
"allOf": [
{
"type": "string",
"format": "date-time"
}
],
"nullable": true
}
},
"required": [
"document_id",
"title",
"source_name",
"media_type",
"byte_size",
"sha256",
"state",
"created_at",
"expires_at"
],
"additionalProperties": false
},
"ApiError": {
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string",
"enum": [
"unauthenticated",
"forbidden",
"not_found",
"conflict",
"invalid_request",
"idempotency_conflict",
"policy_denied",
"capability_unavailable",
"provider_unavailable",
"knowledge_unavailable",
"publication_invalid",
"run_not_active",
"rate_limited",
"outcome_unknown",
"internal"
]
},
"message": {
"type": "string"
},
"retryable": {
"type": "boolean"
},
"outcome": {
"type": "string",
"enum": [
"none",
"unknown"
]
},
"details": {
"type": "object",
"additionalProperties": {}
}
},
"required": [
"code",
"message",
"retryable",
"outcome"
],
"additionalProperties": false
}
},
"required": [
"error"
],
"additionalProperties": false
}
}
}
}
Errors and recovery
See API error handling and Troubleshooting.
Related guides
Content version 1be6f2b8Markdown source