> ## Documentation Index
> Fetch the complete documentation index at: https://docs.olis-ai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Search Endpoint

> POST /api/search

## Search documents

`POST /api/search`

Perform semantic search across indexed documents.

### Request

```json theme={null}
{
  "query": "machine learning basics",
  "limit": 10,
  "filters": {
    "type": "pdf"
  }
}
```

### Parameters

<ParamField body="query" type="string" required>
  Search query
</ParamField>

<ParamField body="limit" type="number" default={10}>
  Maximum number of results to return
</ParamField>

<ParamField body="filters" type="object">
  Optional filters for document type, date range, etc.
</ParamField>

### Response

```json theme={null}
{
  "results": [
    {
      "id": "doc1",
      "content": "Machine learning is...",
      "score": 0.92,
      "metadata": {
        "filename": "ml-guide.pdf",
        "type": "pdf"
      }
    }
  ],
  "total": 42
}
```

### Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST http://localhost:8000/api/search \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -d '{
      "query": "machine learning",
      "limit": 10
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('http://localhost:8000/api/search', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer YOUR_TOKEN'
    },
    body: JSON.stringify({
      query: 'machine learning',
      limit: 10
    })
  })

  const data = await response.json()
  console.log(data.results)
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'http://localhost:8000/api/search',
      headers={'Authorization': 'Bearer YOUR_TOKEN'},
      json={
          'query': 'machine learning',
          'limit': 10
      }
  )

  print(response.json()['results'])
  ```
</CodeGroup>
