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

# List Chat Sessions

> Retrieve a paginated list of all chat sessions for your agents

## Overview

This endpoint returns all chat sessions created through your agents. Use it to monitor chat activity, review conversation history, and manage ongoing sessions.

## Authentication

<ParamField header="X-API-Key" type="string" required>
  Your eigi.ai API key. Must be prefixed with `vk_`.
</ParamField>

## Query Parameters

<ParamField query="page" type="integer" default="1">
  Page number to retrieve (minimum: 1)
</ParamField>

<ParamField query="page_size" type="integer" default="10">
  Number of items per page (minimum: 1, maximum: 100)
</ParamField>

<ParamField query="agent_id" type="string">
  Filter sessions by a specific agent ID. Example: `68ea2517dbb84c09bae1ba0a`
</ParamField>

## Response

<ResponseField name="object" type="string">
  Always `"list"` for list responses.
</ResponseField>

<ResponseField name="data" type="array">
  Array of chat session objects.
</ResponseField>

<ResponseField name="has_more" type="boolean">
  Whether there are more results available beyond this page.
</ResponseField>

<ResponseField name="total" type="integer">
  Total number of sessions matching the query.
</ResponseField>

<ResponseField name="page" type="integer">
  Current page number.
</ResponseField>

<ResponseField name="page_size" type="integer">
  Number of items per page.
</ResponseField>

<ResponseField name="total_pages" type="integer">
  Total number of pages available.
</ResponseField>

### Session Object

<ResponseField name="id" type="string">
  Unique identifier for the chat session.
</ResponseField>

<ResponseField name="object" type="string">
  Always `"chat.session"` for session objects.
</ResponseField>

<ResponseField name="created_at" type="integer">
  Unix timestamp when the session was created.
</ResponseField>

<ResponseField name="updated_at" type="integer">
  Unix timestamp when the session was last updated.
</ResponseField>

<ResponseField name="agent_id" type="string">
  ID of the agent handling this session.
</ResponseField>

<ResponseField name="conversation_name" type="string">
  Name or identifier for the conversation.
</ResponseField>

<ResponseField name="message_count" type="integer">
  Total number of messages in the session.
</ResponseField>

<ResponseField name="metadata" type="object">
  Custom metadata attached to the session.
</ResponseField>

## Examples

### List All Sessions

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://api.eigi.ai/v1/public/chat/sessions?page=1&page_size=10" \
    -H "X-API-Key: vk_your_api_key_here"
  ```

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

  response = requests.get(
      "https://api.eigi.ai/v1/public/chat/sessions",
      headers={"X-API-Key": "vk_your_api_key_here"},
      params={"page": 1, "page_size": 10}
  )

  data = response.json()
  for session in data["data"]:
      print(f"Session: {session['id']} - Messages: {session['message_count']}")
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    "https://api.eigi.ai/v1/public/chat/sessions?page=1&page_size=10",
    {
      headers: {
        "X-API-Key": "vk_your_api_key_here",
      },
    }
  );

  const data = await response.json();
  data.data.forEach((session) => {
    console.log(`Session: ${session.id} - Messages: ${session.message_count}`);
  });
  ```
</CodeGroup>

### Filter by Agent

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://api.eigi.ai/v1/public/chat/sessions?agent_id=68ea2517dbb84c09bae1ba0a" \
    -H "X-API-Key: vk_your_api_key_here"
  ```

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

  response = requests.get(
      "https://api.eigi.ai/v1/public/chat/sessions",
      headers={"X-API-Key": "vk_your_api_key_here"},
      params={"agent_id": "68ea2517dbb84c09bae1ba0a"}
  )

  data = response.json()
  print(f"Found {data['total']} sessions for this agent")
  ```
</CodeGroup>

### Response Example

