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

# Create a segment

`POST /segments`

## Request

- Base URL: `https://api.commonroom.io/api/v2`
- URL: `https://api.commonroom.io/api/v2/segments`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/commonroom/apis/common-room-api-v2/docs/segments/post.ts> (a function with typed inputs; its response is checked against the schema)

Create a new segment in the community.

## Request body

- CreateSegmentRequest
  - `name` string, required: The name for the new segment (max 500 characters)
  - `description` string: Optional description for the segment (markdown supported)
  - `entityType` 'contact' | 'object' | 'organization': The type of entity this segment will contain
  - `objectTypeId` string: Required when entityType is `object`. Prefixed object type ID (format `cot_<number>`)

## Response `201`

Created

- CreateSegmentResponse
  - `success` true, required
  - `data` object, required
    - `id` string, required: Prefixed segment ID (format `s_<number>`)
    - `name` string, required

## Other responses

- `400`: Bad Request (e.g. invalid parameters or missing required fields)
- `403`: Forbidden
- `409`: Conflict (a segment with this name already exists)
- `429`: Rate Limited

---

[API](https://skmtc.dev/commonroom/apis/common-room-api-v2.md) - [All operations](https://skmtc.dev/commonroom/apis/common-room-api-v2/llms.txt) - [OpenAPI document](https://skmtc.dev/commonroom/apis/common-room-api-v2/revisions/865d4d43dadf?raw)
