HTTP API reference for creating, importing into, and querying Knowledge Bases.
The Knowledge Base endpoints let you create and manage reference collections, import chunks, and query them directly. All requests require an Authorization: Bearer <your-api-key> header. See Authentication for details.All endpoints honor per-user tenancy — you can only access Knowledge Bases owned by your account — and respect optional scope boundaries so reference data stays isolated by client, workspace, or agent lane.
Return only Knowledge Bases visible to this agent ID. An agent ID is the portion of a channel string before the first colon — for example, channel my-agent:session-1 has agent ID my-agent.
Scope string that restricts visibility. Only agents operating in a channel matching this scope can see the KB. Omit to make the KB visible to all your agents.
Import chunks into a Knowledge Base with synchronous embedding and graph enrichment. Each chunk is stored and made immediately searchable. Use this for moderate batches where you need results available right away.
POST /api/knowledge-bases/:knowledgeBaseId/bulk-insert
Insert a large batch of chunks without the per-request embedding overhead. Rows are written immediately; embedding and graph enrichment are scheduled automatically and run in the background. Use this for high-volume backfills and large migrations.
Maximum 100 chunks per request. For larger datasets, split your payload into batches of 100 and send multiple requests sequentially.
curl -X POST https://your-deployment.convex.site/api/knowledge-bases/jx7k2m9p4n8q/query \ -H "Authorization: Bearer mc_your_api_key" \ -H "Content-Type: application/json" \ -d '{ "query": "How do I authenticate API requests?", "limit": 5, "channel": "acme-corp" }'
{ "knowledgeBase": { "_id": "jx7k2m9p4n8q", "name": "Product documentation", "memoryCount": 284 }, "memories": [ { "memoryId": "mem_def456", "title": "Authentication overview", "content": "All API endpoints require an Authorization: Bearer header with a valid API key.", "score": 0.94, "tags": ["api", "auth"] } ]}
If a Knowledge Base has a scope set, you must pass a matching channel in the query body or the request returns an empty result array. This is by design — scope restrictions are enforced at query time to maintain workspace isolation.