---
title: "Create Segment"
method: POST
path: "/v3/lists/{listId}/segments"
tags: ["Segments"]
---

# Create Segment

`POST /v3/lists/{listId}/segments`

This endpoint allows you to create a new segment via JSON body or from a CSV file. Query parameters are supported. If csv file is used, then the segment will be created matching content from a source column with a target column (segment will be typed as static). If json body is used, then the conditions for the segment can be passed through the body or as query params.

## Path parameters

- `listId` integer, required

## Query parameters

- `name` string
- `sourceColumn` string
- `targetColumn` string

## Request body

- SegmentJson
  - `name` string, required — name of the segmnet
  - `queryRule` string — segment condition

## Response `201`

Accepted the request to create the segment.

- SegmentResponse
  - `meta` MetadataDTO
    - `timestamp` integer, required — Transaction's date in timestamp
    - `transactionId` string, required — Id for the current transaction (Endpoint's call)
    - `explain` string — Explain string in case of failure
  - `data` Segment — list of segments
    - `id` string, required — segment id
    - `name` string, required — name of the segmnet
    - `userName` string — owner of the segment
    - `listId` integer, required — list id
    - `queryRule` string — segment condition
    - `total` integer, required — total of contacts in segment

## Other responses

- `400` — Bad request
- `500` — Internal server error

---

[API](https://skmtc.net/messangi/apis/raven.md) · [All operations](https://skmtc.net/messangi/apis/raven/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/messangi/raven/versions/c87f398fa338/schema)
