Knowledge Base & Embeddings
A Knowledge Base is a named container of chunked, embedded text that a workflow’s LLM node can retrieve against at runtime (RAG). This page holds the types and the rules that span operations; the operation reference is the per-operation page. For a conceptual walkthrough of how retrieval fits into a workflow, see Knowledge Base; for using the raw embedding endpoint outside the platform’s own retrieval path, see Embeddings.
All operations on this page except embed require a valid JWT (Authorization: Bearer <token>) issued to a user belonging to the tenant that owns the knowledge base — see Authentication. embed uses a separate X-Api-Key header instead (see below). Every knowledge base, document, and chunk is scoped to the caller’s tenant.
Every request in this reference must include the x-huat-platform: customer header in addition to standard GraphQL headers.
The KnowledgeBaseDto type
Section titled “The KnowledgeBaseDto type”| Field | Type | Notes |
|---|---|---|
id | Int! | |
name | String! | |
description | String | |
createdAt | DateTime! | |
updatedAt | DateTime! |
The KnowledgeDocumentDto type
Section titled “The KnowledgeDocumentDto type”| Field | Type | Notes |
|---|---|---|
id | Int! | |
fileName | String! | |
mimeType | String! | |
fileSizeBytes | Int! | |
parseStatus | String! | PENDING | PARSING | READY | FAILED. See the parse lifecycle below. |
parseError | String | Set only when parseStatus is FAILED. |
rawText | String! | The document’s full extracted/stored text. Only ever populated by the singular knowledgeDocument(id) query below — knowledgeDocuments (the list query) never selects it, so listing a knowledge base with many/large documents doesn’t pay for fetching all of their text. Empty while parseStatus is PENDING/PARSING. |
createdAt | DateTime! | |
updatedAt | DateTime! |
The KnowledgeChunkPreviewDto type
Section titled “The KnowledgeChunkPreviewDto type”Returned only by retrieveChunks — a preview of a single retrieved chunk, not a persisted, independently-queryable resource.
| Field | Type | Notes |
|---|---|---|
chunkId | Int! | |
documentId | Int! | The source document this chunk came from. |
content | String! | The chunk’s raw text. |
score | Float! | Cosine similarity to the query, higher is more relevant. |
The parseStatus lifecycle
Section titled “The parseStatus lifecycle”A document’s parseStatus moves through up to four states, depending on how it was created:
- Inline text (via
ingestDocument) — chunked, embedded, and persisted synchronously.parseStatusisREADYimmediately; there is nothing to poll. - Uploaded file (via
requestKnowledgeDocumentUpload+confirmKnowledgeDocumentUpload) — parses asynchronously:PENDING(row created, job enqueued) →PARSING(job running) →READY(chunks embedded and available toretrieveChunks), orFAILEDwithparseErrorpopulated if parsing errors out.
There is no subscription for parse completion — poll knowledgeDocuments(knowledgeBaseId) and check the parseStatus field on the document you just uploaded, or simply refetch after a few seconds.
Operations
Section titled “Operations”The knowledge operation reference is the per-operation page for eleven of the fourteen operations: arguments, allowed values, example responses, the usual errors and code samples in five languages. This page keeps the types, the rules that span operations and the four operations the generated reference does not cover yet (embed, updateKnowledgeBase, updateKnowledgeDocumentText, ingestDocumentFromUrl).
| Operation | Kind | What to know beyond the operation reference |
|---|---|---|
knowledgeBases | query | |
createKnowledgeBase | mutation | Counts against the plan’s knowledge-base quota. |
deleteKnowledgeBase | mutation | See the rule below: documents are not deleted with it. |
knowledgeDocuments | query | Never returns rawText. |
knowledgeDocument | query | The only read that returns rawText. |
ingestDocument | mutation | Synchronous; READY on return. |
requestKnowledgeDocumentUpload | mutation | Step 1 of the file upload. |
confirmKnowledgeDocumentUpload | mutation | Step 3 of the file upload. |
resyncKnowledgeDocument | mutation | Re-runs ingestion with the same content; see below. |
retrieveChunks | query | The same retrieval an llm node with knowledgeBaseId runs. |
deleteKnowledgeDocument | mutation | Deletes the document’s chunks too and releases its quota. |
File upload in three steps
Section titled “File upload in three steps”requestKnowledgeDocumentUploadchecks that the knowledge base is yours, runs a soft quota pre-check ondeclaredSizeBytesand returns a presigneduploadUrl(valid 15 minutes) and anobjectStorageKey.- Your browser or server
PUTs the raw file bytes touploadUrl, with the sameContent-TypeasmimeType. The bytes never pass through the Wetel API server. confirmKnowledgeDocumentUploadverifies the upload, reserves storage quota against the real file size, creates the document (parseStatus: PENDING) and starts parsing. Poll as described in the lifecycle.
requestKnowledgeDocumentUpload
Section titled “requestKnowledgeDocumentUpload”Step 1 of the upload above. Accepts PDF, DOCX, Markdown, CSV or XLSX, at most 20 MB; the real size is checked at step 3. Arguments, the allowed mimeType values and errors: operation reference.
knowledgeDocument
Section titled “knowledgeDocument”Returns one document including its full rawText, which the list query never selects. Use it to preview or edit a document’s text (see updateKnowledgeDocumentText). Operation reference.
resyncKnowledgeDocument
Section titled “resyncKnowledgeDocument”Re-runs ingestion for an existing document from its current stored content; no new input:
- A
FAILEDfile upload that still has its uploaded bytes goes back toPENDINGand is parsed again. - A
READYdocument of any origin is re-chunked and re-embedded in place from its ownrawText, for example after a chunking or embedding change. - Refused while the document is
PENDINGorPARSING.
deleteKnowledgeDocument
Section titled “deleteKnowledgeDocument”Deletes one document and its chunks and releases its chunk-count and storage quota. The knowledge base stays. Operation reference.
deleteKnowledgeBase
Section titled “deleteKnowledgeBase”Deletes the knowledge base row only. Its documents and their chunks are not deleted: they stay in storage, unreachable through any live knowledge base. To reclaim quota or honour a deletion request, delete the documents with deleteKnowledgeDocument first. Operation reference.
retrieveChunks
Section titled “retrieveChunks”Embeds query and returns the topK (default 5, at most 20) most similar chunks, most relevant first. It is the same retrieval path an llm node with knowledgeBaseId uses, so run it to check what a node would retrieve for a typical question before wiring the knowledge base into a live workflow. Operation reference.
Operations not in the generated reference
Section titled “Operations not in the generated reference”API-key-tier: embeds each string in texts (same order in, same order out) using the same model/dimensions as this tenant’s knowledge base (gemini-embedding-001, 768 dims) — a drop-in source for a caller building their own vector index outside Wetel. Max 100 texts per call. usage.costUsd reflects the embedding model’s public paid-tier rate; inputTokens is a character-length estimate, not an exact tokenizer count, so costUsd is an estimate too.
Auth: API key (X-Api-Key header) — not a JWT. See Embeddings for how to generate a key.
embed(texts: [String!]!): EmbedResultDto!EmbedResultDto fields
| Field | Type | Notes |
|---|---|---|
vectors | [[Float!]!]! | One embedding vector per input text, same order as texts. Always fully populated — never contains null entries. |
usage | EmbedUsageDto! | { inputTokens, outputTokens, costUsd }. |
Request
query Embed($texts: [String!]!) { embed(texts: $texts) { vectors usage { inputTokens outputTokens costUsd } }}{ "texts": ["hello world", "a second string to embed"] }POST /graphqlContent-Type: application/jsonX-Api-Key: <api-key>x-huat-platform: customerResponse
{ "data": { "embed": { "vectors": [ [0.0123, -0.0456, 0.0789], [-0.0034, 0.0912, 0.0201] ], "usage": { "inputTokens": 6, "outputTokens": 0, "costUsd": 0.0000012 } } }}Note: the response above truncates each vector to 3 dimensions for readability — real vectors are 768-dimensional.
updateKnowledgeBase
Section titled “updateKnowledgeBase”Renames a knowledge base or changes its description. Fields you omit stay as they are; null or an empty description clears it. It does not touch the base’s documents.
Auth: JWT
updateKnowledgeBase(input: UpdateKnowledgeBaseInput!): KnowledgeBaseDto!| Field | Type | Required | Notes |
|---|---|---|---|
id | Int! | yes | A knowledge base of your workspace. |
name | String | no | New display name, 1 to 120 characters, not blank. |
description | String | no | New description, at most 2000 characters. |
In a workspace where members build, a member may only edit a base they created that is not in a pending or approved release; otherwise it answers NOT_FOUND.
mutation { updateKnowledgeBase( input: { id: 3 name: "Returns policy" description: "Current policy and exceptions" } ) { id name description }}updateKnowledgeDocumentText
Section titled “updateKnowledgeDocumentText”Overwrites a document’s own text and re-chunks/re-embeds it in place, subject to plan quotas — the “edit” counterpart to resyncKnowledgeDocument above (which re-runs with the SAME text; this replaces it). Works for a document of any origin — file upload, pasted text, or URL ingest — once it’s been ingested at least once, since they all converge on the same rawText storage. A FAILED document can also be edited this way: fixing bad or missing content by hand is a valid recovery path distinct from resyncKnowledgeDocument’s “just retry the same bytes.” Rejected if the document is currently PENDING or PARSING.
Auth: JWT
updateKnowledgeDocumentText(id: Int!, text: String!): Boolean!Request
mutation UpdateKnowledgeDocumentText($id: Int!, $text: String!) { updateKnowledgeDocumentText(id: $id, text: $text)}{ "id": 101, "text": "Chapter 1: Getting Started\n\nTo reset your password, go to Settings > Security and click 'Reset Password'. Links expire after 24 hours."}Response
{ "data": { "updateKnowledgeDocumentText": true } }ingestDocumentFromUrl
Section titled “ingestDocumentFromUrl”Ingests a single web page into a knowledge base: fetches url, extracts its text (HTML pages are stripped to plain text; text/plain pages are used as-is), then chunks/embeds/persists it synchronously, subject to plan quotas — same return shape as ingestDocument. Single page only — does not follow links. Rate-limited (10/min per client) since it triggers a real outbound fetch. Blocked for any URL that resolves to a private/internal/reserved IP address range (loopback, RFC 1918 private ranges, link-local/cloud-metadata addresses, etc.) — this is a deliberate SSRF protection, not a bug, and there is no way to override it.
Auth: JWT
ingestDocumentFromUrl(input: IngestDocumentFromUrlInput!): Int!IngestDocumentFromUrlInput fields
| Field | Type | Required | Notes |
|---|---|---|---|
knowledgeBaseId | Int! | yes | |
url | String! | yes | Must be http:// or https://. |
fileName | String | no | Display label. Defaults to the fetched page’s own <title>, or its hostname if no title is found. |
Request
mutation IngestDocumentFromUrl($input: IngestDocumentFromUrlInput!) { ingestDocumentFromUrl(input: $input)}{ "input": { "knowledgeBaseId": 5, "url": "https://example.com/help/password-reset" }}Response
{ "data": { "ingestDocumentFromUrl": 3 } }See also
Section titled “See also”- Knowledge Base — conceptual guide to RAG retrieval in workflows
- Embeddings — using
embedto build your own vector index - Evaluation & Export
- Avatar Config
- API Reference: Overview