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

# Create segment

`POST /v0/segments`

## Request

- Base URL: `https://api.formo.so`
- URL: `https://api.formo.so/v0/segments`
- Auth: HTTP bearer

## Headers

- `Idempotency-Key` string

## Request body

- object
  - `title` string, required
  - `filters` SegmentFilterCondition[], required: Canonical filter objects combined with implicit AND.
    - `field` string, required
    - `op` 'eq' | 'neq' | 'gt' | 'lt' | 'gte' | 'lte' | 'in' | 'nin' | 'startsWith' | 'endsWith' | 'contains' | 'notEmpty' | 'isEmpty', required
    - `value` union: Value to compare against. Omit for `notEmpty` and `isEmpty`. Membership arrays must be non-empty. Array string members cannot contain a literal `|`, which is reserved as the Tinybird membership separator.
      - string
      - number
      - boolean
      - union[]
        - union
          - string
          - number

## Response `200`

Segment created

- Segment: A saved segment. `filters` is an array of canonical filter objects combined with implicit AND.
  - `id` string, required
  - `title` string, required
  - `projectId` string
  - `filters` SegmentFilterCondition[], required
    - `field` string, required
    - `op` 'eq' | 'neq' | 'gt' | 'lt' | 'gte' | 'lte' | 'in' | 'nin' | 'startsWith' | 'endsWith' | 'contains' | 'notEmpty' | 'isEmpty', required
    - `value` union: Value to compare against. Omit for `notEmpty` and `isEmpty`. Membership arrays must be non-empty. Array string members cannot contain a literal `|`, which is reserved as the Tinybird membership separator.
      - string
      - number
      - boolean
      - union[]
        - union
          - string
          - number

## Other responses

- `400`: The request was rejected. `code` is either `INVALID_VALIDATION_REQUEST` (Zod schema mismatch; `details` carries a `{ fieldPath: message }` map) or `BAD_REQUEST` (semantic validation failure outside Zod, e.g. mismatched IDs, business-rule violations). Branch on `code`, not status, to tell the two apart.
- `409`: The request conflicts with current resource state, or an `Idempotency-Key` request with the same key is currently in flight.

---

[API](https://skmtc.dev/formo/apis/formo-public-api.md) · [All operations](https://skmtc.dev/formo/apis/formo-public-api/llms.txt) · [OpenAPI document](https://skmtc.dev/formo/apis/formo-public-api/revisions/67ada57df63c?raw)
