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

# Create a segment

`POST /v1/projectId/{projectId}/segments`

## Request

- Base URL: `https://api.bluefox.email`
- URL: `https://api.bluefox.email/v1/projectId/{projectId}/segments`
- Auth: HTTP bearer

## Path parameters

- `projectId` string, required

## Request body

- SegmentInput
  - `name` string, required
  - `groups` object[]: OR-ed groups of AND-ed conditions - matches the segment builder in the app.
    - `conditions` object[]
      - `category` 'contact-property' | 'engagement'
      - `property` string: A custom contact field name, or "createdAt". Required unless operator is "any" or a tag operator.
      - `operator` 'any' | 'equals' | 'does-not-equal' | 'contains' | 'does-not-contain' | 'is-empty' | 'is-not-empty' | 'is-true' | 'is-false' | 'greater-than' | 'greater-than-or-equal' | 'less-than' | 'less-than-or-equal' | 'has-tag' | 'does-not-have-tag' | 'opened' | 'not-opened' | 'clicked' | 'not-clicked' | 'received' | 'not-received' | 'date-equals' | 'date-before' | 'date-after' | 'date-in-last' | 'date-more-than'
      - `value` unknown

## Response `201`

Created

- object
  - `status` integer
  - `result` Segment
    - `_id` string
    - `name` string
    - `groups` object[]: OR-ed groups of AND-ed conditions - matches the segment builder in the app.
      - `conditions` object[]
        - `category` 'contact-property' | 'engagement'
        - `property` string: A custom contact field name, or "createdAt". Required unless operator is "any" or a tag operator.
        - `operator` 'any' | 'equals' | 'does-not-equal' | 'contains' | 'does-not-contain' | 'is-empty' | 'is-not-empty' | 'is-true' | 'is-false' | 'greater-than' | 'greater-than-or-equal' | 'less-than' | 'less-than-or-equal' | 'has-tag' | 'does-not-have-tag' | 'opened' | 'not-opened' | 'clicked' | 'not-clicked' | 'received' | 'not-received' | 'date-equals' | 'date-before' | 'date-after' | 'date-in-last' | 'date-more-than'
        - `value` unknown
    - `createdAt` string, date-time
    - `updatedAt` string, date-time

## Other responses

- `400`: Invalid request body or query - every violation found (missing/invalid/unexpected fields) is reported in one response, semicolon-separated, not just the first one hit.
- `403`: Missing or invalid API key

---

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