Documentation menu

API reference

Knowledge

A knowledge base is a set of Q&A entries (subject · question · answer), vector- and keyword-indexed, that your flows and the Ask endpoint retrieve from. Read tokens can list, read, search and ask; write tokens can also create bases, add and maintain entries, and submit material for AI extraction.

GET/meWho am I
GET/basesList knowledge bases
POST/basesCreate a knowledge base
GET/bases/{kbId}Get a knowledge base
PATCH/bases/{kbId}Update a knowledge base
POST/bases/{kbId}/searchSearch entries
POST/bases/{kbId}/askAsk (grounded answer)
GET/bases/{kbId}/entriesList entries
GET/bases/{kbId}/subjectsList subjects
POST/bases/{kbId}/entriesAdd one entry
PATCH/bases/{kbId}/entries/{id}Edit an entry
DELETE/bases/{kbId}/entries/{id}Delete an entry
POST/bases/{kbId}/entries/bulkBulk action
POST/bases/{kbId}/importImport ready Q&A pairs
GET/bases/{kbId}/exportExport entries
POST/bases/{kbId}/submissionsSubmit material for extraction
GET/bases/{kbId}/messagesSubmission history
DELETE/bases/{kbId}/messages/{id}Delete a submission turn
GET/bases/{kbId}/sourcesList sources
POST/bases/{kbId}/sources/uploadUpload a source
GET/bases/{kbId}/sources/{id}/downloadDownload the original file
DELETE/bases/{kbId}/sources/{id}Delete a source and its entries
GET/bases/{kbId}/unansweredUnanswered questions (gaps)
DELETE/bases/{kbId}/unansweredClear unanswered questions
GET/mescope · read

Who am I

Confirms the token works and tells you what it may do on this resource. Always call this first.

No parameters

Request
curl https://api.simplynice.ai/api/ai/knowledge/me -H "Authorization: Bearer $DJC_TOKEN"
Response · 200
{
  "userId": "Qrpc3k06…", "orgId": "d3fe674f-…",
  "tokenKind": "token",
  "access": "write",
  "scopes": ["knowledge:write", "workflows:read"],
  "knowledgeBaseId": null,
  "base": "/bases"
}

access is the highest level this token holds on Knowledge. knowledgeBaseId is only set for legacy per-base keys; personal tokens see every base in the workspace.

StatusWhen
401Missing, revoked or expired token.
403Token lacks knowledge:read (INSUFFICIENT_SCOPE).
GET/basesscope · read

List knowledge bases

Every base in your workspace, most recently updated first.

No parameters

Request
curl https://api.simplynice.ai/api/ai/knowledge/bases -H "Authorization: Bearer $DJC_TOKEN"
Response · 200
[ {
    "id": "5327d9b2-…", "orgId": "d3fe674f-…",
    "name": "Product FAQ", "description": "Answers about the X-series product line.",
    "embeddingModel": "qwen3.7-text-embedding",
    "reviewBeforeIndex": false, "defaultLanguage": null,
    "sourceCount": 3, "entryCount": 142, "indexing": false,
    "lastIndexedAt": "2026-08-29T07:55:47Z",
    "createdAt": "2026-08-29T07:05:04Z", "updatedAt": "2026-08-29T07:56:28Z"
  } ]
StatusWhen
403Token lacks knowledge:read (INSUFFICIENT_SCOPE).
POST/basesscope · read & write

Create a knowledge base

Creates an empty base. Keep description accurate — flows read it to decide *when* to search this base.

ParameterTypeDescription
namerequiredstring1–120 characters.
descriptionstringUp to 2000 characters. Shown to the model that decides whether to search this base.
reviewBeforeIndexbooleanWhen true, AI-extracted entries land as drafts until approved. Default false.
defaultLanguagestringLanguage extraction should write questions and answers in. Default: the source's language.
Request
curl -X POST https://api.simplynice.ai/api/ai/knowledge/bases -H "Authorization: Bearer $DJC_TOKEN" -H "Content-Type: application/json" \
  -d '{ "name": "Product FAQ", "description": "Answers about the X-series product line." }'
