Menu

Get List of Segments

Get List of Segments

GET /segments/2.0

The Segmentation V2 API is currently in private beta. If you'd like to be added to the beta, please fill out this form

The query param parent_list_ids is treated as a filter. Any match will be returned. 0 matches will return a response code of 200 with an empty results array.

parent_list_ids no_parent_list_id result
empty false all segments
values false segments filtered by list_ids
values true segments filtered by list_ids and segments with no parent list_ids
empty true segments with no parent list_ids

Authentication

  • API Key

Headers

Authorization
string
default: Bearer <<YOUR_API_KEY_HERE>>
required

Query String

parent_list_ids
string

A comma separated list up to 50 in size, to filter segments on. Only segments that have any of these list ids as the parent list will be retrieved. This is different from the parameter of the same name used when creating a segment.

no_parent_list_id
boolean

If set to true segments with an empty value of parent_list_id will be returned in the filter. If the value is not present it defaults to 'false'.

default: False

Responses

object
id
string

ID assigned to the segment when created.

format: uuidmaxLength: 36minLength: 36
required
name
string

Name of the segment.

maxLength: 100minLength: 1
required
contacts_count
integer

Total number of contacts present in the segment

required
created_at
string

ISO8601 timestamp of when the object was created

required
updated_at
string

ISO8601 timestamp of when the object was last updated

required
sample_updated_at
string

ISO8601 timestamp of when the samples were last updated

required
next_sample_update
string

ISO8601 timestamp of when the samples will be next updated

required
parent_list_ids
array[string]

The array of list ids to filter contacts on when building this segment. It allows only one such list id for now. We will support more in future

uniqueItems: True
required
query_version
string

If not set, segment contains a query for use with Segment v1 APIs. If set to '2', segment contains a SQL query for use in v2.

required
_metadata
object
prev
string
format: uri
self
string
format: uri
next
string
format: uri
count
integer
minimum: 0
status
object

Segment status indicates whether the segment's contacts will be updated periodically

required
query_validation
string

Status of query validation. PENDING, VALID, or INVALID

required
error_message
string

Describes any errors that were encountered during query validation

object

If the request is incorrect, an array of errors will be returned.

errors
array[object]
required
field
string

the field in the request body that is incorrect

message
string

a description of what is specifically wrong with the field passed in the request

No response body.
object

If the request is incorrect, an array of errors will be returned.

errors
array[object]
required
field
string

the field in the request body that is incorrect

message
string

a description of what is specifically wrong with the field passed in the request

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the SendGrid tag on Stack Overflow.