# GET /lists-and-segments — Get all Lists and Segments

> Product: **Pabbly Email Marketing** (v2)
> Base URL: `https://emails.pabbly.com/api/v2`
> Auth: Bearer via `Authorization` header
> Canonical: `/email-marketing/subscriber-lists/get-all-lists-and-segments`

The token must be included in the Authorization header as a Bearer token. Retrieves a complete list of all subscriber lists and segments belonging to your authenticated business. Returns both lists and segments with their IDs, names, subscriber counts, and metadata. Lists and segments are sorted alphabetically by name (A-Z). This endpoint is useful for selecting target lists or segments when sending campaigns via the API. The response includes separate arrays for lists and segments, along with total counts for each type.

**Response (200)** — Get all Lists and Segments:

```json
{
    "success": true,
    "status": "success",
    "message": "Lists and segments retrieved successfully",
    "data": {
        "lists": [
            {
                "id": "1024158",
                "name": "Default list",
                "type": "list",
                "count": 9156,
                "counts": {
                    "totalSubscribers": 9156,
                    "unsubscribedCount": 6,
                    "engagedCount": 5,
                    "lastUpdated": "2026-02-02T06:47:24.447Z"
                },
                "createdAt": "2025-12-16T10:57:37.141Z",
                "updatedAt": "2025-12-16T10:57:37.141Z"
            },
            {
                "id": "1024165",
                "name": "new demo",
                "type": "list",
                "count": 0,
                "counts": {
                    "totalSubscribers": 0,
                    "unsubscribedCount": 0,
                    "engagedCount": 0,
                    "lastUpdated": "2026-02-02T06:47:24.447Z"
                },
                "createdAt": "2025-12-16T10:57:37.170Z",
                "updatedAt": "2025-12-16T10:57:37.170Z"
            },
            {
                "id": "69412881c231c8db46a01b23",
                "name": "pem-dev",
                "type": "list",
                "count": 6,
                "counts": {
                    "totalSubscribers": 6,
                    "unsubscribedCount": 0,
                    "engagedCount": 6,
                    "lastUpdated": "2026-02-02T06:47:24.447Z"
                },
                "createdAt": "2025-12-16T09:38:09.224Z",
                "updatedAt": "2025-12-16T09:38:09.224Z"
            },
            {
                "id": "6965320222f445bcaacb5ef8",
                "name": "test-1",
                "type": "list",
                "count": 0,
                "counts": {
                    "totalSubscribers": 0,
                    "unsubscribedCount": 0,
                    "engagedCount": 0,
                    "lastUpdated": "2026-02-02T06:47:24.447Z"
                },
                "createdAt": "2026-01-12T17:40:18.139Z",
                "updatedAt": "2026-01-12T17:40:18.139Z"
            }
        ],
        "segments": [
            {
                "id": "6952345b2011e7f242a11836",
                "name": "test",
                "type": "segment",
                "conditions": [
                    [
                        {
                            "filterBy": "Custom Field",
                            "customField": "firstName",
                            "filterType": "Contains",
                            "value": "user",
                            "_id": "695234652011e7f242a11a2a"
                        }
                    ]
                ],
                "createdAt": "2025-12-29T07:57:15.811Z",
                "updatedAt": "2026-01-13T07:35:42.766Z"
            },
            {
                "id": "695255f52011e7f242adc8bf",
                "name": "test1",
                "type": "segment",
                "conditions": [
                    [
                        {
                            "filterBy": "Custom Field",
                            "customField": "email",
                            "filterType": "Contains",
                            "value": "user",
                            "_id": "695256002011e7f242add121"
                        }
                    ]
                ],
                "createdAt": "2025-12-29T10:20:37.265Z",
                "updatedAt": "2026-01-13T07:35:42.765Z"
            }
        ],
        "totalLists": 4,
        "totalSegments": 2,
        "total": 6
    }
}
```

**Code examples:**

_cURL_

```curl
curl https://emails.pabbly.com/api/v2/lists-and-segments \
  -H "Authorization: Bearer {{YOUR_API_KEY}}"
```

_Ruby_

```ruby
require 'net/http'
require 'json'

uri = URI('https://emails.pabbly.com/api/v2/lists-and-segments')
request = Net::HTTP::Get.new(uri)
request['Authorization'] = 'Bearer {{YOUR_API_KEY}}'

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
  http.request(request)
end

data = JSON.parse(response.body)
```

_Python_

```python
import requests

response = requests.get(
    'https://emails.pabbly.com/api/v2/lists-and-segments',
    headers={'Authorization': 'Bearer {{YOUR_API_KEY}}'},
)

data = response.json()
```

_PHP_

```php
<?php
$ch = curl_init('https://emails.pabbly.com/api/v2/lists-and-segments');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer {{YOUR_API_KEY}}']);

$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
```

_Java_

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

HttpClient client = HttpClient.newHttpClient();
HttpRequest.Builder builder = HttpRequest.newBuilder()
    .uri(URI.create("https://emails.pabbly.com/api/v2/lists-and-segments"))
    .header("Authorization", "Bearer {{YOUR_API_KEY}}")
    .GET();

HttpRequest request = builder.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```

_Node.js_

```node
const response = await fetch('https://emails.pabbly.com/api/v2/lists-and-segments', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer {{YOUR_API_KEY}}',
  },
});

const data = await response.json();
```

_Go_

```go
package main

import (
    "fmt"
    "io"
    "net/http"
)

func main() {
    req, _ := http.NewRequest("GET", "https://emails.pabbly.com/api/v2/lists-and-segments", nil)
    req.Header.Set("Authorization", "Bearer {{YOUR_API_KEY}}")

    res, _ := http.DefaultClient.Do(req)
    defer res.Body.Close()
    body, _ := io.ReadAll(res.Body)
    fmt.Println(string(body))
}
```

_.NET_

```dotnet
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://emails.pabbly.com/api/v2/lists-and-segments");
request.Headers.TryAddWithoutValidation("Authorization", "Bearer {{YOUR_API_KEY}}");

var response = await client.SendAsync(request);
var data = await response.Content.ReadAsStringAsync();
Console.WriteLine(data);
```

---

**Other endpoints in Subscriber Lists:**

- [GET /lists — Get All Subscriber Lists](/email-marketing/subscriber-lists/get-all-subscriber-lists)
- [GET /lists/{{listId}} — Get Single Subscriber List by ID](/email-marketing/subscriber-lists/get-single-subscriber-list-by-id)
- [POST /lists/add-subscriber — Add Subscriber to Lists](/email-marketing/subscriber-lists/add-subscriber-to-lists)
- [POST /lists/remove-subscriber — Remove Subscriber from Lists](/email-marketing/subscriber-lists/remove-subscriber-from-lists)
- [POST /lists — Create Subscriber List](/email-marketing/subscriber-lists/create-subscriber-list)
- [GET /lists — Get Single Subscriber List by List Name](/email-marketing/subscriber-lists/get-single-subscriber-list-by-list-name)
- [POST /lists/move-subscriber — Move Subscriber Between Lists](/email-marketing/subscriber-lists/move-subscriber-between-lists)

