GET /api/v1/segments
List all segments with their base schema names. Supports cursor-based pagination.Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
limit | integer | 20 | Max results per page |
cursor | string | — | Cursor for pagination |
Response
POST /api/v1/segments
Create a segment with optional join and filter definitions. A backing PostgreSQL view is automatically created and the initial row count is computed.Request Body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Segment name (max 255 chars) |
baseSchemaId | string | Yes | Base schema to query |
description | string | No | Description |
status | string | No | "draft", "active", "paused", "archived". Default: "draft" |
entityType | string | No | Default: "customer" |
joins | array | No | Cross-schema join definitions |
filters | array | No | Filter conditions applied to the view |
Example
201 Created
PUT /api/v1/segments
Update a segment. Whenjoins or filters change, the backing view is rebuilt and the customer count is recomputed.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Segment ID |
name | string | No | Updated name |
description | string | No | Updated description |
status | string | No | Updated status |
baseSchemaId | string | No | Updated base schema |
joins | array | No | Updated joins (triggers view rebuild) |
filters | array | No | Updated filters (triggers view rebuild) |
200 OK
DELETE /api/v1/segments
Delete a segment and drop its backing view.| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Segment ID (query parameter) |
204 No Content
GET /api/v1/segments/
Get full segment details including base schema name. Response:200 OK with the segment object.
POST /api/v1/segments/?action=refresh
Recount the rows in the segment’s backing view and updatecustomerCount and lastRefreshedAt.
Response: 200 OK with the updated segment.
POST /api/v1/segments/?action=preview
Return a preview of the first 20 rows from the segment view.Response
Roles
| Endpoint | Allowed Roles |
|---|---|
GET /segments | admin, editor, viewer |
POST /segments | admin, editor |
PUT /segments | admin, editor |
DELETE /segments | admin, editor |
GET /segments/{id} | any authenticated |
POST /segments/{id} (refresh/preview) | admin, editor |