> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developers.beehiiv.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.beehiiv.com/_mcp/server.

# List segments <Badge intent="info" minimal outlined>OAuth Scope: segments:read</Badge>

GET https://api.beehiiv.com/v2/publications/{publicationId}/segments

Retrieve information about all segments belonging to a specific publication

Reference: https://developers.beehiiv.com/api-reference/segments/index

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Path parameters

- `publicationId` (string, required) — The prefixed ID of the publication object

### Query parameters

- `type` (enum, optional, default: all) — Optionally filter the results by the segment's type.
  - Allowed values: `dynamic`, `static`, `manual`, `all`
- `status` (enum, optional, default: all) — Optionally filter the results by the segment's status.
  - Allowed values: `pending`, `processing`, `completed`, `failed`, `all`
- `limit` (integer, optional) — A limit on the number of objects to be returned. The limit can range between 1 and 100, and the default is 10.
- `page` (integer, optional) — Pagination returns the results in pages. Each page contains the number of results specified by the `limit` (default: 10).If not specified, results 1-10 from page 1 will be returned.
- `order_by` (enum, optional, default: created) — The field that the results are sorted by. Defaults to created `created` - The time in which the segment was first created. `last_calculated` - The time that the segment last completed calculation. Measured in seconds since the Unix epoch.
  - Allowed values: `created`, `last_calculated`
- `direction` (enum, optional, default: asc) — The direction that the results are sorted in. Defaults to asc `asc` - Ascending, sorts from smallest to largest. `desc` - Descending, sorts from largest to smallest.
  - Allowed values: `asc`, `desc`
- `expand[]` (list of enum, optional) — Optionally expand the response to include additional data. `stats` - Requests the most recently calculated statistics for a segment. Segment stats are recalculated once daily around 7 a.m. UTC for dynamic segments, but can be manually recalculated at any time in the dashboard. Manual and static segments only calculate once upon upload or creation.
  - Allowed values: `stats`

## Response

### 200

OK

- `data` (list of Segment, required) — An array of all segments.
- `limit` (integer, required) — The limit placed on the results. If no limit was specified in the request,this defaults to 10.
- `page` (integer, required, default: 1) — The page number the results are from. If no page was specified in the request, this defaults to page 1.
- `total_results` (integer, required) — The total number of results from all pages.
- `total_pages` (integer, required) — The total number of pages.

## Errors

### 400 Bad Request Error

Bad Request

- `status` (integer, required)
- `statusText` (string, required)
- `errors` (list of ErrorDetail, required)

### 401 Unauthorized Error

Unauthorized. The API key or OAuth access token is missing, invalid, or expired.

- `status` (integer, required)
- `statusText` (string, required)
- `errors` (list of ErrorDetail, required)

### 404 Not Found Error

Resource Not Found

- `status` (integer, required)
- `statusText` (string, required)
- `errors` (list of ErrorDetail, required)

### 429 Too Many Requests Error

Rate Limit Exceeded

- `status` (integer, required)
- `statusText` (string, required)
- `errors` (list of ErrorDetail, required)

### 500 Internal Server Error

Internal Server Error

- `status` (integer, required)
- `statusText` (string, required)
- `errors` (list of ErrorDetail, required)

## Types

### Segment

The segment object. To expand results, see the results endpoint.

- `id` (string, required) — The prefixed ID of the segment.
- `name` (string, required) — The name of the segment.
- `type` (enum, required, default: all) — The type of segment.`dynamic` - The segment is recalculated at set intervals.`static` - The segment is calculated once at creation.`manual` - The segment is not calculated at all. The results are created via CSV.
  - Allowed values: `dynamic`, `static`, `manual`, `all`
- `total_results` (integer, required) — The total number of subscriptions that belong in the segment from the last calculation.
- `status` (enum, required) — The status of the segment's most recent calculation.`pending` - The segment has not been calculated yet.`processing` - The calculation is in progress, and has not completed.`completed` - The calculation was successful.`failed` - Something went wrong during the calculation.
  - Allowed values: `pending`, `processing`, `completed`, `failed`
