Skip to content

Documents API

The Documents API lets you upload, manage and query documents indexed in the platform. Every document goes through an automatic processing pipeline that makes it available for semantic search.

Upload

Single upload

POST /api/documents/upload
Content-Type: multipart/form-data
FieldTypeRequiredDescription
fileFileYesDocument to upload
topicIdstringNoDestination category
descriptionstringNoDocument description
confidentialitystringNoLevel: public, internal, confidential

Example:

bash
curl -X POST https://api.queria.pro/api/documents/upload \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..." \
  -F "file=@supply_contract.pdf" \
  -F "topicId=topic_123" \
  -F "description=Annual contract supplier ABC" \
  -F "confidentiality=internal"

Response:

json
{
  "success": true,
  "data": {
    "id": "doc_8f3a2b1c",
    "name": "supply_contract.pdf",
    "mimeType": "application/pdf",
    "size": 2458624,
    "status": "UPLOADED",
    "topicId": "topic_123",
    "message": "Document uploaded, processing started",
    "createdAt": "2026-03-04T10:30:00Z"
  }
}

Multiple upload

POST /api/documents/upload-multiple
Content-Type: multipart/form-data

Supports up to 10 files at once. Each file is processed in parallel.

FieldTypeDescription
files[]File[]Document array (max 10)
topicIdstringCommon category for all files

Response:

json
{
  "success": true,
  "data": {
    "uploaded": 3,
    "documents": [
      { "id": "doc_001", "name": "File1.pdf", "status": "UPLOADED" },
      { "id": "doc_002", "name": "File2.docx", "status": "UPLOADED" },
      { "id": "doc_003", "name": "File3.xlsx", "status": "UPLOADED" }
    ]
  }
}

Import from URL

POST /api/documents/upload-url
json
{
  "url": "https://example.com/docs/report-2025.pdf",
  "topicId": "topic_123",
  "description": "Annual report downloaded from the portal"
}

Size limits

FormatMaximum size
PDF50 MB
DOCX, XLSX, PPTX25 MB
TXT, CSV, MD10 MB
HTML5 MB

Max simultaneous uploads: 10 files per request. Rate limit: 10 uploads per minute.

GET /api/documents

Query parameters:

ParameterTypeDefaultDescription
pagenumber1Current page
limitnumber20Results per page (max 100)
searchstring-Search in name and description
statusstring-Filter by status: UPLOADED, PROCESSING, VECTORIZED, ERROR
topicIdstring-Filter by category
mimeTypestring-Filter by file type
sortstringcreatedAtSort field: name, createdAt, updatedAt
orderstringdescDirection: asc or desc

Example:

bash
curl -X GET "https://api.queria.pro/api/documents?status=VECTORIZED&topicId=topic_123&limit=10" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..."

Response:

json
{
  "success": true,
  "data": {
    "items": [
      {
        "id": "doc_8f3a2b1c",
        "name": "supply_contract.pdf",
        "originalName": "supply_contract.pdf",
        "mimeType": "application/pdf",
        "size": 2458624,
        "status": "VECTORIZED",
        "chunkCount": 47,
        "topicId": "topic_123",
        "topicName": "Contracts",
        "createdAt": "2026-03-04T10:30:00Z",
        "updatedAt": "2026-03-04T10:31:15Z"
      }
    ],
    "pagination": { "page": 1, "limit": 10, "total": 156, "totalPages": 16 }
  }
}

Document details

Document information

GET /api/documents/:id
json
{
  "success": true,
  "data": {
    "id": "doc_8f3a2b1c",
    "name": "supply_contract.pdf",
    "originalName": "supply_contract.pdf",
    "mimeType": "application/pdf",
    "size": 2458624,
    "status": "VECTORIZED",
    "topicId": "topic_123",
    "topic": {
      "id": "topic_123",
      "name": "Contracts",
      "color": "#3B82F6"
    },
    "description": "Service supply contract",
    "chunkCount": 47,
    "pageCount": 12,
    "processingInfo": {
      "ocrUsed": false,
      "language": "en",
      "processingTime": 15234
    },
    "createdAt": "2026-03-04T10:30:00Z",
    "updatedAt": "2026-03-04T10:31:15Z"
  }
}

