Skip to content

Knowledge bases

Search knowledge

Search one or more knowledge bases with semantic vector retrieval, optional hybrid full-text retrieval, and structured tag filters. Every result names the `knowledgeBaseId` it came from. A request body over 2 MiB is a `413`. Reranking returns `409` when the stored results cannot pass secret-provenance enforcement. OAuth scope: `api:read`.

POST/api/v2/knowledge/search

Search one or more knowledge bases with semantic vector retrieval, optional hybrid full-text retrieval, and structured tag filters. Every result names the knowledgeBaseId it came from. A request body over 2 MiB is a 413. Reranking returns 409 when the stored results cannot pass secret-provenance enforcement.

OAuth scope: api:read.

Authentication

Send a personal or workspace API key in X-API-Key. See key types and access; operations that reject workspace keys say so in their description.

Send X-API-Key in the request header.

Alternatively

Send a Sim OAuth access token in Authorization: Bearer. See OAuth authentication and scopes.

Authorization: Bearer YOUR_ACCESS_TOKEN

Required scopes: api:read

OAuth flows
json
{
  "authorizationCode": {
    "authorizationUrl": "https://www.sim.ai/api/auth/oauth2/authorize",
    "tokenUrl": "https://www.sim.ai/api/auth/oauth2/token",
    "refreshUrl": "https://www.sim.ai/api/auth/oauth2/token",
    "scopes": {
      "api:read": "Read your workspaces, workflows, files, tables, and logs",
      "api:write": "Read, create, change, run, and delete resources in your workspaces",
      "offline_access": "Stay signed in without asking again"
    }
  }
}

OAuth scope: api:read.

Request body

Required

Knowledge bases, query, result limit, retrieval mode, and optional tag filters.

object

Knowledge bases, query, result limit, retrieval mode, and optional tag filters.

9 fields
workspaceIdstringRequired

Workspace that owns the knowledge bases.

minLength
1
maxLength
128
knowledgeBaseIdsvalueRequired

One knowledge base ID or an array of up to 20 IDs. Query searches require the same embedding model and dimensions across all selected bases; search incompatible bases separately. Tag-only searches do not require this.

Schema details

Any of

Option 1string
minLength
1
Option 2array
minItems
1
maxItems
20
Schema details
Array itemstring
minLength
1
querystring

Natural-language query; required when tag filters are omitted. At most 32768 characters — longer text exceeds the embedding model's per-input token ceiling and would be truncated before the billed search ran.

maxLength
32768
topKnumber

Maximum number of search results to return. Must be a whole number between 1 and 100.

default
10
minimum
1
maximum
100
tagFiltersarray

Up to 10 filters combined with AND; repeating a tag narrows results. To express OR, run separate searches. Every tag must exist with the same slot and field type in each selected knowledge base or the request is rejected. List valid names with the knowledge-base tag-list operation.

maxItems
10
Schema details
Array itemobject

A structured tag filter applied to knowledge search.

5 fields
tagNamestringRequired

Display name of the tag to filter.

fieldTypestring

Tag field type.

enum
["text","number","date","boolean"]
operatorstring

Comparison operator; valid operators depend on the field type. Text tags accept eq, neq, contains, not_contains, starts_with, ends_with; number and date tags accept eq, neq, gt, gte, lt, lte, between; boolean tags accept eq, neq. An operator the tag's field type does not implement is rejected, never ignored.

default
eq
enum
["eq","neq","contains","not_contains","starts_with","ends_with","gt","gte","lt","lte","between"]
valuevalueRequired

Tag value to compare against.

Schema details

Any of

Option 1string
Option 2number
Option 3boolean
valueTovalue

Upper bound for the between operator, and required whenever that operator is used.

Schema details

Any of

Option 1string
Option 2number

Additional properties are not allowed.

searchModevalue

Retrieval strategy: vector uses semantic search; hybrid also runs full-text search. Omit to use the workspace policy.

Schema details

Any of

Option 1string
enum
["vector","hybrid"]
Option 2null
rerankerEnabledboolean