```json theme={null}
{
  "object": "list",
  "data": [
    {
      "id": "58a6b549-ef07-4a31-86bc-0eb0e026840a",
      "object": "chat.session",
      "created_at": 1701792000,
      "updated_at": 1701792100,
      "agent_id": "68ea2517dbb84c09bae1ba0a",
      "conversation_name": "Support Chat",
      "message_count": 12,
      "metadata": {
        "user_id": "user_123",
        "source": "website"
      }
    },
    {
      "id": "a7c3d421-b89e-4f12-9c6a-1e2f3g4h5i6j",
      "object": "chat.session",
      "created_at": 1701788400,
      "updated_at": 1701789500,
      "agent_id": "68ea2517dbb84c09bae1ba0a",
      "conversation_name": "Product Inquiry",
      "message_count": 8,
      "metadata": {}
    }
  ],
  "has_more": true,
  "total": 45,
  "page": 1,
  "page_size": 10,
  "total_pages": 5
}
```

## Error Responses

| Status Code          | Description                                              |
| -------------------- | -------------------------------------------------------- |
| **401 Unauthorized** | Missing, invalid, inactive, or expired API key           |
| **403 Forbidden**    | API key owner doesn't have access to the specified agent |

```json Example Error Response theme={null}
{
  "detail": "Invalid API key"
}
```

## Use Cases

<CardGroup cols={2}>
  <Card title="Analytics Dashboard" icon="chart-bar">
    Track chat volume, session counts, and engagement metrics
  </Card>

  <Card title="Customer Support" icon="headset">
    Monitor active chat sessions and review conversation history
  </Card>

  <Card title="Quality Assurance" icon="check-double">
    Review chat interactions for training and improvement
  </Card>

  <Card title="CRM Integration" icon="plug">
    Sync chat sessions with your customer management system
  </Card>
</CardGroup>


## OpenAPI

````yaml GET /v1/public/chat/sessions
openapi: 3.0.0
info:
  title: eigi.ai API
  description: REST API for managing AI voice agents and conversations
  version: 1.0.0
  contact:
    email: buddy@eigi.ai
    url: https://eigi.ai
servers:
  - url: https://api.eigi.ai
    description: Production server
security:
  - ApiKeyAuth: []
paths:
  /v1/public/chat/sessions:
    get:
      tags:
        - Chat
      summary: List Chat Sessions
      description: Retrieve a paginated list of all chat sessions for your agents
      operationId: listChatSessions
      parameters:
        - name: page
          in: query
          description: 'Page number (minimum: 1)'
          schema:
            type: integer
            default: 1
            minimum: 1
        - name: page_size
          in: query
          description: 'Items per page (minimum: 1, maximum: 100)'
          schema:
            type: integer
            default: 10
            minimum: 1
            maximum: 100
        - name: agent_id
          in: query
          description: Filter sessions by agent ID
          schema:
            type: string
      responses:
        '200':
          description: Successfully retrieved chat sessions
          content:
            application/json:
              schema:
                type: object
                properties:
                  object:
                    type: string
                    example: list
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/ChatSession'
                  has_more:
                    type: boolean
                  total:
                    type: integer
                  page:
                    type: integer
                  page_size:
                    type: integer
                  total_pages:
                    type: integer
        '401':
          description: Unauthorized - Invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Forbidden - Access denied to agent
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    ChatSession:
      type: object
      properties:
        id:
          type: string
          description: Unique session identifier
        object:
          type: string
          example: chat.session
        created_at:
          type: integer
          description: Unix timestamp of creation
        updated_at:
          type: integer
          description: Unix timestamp of last update
        agent_id:
          type: string
          description: ID of the agent handling this session
        conversation_name:
          type: string
          description: Name of the conversation
        message_count:
          type: integer
          description: Total messages in session
        metadata:
          type: object
          description: Custom metadata
    Error:
      type: object
      properties:
        detail:
          type: string
          description: Error message
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: >-
        API key for authentication. Get your API key from the eigi.ai Dashboard
        under Settings â†’ API Keys.

````