Skip to content

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.

FieldTypeNotes
idInt!
nameString!
descriptionString
createdAtDateTime!
updatedAtDateTime!
FieldTypeNotes
idInt!
fileNameString!
mimeTypeString!
fileSizeBytesInt!
parseStatusString!PENDING | PARSING | READY | FAILED. See the parse lifecycle below.
parseErrorStringSet only when parseStatus is FAILED.
rawTextString!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.
createdAtDateTime!
updatedAtDateTime!

Returned only by retrieveChunks — a preview of a single retrieved chunk, not a persisted, independently-queryable resource.

FieldTypeNotes
chunkIdInt!
documentIdInt!The source document this chunk came from.
contentString!The chunk’s raw text.
scoreFloat!Cosine similarity to the query, higher is more relevant.

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. parseStatus is READY immediately; 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 to retrieveChunks), or FAILED with parseError populated 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.


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).

OperationKindWhat to know beyond the operation reference
knowledgeBasesquery
createKnowledgeBasemutationCounts against the plan’s knowledge-base quota.
deleteKnowledgeBasemutationSee the rule below: documents are not deleted with it.
knowledgeDocumentsqueryNever returns rawText.
knowledgeDocumentqueryThe only read that returns rawText.
ingestDocumentmutationSynchronous; READY on return.
requestKnowledgeDocumentUploadmutationStep 1 of the file upload.
confirmKnowledgeDocumentUploadmutationStep 3 of the file upload.
resyncKnowledgeDocumentmutationRe-runs ingestion with the same content; see below.
retrieveChunksqueryThe same retrieval an llm node with knowledgeBaseId runs.
deleteKnowledgeDocumentmutationDeletes the document’s chunks too and releases its quota.
  1. requestKnowledgeDocumentUpload checks that the knowledge base is yours, runs a soft quota pre-check on declaredSizeBytes and returns a presigned uploadUrl (valid 15 minutes) and an objectStorageKey.
  2. Your browser or server PUTs the raw file bytes to uploadUrl, with the same Content-Type as mimeType. The bytes never pass through the Wetel API server.
  3. confirmKnowledgeDocumentUpload verifies the upload, reserves storage quota against the real file size, creates the document (parseStatus: PENDING) and starts parsing. Poll as described in the lifecycle.

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.

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.

Re-runs ingestion for an existing document from its current stored content; no new input:

  • A FAILED file upload that still has its uploaded bytes goes back to PENDING and is parsed again.
  • A READY document of any origin is re-chunked and re-embedded in place from its own rawText, for example after a chunking or embedding change.
  • Refused while the document is PENDING or PARSING.

Operation reference.

Deletes one document and its chunks and releases its chunk-count and storage quota. The knowledge base stays. Operation reference.

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.

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.

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

FieldTypeNotes
vectors[[Float!]!]!One embedding vector per input text, same order as texts. Always fully populated — never contains null entries.
usageEmbedUsageDto!{ 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 /graphql
Content-Type: application/json
X-Api-Key: <api-key>
x-huat-platform: customer

Response

{
"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.

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!
FieldTypeRequiredNotes
idInt!yesA knowledge base of your workspace.
nameStringnoNew display name, 1 to 120 characters, not blank.
descriptionStringnoNew 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
}
}

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 } }

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

FieldTypeRequiredNotes
knowledgeBaseIdInt!yes
urlString!yesMust be http:// or https://.
fileNameStringnoDisplay 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 } }