Skip to main content

Search API

Search your knowledge base using semantic (AI-powered) search.

Endpoints

MethodPathDescription
POST/workspaces/:id/searchSearch documents
GET/s/:linkIdPublic search via search link

Search documents

POST /workspaces/:id/search

Perform semantic search across all documents in a workspace.

Request

{
"query": "What is the refund policy?",
"limit": 5,
"filters": {
"tags": ["tag_abc"],
"purpose": "KNOWLEDGE"
}
}

Parameters

FieldTypeRequiredDescription
queryStringYesNatural language question
limitNumberNoMax results (default: 5, max: 20)
filters.tagsString[]NoFilter by tag IDs
filters.purposeStringNoFilter by purpose
filters.documentIdsString[]NoLimit to specific docs

Response

{
"query": "What is the refund policy?",
"results": [
{
"documentId": "doc_xyz789",
"documentTitle": "Terms of Service",
"content": "Our refund policy allows customers to request a full refund within 14 days of purchase...",
"score": 0.95,
"chunkIndex": 3,
"metadata": {
"page": 5,
"section": "Refunds"
}
},
{
"documentId": "doc_abc123",
"documentTitle": "FAQ",
"content": "Q: Can I get a refund? A: Yes, we offer a 14-day money-back guarantee...",
"score": 0.88,
"chunkIndex": 12
}
],
"processingTime": 245
}

Example

curl -X POST "https://api.synjar.com/v1/workspaces/ws_abc123/search" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "What is the refund policy?",
"limit": 5
}'
GET /s/:linkId

Search via public search link. No authentication required.

Query parameters

ParameterTypeDescription
qStringSearch query
limitNumberMax results (default: 3)

Example

curl "https://api.synjar.com/s/sl_abc123?q=refund%20policy&limit=3"

See Search links API for details.

How semantic search works

Synjar uses RAG (Retrieval-Augmented Generation):

  1. Query embedding: Your question is converted to a vector
  2. Vector search: Similar document chunks are retrieved
  3. Ranking: Results are ranked by semantic similarity
  4. Response: Top-N most relevant chunks are returned

Similarity score

The score field (0-1) indicates semantic similarity:

ScoreMeaning
0.9+Very high relevance
0.7-0.9Good relevance
0.5-0.7Moderate relevance
<0.5Low relevance

Search tips

Be specific

// Good
{ "query": "What is the return window for electronics?" }

// Too vague
{ "query": "returns" }

Ask questions

Natural language questions work better than keywords:

// Better
{ "query": "How do I cancel my subscription?" }

// Less effective
{ "query": "cancel subscription" }

Use filters

Narrow results with filters:

{
"query": "pricing",
"filters": {
"tags": ["tag_sales"],
"documentIds": ["doc_terms", "doc_pricing"]
}
}

Rate limits

EndpointLimit
Workspace search60/minute
Public search links30/minute

See Rate limits for details.

Error responses

StatusCodeDescription
400QUERY_REQUIREDMissing query parameter
400QUERY_TOO_LONGQuery exceeds 1000 characters
401UNAUTHORIZEDMissing or invalid token
404WORKSPACE_NOT_FOUNDWorkspace doesn't exist
429RATE_LIMITEDToo many requests

See also