Segments
CRUD for rule-based user segments and on-demand re-evaluation.
Segments are JSON rule trees evaluated against user profile properties and the engagement-event stream. They're re-evaluated every 15 minutes; the /evaluate endpoint triggers an immediate out-of-band re-evaluation.
Endpoints
| Method | Path | Description |
|---|---|---|
| POST | /admin/projects/:projectId/segments | Create a segment. |
| GET | /admin/projects/:projectId/segments | List segments (system segments first). |
| GET | /admin/projects/:projectId/segments/:segmentId | Fetch a segment. |
| PATCH | /admin/projects/:projectId/segments/:segmentId | Update a non-system segment. |
| DELETE | /admin/projects/:projectId/segments/:segmentId | Delete a non-system segment. |
| POST | /admin/projects/:projectId/segments/:segmentId/evaluate | Kick off an out-of-band re-evaluation. |
Rule shape
Operators: eq, neq, gt, gte, lt, lte, contains, not_contains, exists, not_exists, within, not_within.
POST /admin/projects/:projectId/segments
Request
| Field | Type | Required |
|---|---|---|
name | string | yes |
description | string | no |
rules | SegmentRules object | yes |
Response 201
Errors
400 INVALID_SEGMENT_RULES—rulesis missing or malformed.400 SEGMENT_RULES_TOO_DEEP—rulesnests deeper than the supported cap (5 levels).500 CREATE_FAILED.
rules is a recursive shape: each group has operator (AND / OR) and a conditions array, where each entry is either a leaf ({ field, op, value }) or a nested group. See Segment operators → Composing rules for the full reference.
Try it:
/admin/projects/%7B%7BprojectId%7D%7D/segmentscurl -X POST 'https://api.amba.dev/v1/admin/projects/%7B%7BprojectId%7D%7D/segments'Curl:
GET /admin/projects/:projectId/segments
List segments. System segments (created by provisioning) are returned first.
Response 200
Try it:
/admin/projects/%7B%7BprojectId%7D%7D/segmentscurl -X GET 'https://api.amba.dev/v1/admin/projects/%7B%7BprojectId%7D%7D/segments'Curl:
GET /admin/projects/:projectId/segments/:segmentId
Response 200
Errors
404 NOT_FOUND.
Try it:
/admin/projects/%7B%7BprojectId%7D%7D/segments/%7B%7BsegmentId%7D%7Dcurl -X GET 'https://api.amba.dev/v1/admin/projects/%7B%7BprojectId%7D%7D/segments/%7B%7BsegmentId%7D%7D'Curl:
PATCH /admin/projects/:projectId/segments/:segmentId
Update name, description, and/or rules. Only keys present in the body are changed — a PATCH never nulls out omitted keys.
Errors
403 SYSTEM_SEGMENT— system segments are read-only.404 NOT_FOUND.500 UPDATE_FAILED.
Try it:
/admin/projects/%7B%7BprojectId%7D%7D/segments/%7B%7BsegmentId%7D%7Dcurl -X PATCH 'https://api.amba.dev/v1/admin/projects/%7B%7BprojectId%7D%7D/segments/%7B%7BsegmentId%7D%7D'Curl:
DELETE /admin/projects/:projectId/segments/:segmentId
Response 200
Errors
403 SYSTEM_SEGMENT.500 DELETE_FAILED.
Try it:
/admin/projects/%7B%7BprojectId%7D%7D/segments/%7B%7BsegmentId%7D%7Dcurl -X DELETE 'https://api.amba.dev/v1/admin/projects/%7B%7BprojectId%7D%7D/segments/%7B%7BsegmentId%7D%7D'Curl:
POST /admin/projects/:projectId/segments/:segmentId/evaluate
Start a SEGMENT_EVALUATION workflow for a single segment. Returns immediately — poll the segment row to see last_evaluated_at advance.
Response 200
Errors
404 NOT_FOUND.500 EVALUATE_FAILED.
Try it:
/admin/projects/%7B%7BprojectId%7D%7D/segments/%7B%7BsegmentId%7D%7D/evaluatecurl -X POST 'https://api.amba.dev/v1/admin/projects/%7B%7BprojectId%7D%7D/segments/%7B%7BsegmentId%7D%7D/evaluate'Curl: