Knowledge
Add documents and files your agents can search and cite.
Add or update a document (developer)
POST /v1/knowledge/documents
Upserts one document by (source_id, external_id): sending the same
IDs again replaces it, and unchanged text is not re-embedded. Agents
with knowledge: true search these documents and cite them. The
workspace’s knowledge store is created on first use.
Request body (application/json)
| Field | Type | Required | Notes |
|---|---|---|---|
external_id | string | yes | Your ID for the document. |
source_id | string | yes | Groups documents, e.g. website or faq. |
kind | faq | doc | web | business | content | location | yes | |
title | string | yes | |
text | string | yes | |
url | string (uri) | ||
lang | string | Language code (e.g. sw, en) or “mixed”; detected when omitted. | |
tags | array of string | ||
meta | object |
curl -X POST https://api.ngamia.com/v1/knowledge/documents \
-H "Authorization: Bearer $NGAMIA_TOKEN" \
-H 'content-type: application/json' \
-d '{"external_id": "…", "source_id": "…", "kind": "faq", "title": "…", "text": "…"}'Responses
| Status | Meaning |
|---|---|
200 | Stored |
201 | Stored |
400 | The request is invalid (invalid_request). |
Delete a document (developer)
DELETE /v1/knowledge/documents/{id}
Parameters
| Parameter | In | Type | Notes |
|---|---|---|---|
id | path | string | The document ID returned when it was stored. required |
curl -X DELETE https://api.ngamia.com/v1/knowledge/documents/<id> \
-H "Authorization: Bearer $NGAMIA_TOKEN"Responses
| Status | Meaning |
|---|---|
204 | Deleted |
404 | Not found in this workspace (not_found). |
Upload a file (developer)
POST /v1/knowledge/files
PDF, DOCX, TXT, Markdown or HTML, up to 30 MiB. Files are virus-scanned
and parsed in isolation, then indexed in the background: the response
has a job to poll at /v1/knowledge/jobs/{id}.
Request body (multipart/form-data)
| Field | Type | Required | Notes |
|---|---|---|---|
file | string (binary) | yes | |
source_id | string | ||
external_id | string | ||
title | string |
curl -X POST https://api.ngamia.com/v1/knowledge/files \
-H "Authorization: Bearer $NGAMIA_TOKEN" \
-F file=@price-list.pdf -F source_id=documentsResponses
| Status | Meaning |
|---|---|
202 | Accepted for indexing |
400 | The request is invalid (invalid_request). |
413 | File too large |
List indexing jobs
GET /v1/knowledge/jobs
Parameters
| Parameter | In | Type | Notes |
|---|---|---|---|
limit | query | integer | min 1, max 200 |
offset | query | integer | min 0 |
curl -X GET https://api.ngamia.com/v1/knowledge/jobs \
-H "Authorization: Bearer $NGAMIA_TOKEN"Responses
| Status | Meaning |
|---|---|
200 | Jobs |
Get an indexing job
GET /v1/knowledge/jobs/{id}
Parameters
| Parameter | In | Type | Notes |
|---|---|---|---|
id | path | string | required |
curl -X GET https://api.ngamia.com/v1/knowledge/jobs/<id> \
-H "Authorization: Bearer $NGAMIA_TOKEN"Responses
| Status | Meaning |
|---|---|
200 | The job and its status |
404 | Not found in this workspace (not_found). |
Search the workspace’s knowledge
POST /v1/knowledge/search
The same hybrid (semantic and keyword) search agents use. Use it to check what an agent will find.
Request body (application/json)
| Field | Type | Required | Notes |
|---|---|---|---|
query | string | yes | min length 1 |
limit | integer | min 1, default 8 | |
filters | object |
curl -X POST https://api.ngamia.com/v1/knowledge/search \
-H "Authorization: Bearer $NGAMIA_TOKEN" \
-H 'content-type: application/json' \
-d '{"query": "…"}'Response 200 fields
| Field | Type | Required | Notes |
|---|---|---|---|
hits | array of object | ||
score_semantics | string |
Responses
| Status | Meaning |
|---|---|
200 | Hits, best first |