Menu

Expand
Rate this page:

Segmenting Contacts

Segments are similar to contact lists, except they update dynamically over time as information stored about your contacts or the criteria used to define your segments changes. When you segment your audience, you are able to create personalized Automation emails and Single Sends that directly address the wants and needs of your particular audience.

The Marketing Campaigns Segments API allows you to create, edit, and delete segments as well as retrieve a list of segments or an individual segment by ID.

Note that Twilio SendGrid checks for newly added or modified contacts who meet a segment's criteria on an hourly schedule. Only existing contacts who meet a segment's criteria will be included in the segment searches within 15 minutes.

Segments built using engagement data such as "was sent" or "clicked" will take approximately 30 minutes to begin populating.

Segment samples and counts are refreshed approximately once per hour; they do not update immediately. If no contacts are added to or removed from a segment since the last refresh, the sample and UI count displayed will be refreshed at increasing time intervals with a maximum sample and count refresh delay of 24 hours.

For more information on creating segments with the Twilio SendGrid Marketing Campaigns UI see "Segmenting your Contacts."

For help with Segmentation Query Language, see our Segmentation Query Language reference

Get List of Segments

GET /v3/marketing/segments

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

Authorization
string
default: Bearer <<YOUR_API_KEY_HERE>>
required

Query String

ids
array

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.

default: None
parent_list_ids
string

A comma separated list of list ids to be used when searching for segments with the specified parent_list_id, no more than 50 is allowed

default: None
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
results
array[object]
minItems: 0uniqueItems: True
required
id
string
format: uuidmaxLength: 36minLength: 36
contacts_count
integer
created_at
string

ISO8601 of created timestamp

format: date-time
name
string
maxLength: 100minLength: 1
parent_list_id
string

The id of the list if this segment is a child of a list. This implies the query AND CONTAINS(list_ids, ${parent_list_id})

format: uuidmaxLength: 36minLength: 36
sample_updated_at
string

ISO8601 timestamp the sample was last updated

format: date-time
updated_at
string

ISO8601 timestamp the object was last updated

format: date-time
next_sample_update
string

ISO8601 string that is equal to sample_updated_at plus an internally calculated offset that depends on how often contacts enter or exit segments as the scheduled pipeline updates the samples.

object
errors
array[object]
message
string

the error message

field
string or null

the field that generated the error

help
object

helper text or docs for troubleshooting

id
string
{
  "errors": [
    {
      "field": "field_name",
      "message": "error message"
    }
  ]
}
object
errors
array[object]
message
string

the error message

field
string or null

the field that generated the error

help
object

helper text or docs for troubleshooting

id
string
{
  "errors": [
    {
      "field": "field_name",
      "message": "error message"
    }
  ]
}
object
errors
array[object]
message
string

the error message

field
string or null

the field that generated the error

help
object

helper text or docs for troubleshooting

id
string
{
  "errors": [
    {
      "field": "field_name",
      "message": "error message"
    }
  ]
}
object
errors
array[object]
required
message
string
        
        
        
        Rate this page:

        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.

              
              
              

              Thank you for your feedback!

              Please select the reason(s) for your feedback. The additional information you provide helps us improve our documentation:

              Sending your feedback...
              🎉 Thank you for your feedback!
              Something went wrong. Please try again.

              Thanks for your feedback!

              Refer us and get $10 in 3 simple steps!

              Step 1

              Get link

              Get a free personal referral link here

              Step 2

              Give $10

              Your user signs up and upgrade using link

              Step 3

              Get $10

              1,250 free SMSes
              OR 1,000 free voice mins
              OR 12,000 chats
              OR more