Rag Up
Documentação Entrar Criar conta

API Reference

Everything you need to integrate with RagUp

Get your API Key

Quick Start

Authenticate, upload documents, and start querying your knowledge base in minutes.

Base URL

Authentication

All API requests require an x-api-key header. Get your key from API Keys.

Header
x-api-key: YOUR_API_KEY

Folders

Organize your documents into folders. Each folder scopes the RAG search — queries within a folder only search documents in that folder.

POST /api/v1/folders
curl -X POST ${baseUrl}/folders \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"name": "Contratos", "description": "Documentos contratuais"}'
GET /api/v1/folders

Returns all active folders for the authenticated user.

POST /api/v1/documents/upload

Upload a document (PDF, TXT, MD, Word .doc/.docx, or CSV). The file is processed asynchronously — text is extracted, chunked, and embedded for RAG queries. Returns 202 Accepted immediately.

Processing Pipeline

Upload
Extract
Chunk
Embed
Ready

Parameters (multipart/form-data)

Field Type Required Description
file binary required PDF, TXT, Word (.doc, .docx), or CSV. Max size set by server (env MAX_UPLOAD_SIZE, in MB).
folderId UUID required Target folder ID
metadata JSON string optional Custom key-value metadata for filtering
linkedDocumentIds JSON string (UUID array) optional Link this document to existing documents. Array of UUIDs. Creates edges in the document graph.
ups JSON string (string array) optional Auto-link groups. Documents with the same UP value are automatically linked after processing. Example: ["projeto-x", "cliente-acme"]

Example

Response 202 Accepted

JSON
{
  "message": "Document uploaded and queued for processing",
  "document": {
    "id": "d1e2f3a4-b5c6-...",
    "fileName": "document.pdf",
    "status": "processing",
    "folderId": "f47ac10b-...",
    "ups": ["projeto-x", "cliente-acme"]
  },
  "jobId": "job-uuid",
  "checkStatusUrl": "/api/v1/queue/jobs/job-uuid"
}

Polling: Check GET /api/v1/documents/:id until status changes to "ready". Only then can you query the document.

Document Graph

Documents in a folder can be linked to each other, forming a knowledge graph. Links are created during upload via linkedDocumentIds or ups (auto-link groups), or manually via the graph API. The graph helps AI agents understand document relationships.

UPs (auto-link groups): Pass ups: ["projeto-x"] on upload. The worker automatically links this document to all other documents in the same folder that share the same UP. No need to know document IDs upfront. See upload docs.

REST API

GET /api/v1/folders/:id/graph

Returns graph structure: nodes (documents) + edges (links).

POST /api/v1/folders/:id/graph/links

Create a link between two documents. Body: {"sourceDocumentId": "...", "targetDocumentId": "..."}.

DELETE /api/v1/folders/:id/graph/links/:linkId

Remove a link between documents.

GET /api/v1/folders/:id/graph/nodes/:documentId/chunks

Read content chunks of a specific graph node.

Example — Get graph and read linked document
# 1. Get the graph
curl ${baseUrl}/folders/FOLDER_UUID/graph   -H "x-api-key: YOUR_API_KEY"

# 2. Read chunks of a linked document
curl ${baseUrl}/folders/FOLDER_UUID/graph/nodes/DOC_UUID/chunks   -H "x-api-key: YOUR_API_KEY"

MCP Integration

Connect remote LLMs, AI agents, or MCP clients to query your RAG via the Model Context Protocol. Uses the same authentication (API key) and rate limits as the REST API.

Endpoint

POST

Authentication

Use header x-api-key: YOUR_API_KEY (rag-service only).

Plano

Disponível apenas para planos Pro, Business e Enterprise.

Tool: rag_query

Query the RAG. Parameters: question (required), folderId, filters, topK.

Tool: rag_list_folders

List all folders. No parameters. Returns folders array with id, name, description.

Tool: unlink_documents

Remove a link between two documents. Parameters: folderId, sourceDocumentId, targetDocumentId.

Tool: rag_graph_explore

Explore document relationships in a folder. Parameters: folderId (required). Returns nodes (documents with chunk counts) + edges (links).

Tool: rag_read_document

Read content chunks of one or more documents. Parameters: folderId (required), documentIds[] (required, 1-10 UUIDs). Returns up to 50 chunks per document.

Example — Full agentic flow

cURL
# 1. Discover folders
curl -X POST ${baseUrl}/mcp \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "rag_list_folders",
      "arguments": {}
    }
  }'

# 2. Explore document relationships in a folder
curl -X POST ${baseUrl}/mcp \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 2,
    "method": "tools/call",
    "params": {
      "name": "rag_graph_explore",
      "arguments": { "folderId": "FOLDER_UUID" }
    }
  }'

# 3. Read content of linked documents
curl -X POST ${baseUrl}/mcp \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 3,
    "method": "tools/call",
    "params": {
      "name": "rag_read_document",
      "arguments": {
        "folderId": "FOLDER_UUID",
        "documentIds": ["DOC_UUID_1", "DOC_UUID_2"]
      }
    }
  }'

