Get List of Segments
The Segmentation V2 API is in public beta. V2 segments can now be created and edited through both the UI and API.
You can see both V1 and V2 segments you have created with their contacts in the UI. While the UI only supports creation of V2 segments, you can still edit or delete either V1 or V2 segments in the UI. Both V1 and V2 segments can be exported and used as an audience for a Single Send or Automation. See the V2 Segmentation API documentation for more information.
GET /v3/marketing/segments/2.0
Base url: https://api.sendgrid.com
This endpoint allows you to retrieve a list of segments.
The query param parent_list_ids
is treated as a filter. Any match will be returned. Zero matches will return a response code of 200 with an empty results
array.
parent_list_ids |
no_parent_list_id |
ids |
result |
---|---|---|---|
empty | false | empty | all segments values |
list_ids | false | empty | segments filtered by list_ids values |
list_ids | true | empty | segments filtered by list_ids and segments with no parent list_ids empty |
empty | true | empty | segments with no parent list_ids |
anything | anything | ids | segments with matching segment ids |
Authentication
- API Key
Headers
Query String
A list of segment IDs to retrieve. When this parameter is included, the no_parent_list_ids
and parent_list_ids
parameters are ignored and only segments with given IDs are returned.
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.
default: NoneIf 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'.
Responses
ID assigned to the segment when created.
format: uuidmaxLength: 36minLength: 36Name of the segment.
maxLength: 100minLength: 1Total number of contacts present in the segment
ISO8601 timestamp of when the object was created
ISO8601 timestamp of when the object was last updated
ISO8601 timestamp of when the samples were last updated
ISO8601 timestamp of when the samples will be next updated
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: TrueIf 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.
Segment status indicates whether the segment's contacts will be updated periodically
Status of query validation. PENDING, VALID, or INVALID
Describes any errors that were encountered during query validation
If the request is incorrect, an array of errors will be returned.
the field in the request body that is incorrect
a description of what is specifically wrong with the field passed in the request
If the request is incorrect, an array of errors will be returned.
the field in the request body that is incorrect
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.