- `active` (boolean, required) — Dynamic segments are marked inactive if they haven't been used in a specific period of time. Inactive segments will not automatically be recalculated.
- `last_calculated` (integer, optional) — The time the Segment was last calculated. Measured in seconds since the Unix epoch
- `stats` (SegmentStats, optional)

### ErrorDetail

- `message` (string, required)
- `code` (string, required)

### SegmentStats

- `open_rate` (double, required) — The average open rate of the subscribers in the segment.
- `total_sent` (integer, required) — The total number of emails sent to the subscribers in the segment.
- `percentage_premium_subscribers` (double, required) — The percentage of subscribers in this segment who are premium in any tier.
- `percentage_subscribers_with_referrals` (double, required) — The percentage of subscribers in this segment who have referred at least one other subscriber.
- `unique_emails_clicked` (integer, required) — The total number of unique emails clicked by subscribers in the segment.
- `total_delivered` (integer, required) — The total number of emails delivered to subscribers in the segment.
- `total_referrals` (integer, required) — The total number of referrals from subscribers in the segment.
- `unsubscribed_rate` (double, required) — The percentage of subscribers in this segment who have unsubscribed.
- `total_subscribers` (integer, required) — The total number of subscribers in the segment.
- `clickthrough_rate` (double, required) — The average clickthrough rate of the subscribers in the segment.
- `unsubscribed_count` (integer, required) — The total number of subscribers in the segment who are unsubscribed.
- `unique_emails_opened` (integer, required) — The total number of unique emails opened by subscribers in the segment.
- `premium_subscribers` (integer, required) — The total number of premium subscribers in the segment.
- `average_referrals_per_subscriber` (double, required) — The average number of referrals per subscriber in the segment.

## Examples

**Response**

```json
{
  "data": [
    {
      "id": "seg_00000000-0000-0000-0000-000000000000",
      "name": "name",
      "type": "dynamic",
      "total_results": 15,
      "status": "pending",
      "active": true,
      "last_calculated": 1666800076,
      "stats": {
        "open_rate": 0.5,
        "total_sent": 100,
        "percentage_premium_subscribers": 0.2,
        "percentage_subscribers_with_referrals": 0.1,
        "unique_emails_clicked": 10,
        "total_delivered": 100,
        "total_referrals": 10,
        "unsubscribed_rate": 0.05,
        "total_subscribers": 100,
        "clickthrough_rate": 0.5,
        "unsubscribed_count": 5,
        "unique_emails_opened": 10,
        "premium_subscribers": 20,
        "average_referrals_per_subscriber": 0.1
      }
    }
  ],
  "limit": 1,
  "page": 1,
  "total_results": 1,
  "total_pages": 1
}
```

**SDK Code**

```typescript
import { BeehiivClient } from "beehiiv";

const client = new BeehiivClient({ token: "YOUR_TOKEN" });
await client.segments.list("pub_00000000-0000-0000-0000-000000000000");

```

```python
import requests

url = "https://api.beehiiv.com/v2/publications/pub_00000000-0000-0000-0000-000000000000/segments"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```go
package main

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

func main() {

	url := "https://api.beehiiv.com/v2/publications/pub_00000000-0000-0000-0000-000000000000/segments"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.beehiiv.com/v2/publications/pub_00000000-0000-0000-0000-000000000000/segments")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.beehiiv.com/v2/publications/pub_00000000-0000-0000-0000-000000000000/segments")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.beehiiv.com/v2/publications/pub_00000000-0000-0000-0000-000000000000/segments', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.beehiiv.com/v2/publications/pub_00000000-0000-0000-0000-000000000000/segments");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.beehiiv.com/v2/publications/pub_00000000-0000-0000-0000-000000000000/segments")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```