> ## 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.

# List Agents

> Lists all active agents for the specified account. locationId is required parameter to ensure optimal performance. Supports pagination using limit and offset. Optionally filter by isPublished=true to 

Lists all active agents for the specified account. locationId is required parameter to ensure optimal performance. Supports pagination using limit and offset. Optionally filter by isPublished=true to return only agents with a published production version.

```http theme={null}
GET https://services.leadconnectorhq.com/agent-studio/agent
```

## 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="locationId" type="string" required default="C2QujeCh8ZnC7al2InWR" />

<ParamField query="isPublished" type="string" default="true">
  Optional filter to return only agents with a published production version
</ParamField>

<ParamField query="limit" type="string" required default="20" />

<ParamField query="offset" type="string" required default="0" />

<ParamField query="source" type="string" default="api" />

## Respuestas

<Accordion title="200 - Agents retrieved successfully">
  <ResponseField name="success" type="boolean" required default="True">
    Success status
  </ResponseField>

  <ResponseField name="message" type="string" required default="Agents retrieved successfully">
    Response message
  </ResponseField>

  <ResponseField name="agents" type="object[]" required>
    List of agents with metadata

    <Expandable title="cada item">
      <ResponseField name="agentId" type="string">
        Agent ID
      </ResponseField>

      <ResponseField name="name" type="string">
        Agent name
      </ResponseField>

      <ResponseField name="description" type="string">
        Agent description
      </ResponseField>

      <ResponseField name="locationId" type="string">
        Account ID
      </ResponseField>

      <ResponseField name="status" type="string">
        Agent status (always "active")
      </ResponseField>

      <ResponseField name="createdAt" type="string">
        Creation timestamp
      </ResponseField>

      <ResponseField name="updatedAt" type="string">
        Last update timestamp
      </ResponseField>
    </Expandable>
  </ResponseField>

  <ResponseField name="pagination" type="object" required>
    Pagination metadata

    <Expandable title="propiedades">
      <ResponseField name="total" type="number">
        Total number of agents
      </ResponseField>

      <ResponseField name="limit" type="number">
        Number of agents per page
      </ResponseField>

      <ResponseField name="offset" type="number">
        Starting position
      </ResponseField>

      <ResponseField name="hasMore" type="boolean">
        Whether more agents exist
      </ResponseField>
    </Expandable>
  </ResponseField>

  ```json theme={null}
  {
    "success": true,
    "message": "Agents retrieved successfully",
    "agents": [
      {
        "agentId": "p1q2r3s4t5u6v7w8x9y0z1a2",
        "name": "Marketing Assistant",
        "description": "AI agent specialized in marketing strategy and content creation",
        "locationId": "C2QujeCh8ZnC7al2InWR",
        "status": "active",
        "createdAt": "2024-01-15T10:30:00.000Z",
        "updatedAt": "2024-02-20T14:45:00.000Z"
      },
      {
        "agentId": "b3c4d5e6f7g8h9i0j1k2l3m4",
        "name": "Customer Support Bot",
        "description": "AI agent for handling customer inquiries and support tickets",
        "locationId": "C2QujeCh8ZnC7al2InWR",
        "status": "active",
        "createdAt": "2024-01-10T09:15:00.000Z",
        "updatedAt": "2024-02-18T16:20:00.000Z"
      }
    ],
    "pagination": {
      "total": 25,
      "limit": 20,
      "offset": 0,
      "hasMore": true
    }
  }
  ```
</Accordion>

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

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

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

<Accordion title="500 - Internal Server Error">
  <ResponseField name="statusCode" type="number" default="500" />

  <ResponseField name="message" type="string" default="Internal Server Error" />

  ```json theme={null}
  {
    "statusCode": 500,
    "message": "Internal Server Error"
  }
  ```
</Accordion>

## Ejemplo

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

  ```javascript Node.js theme={null}
  const response = await fetch('https://services.leadconnectorhq.com/agent-studio/agent', {
    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/agent-studio/agent',
      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/agent-studio/agent');
  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>