Response · 201
{
  "id": "5327d9b2-…", "orgId": "d3fe674f-…",
  "name": "Product FAQ", "description": "Answers about the X-series product line.",
  "embeddingModel": "qwen3.7-text-embedding",
  "reviewBeforeIndex": false, "defaultLanguage": null,
  "sourceCount": 3, "entryCount": 142, "indexing": false,
  "lastIndexedAt": "2026-08-29T07:55:47Z",
  "createdAt": "2026-08-29T07:05:04Z", "updatedAt": "2026-08-29T07:56:28Z"
}
StatusWhen
400Invalid body, or the workspace already has 50 bases.
403Token lacks knowledge:write (INSUFFICIENT_SCOPE).
GET/bases/{kbId}scope · read

Get a knowledge base

Name, description, counts and indexing state.

Request
curl https://api.simplynice.ai/api/ai/knowledge/bases/$KB_ID -H "Authorization: Bearer $DJC_TOKEN"
Response · 200
{
  "id": "5327d9b2-…", "orgId": "d3fe674f-…",
  "name": "Product FAQ", "description": "Answers about the X-series product line.",
  "embeddingModel": "qwen3.7-text-embedding",
  "reviewBeforeIndex": false, "defaultLanguage": null,
  "sourceCount": 3, "entryCount": 142, "indexing": false,
  "lastIndexedAt": "2026-08-29T07:55:47Z",
  "createdAt": "2026-08-29T07:05:04Z", "updatedAt": "2026-08-29T07:56:28Z"
}
StatusWhen
404Knowledge base not found in your workspace.
PATCH/bases/{kbId}scope · read & write

Update a knowledge base

Any of name, description, reviewBeforeIndex, defaultLanguage. Deleting a base is only possible in the app.

Request
curl -X PATCH https://api.simplynice.ai/api/ai/knowledge/bases/$KB_ID -H "Authorization: Bearer $DJC_TOKEN" -H "Content-Type: application/json" \
  -d '{ "description": "Answers about the X-series product line and its warranty." }'
Response · 200
{
  "id": "5327d9b2-…", "orgId": "d3fe674f-…",
  "name": "Product FAQ", "description": "Answers about the X-series product line.",
  "embeddingModel": "qwen3.7-text-embedding",
  "reviewBeforeIndex": false, "defaultLanguage": null,
  "sourceCount": 3, "entryCount": 142, "indexing": false,
  "lastIndexedAt": "2026-08-29T07:55:47Z",
  "createdAt": "2026-08-29T07:05:04Z", "updatedAt": "2026-08-29T07:56:28Z"
}
StatusWhen
404Knowledge base not found in your workspace.
403Token lacks knowledge:write (INSUFFICIENT_SCOPE).
  • DELETE /bases/{kbId} always returns 403 — a base (and every entry in it) can only be deleted from the app.
POST/bases/{kbId}/askscope · read

Ask (grounded answer)

Runs the same search, then has the model answer **only** from the hits — exactly what a flow's Knowledge tool sees. Uses credits. Counts as a **read**.

ParameterTypeDescription
queryrequiredstringThe customer's question.
topKnumber1–20, default 6.
minScorenumberDefault 0.35.
Request
curl -X POST https://api.simplynice.ai/api/ai/knowledge/bases/$KB_ID/ask -H "Authorization: Bearer $DJC_TOKEN" -H "Content-Type: application/json" \
  -d '{ "query": "How long is the X200 warranty?" }'
Response · 200
{
  "answer": "Two years from purchase (parts and labour); batteries one year.",
  "hits": [  ],
  "usage": { "model": "qwen3.7-flash", "inputTokens": 412, "outputTokens": 38, "credits": 0.01 }
}

No match → { "answer": null, "hits": [], "note": "No entries matched this question." } and the query is logged under *unanswered*.

StatusWhen
404Knowledge base not found in your workspace.
402Your credit balance in this workspace is 0 (INSUFFICIENT_CREDITS, balance in details.balance).
403Token lacks knowledge:read (INSUFFICIENT_SCOPE).
GET/bases/{kbId}/entriesscope · read

List entries

Filter, sort and page through a base's entries.

