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

# Search Agents

> Searches for AI agents based on various criteria including name, status, and configuration. Supports advanced filtering and full-text search capabilities.

Searches for AI agents based on various criteria including name, status, and configuration. Supports advanced filtering and full-text search capabilities.

```http theme={null}
GET https://services.leadconnectorhq.com/conversation-ai/agents/search
```

## Autorización

<ParamField header="Authorization" type="string" required>
  Bearer token generado desde el portal Leadway. Ver [Autenticación](/authentication).
</ParamField>

<ParamField header="Version" type="string" required default="2021-07-28">
  Versión de la API.
</ParamField>

## Query parameters

<ParamField query="startAfter" type="string" default="Exampleee123">
  Start after is the agent id to start after, Serving as skip, send empty when first page
</ParamField>

<ParamField query="limit" type="number" default="1">
  Records per page
</ParamField>

<ParamField query="query" type="string" default="booking">
  query to search on agent name, must be provided in lowercase
</ParamField>

## Respuestas

<Accordion title="200 - Successful response">
  <ResponseField name="agents" type="object[]" required>
    List of agents matching the search criteria.

    <Expandable title="cada item">
      <ResponseField name="id" type="string" required default="emp_123">
        Unique identifier for the agent.
      </ResponseField>

      <ResponseField name="name" type="string" required default="John Doe">
        Name of the agent.
      </ResponseField>

      <ResponseField name="businessName" type="string" default="Tech Corp">
        Name of the business the agent represents.
      </ResponseField>

      <ResponseField name="mode" type="string" required default="auto-pilot">
        Current operating mode of the agent. Posibles valores: 'off', 'suggestive', 'auto-pilot'
      </ResponseField>

      <ResponseField name="channels" type="string[]" required>
        Communication channels the agent operates on.
      </ResponseField>

      <ResponseField name="waitTime" type="number" required default="30">
        Wait time before agent responds.
      </ResponseField>

      <ResponseField name="waitTimeUnit" type="string" required default="seconds">
        Unit for wait time. Posibles valores: 'minutes', 'seconds'
      </ResponseField>

      <ResponseField name="sleepEnabled" type="boolean" required default="False">
        Indicates if sleep functionality is enabled.
      </ResponseField>

      <ResponseField name="sleepTime" type="number" default="2">
        Duration of sleep period.
      </ResponseField>

      <ResponseField name="sleepTimeUnit" type="string" default="hours">
        Unit of sleep time. Posibles valores: 'hours', 'minutes', 'seconds'
      </ResponseField>

      <ResponseField name="actions" type="object[]" required>
        List of actions associated with this agent.
      </ResponseField>

      <ResponseField name="isPrimary" type="boolean" required default="False">
        Indicates if this agent is a primary agent. (First agent created for a account is primary by default)
      </ResponseField>

      <ResponseField name="autoPilotMaxMessages" type="number" required default="25">
        Maximum number of messages in auto-pilot mode before requiring human intervention.
      </ResponseField>

      <ResponseField name="goal" type="object">
        Goal configuration for the agent.
      </ResponseField>

      <ResponseField name="knowledgeBaseIds" type="string[]">
        Array of knowledge base IDs associated with this agent.
      </ResponseField>

      <ResponseField name="createdAt" type="string" required default="2024-01-01T00:00:00Z">
        Timestamp when the agent was created.
      </ResponseField>

      <ResponseField name="updatedAt" type="string" required default="2024-01-01T00:00:00Z">
        Timestamp when the agent was last updated.
      </ResponseField>

      <ResponseField name="sleepOnManualMessage" type="boolean" default="False">
        Whether the bot sleeps on manual outbound messages.
      </ResponseField>

      <ResponseField name="sleepOnWorkflowMessage" type="boolean" default="False">
        Whether the bot sleeps on workflow outbound messages.
      </ResponseField>
    </Expandable>
  </ResponseField>

  <ResponseField name="totalCount" type="number" required default="100">
    Total number of agents in the account (unfiltered count).
  </ResponseField>

  <ResponseField name="count" type="number" required default="25">
    Number of agents in the current response (filtered/paginated count).
  </ResponseField>

  ```json theme={null}
  {
    "agents": [
      {
        "id": "emp_123",
        "name": "John Doe",
        "businessName": "Tech Corp",
        "mode": "auto-pilot",
        "channels": [
          "SMS",
          "LIVE_CHAT"
        ],
        "waitTime": 30,
        "waitTimeUnit": "seconds",
        "sleepEnabled": false,
        "sleepTime": 2,
        "sleepTimeUnit": "hours",
        "actions": [
          {
            "id": "action_123",
            "type": "triggerWorkflow"
          }
        ],
        "isPrimary": false,
        "autoPilotMaxMessages": 25,
        "goal": {
          "prompt": "Assist customers",
          "type": "custom",
          "actionId": null
        },
        "knowledgeBaseIds": [
          "kb_123",
          "kb_456"
        ],
        "createdAt": "2024-01-01T00:00:00Z",
        "updatedAt": "2024-01-01T00:00:00Z",
        "sleepOnManualMessage": false,
        "sleepOnWorkflowMessage": false
      }
    ],
    // truncado: 3 lineas mas
  }
  ```
</Accordion>

<Accordion title="400 - Bad Request">
  ```json theme={null}
  {}
  ```
</Accordion>

<Accordion title="401 - Unauthorized">
  ```json theme={null}
  {}
  ```
</Accordion>

<Accordion title="422 - Unprocessable Entity">
  ```json theme={null}
  {}
  ```
</Accordion>

## Ejemplo

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET 'https://services.leadconnectorhq.com/conversation-ai/agents/search' \
    -H 'Authorization: Bearer YOUR_TOKEN' \
    -H 'Version: 2021-07-28'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://services.leadconnectorhq.com/conversation-ai/agents/search', {
    method: 'GET',
    headers: {
      Authorization: `Bearer ${process.env.LEADWAY_TOKEN}`,
      Version: '2021-07-28',
    },
  });
  const data = await response.json();
  ```

  ```python Python theme={null}
  import os, requests
  response = requests.request(
      'GET',
      'https://services.leadconnectorhq.com/conversation-ai/agents/search',
      headers={
          'Authorization': f"Bearer {os.environ['LEADWAY_TOKEN']}",
          'Version': '2021-07-28',
      },
  )
  data = response.json()
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init('https://services.leadconnectorhq.com/conversation-ai/agents/search');
  curl_setopt_array($ch, [
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_CUSTOMREQUEST => 'GET',
      CURLOPT_HTTPHEADER => [
          'Authorization: Bearer ' . getenv('LEADWAY_TOKEN'),
          'Version: 2021-07-28',
      ],
  ]);
  $data = json_decode(curl_exec($ch), true);
  ```
</CodeGroup>
