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

# Create a segment

`POST /api/v1/segments`

## Request

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

Creates a new segment in the active project. Segment names are unique per project and case-insensitive.

## Headers

- `Pineprompt-Project-Id` integer, required

## Request body

- StoreSegment
  - `name` string, required: A label for the segment. May be up to <strong>64</strong> characters. Segment names are unique per project and case-insensitive, so `Direct Competitors` and `direct competitors` will collide.

## Response `201`

Created

- Segment: A segment groups brands into a named cohort, such as `Direct Competitors`. Your own brand is implicit in every segment, so a segment only ever lists competitors.
  - `id` integer: The unique ID of the segment.
  - `project_id` integer: The ID of the project this segment belongs to.
  - `name` string: The display label of the segment.
  - `project` Project: A project represents a single brand or site you monitor. Its `brand_id` names the own brand, the brand every core metric is computed for.
    - `id` integer: The unique ID of the project.
    - `organization_id` integer: The ID of the organization that owns the project.
    - `name` string: The display name of the project.
    - `brand_id` integer, nullable: The ID of the project's own brand, or null while none has been designated.
    - `organization` Organization: An organization is the top-level billing entity and tenant boundary in Pineprompt. Every project, member, and API key belongs to exactly one organization.
      - `id` integer: The unique ID of the organization.
      - `name` string: The display name of the organization.
      - `created_at` string, date-time: When the organization was created.
      - `updated_at` string, date-time: When the organization was last updated.
    - `created_at` string, date-time: When the project was created.
    - `updated_at` string, date-time: When the project was last updated.
  - `created_at` string, date-time: When the segment was created.
  - `updated_at` string, date-time: When the segment was last updated.

## Other responses

- `400`: Missing project header
- `401`: Unauthorized
- `403`: Missing ability
- `404`: Project not in this organization
- `422`: Validation failed

---

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