Segments

Create Segment

Creates a saved segment. Members create site segments they own; editors, admins and owners can also create organization-wide segments.

POST /api/sites/:site/segments

Creates a saved segment. Members create site segments they own; editors, admins and owners can also create organization-wide segments.

The body is strict: unknown fields return 400. Creating an organization-wide segment without the editor role in the organization returns 403.

Path Parameters

Prop

Type

Request Body

Prop

Type

Response

Returns the created segment with status 201.

Prop

Type

Request
curl -X POST "https://app.rybbit.io/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"]}]}'
Request
const response = await fetch(
  'https://app.rybbit.io/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();
Request
import requests

response = requests.post(
    'https://app.rybbit.io/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()
Response
{
  "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-02 10:15:00.482913",
  "updatedAt": "2026-09-02 10:15:00.482913"
}