Returns an array of segments from an app.
Overview
The View Segment method is used when you want to programmatically obtain a list of available segments instead of using the OneSignal Dashboard UI.
Does not update segments
This endpoint will only view segments, it does not edit or update currently created Segments.
How to use this API
You can pass in parameters dictating how to receive the list of segments that are available within your OneSignal App Dashboard. The parameters available are:
offset
offset
Description
Controls the starting point for the segments being returned. Defaults to 0.
- Results are returned and sorted in ascending order by the date the segment was created (
created_at
).
limit
limit
Description
Specifies the maximum number of segment to return in a single query. Default and maximum is 300.
This parameter helps control the volume of data retrieved during one operation, especially when navigating many segments.
Example
curl --request GET \
--url 'https://api.onesignal.com/apps/app_id/segments%20(COPY)?offset=0&limit=300' \
--header 'Authorization: Basic YOUR_REST_API_KEY' \
--header 'Content-Type: application/json; charset=utf-8' \
--header 'accept: application/json'
Response body parameters
total_count
total_count
Description
The number of Segments in the response.
offset
offset
Description
Set with the offset
query parameter. Default 0
.
limit
limit
Description
Maximum number of Segments returned. Default 300
.
segments
segments
Description
An array containing the Segment information.
Segment data definitions
Parameter | Type | Description |
---|---|---|
id | String | The segment ID. |
name | String | The segment name. |
created_at | String | Date segment created. |
updated_at | String | Date segment last updated. |
app_id | String | The app id. |
read_only | Boolean | Is the segment read only? |
is_active | Boolean | Is the segment active? |