ParameterTypeDescription
qstringSubstring match on question, answer or subject.
subjectstringExact subject.
sourcestringOnly entries extracted from this source id.
statusstringactive · draft · archived · all · conflicts · expiring. Default: everything except archived.
sortstringnewest (default) · hits · unused · subject.
limitnumber1–500.
offsetnumberFor paging.
Request
curl "https://api.simplynice.ai/api/ai/knowledge/bases/$KB_ID/entries?subject=Shipping&limit=50" -H "Authorization: Bearer $DJC_TOKEN"
Response · 200
{ "items": [ {
      "id": "6f2c…", "subject": "Shipping", "question": "Do you ship to Singapore?",
      "altQuestions": ["International shipping", "Can I order from Singapore?"],
      "answer": "Not yet — we ship within Malaysia only.",
      "keywords": ["Singapore", "international"],
      "sourceExcerpt": null, "page": null,
      "status": "active", "conflictOfId": null, "validUntil": null,
      "hitCount": 0, "lastHitAt": null,
      "sourceId": null, "sourceTitle": null, "messageId": null,
      "createdAt": "2026-08-29T08:05:34Z", "updatedAt": "2026-08-29T08:05:34Z"
    } ], "total": 1 }
StatusWhen
404Knowledge base not found in your workspace.
GET/bases/{kbId}/subjectsscope · read

List subjects

The subject taxonomy in use, most used first. Reuse these when you add entries instead of inventing near-duplicates.

No parameters

Request
curl https://api.simplynice.ai/api/ai/knowledge/bases/$KB_ID/subjects -H "Authorization: Bearer $DJC_TOKEN"
Response · 200
[ { "subject": "Shipping", "count": 12 }, { "subject": "Returns", "count": 9 }, { "subject": "Warranty", "count": 4 } ]
StatusWhen
404Knowledge base not found in your workspace.
POST/bases/{kbId}/entriesscope · read & write

Add one entry

A hand-written Q&A pair, indexed immediately and active. One fact per entry; put the wordings in altQuestions, not in separate entries. Costs only the embedding (tiny).

ParameterTypeDescription
subjectrequiredstring1–60 chars, Title Case, one or two words. Part of the embedding text.
questionrequiredstring1–500 chars. An exact duplicate (case-insensitive) of an existing question is rejected.
answerrequiredstring1–2000 chars, complete and self-contained — the model only ever sees matched entries.
altQuestionsstring[]Up to 5 paraphrases (≤ 300 chars each) to improve recall.
keywordsstring[]Up to 10 product codes, names, numbers that keyword search should hit.
validUntilstring | nullISO datetime for promotions and seasonal facts. Listed under status=expiring 30 days before.
Request
curl -X POST https://api.simplynice.ai/api/ai/knowledge/bases/$KB_ID/entries -H "Authorization: Bearer $DJC_TOKEN" -H "Content-Type: application/json" \
  -d '{
    "subject": "Shipping",
    "question": "Do you ship to Singapore?",
    "altQuestions": ["International shipping", "Can I order from Singapore?"],
    "answer": "Not yet — we ship within Malaysia only.",
    "keywords": ["Singapore", "international"]
  }'
Response · 201
{
  "id": "6f2c…", "subject": "Shipping", "question": "Do you ship to Singapore?",
  "altQuestions": ["International shipping", "Can I order from Singapore?"],
  "answer": "Not yet — we ship within Malaysia only.",
  "keywords": ["Singapore", "international"],
  "sourceExcerpt": null, "page": null,
  "status": "active", "conflictOfId": null, "validUntil": null,
  "hitCount": 0, "lastHitAt": null,
  "sourceId": null, "sourceTitle": null, "messageId": null,
  "createdAt": "2026-08-29T08:05:34Z", "updatedAt": "2026-08-29T08:05:34Z",
  "conflicts": 0
}

conflicts is 1 when the new entry is ≥ 0.92 similar to an existing one; it is then stored as a **draft** with conflictOfId set, and is not searchable until you resolve it.

StatusWhen
400Invalid body, or an entry with this exact question already exists.
404Knowledge base not found in your workspace.
402Your credit balance in this workspace is 0 (INSUFFICIENT_CREDITS, balance in details.balance).
403Token lacks knowledge:write (INSUFFICIENT_SCOPE).
PATCH/bases/{kbId}/entries/{id}scope · read & write

Edit an entry