Document chunks

GET /api/documents/:id/chunks

Returns the indexed text fragments with their metadata.

json
{
  "success": true,
  "data": {
    "items": [
      {
        "id": "chk_001",
        "content": "Art. 1 - Subject of the contract. This agreement...",
        "chunkType": "ARTICLE",
        "chunkIndex": 0,
        "page": 1,
        "metadata": {
          "charCount": 680,
          "tokenCount": 180
        }
      }
    ],
    "pagination": { "page": 1, "limit": 20, "total": 47, "totalPages": 3 }
  }
}

Processing status

GET /api/documents/:id/status
json
{
  "success": true,
  "data": {
    "id": "doc_8f3a2b1c",
    "status": "PROCESSING",
    "currentStep": "EMBEDDING",
    "progress": 72,
    "steps": [
      { "name": "PARSING", "status": "completed", "duration": 1200 },
      { "name": "CHUNKING", "status": "completed", "duration": 800, "chunksCreated": 47 },
      { "name": "EMBEDDING", "status": "in_progress", "progress": 72 },
      { "name": "STORAGE", "status": "pending" }
    ]
  }
}

Document states

A document goes through the following states during processing:

UPLOADED --> PROCESSING --> VECTORIZED
                |
                +--> ERROR
StateDescription
UPLOADEDFile received, waiting for processing
PROCESSINGActive pipeline (parsing, chunking, embedding, storage)
VECTORIZEDProcessing complete, document available for search
ERRORError during processing

Pipeline phases: PARSING -> CHUNKING -> EMBEDDING -> STORAGE.

Management

Update metadata

PUT /api/documents/:id
json
{
  "topicId": "topic_789",
  "description": "Updated document description",
  "confidentiality": "confidential"
}

Delete document

DELETE /api/documents/:id

Removes the document, all associated chunks and vectors from the vector database.

Bulk delete

DELETE /api/documents
json
{
  "documentIds": ["doc_8f3a2b1c", "doc_4d5e6f7g", "doc_1a2b3c4d"]
}

Reprocess document

POST /api/documents/:id/reprocess

Restarts the processing pipeline. Useful after updates to chunking or embedding configuration.

json
{
  "success": true,
  "data": {
    "id": "doc_8f3a2b1c",
    "status": "PROCESSING",
    "message": "Reprocessing started"
  }
}

Download and preview

Original download

GET /api/documents/:id/download

Returns the original file with appropriate Content-Disposition headers.

Preview

GET /api/documents/:id/preview?page=1
json
{
  "success": true,
  "data": {
    "totalPages": 12,
    "currentPage": 1,
    "content": "Extracted page text...",
    "previewUrl": "/api/documents/doc_8f3a2b1c/preview-image?page=1"
  }
}

Document generation

Queria includes a template-based document generation engine.

Template list

GET /api/doc-engine/templates

Template schema

GET /api/doc-engine/templates/:id/schema

Returns the schema of the fields required for rendering.

Document rendering

POST /api/doc-engine/render
json
{
  "templateId": "tpl_report_standard",
  "data": {
    "title": "Q1 2026 Quarterly Report",
    "author": "Mario Rossi",
    "sections": [
      { "title": "Summary", "content": "..." },
      { "title": "Analysis", "content": "..." }
    ]
  },
  "format": "docx"
}

Returns the generated DOCX file as a direct download.

Common errors

CodeErrorDescription
400INVALID_FILE_TYPEUnsupported file format
413FILE_TOO_LARGEFile exceeds maximum size
422PROCESSING_ERRORError during document processing

Webhook (Coming Soon)

Document events for asynchronous notifications:

EventDescription
document.uploadedDocument uploaded
document.vectorizedProcessing completed
document.errorProcessing error

Queria - Document Intelligence con Cog-RAG