Skip to main content

API Reference

Base URL: http://localhost:9000/api/v1

All requests require an API key. On first startup the backend prints it to the logs and saves it to /data/api_key inside the container. To retrieve it:

ragpack logs backend | grep "Key:"

Pass it as a bearer token in every request:

export RAGPACK_API_KEY=rp_...

Collections

MethodPathDescription
GET/collectionsList all collections
POST/collectionsCreate a collection
GET/collections/:slugGet a collection
DELETE/collections/:slugDelete a collection and all its data
curl -X POST http://localhost:9000/api/v1/collections \
-H "Authorization: Bearer $RAGPACK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "My Docs"}'

Ingest

MethodPathDescription
POST/collections/:slug/ingestIngest a URL or file upload
# Ingest a URL
curl -X POST http://localhost:9000/api/v1/collections/my-docs/ingest \
-H "Authorization: Bearer $RAGPACK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"file_uri": "https://example.com/docs/guide"}'

# Upload a file
curl -X POST http://localhost:9000/api/v1/collections/my-docs/ingest \
-H "Authorization: Bearer $RAGPACK_API_KEY" \
-F "file=@./document.pdf"

Supported sources: https://, s3://, file uploads.
Supported formats: .txt, .md, .html, .pdf, .docx, .pptx, .xlsx

Query

MethodPathDescription
POST/collections/:slug/querySemantic or hybrid search
POST/collections/:slug/ragRetrieve chunks and generate an LLM answer
curl -X POST http://localhost:9000/api/v1/collections/my-docs/query \
-H "Authorization: Bearer $RAGPACK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "how do I configure authentication?", "top_k": 5}'

By default query runs hybrid search (vector + keyword, merged with weighted RRF). Pass vector_search_only: true to skip the keyword pass, filters for a MongoDB-style filter DSL over registered metadata fields, and hybrid_settings to override the RRF merge for that request:

curl -X POST http://localhost:9000/api/v1/collections/my-docs/query \
-H "Authorization: Bearer $RAGPACK_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "how do I configure authentication?",
"top_k": 5,
"filters": { "$and": [ { "category": "docs" }, { "score": { "$gte": 0.5 } } ] },
"hybrid_settings": { "semantic_weight": 0.7, "full_text_weight": 0.3, "rrf_k": 60 }
}'

Filter operators: $and, $or, $eq, $ne, $gt, $gte, $lt, $lte, $in, $nin, $exists, $like, $ilike (string fields), $contains/$containsAny/$containsAll (array fields).

Each matched chunk includes chunk_text, file_uri, vector_distance, and vector_similarity (0–100). When hybrid search ran, it also includes keyword_bm25_score, rrf_score, and rrf_score_normalized. rag returns the same chunk shape (as chunks) plus answer and formatted_prompt; it requires prompt_slug and model.

Documents

MethodPathDescription
GET/collections/:slug/documentsList ingested documents (paginated)
GET/collections/:slug/documents/:idGet a document
GET/collections/:slug/documents/:id/metadataGet a document's typed metadata field values
PATCH/collections/:slug/documents/:idUpdate name, extra_json, and/or metadata
DELETE/collections/:slug/documents/:idDelete a document and its chunks
GET/collections/:slug/documents/:id/chunksList all chunks

PATCH accepts any combination of name, extra_json (a JSON string), and metadata (a map merged into the collection's registered typed metadata fields — unregistered or mistyped keys are silently dropped):

curl -X PATCH http://localhost:9000/api/v1/collections/my-docs/documents/doc_123 \
-H "Authorization: Bearer $RAGPACK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "Q3 Report (final)", "metadata": {"status": "published"}}'

Every document route above is also mounted at the top level (/documents/:id, /documents/:id/chunks, /documents/:id/metadata) without a collection slug, resolving the collection from the document itself.

Jobs

MethodPathDescription
GET/collections/:slug/jobsList ingestion jobs (also at top-level /jobs)
GET/collections/:slug/jobs/:idGet a job
DELETE/collections/:slug/jobs/:idDelete a job

Jobs are the internal ingestion queue/audit trail — for tracking a document's ingest status, prefer GET /documents/:id (status: ingesting/complete/failed). Jobs are mainly useful for debugging stuck or failed async ingests.

Metadata fields

MethodPathDescription
POST/collections/:slug/metadata-fieldsRegister a typed metadata field
GET/collections/:slug/metadata-fieldsList registered metadata fields
DELETE/collections/:slug/metadata-fields/:nameRemove a metadata field

API keys

MethodPathDescription
GET/keysList API keys
POST/keysCreate an API key
DELETE/keys/:idDelete an API key

Keys carry two independent grant kinds, both required atomically at creation and both fail-closed (no grants = no access):

  • grants — per-collection access: {"collection_slug": "my-docs", "permission": "read" | "write" | "both"}. Omit collection_slug for a wildcard grant covering every collection, including ones created later.
  • admin_grants — instance-administration access, gated separately from collection content: {"resource_type": "keys" | "prompts" | "collections" | "*", "permission": "read" | "write" | "both"}.
# Scoped collection key
curl -X POST http://localhost:9000/api/v1/keys \
-H "Authorization: Bearer $RAGPACK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "ingestion-bot", "grants": [{"collection_slug": "my-docs", "permission": "write"}]}'

# Admin-only key (manages keys and prompts, no collection access)
curl -X POST http://localhost:9000/api/v1/keys \
-H "Authorization: Bearer $RAGPACK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "ops-admin", "admin_grants": [{"resource_type": "keys", "permission": "both"}, {"resource_type": "prompts", "permission": "both"}]}'

The plaintext key is only ever returned once, in the POST response.

Prompts

MethodPathDescription
GET/promptsList RAG prompt templates
POST/promptsCreate a prompt template
GET/prompts/:slugGet a prompt template
PATCH/prompts/:slugUpdate a prompt template
DELETE/prompts/:slugDelete a prompt template

Embedders and LLMs

MethodPathDescription
GET/embeddingsList registered embedding models and the default
GET/llmsList registered LLM models and the default