Skip to main content

Get Segments

Retrieve a list of segments (saved audience groups) or cohorts (time-based user groups) for a specific website.

Endpoint

GET /api/websites/{websiteId}/segments

Headers

Authorization
string
required
Bearer token for authentication

Path Parameters

websiteId
string
required
Website UUID

Query Parameters

type
string
Segment type: segment or cohort
Search term to filter segments by name

Response

data
array
Array of segment objects

Example Request

curl "https://your-umami-instance.com/api/websites/550e8400-e29b-41d4-a716-446655440000/segments?type=segment" \
  -H "Authorization: Bearer YOUR_TOKEN"

Example Response

[
  {
    "id": "770e8400-e29b-41d4-a716-446655440001",
    "websiteId": "550e8400-e29b-41d4-a716-446655440000",
    "type": "segment",
    "name": "Mobile Users",
    "parameters": {
      "filters": {
        "device": "mobile"
      }
    },
    "createdAt": "2024-01-15T10:30:00.000Z",
    "updatedAt": "2024-01-15T10:30:00.000Z"
  },
  {
    "id": "880e8400-e29b-41d4-a716-446655440002",
    "websiteId": "550e8400-e29b-41d4-a716-446655440000",
    "type": "segment",
    "name": "US Visitors",
    "parameters": {
      "filters": {
        "country": "US"
      }
    },
    "createdAt": "2024-02-20T14:45:00.000Z",
    "updatedAt": "2024-02-20T14:45:00.000Z"
  }
]
Segments allow you to save filter combinations for quick access. Cohorts are time-based groups that track user behavior over time.

Build docs developers (and LLMs) love