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.


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?
Path Params
string
required
Defaults to YOUR_APP_ID

The OneSignal App ID represented as a UUID.

Query Params
int32
Defaults to 0

Segments are listed in ascending order of created_at date. offset will omit that number of segments from the beginning of the list. Eg offset 5, will remove the 5 earliest created Segments.

int32
Defaults to 300

The amount of Segments in the response. Maximum 300.

Headers
string
required
Defaults to Key YOUR_APP_API_KEY

Your App API key with prefix Key . See Keys & IDs for details.

Responses

Language
Choose an example:
application/json