# 4. Query the RAG for answers
curl -X POST ${baseUrl}/mcp \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 4,
    "method": "tools/call",
    "params": {
      "name": "rag_query",
      "arguments": { "question": "What is the contract duration?", "folderId": "FOLDER_UUID" }
    }
  }'

Response format

JSON-RPC 2.0. Tool result contains answer, sources, tokens, confidence, conversationId.

Rate limit

Same as REST API (per plan). Headers: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset.

Error codes (JSON-RPC)

CodeMeaning
-32001Missing or invalid API key
-32002Forbidden (host restriction)
-32003MCP disponível a partir do plano Pro
-32005Rate limit exceeded
-32600Request entity too large (max 256KB)
-32603Internal server error
POST /api/v1/rag/ask
Stateless Each call creates an individual audit record

Ask a question and get relevant document chunks (retrieve-only, default) or an AI-generated answer (when synthesize: true). By default the endpoint only runs vector similarity search and returns sources and confidence — no LLM call.

Stateless endpoint: Every call creates a new conversation record for audit trail. For multi-turn chat with conversation history, use Conversations API instead.

Default (retrieve-only)

Question
Vector Search
Sources + confidence

With synthesize: true

Question
Vector Search
LLM (gpt-5)
Answer + Sources

Body (application/json)

Field Type Required Description
question string required Your question (1-10,000 chars)
folderId UUID optional Restrict search to a specific folder
filters array optional Metadata filters (max 10). Each: { field, operator, value }
synthesize boolean optional If true, runs the LLM and returns answer, tokens, conversationId. Omitted or false = retrieve-only (sources + confidence).
Filter Operators
Operator Description Example
=Equal{"field":"status","operator":"=","value":"active"}
!=Not equal{"field":"status","operator":"!=","value":"archived"}
>Greater than{"field":"amount","operator":">","value":1000}
containsContains (case-insensitive){"field":"client","operator":"contains","value":"abc"}
inIn list{"field":"type","operator":"in","value":["a","b"]}
betweenRange{"field":"amount","operator":"between","value":[1000,5000]}

Example

Response 200 OK

JSON

Default (retrieve-only):

{
  "sources": [
    { "chunkId": "...", "content": "...", "distance": 0.12, "documentId": "..." }
  ],
  "confidence": 0.88
}

With synthesize: true: adds answer, tokens, conversationId. With x-api-key, sources may be omitted in the synthesized response; with JWT (dashboard), sources is included.

Response Fields
sources Retrieved chunks (chunkId, content, distance, documentId). Always present.
confidence Heuristic retrieval confidence score (0-1). Higher = better match between question and retrieved chunks. Always present.
answer The AI-generated answer. Only when synthesize: true.
tokens Token usage (prompt + completion). Only when synthesize: true.
conversationId Inbox conversation ID (message history). Only when synthesize: true.

Conversations (Multi-turn)

Stateful

For chat interfaces that need conversation history. Create a conversation once, then send multiple questions — the LLM receives the full message history for context-aware answers.

Step 1 — Create a conversation

POST /api/v1/conversations
curl -X POST ${baseUrl}/conversations \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"title": "Chat session", "folderId": "FOLDER_UUID"}'

Returns a conversation object with id. Use this ID for subsequent questions.

Step 2 — Send questions

POST /api/v1/conversations/:id/ask
curl -X POST ${baseUrl}/conversations/CONVERSATION_ID/ask \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"question": "What are the delivery deadlines?"}'

The LLM receives the last 10 messages as context. Supports SSE streaming via Accept: text/event-stream header.

When to use Conversations vs RAG Ask

Chat interfaces with multi-turn history
Assistants that need follow-up context
Single-shot API queries → use /rag/ask
Batch document retrieval → use /rag/ask

Webhooks

Pro+

Receive real-time notifications when events happen in your account. Configure endpoints to receive HTTP POST callbacks with event payloads.

POST /api/v1/webhooks/endpoints
curl -X POST ${baseUrl}/webhooks/endpoints \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"url": "https://your-app.com/webhook", "events": ["document.ready", "conversation.message.created"]}'
Event Description
document.readyDocument processed and ready for queries
document.errorDocument processing failed
conversation.createdNew conversation created
conversation.message.createdNew message in a conversation
scraping.completedWeb scraping finished successfully
scraping.errorWeb scraping failed

Deliveries are retried up to 5 times with exponential backoff. Each delivery includes an HMAC-SHA256 signature for verification.

Error Codes

Code Meaning Fix
400 Invalid request body or params Check required fields and types
401 Invalid or missing API key Verify x-api-key header
403 Plan quota exceeded Upgrade plan or wait for monthly reset
404 Resource not found Check folderId/documentId
429 Rate limit exceeded Wait for Retry-After seconds

Rate Limits

Plan Requests/min Queries/month Documents
Free201503
Starter601,50030
Pro1004,000150
Business3008,000500
Enterprise1,000UnlimitedUnlimited

Rate limit headers are included in every response: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset