Skip to content

Sources API

Manage data sources and RAG search.

Endpoints

MethodEndpointDescription
GET/api/agents/{id}/sourcesList sources
POST/api/agents/{id}/sourcesCreate source
GET/api/agents/{id}/sources/searchSearch sources
GET/api/agents/{id}/sources/{sourceId}Get source
DELETE/api/agents/{id}/sources/{sourceId}Delete source

List Sources

bash
GET /api/agents/{id}/sources

Response

json
{
  "sources": [
    {
      "id": "source-123",
      "type": "file",
      "name": "Product Manual",
      "status": "ready",
      "chunks": 150,
      "created_at": "2024-12-01T00:00:00Z"
    }
  ]
}

Create Source

File Upload

bash
POST /api/agents/{id}/sources
Content-Type: multipart/form-data

-F "type=file"
-F "name=Product Manual"
-F "file=@/path/to/manual.pdf"

URL Source

bash
POST /api/agents/{id}/sources
Content-Type: application/json

{
  "type": "url",
  "name": "Documentation",
  "url": "https://docs.example.com",
  "config": {
    "depth": 2,
    "max_pages": 100
  }
}

Response

json
{
  "id": "source-123",
  "type": "file",
  "name": "Product Manual",
  "status": "processing",
  "created_at": "2024-12-15T10:00:00Z"
}

Search Sources

bash
GET /api/agents/{id}/sources/search?query=how+to+reset+password&limit=5

Query Parameters

ParameterTypeDescription
querystringSearch query (required)
limitnumberMax results (default: 10)
source_idstringFilter by source
min_scorenumberMinimum similarity score

Response

json
{
  "results": [
    {
      "id": "chunk-123",
      "source_id": "source-456",
      "content": "To reset your password, go to Settings > Account > Password...",
      "score": 0.92,
      "metadata": {
        "source_name": "User Guide",
        "page": 15,
        "section": "Account Settings"
      }
    }
  ]
}

Get Source

bash
GET /api/agents/{id}/sources/{sourceId}

Response

json
{
  "id": "source-123",
  "type": "file",
  "name": "Product Manual",
  "file_path": "uploads/manual.pdf",
  "status": "ready",
  "chunks": 150,
  "config": {
    "chunk_size": 1000,
    "overlap": 200
  },
  "created_at": "2024-12-01T00:00:00Z",
  "updated_at": "2024-12-15T10:00:00Z"
}

Delete Source

bash
DELETE /api/agents/{id}/sources/{sourceId}

Response

json
{
  "success": true
}

Refresh Source

bash
POST /api/agents/{id}/sources/{sourceId}/refresh

Reprocesses the source content.

Source Types

TypeDescription
fileUploaded file
urlWeb page/site
databaseDatabase query
apiAPI endpoint

Source Status

StatusDescription
pendingWaiting to process
processingCurrently processing
readyAvailable for search
errorProcessing failed
updatingRefreshing content

Supported Formats

FormatExtensions
PDF.pdf
Text.txt
Markdown.md
Word.docx
JSON.json
CSV.csv

Chunking Config

json
{
  "config": {
    "chunk_size": 1000,
    "overlap": 200,
    "method": "semantic"
  }
}

Errors

CodeDescription
400Invalid source data
404Source not found
413File too large
415Unsupported format

Examples

Upload PDF

bash
curl -X POST .../sources \
  -F "type=file" \
  -F "name=User Guide" \
  -F "file=@guide.pdf"

Search with Filter

bash
curl ".../sources/search?query=installation&source_id=source-123&min_score=0.8"

Crawl Website

bash
curl -X POST .../sources \
  -d '{
    "type": "url",
    "name": "Help Center",
    "url": "https://help.example.com",
    "config": {
      "depth": 3,
      "max_pages": 500
    }
  }'

Released under the MIT License.