Update segment
Update an existing segment’s name and/or filters. The name parameter is always required. When filters are provided, all existing filters are replaced with the new ones.
Documentation Index
Fetch the complete documentation index at: https://documentation.onesignal.com/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Update an existing segment’s name and/or filters. This API allows you to modify Segments programmatically without having to delete and recreate them.name parameter is always required, even if you’re not changing it. When filters are provided, all existing filters are replaced with the new ones. Omit the filters parameter to keep existing filters intact. The filters array cannot be empty—if provided, it must contain at least one filter.How to use this API
Update segment name only
To update just the segment name without changing filters:Update segment description
Update the optionaldescription (max 255 characters). Pass an empty string to clear the existing description; omit the field to leave it unchanged.
Update segment filters
To update the segment filters (this replaces all existing filters), provide thename (required) and filters:
Filter syntax
The filter syntax is identical to the Create segment API. Available filters include:tag- Filter by Tagslast_session- Filter by last active timefirst_session- Filter by first session timesession_count- Filter by number of sessionssession_time- Filter by total usage durationlanguage- Filter by user languageapp_version- Filter by app versionlocation- Filter by GPS coordinatescountry- Filter by country
AND and OR operators to combine filters:
Response
Success response
Error responses
| Status Code | Description |
|---|---|
| 400 | Bad request - Invalid filters, duplicate segment name, or segment used by active Journey |
| 403 | Forbidden - API not available for your plan |
| 404 | Not found - Segment does not exist |
| 429 | Rate limit exceeded |
Path Parameters
Your OneSignal App ID in UUID v4 format. See Keys & IDs.
The segment_id can be found in the URL of the segment when viewing it in the dashboard.
Body
Required. The segment name. Maximum 128 characters.
Optional human-readable description for the segment. Maximum 255 characters. Pass an empty string to clear; omit to leave unchanged.
255Optional. When provided, replaces all existing filters. Filters define the segment based on user properties like tags, activity, or location using flexible AND/OR logic. Limited to 200 total entries, including fields and OR operators. See Create segment for filter syntax.
1 - 200 elementsRequired. The filter object.
- Filter
- Operator