> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.livingbrain.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.livingbrain.com/_mcp/server.

# Search pages

POST https://api.livingbrain.com/v1/brains/{brainId}/search
Content-Type: application/json

Search pages using combined semantic and keyword matching. Results are ranked by relevance and include a snippet showing why each page matched.

Reference: https://docs.livingbrain.com/api-reference/workspace/search-pages

## Authentication

- `x-api-key` header (required) — Your Living Brain API key. Create one from the dashboard; keys are scoped to an organization and carry the role of the member they were issued to.

## Request

### Path parameters

- `brainId` (string, required) — Brain id

### Body (application/json)

This endpoint expects a BrainSearchReqDto.

- `query` (string, required) — Search query
- `topK` (integer, optional, default: 5) — Max results
- `minSimilarity` (double, optional, default: 0.35) — Minimum similarity (0-1)

## Response

### 201

- `list of BrainSearchResultDto`

## Errors

### 400 Bad Request Error

Validation failed (e.g. empty title/body, slug already in use)

- `statusCode` (integer, required) — HTTP status code
- `timestamp` (string, required) — ISO timestamp of the failure
- `path` (string, required) — Request path (query string stripped)
- `message` (string, required) — Human-readable error message
- `body` (ErrorResDtoBody, optional) — Original framework exception response when available, e.g. `{ statusCode, message, error }` with per-field validation messages

### 401 Unauthorized Error

Unauthorized

- `statusCode` (integer, required) — HTTP status code
- `timestamp` (string, required) — ISO timestamp of the failure
- `path` (string, required) — Request path (query string stripped)
- `message` (string, required) — Human-readable error message
- `body` (ErrorResDtoBody, optional) — Original framework exception response when available, e.g. `{ statusCode, message, error }` with per-field validation messages

### 404 Not Found Error

Brain, page, change, or connection not found

- `statusCode` (integer, required) — HTTP status code
- `timestamp` (string, required) — ISO timestamp of the failure
- `path` (string, required) — Request path (query string stripped)
- `message` (string, required) — Human-readable error message
- `body` (ErrorResDtoBody, optional) — Original framework exception response when available, e.g. `{ statusCode, message, error }` with per-field validation messages

## Types

### BrainSearchResultDto

- `pageId` (string, required) — Page id
- `slug` (string, required) — URL-safe identifier, unique within the brain.
- `title` (string, required) — Human-readable title.
- `summary` (string, required) — Summary of the matched page.
- `pageType` (enum, required) — What kind of knowledge this page holds.
  - Allowed values: `source`, `topic`, `entity`, `project`, `decision`, `brief`
- `status` (enum, required) — Lifecycle state. Deprecated and archived items are hidden from listings by default.
  - Allowed values: `active`, `deprecated`, `stale`, `contested`, `archived`
- `similarity` (double, required) — Similarity score (0-1)
- `matchedOn` (enum, required) — Why the page matched: semantic similarity, keyword (title/summary/body words), or both. Keyword matches are returned even when similarity is below minSimilarity.
  - Allowed values: `semantic`, `keyword`, `both`

### ErrorResDtoBody

Original framework exception response when available, e.g. `{ statusCode, message, error }` with per-field validation messages

## Examples

**Request**

```json
{
  "query": "what does the customer care about?"
}
```

**Response**

```json
[
  {
    "pageId": "string",
    "slug": "string",
    "title": "string",
    "summary": "string",
    "pageType": "source",
    "status": "active",
    "similarity": 1.1,
    "matchedOn": "semantic"
  }
]
```

**SDK Code**

```python
import requests

url = "https://api.livingbrain.com/v1/brains/brainId/search"

payload = { "query": "what does the customer care about?" }
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.livingbrain.com/v1/brains/brainId/search';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"query":"what does the customer care about?"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.livingbrain.com/v1/brains/brainId/search"

	payload := strings.NewReader("{\n  \"query\": \"what does the customer care about?\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.livingbrain.com/v1/brains/brainId/search")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"query\": \"what does the customer care about?\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.livingbrain.com/v1/brains/brainId/search")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"query\": \"what does the customer care about?\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.livingbrain.com/v1/brains/brainId/search', [
  'body' => '{
  "query": "what does the customer care about?"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.livingbrain.com/v1/brains/brainId/search");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"query\": \"what does the customer care about?\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["query": "what does the customer care about?"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.livingbrain.com/v1/brains/brainId/search")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```