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

# Get segments

> Retrieve all segments created in a specific list.

<ParamField path="list_id" type="integer" required>
  ID of the list.
</ParamField>

<Note>
  A list with no segments returns an empty array.
</Note>

<RequestExample>
  ```bash cURL theme={null}
  curl https://api2.ecomailapp.cz/lists/1/segments \
    -H "key: YOUR_API_KEY" \
    -H "Content-Type: application/json"
  ```

  ```php PHP theme={null}
  $listId = 1;
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, "https://api2.ecomailapp.cz/lists/{$listId}/segments");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
      'key: YOUR_API_KEY',
      'Content-Type: application/json',
  ]);
  $response = curl_exec($ch);
  curl_close($ch);
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "segments": {
      "5c36008811e45": { "name": "Segment 1", "id": "5c36008811e45", "count": 860 },
      "5cbf2405a77ce": { "name": "Segment 2", "id": "5cbf2405a77ce", "count": 540 }
    }
  }
  ```

  ```json 404 theme={null}
  {
    "message": "Not Found!"
  }
  ```
</ResponseExample>
