Documentation menuAPI: Segments

API

Segments endpoints

These endpoints manage saved segments. Reading needs segments:read, and writing needs segments:write. To apply a segment, send its ID as segment_id on any analytics endpoint.

Last updated .

GET /sites/:siteId/segments

Returns the segments for the site and the organization, sorted by name. Public sites and private links get only public segments.

[ { "segmentId": 4, "siteId": null, "name": "Norwegian mobile", "filters": [ { "parameter": "country", "type": "equals", "value": ["NO"] }, { "parameter": "device_type", "type": "equals", "value": ["Mobile"] } ], "isPublic": false, "canEdit": true } ]

siteId is null for a segment that covers the whole organization.

How do you create or change a segment?

RequestResult
POST /sites/:siteId/segmentsCreates one. Status 201 with the segment
PUT /sites/:siteId/segments/:idChanges the fields you send
DELETE /sites/:siteId/segments/:idDeletes it
FieldRequiredLimits
nameYes1 to 80 characters
filtersYes1 to 20 filters, each with up to 50 values
descriptionNoUp to 500 characters
isPublicNotrue shows it on shared dashboards
scopeNosite or organization. organization needs an admin

The body is checked strictly. A field that is not in the table returns status 400.