---
title: "Create a segment"
method: POST
path: "/v1/segments"
tags: ["Segments"]
---

# Create a segment

`POST /v1/segments`

## Request

- Base URL: `https://api.volanea.com`
- URL: `https://api.volanea.com/v1/segments`
- Auth: HTTP bearer

Dynamic segments require `conditions` and are computed immediately; static segments start empty and are managed via the members endpoints.

Pass `dryRun: true` to preview instead of create — identical to `POST /v1/segments/preview`, and `name` is not required. The alias exists because the MCP `create_segment` tool takes `dryRun` and tells agents to run one first: until this was honoured, carrying that parameter into the REST call created a live segment on every "preview", and deleting it afterwards did not undo the `segment.entered` activity it had already written onto contacts.

## Request body

- object
  - `name` string: Required unless `dryRun` is true.
  - `description` string
  - `type` 'dynamic' | 'static'
  - `conditions` SegmentConditions: Nested condition tree evaluated against contacts, their custom `data`, and their activity.
    - `logic` 'and' | 'or', required
    - `groups` object[], required
      - `filters` object[], required
        - `field` string, required: `email`, `subscribed`, `locale`, `createdAt`, `data.<key>`, `event.<name>`, `email.opened`, …
        - `operator` string, required: `equals`, `notEquals`, `contains`, `notContains`, `greaterThan`, `lessThan`, `exists`, `notExists`, `within`, `notWithin`, `triggered`, `notTriggered`, …
        - `value` union
          - string
          - number
          - boolean
        - `days` integer: Time window (days) for activity operators.
  - `dryRun` boolean: Preview only — nothing is created. Returns the same shape as `POST /v1/segments/preview`.

## Response `200`

Preview, when `dryRun` is true.

- object
  - `dryRun` true, required
  - `segmentId` unknown
  - `count` integer, required
  - `sample` Contact[]
    - `contactId` string, required
    - `projectId` string
    - `email` string, email, required
    - `firstName` string, nullable
    - `lastName` string, nullable
    - `subscribed` boolean, required
    - `data` object, nullable: Arbitrary custom fields.
    - `locale` string, nullable
    - `createdAt` string, date-time, required
    - `updatedAt` string, date-time, required

## Other responses

- `201`: Created.
- `401`: Missing or invalid API key.
- `422`: Request validation failed (code `validation_error`, 422).

---

[API](https://skmtc.dev/volanea/apis/volanea-api.md) · [All operations](https://skmtc.dev/volanea/apis/volanea-api/llms.txt) · [OpenAPI document](https://skmtc.dev/volanea/apis/volanea-api/revisions/9e187ae84fda?raw)