Reorder retrieved chunks with a reranking model before truncating to topK. Ignored for tag-only searches. A completed reranking call adds a search unit. If reranking is unavailable, results keep their retrieval order; check rerankerStatus.

rerankerModelstring

Reranking model to use when rerankerEnabled is true. Defaults to rerank-v4.0-fast.

default
rerank-v4.0-fast
enum
["rerank-v4.0-pro","rerank-v4.0-fast","rerank-v3.5"]
rerankerInputCountinteger

How many candidate chunks to retrieve before reranking. Defaults to four times topK, capped at 100. A larger pool costs more retrieval work but gives the reranker more to choose from.

minimum
1
maximum
100

Additional properties are not allowed.

Request example 1

json
{
  "workspaceId": "a91c4b2e-6d3f-4e8a-b5c7-0d9e2f1a8c64",
  "knowledgeBaseIds": [
    "7c9e6679-7425-40de-944b-e07fc1f90ae7"
  ],
  "query": "How do I reset my password?",
  "topK": 10
}

Responses

200

Matching document chunks ordered by relevance.

object

Matching chunks and search execution context.

1 field
dataobjectRequired

Response data.

6 fields
resultsarrayRequired

Matching chunks ordered by relevance.

Schema details
Array itemobject

A matching document chunk returned by knowledge search.

11 fields
knowledgeBaseIdstringRequired

Knowledge base the matching chunk came from; a search may span up to 20.

documentIdstringRequired

Identifier of the document containing the matching chunk.

documentNamevalueRequired

Filename of the source document, or null when unavailable.

Schema details

Any of

Option 1string
Option 2null
sourceUrlvalueRequired

Original source URL, or null for a directly uploaded document.

Schema details

Any of

Option 1string
Option 2null
contentstringRequired

Text content of the matching chunk.

chunkIndexintegerRequired

Zero-based chunk index within the document.

minimum
0
maximum
9007199254740991
metadataobjectRequired

Document tag values keyed by tag display name.

Schema details
Additional propertiesvalue

User-defined string, number, boolean, or date tag value.

similaritynumberRequired

Cosine similarity between the query embedding and the chunk (1 - cosine distance), reported the same way in vector and hybrid mode; tag-only matches use 1. In hybrid mode results are not ordered by this value — see rankScore.

rankScorenumberRequired

The retrieval score, or reranker score when reranked. In vector mode it equals similarity; in hybrid mode it is the reciprocal-rank-fusion score (a sum of 1/(60 + rank) over the lexical and vector legs, so a chunk both legs ranked first scores 2/61); when a reranker ordered the results it is rerankerScore. Recency boosting may reorder retrieval results without changing this score; rank always reflects returned order.

rankintegerRequired

1-based position in the returned order.

maximum
9007199254740991
exclusiveMinimum
0
rerankerScorenumber

Relevance score assigned by the reranker, present only on results a reranker ordered. Results are ordered by this score when it is present, which is why it can disagree with similarity.

Additional properties are not allowed.

querystringRequired

Executed query, or an empty string for tag-only search.

knowledgeBaseIdsarrayRequired

Knowledge base identifiers that were searched.

Schema details
Array itemstring
topKintegerRequired

Maximum number of results requested.

maximum
9007199254740991
exclusiveMinimum
0
totalResultsintegerRequired

Number of results returned.

minimum
0
maximum
9007199254740991
rerankerStatusstringRequired

Reranking outcome. applied means results carry rerankerScore and follow that score. unavailable means reranking could not produce a usable order; the search succeeded in retrieval order without rerankerScore. Retry if reranking is needed. skipped means there was nothing to rank. not_requested means rerankerEnabled was absent or false.

enum
["not_requested","skipped","unavailable","applied"]

Additional properties are not allowed.

Additional properties are not allowed.

Response headers

X-RateLimit-Limitinteger

Maximum requests allowed in the current window.

minimum
0
maximum
9007199254740991
X-RateLimit-Remaininginteger

Requests remaining in the current window.

minimum
0
maximum
9007199254740991
X-RateLimit-Resetstring

ISO 8601 timestamp when the current rate-limit window resets.

format
date-time
pattern
^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
Was this helpful?
Suggest an edit