Skip to content

Knowledge API Reference ​

Base URL: https://api.universalapi.co

All endpoints require authentication.

List Files ​

GET /knowledge/list?prefix={folder}
bash
# List root
curl -s https://api.universalapi.co/knowledge/list \
  -H "Authorization: Bearer YOUR_TOKEN" | jq

# List a folder
curl -s "https://api.universalapi.co/knowledge/list?prefix=documents" \
  -H "Authorization: Bearer YOUR_TOKEN" | jq

Upload File (Direct) ​

POST /knowledge/upload

Upload a file directly in a single API call — no presigned URL needed. This is the preferred method for AI agents and programmatic uploads.

Max size: 5 MB. For larger files, use Get Upload URL instead.

bash
# Upload a text file
curl -s -X POST https://api.universalapi.co/knowledge/upload \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "fileName": "notes.md",
    "content": "# My Notes\n\nHello from the API!",
    "contentType": "text/markdown",
    "folder": "documents"
  }' | jq

Request body:

FieldTypeRequiredDescription
fileNamestring✅File name (e.g., notes.md, data.csv)
contentstring✅File content as text, or base64-encoded for binary
contentTypestringMIME type (default: text/plain)
folderstringTarget folder (omit for root)
isBase64booleanSet true if content is base64-encoded

Response:

json
{
  "data": {
    "key": "users/{userId}/documents/notes.md",
    "fileName": "notes.md",
    "size": 32,
    "storageUsedMb": 7.41,
    "storageQuotaMb": 100
  }
}

TIP

Files uploaded via this endpoint are automatically indexed for semantic search, just like presigned URL uploads.

Get Upload URL ​

POST /knowledge/upload-url
bash
curl -s -X POST https://api.universalapi.co/knowledge/upload-url \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "fileName": "report.pdf",
    "contentType": "application/pdf",
    "folder": "documents"
  }' | jq

Returns a presigned PUT URL valid for 1 hour. Upload the file with:

bash
curl -X PUT -H "Content-Type: application/pdf" \
  --data-binary @report.pdf "PRESIGNED_URL"

Get Download URL ​

POST /knowledge/download-url
bash
curl -s -X POST https://api.universalapi.co/knowledge/download-url \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"key": "users/xxx/documents/report.pdf"}' | jq

The key comes from the list response.

Delete File ​

ANY /knowledge/delete
bash
curl -s -X POST https://api.universalapi.co/knowledge/delete \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"key": "users/xxx/documents/report.pdf"}' | jq

Create Folder ​

POST /knowledge/create-folder

Supports nested folder paths using forward slashes:

bash
# Create a simple folder
curl -s -X POST https://api.universalapi.co/knowledge/create-folder \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"folderName": "documents", "parentFolder": ""}' | jq

# Create nested folders (e.g., for agent configs)
curl -s -X POST https://api.universalapi.co/knowledge/create-folder \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"folderName": "uapi/agents/my-agent"}' | jq

Nested Folders

Use forward slashes (/) in folder names to create nested directory structures. For example, projects/my-app/data creates a three-level hierarchy. This works in both the folder parameter (for uploads) and folderName (for folder creation).

Delete Folder ​

POST /knowledge/delete-folder
bash
curl -s -X POST https://api.universalapi.co/knowledge/delete-folder \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"key": "users/xxx/documents/"}' | jq

DANGER

Deleting a folder removes all files inside it. This cannot be undone.

POST /knowledge/search
bash
curl -s -X POST https://api.universalapi.co/knowledge/search \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "quarterly revenue figures",
    "folder": "reports",
    "limit": 5
  }' | jq
ParameterTypeRequiredDescription
querystringYesWhat you are looking for — a question, a phrase, or an exact term such as an invoice number
folderstringNoRestrict to a folder and its subfolders (reports also covers reports/q4)
fileTypestringNoFilter by file type (PDF, TXT, MD, …, as shown in the file list)
limitnumberNoMax results (default: 5, max: 20)

How results are ranked ​

Search is hybrid: every query runs as a meaning search (an embedding of your query against each chunk of your files) and as an exact-words search (BM25 over the chunk text) in one call, and the two rankings are fused. A chunk that matches both ranks highest; a chunk that only contains the exact term (an identifier, a code, a name) still appears even when its meaning is far from the query. Results are chunks of about 2,000 characters; several chunks of one file can appear.

json
{
  "data": {
    "results": [
      {
        "fileName": "q4-analysis.pdf",
        "s3Key": "users/d468e4e8/reports/q4-analysis.pdf",
        "fileType": "PDF",
        "folder": "reports",
        "chunk_text": "Q4 revenue grew 23% to $4.2M, driven by ...",
        "chunk_index": 3,
        "total_chunks": 12,
        "distance": 0.15,
        "similarity": 0.85,
        "score": 0.0325,
        "matchedBy": ["vector", "text"]
      }
    ],
    "query": "quarterly revenue figures",
    "count": 1,
    "limit": 5,
    "mode": "hybrid"
  }
}
FieldMeaning
similarity1 − cosine distance between the query and the chunk (0–1). null when the chunk was found only by exact words
scoreFused rank score (Reciprocal Rank Fusion) — compare within one response only
matchedBy["vector"], ["text"] or both — how the chunk was found
modehybrid normally; vector while a freshly created index is still building its text index (meaning search only); none when you have no searchable files yet

Universal API - The agentic entry point to the universe of APIs