Any of subject, question, answer, altQuestions, keywords, validUntil, status, or resolveConflict. Text changes re-embed the entry automatically.

ParameterTypeDescription
statusstringactive · draft · archived.
resolveConflictstringkeep — both entries stay, flag cleared. replace — archives the older entry and activates this one.
Request
curl -X PATCH https://api.simplynice.ai/api/ai/knowledge/bases/$KB_ID/entries/$ENTRY_ID -H "Authorization: Bearer $DJC_TOKEN" -H "Content-Type: application/json" \
  -d '{ "answer": "Two years from purchase (parts and labour). Batteries: one year.",
        "altQuestions": ["X200 warranty length", "Is the X200 battery covered?"] }'
Response · 200
{
  "id": "6f2c…", "subject": "Shipping", "question": "Do you ship to Singapore?",
  "altQuestions": ["International shipping", "Can I order from Singapore?"],
  "answer": "Not yet — we ship within Malaysia only.",
  "keywords": ["Singapore", "international"],
  "sourceExcerpt": null, "page": null,
  "status": "active", "conflictOfId": null, "validUntil": null,
  "hitCount": 0, "lastHitAt": null,
  "sourceId": null, "sourceTitle": null, "messageId": null,
  "createdAt": "2026-08-29T08:05:34Z", "updatedAt": "2026-08-29T08:05:34Z"
}
StatusWhen
404Entry not found in this base.
403Token lacks knowledge:write (INSUFFICIENT_SCOPE).
DELETE/bases/{kbId}/entries/{id}scope · read & write

Delete an entry

Permanent. Prefer status: "archived" when you may want it back.

Request
curl -X DELETE https://api.simplynice.ai/api/ai/knowledge/bases/$KB_ID/entries/$ENTRY_ID -H "Authorization: Bearer $DJC_TOKEN"
Response · 200
{ "ok": true }
StatusWhen
404Entry not found.
403Token lacks knowledge:write (INSUFFICIENT_SCOPE).
POST/bases/{kbId}/entries/bulkscope · read & write

Bulk action

Apply one action to up to 500 entries.

ParameterTypeDescription
idsrequiredstring[]Up to 500 entry ids in this base.
actionrequiredstringapprove (draft → active, clears conflict flags) · activate · archive · delete · setSubject.
subjectstringRequired for setSubject. Re-embeds in the background.
Request
curl -X POST https://api.simplynice.ai/api/ai/knowledge/bases/$KB_ID/entries/bulk -H "Authorization: Bearer $DJC_TOKEN" -H "Content-Type: application/json" \
  -d '{ "ids": ["6f2c…", "a41b…"], "action": "approve" }'
Response · 200
{ "affected": 2 }
StatusWhen
404Knowledge base not found in your workspace.
403Token lacks knowledge:write (INSUFFICIENT_SCOPE).
POST/bases/{kbId}/importscope · read & write

Import ready Q&A pairs

The fast path for pairs you already have (a spreadsheet, another system). Stored verbatim and indexed immediately — no AI rewriting, embedding cost only.

ParameterTypeDescription
rowsrequiredobject[]1–2000 rows of { subject?, question, answer, altQuestions?, keywords? }. Missing subjectGeneral.
Request
curl -X POST https://api.simplynice.ai/api/ai/knowledge/bases/$KB_ID/import -H "Authorization: Bearer $DJC_TOKEN" -H "Content-Type: application/json" \
  -d '{ "rows": [
    { "subject": "Shipping", "question": "Do you ship to Singapore?", "answer": "Not yet — Malaysia only." },
    { "question": "What are your office hours?", "answer": "Mon–Fri 9am–6pm." }
  ] }'
Response · 200
{ "inserted": 2, "duplicates": 0, "conflicts": 0 }

duplicates — exact-duplicate questions skipped (against the base and within the batch). conflicts — near-duplicates stored as drafts; review them under entries?status=conflicts. Everything else lands active, even when the base uses review mode.

StatusWhen
400Invalid rows, or the import would take the base past 20 000 entries.
404Knowledge base not found in your workspace.
402Your credit balance in this workspace is 0 (INSUFFICIENT_CREDITS, balance in details.balance).
403Token lacks knowledge:write (INSUFFICIENT_SCOPE).
GET/bases/{kbId}/exportscope · read

