Skip to main content

Update Segment

Update the properties of an existing segment or cohort.

Endpoint

PUT /api/websites/{websiteId}/segments/{segmentId}
This endpoint uses the POST HTTP method in the actual implementation, but follows PUT semantics for updating resources.

Headers

Authorization
string
required
Bearer token for authentication

Path Parameters

websiteId
string
required
Website UUID
segmentId
string
required
Segment UUID

Request Body

type
string
required
Segment type: segment or cohort
name
string
required
Segment name (max 200 characters)
parameters
object
required
Segment configuration parameters

Response

id
string
Segment UUID
websiteId
string
Website UUID
type
string
Segment type
name
string
Segment name
parameters
object
Segment configuration parameters
updatedAt
string
ISO 8601 timestamp of last update

Example Request

curl -X POST "https://your-umami-instance.com/api/websites/550e8400-e29b-41d4-a716-446655440000/segments/770e8400-e29b-41d4-a716-446655440001" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "segment",
    "name": "Mobile Users from US (Updated)",
    "parameters": {
      "filters": {
        "device": "mobile",
        "country": "US",
        "browser": "Chrome"
      }
    }
  }'

Example Response

{
  "id": "770e8400-e29b-41d4-a716-446655440001",
  "websiteId": "550e8400-e29b-41d4-a716-446655440000",
  "type": "segment",
  "name": "Mobile Users from US (Updated)",
  "parameters": {
    "filters": {
      "device": "mobile",
      "country": "US",
      "browser": "Chrome"
    }
  },
  "updatedAt": "2024-03-15T09:20:00.000Z"
}

Error Responses

401
error
Unauthorized - You don’t have permission to update this segment
404
error
Not Found - Segment does not exist
You must have update permissions for the website to modify its segments.

Build docs developers (and LLMs) love