Segments
Create Segment
Creates a saved segment. Members create site segments they own; admins and owners can also create organization-wide segments.
POST /api/sites/:site/segmentsCreates a saved segment. Members create site segments they own; admins and owners can also create organization-wide segments.
Path Parameters
Prop
Type
Request Body
Prop
Type
Response
Returns the created segment with status 201.
Prop
Type
curl -X POST "https://app.onyxmetric.com/api/sites/1/segments" \
-H "Authorization: Bearer your_api_key_here" \
-H "Content-Type: application/json" \
-d '{"name": "Mobile organic from Germany", "filters": [{"parameter": "device_type", "type": "equals", "value": ["Mobile"]}, {"parameter": "channel", "type": "equals", "value": ["Organic Search"]}, {"parameter": "country", "type": "equals", "value": ["DE"]}]}'const response = await fetch(
'https://app.onyxmetric.com/api/sites/1/segments',
{
method: 'POST',
headers: {
'Authorization': 'Bearer your_api_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({"name": "Mobile organic from Germany", "filters": [{"parameter": "device_type", "type": "equals", "value": ["Mobile"]}, {"parameter": "channel", "type": "equals", "value": ["Organic Search"]}, {"parameter": "country", "type": "equals", "value": ["DE"]}]})
}
);
const data = await response.json();import requests
response = requests.post(
'https://app.onyxmetric.com/api/sites/1/segments',
json={"name": "Mobile organic from Germany", "filters": [{"parameter": "device_type", "type": "equals", "value": ["Mobile"]}, {"parameter": "channel", "type": "equals", "value": ["Organic Search"]}, {"parameter": "country", "type": "equals", "value": ["DE"]}]},
headers={'Authorization': 'Bearer your_api_key_here'}
)
data = response.json(){
"segmentId": 12,
"siteId": 1,
"organizationId": "org_abc123",
"userId": "user_xyz",
"name": "Mobile organic from Germany",
"description": null,
"filters": [
{ "parameter": "device_type", "type": "equals", "value": ["Mobile"] },
{ "parameter": "channel", "type": "equals", "value": ["Organic Search"] },
{ "parameter": "country", "type": "equals", "value": ["DE"] }
],
"isPublic": false,
"type": "segment",
"canEdit": true,
"createdAt": "2026-09-02T10:15:00.000Z",
"updatedAt": "2026-09-02T10:15:00.000Z"
}