Export entries

All non-archived entries as CSV or JSON.

ParameterTypeDescription
formatstringcsv (default) or json.
Request
curl "https://api.simplynice.ai/api/ai/knowledge/bases/$KB_ID/export?format=csv" -H "Authorization: Bearer $DJC_TOKEN" -o entries.csv
Response · 200
subject,question,answer,altQuestions,keywords,status,validUntil
Shipping,Do you ship to Singapore?,Not yet — Malaysia only.,International shipping | Can I order from Singapore?,Singapore | international,active,
StatusWhen
404Knowledge base not found in your workspace.
POST/bases/{kbId}/submissionsscope · read & write

Submit material for extraction

Send raw text (or point at uploaded sources) and the AI extracts Q&A pairs into the base. Use this for documents and pasted text — **not** for ready-made pairs (use import). Uses credits.

ParameterTypeDescription
textrequiredstringUp to 400 000 characters. With no attachments this **is** the material; with attachments it is an instruction ("Focus on prices and warranty").
attachmentsobject[]Up to 8 { sourceId } from *Upload a source*.
webSearchbooleanLet the model add verified facts from the web (extra per-search fee).
Request
curl -X POST https://api.simplynice.ai/api/ai/knowledge/bases/$KB_ID/submissions -H "Authorization: Bearer $DJC_TOKEN" -H "Content-Type: application/json" \
  -d '{ "text": "## Returns policy\nItems can be returned within 30 days of delivery in original packaging. Refunds are issued within 5 working days of receipt.\n\n## Shipping\nWest Malaysia: RM 8 flat, 2–4 working days. Free above RM 150." }'
Response · 200
{
  "status": "success",
  "userMessageId": "…", "assistantMessageId": "…",
  "title": "Returns & Shipping Policy",
  "summary": "Return window, refund timing and domestic shipping rates.",
  "entries": [ { "id": "…", "subject": "Returns", "question": "How long do I have to return an item?", "answer": "30 days from delivery, in original packaging.", "status": "active" },  ],
  "extraction": { "status": "done", "windows": 1, "pairsExtracted": 5, "pairsInserted": 5, "duplicates": 0, "conflicts": 0,
                  "inputTokens": 412, "outputTokens": 590, "embeddingTokens": 380, "credits": 0.02 },
  "statusLog": ["Extracting 1 of 1…", "Indexing 5 entries…"]
}

The response is returned once extraction finishes (typically seconds; large documents take longer). Add ?stream=1 to receive NDJSON events (status, entry, title, done, error) as they happen. 5–40 k characters per call gives the best pair quality.

StatusWhen
400Text too long, too many attachments, or the base holds 20 000 entries.
404Knowledge base not found in your workspace.
402Your credit balance in this workspace is 0 (INSUFFICIENT_CREDITS, balance in details.balance).
403Token lacks knowledge:write (INSUFFICIENT_SCOPE).
GET/bases/{kbId}/messagesscope · read

Submission history

The base's studio thread — each submission and the extraction report that answered it.

ParameterTypeDescription
limitnumber1–200, default 60.
beforestringISO datetime — return turns older than this.
Request
curl "https://api.simplynice.ai/api/ai/knowledge/bases/$KB_ID/messages?limit=20" -H "Authorization: Bearer $DJC_TOKEN"
Response · 200
{
  "items": [
    { "id": "…", "role": "user", "content": "## Returns policy…", "attachments": [], "entries": [  ], "createdAt": "…" },
    { "id": "…", "role": "assistant", "content": "Returns & Shipping Policy", "extraction": { "status": "done",  }, "entries": [], "createdAt": "…" }
  ],
  "hasMore": false
}
StatusWhen
404Knowledge base not found in your workspace.
DELETE/bases/{kbId}/messages/{id}scope · read & write

Delete a submission turn

Removes the turn and its paired reply from the thread. Entries extracted from it are kept.

Request
curl -X DELETE https://api.simplynice.ai/api/ai/knowledge/bases/$KB_ID/messages/$MESSAGE_ID -H "Authorization: Bearer $DJC_TOKEN"
Response · 200
{ "ok": true }
StatusWhen
404Message not found.
403Token lacks knowledge:write (INSUFFICIENT_SCOPE).
GET/bases/{kbId}/sourcesscope · read

