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

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

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

Description

The number of Segments in the response.

offset

Description

Set with the offset query parameter. Default 0.

limit

Description

Maximum number of Segments returned. Default 300.

segments

Description

An array containing the Segment information.

Segment data definitions

ParameterTypeDescription
idStringThe segment ID.
nameStringThe segment name.
created_atStringDate segment created.
updated_atStringDate segment last updated.
app_idStringThe app id.
read_onlyBooleanIs the segment read only?
is_activeBooleanIs the segment active?
Language