---
title: "Segments API"
description: "Named groups of contacts used to target campaigns."
url: https://www.unitpost.com/docs/platform/segments
section: "Platform API reference"
updated: 2026-11-17
---
# Segments API

> Named groups of contacts used to target campaigns. Segments decide who a campaign goes to; topics (below) decide what recipients can opt out of.

Full schemas: [OpenAPI 3.1](https://www.unitpost.com/api/v1/openapi.json). HTML reference: https://www.unitpost.com/docs/platform/segments.

## Operations

### `GET /api/v1/segments`

List segments

Retrieve a list of the segments in your workspace, cursor-paginated. A segment is a saved group of contacts you can target when sending a campaign. Create one with [Create a segment](https://www.unitpost.com/docs/platform/post-segments), or list a segment's members with [List segment members](https://www.unitpost.com/docs/platform/get-segments-id-contacts). Deleted (archived) segments are hidden; pass `?archived=true` to list only archived ones, which can be restored for 30 days. Requires the `segments:read` capability.

Reference: https://www.unitpost.com/docs/platform/get-segments ([Markdown](https://www.unitpost.com/docs/platform/get-segments.md))

### `POST /api/v1/segments`

Create a segment

Create a segment — a named group of contacts you can target when sending a campaign. Once created, add contacts with [Add a member](https://www.unitpost.com/docs/platform/post-segments-id-contacts) and target it from [Create a campaign](https://www.unitpost.com/docs/email/post-email-campaigns). A dynamic segment's `filter` is evaluated live: a condition on a custom field uses the field's `default_value` for any contact that has no value, and `is_set` / `is_not_set` check whether the contact itself has a value. To let recipients opt out of a category of mail instead, see [Create a topic](https://www.unitpost.com/docs/email/post-email-topics). Requires the `segments:write` capability.

Reference: https://www.unitpost.com/docs/platform/post-segments ([Markdown](https://www.unitpost.com/docs/platform/post-segments.md))

### `GET /api/v1/segments/{id}`

Retrieve a segment

Retrieve a single segment by `id`, including its name and member count. To page through the contacts inside it, use [List segment members](https://www.unitpost.com/docs/platform/get-segments-id-contacts). Requires the `segments:read` capability.

Reference: https://www.unitpost.com/docs/platform/get-segments-id ([Markdown](https://www.unitpost.com/docs/platform/get-segments-id.md))

### `PATCH /api/v1/segments/{id}`

Update a segment

Update a segment's editable metadata, such as its name. To change who's in the segment, add or remove members with [Add a member](https://www.unitpost.com/docs/platform/post-segments-id-contacts) and [Remove a member](https://www.unitpost.com/docs/platform/delete-segments-id-contacts-contact). Requires the `segments:write` capability.

Reference: https://www.unitpost.com/docs/platform/patch-segments-id ([Markdown](https://www.unitpost.com/docs/platform/patch-segments-id.md))

### `DELETE /api/v1/segments/{id}`

Delete a segment

Delete a segment. The contacts themselves are untouched — only the grouping is removed. This is blocked with `409` while an active campaign still targets the segment; cancel or finish that campaign first (see [List campaigns](https://www.unitpost.com/docs/email/get-email-campaigns)). Requires the `segments:write` capability.

Reference: https://www.unitpost.com/docs/platform/delete-segments-id ([Markdown](https://www.unitpost.com/docs/platform/delete-segments-id.md))

### `GET /api/v1/segments/{id}/contacts`

List segment members

Retrieve the contacts in a segment, cursor-paginated. Add a contact with [Add a member](https://www.unitpost.com/docs/platform/post-segments-id-contacts) or take one out with [Remove a member](https://www.unitpost.com/docs/platform/delete-segments-id-contacts-contact). Requires the `segments:read` capability.

Reference: https://www.unitpost.com/docs/platform/get-segments-id-contacts ([Markdown](https://www.unitpost.com/docs/platform/get-segments-id-contacts.md))

### `POST /api/v1/segments/{id}/contacts`

Add a member

Add a contact to a segment, referenced by contact id or email. The operation is idempotent — adding a contact that's already a member is a no-op and still succeeds. See the current members with [List segment members](https://www.unitpost.com/docs/platform/get-segments-id-contacts). Requires the `segments:write` capability.

Reference: https://www.unitpost.com/docs/platform/post-segments-id-contacts ([Markdown](https://www.unitpost.com/docs/platform/post-segments-id-contacts.md))

### `PATCH /api/v1/segments/{id}/contacts/{contact}`

Opt a member in or out

Opt a member out of this segment's sends without removing it (`subscribed: false`), or back in, as the members table's toggle and the preference page do. It stays a member. A dynamic segment has no per-segment opt-out (`422`). Requires the `segments:write` capability.

Reference: https://www.unitpost.com/docs/platform/patch-segments-id-contacts-contact ([Markdown](https://www.unitpost.com/docs/platform/patch-segments-id-contacts-contact.md))

### `DELETE /api/v1/segments/{id}/contacts/{contact}`

Remove a member

Remove a contact from a segment, referenced by contact id or email. The contact itself is not deleted — only its membership. Add it back any time with [Add a member](https://www.unitpost.com/docs/platform/post-segments-id-contacts). Requires the `segments:write` capability.

Reference: https://www.unitpost.com/docs/platform/delete-segments-id-contacts-contact ([Markdown](https://www.unitpost.com/docs/platform/delete-segments-id-contacts-contact.md))

### `POST /api/v1/segments/preview`

Preview a filter

Count an unsaved dynamic filter before you create the segment, as the segment dialog's live count does: how many contacts match, how many of them a campaign would mail, and a sample (which also needs `contacts:read`). It reads with the same filter builder the send uses. Nothing is saved. Requires the `segments:read` capability.

Reference: https://www.unitpost.com/docs/platform/post-segments-preview ([Markdown](https://www.unitpost.com/docs/platform/post-segments-preview.md))

### `GET /api/v1/segments/{id}/preview`

Preview a segment

How many contacts a saved segment reaches: its members, the subscribed set a campaign would mail (`0` means a campaign would send nothing), and a sample (which also needs `contacts:read`). Requires the `segments:read` capability.

Reference: https://www.unitpost.com/docs/platform/get-segments-id-preview ([Markdown](https://www.unitpost.com/docs/platform/get-segments-id-preview.md))

### `POST /api/v1/segments/all-contacts`

Get the all-contacts segment

The workspace's managed "All subscribed contacts" segment, made the first time it's asked for: the dashboard's "Everyone subscribed" campaign target. Repeating the call returns the same segment. Takes no body. Requires the `segments:write` capability.

Reference: https://www.unitpost.com/docs/platform/post-segments-all-contacts ([Markdown](https://www.unitpost.com/docs/platform/post-segments-all-contacts.md))