List sources

Every piece of material submitted to the base — uploaded files and pasted text — with how many entries each produced. Never returns the text itself.

No parameters

Request
curl https://api.simplynice.ai/api/ai/knowledge/bases/$KB_ID/sources -H "Authorization: Bearer $DJC_TOKEN"
Response · 200
[ { "id": "…", "kind": "file", "title": "X-series datasheet", "fileName": "datasheet.pdf", "mimeType": "application/pdf",
    "sizeBytes": 812331, "pageCount": 12, "charCount": 48210, "entryCount": 37, "status": "ready", "createdAt": "…" } ]
StatusWhen
404Knowledge base not found in your workspace.
POST/bases/{kbId}/sources/uploadscope · read & write

Upload a source

Stores a document (the original is kept) together with its extracted text, ready to be attached to a submission. **The API does not parse PDFs or Office files** — send the text yourself.

ParameterTypeDescription
filerequiredfile≤ 20 MB — pdf, doc, docx, xls, xlsx, csv, txt, md, json.
contentrequiredstringThe file's text, ≤ 400 000 characters. Mark page boundaries with lines --- page N --- so entries get page numbers.
pageCountnumberFor PDFs.
Request
curl -X POST https://api.simplynice.ai/api/ai/knowledge/bases/$KB_ID/sources/upload -H "Authorization: Bearer $DJC_TOKEN" \
  -F "file=@datasheet.pdf" -F "content=<datasheet.txt" -F "pageCount=12"
Response · 201
{ "id": "b7e1…", "kind": "file", "title": "datasheet", "fileName": "datasheet.pdf", "charCount": 48210, "pageCount": 12, "entryCount": 0, "status": "ready", "createdAt": "…" }

Then extract from it: POST /submissions { "text": "Focus on specifications and warranty.", "attachments": [{ "sourceId": "b7e1…" }] }. A source can be attached to one submission; upload again to extract again.

StatusWhen
400Unsupported type, file too large, or content missing.
404Knowledge base not found in your workspace.
403Token lacks knowledge:write (INSUFFICIENT_SCOPE).
GET/bases/{kbId}/sources/{id}/downloadscope · read

Download the original file

The stored file, as binary.

Request
curl https://api.simplynice.ai/api/ai/knowledge/bases/$KB_ID/sources/$SOURCE_ID/download -H "Authorization: Bearer $DJC_TOKEN" -o datasheet.pdf
StatusWhen
404Source not found, or it was pasted text with no file.
DELETE/bases/{kbId}/sources/{id}scope · read & write

Delete a source and its entries

Removes the source **and every entry extracted from it**.

Request
curl -X DELETE https://api.simplynice.ai/api/ai/knowledge/bases/$KB_ID/sources/$SOURCE_ID -H "Authorization: Bearer $DJC_TOKEN"
Response · 200
{ "ok": true }
StatusWhen
404Source not found.
403Token lacks knowledge:write (INSUFFICIENT_SCOPE).
GET/bases/{kbId}/unansweredscope · read

Unanswered questions (gaps)

Real questions — from flows, the app's Test drawer and this API — that retrieval could not answer. Up to 200, most frequent first. Write entries for them, then clear the list.

No parameters

Request
curl https://api.simplynice.ai/api/ai/knowledge/bases/$KB_ID/unanswered -H "Authorization: Bearer $DJC_TOKEN"
Response · 200
[ { "query": "do you ship to singapore", "count": 4, "lastAt": "2026-08-29T06:12:00Z" } ]
StatusWhen
404Knowledge base not found in your workspace.
DELETE/bases/{kbId}/unansweredscope · read & write

Clear unanswered questions

Clears one query (?query=) or all of them.

ParameterTypeDescription
querystringThe exact logged query. Omit to clear everything.
Request
curl -X DELETE "https://api.simplynice.ai/api/ai/knowledge/bases/$KB_ID/unanswered?query=do%20you%20ship%20to%20singapore" -H "Authorization: Bearer $DJC_TOKEN"
Response · 200
{ "ok": true }
StatusWhen
404Knowledge base not found in your workspace.
403Token lacks knowledge:write (INSUFFICIENT_SCOPE).