Skip to main content
persona.knowledge — /api/v1/developer/knowledge. A Knowledge base stores documents that have been chunked and embedded for retrieval-augmented generation (RAG). Agents with the Knowledge base attached retrieve from it automatically; you can also search it directly from the SDK. Project-owned, or — with externalUserId — owned by that end user.

Methods

create(input, idempotencyKey?)

name and providerId are required (the Provider supplies the embedding model’s API key — there is no “my default provider” concept on this API, unlike Persona’s own routes).

list(params?)

Lists/searches Knowledge bases visible to this credential (this Project’s own, plus any public ones). Returns PaginatedResult<KnowledgeBase>.

update(kbId, input)

Partially updates a Knowledge base. Note: changing providerId/embeddingModel/chunkSize/ chunkOverlap does not retroactively re-embed already-uploaded documents — those settings apply to future uploads only.

uploadDocuments(kbId, files)

Uploads and chunks/embeds one or more documents into the Knowledge base.
  • Synchronous — returns only once embedding finishes. Expect it to take longer for larger/more files.
  • Limits: up to 10 files per call, 20MB each, restricted to PDF/TXT/MD/JSON/CSV.
  • UploadFileInput is { filename, content: Uint8Array | Blob, contentType? } — pass a Node Buffer/Uint8Array (with contentType), or an already-constructed Blob (its own type is used).
  • Returns { documentCount, chunkCount, files: [{ fileName, fileSize, mimeType, chunkCount }] }. documentCount/chunkCount are totals after this upload (not just this call’s files).

listDocuments(kbId)

Lists the distinct source documents currently chunked/embedded in this Knowledge base (not the individual chunks). Each entry: { fileName, fileSize, mimeType, chunkCount, uploadedAt }.

deleteDocument(kbId, sourceName)

Deletes every chunk that came from one uploaded source document.
sourceName must be the document’s fileName as returned by listDocuments() — it is URL-encoded by the SDK automatically.

search(kbId, query, options?)

Runs a similarity search against the Knowledge base’s embedded chunks — the same retrieval an Agent with this Knowledge base attached would use internally.
  • options.topK overrides the Knowledge base’s own configured topK for that one call only.
  • Each hit: { text, source, score } — source is the source document’s fileName; score (higher = more relevant) is null if the underlying store didn’t return one.

getUsage / delete

  • getUsage(kbId) returns ResourceUsage. Unlike Providers/Skills/MCP, Knowledge base deletion does not currently block on in-use Agents — this is informational only, not a guarantee that delete() will reject while agentCount > 0.
  • delete(kbId) deletes the Knowledge base and all its embedded chunks.

Complete example