Skip to content
dhanu docs
Browse pages

API reference

Search the brain

POST /api/pub/v1/brain/search, semantic search over the workspace brain.

POSThttps://api.dhanu.ai/api/pub/v1/brain/search

Runs a semantic search over the workspace brain, the knowledge pages Dhanu synthesises from what the workspace works on, and returns the best-matching pages, ranked, each with a short snippet. Results are limited to what the key’s creator is allowed to see. The query itself is not billed.

Request

FieldTypeRequiredNotes
querystringYesAt least 1 characters, up to 2000 characters.
curl -X POST https://api.dhanu.ai/api/pub/v1/brain/search \
  -H "Authorization: Bearer $DHANU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "query": "refund policy for annual plans" }'
const results = await dhanu.brain.search("refund policy for annual plans");
for (const hit of results) console.log(hit.title, hit.score);
for hit in dhanu.brain.search("refund policy for annual plans"):
    print(hit.title, hit.score)

Response

200 OK

{ "results": [{ "pageId": "…", "slug": "refunds", "title": "Refunds", "score": 0.83, "snippet": "Annual plans are refundable within 14 days…" }] }

Errors

CodeStatusMeaning
invalid_api_key401The bearer key is missing or unknown.
api_key_revoked401The key was revoked.
api_key_expired401The key passed its expiry date.
api_key_ip_not_allowed403The caller's IP is outside the key's allowlist.
developer_access_revoked403The key's creator lost developer access in the workspace.
api_key_project_scope403The key covers no active projects, or projectId is outside its scope.
invalid_request_body422The body did not match the schema; error.issues names each field.