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

# Session Search

> Search past conversations by content to find relevant sessions and retrieve conversation history.

# Session Search

Session search lets you find past conversations by their content. Instead of scrolling through hundreds of sessions, you can search for specific topics, keywords, or phrases and get matching sessions with previews.

## How It Works

Every message in a conversation is indexed for search. When you search, thinnestAI scans the full text of all messages (both user and agent) and returns sessions that contain matching content, ranked by relevance.

## Using Session Search

### From the Dashboard

1. Navigate to your agent's **Sessions** tab.
2. Use the search bar at the top of the session list.
3. Type your query (e.g., "refund policy" or "order #12345").
4. Matching sessions appear with highlighted preview snippets.

### Via the API

```bash theme={null}
curl -X GET "https://api.thinnest.ai/api/agents/{agent_id}/sessions/search?q=refund+policy&limit=20" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

**Parameters:**

| Parameter | Type    | Default  | Description                                    |
| --------- | ------- | -------- | ---------------------------------------------- |
| `q`       | string  | required | Search query — matches against message content |
| `limit`   | integer | 20       | Maximum number of sessions to return (1-100)   |

**Response:**

```json theme={null}
{
  "sessions": [
    {
      "session_id": "sess_abc123",
      "created_at": "2026-03-07T14:30:00Z",
      "preview": "...customer asked about the refund policy for their recent order...",
      "message_count": 12,
      "last_message_at": "2026-03-07T14:45:00Z"
    },
    {
      "session_id": "sess_def456",
      "created_at": "2026-03-05T09:15:00Z",
      "preview": "...processed a refund for order #54321 per the standard policy...",
      "message_count": 8,
      "last_message_at": "2026-03-05T09:22:00Z"
    }
  ],
  "total": 2
}
```

## Use Cases

* **Quality review** — Search for sessions where a specific topic was discussed to audit agent responses.
* **Customer lookup** — Find all conversations related to a particular customer or order.
* **Training data** — Search for edge cases or complex conversations to use as evaluation examples.
* **Compliance** — Locate sessions that discussed sensitive topics for audit purposes.

## Tips

* Search is case-insensitive and matches partial words.
* Use specific terms for better results — "billing dispute March" works better than "problem".
* Search covers both user messages and agent responses.
* Results are ordered by relevance, with the best matches first.
