Menu

Expand
Rate this page:

Segmenting Contacts

Segmentation V2 APIs are now available! See the Getting Started guide to find out what new features are available.

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

Delete Segment

The Segmentation v1 API was deprecated on December 31, 2022. Following deprecation, all segments created in the Marketing Campaigns user interface began using the Segmentation v2 API.

To enable manual migration and data retrieval, the GET and DELETE v1 API endpoints will remain available. The POST (create) and PATCH (update) v1 endpoints were removed on January 31, 2023 because it is no longer possible to create new v1 segments or modify existing ones. See our Segmentation v1 to v2 upgrade instructions to manually migrate your segments to the v2 API.

DELETE /v3/marketing/segments/{segment_id}

Base url: https://api.sendgrid.com

This endpoint allows you to delete a segment by segment_id.

Note that deleting a segment does not delete the contacts associated with the segment by default. Contacts associated with a deleted segment will remain in your list of all contacts and any other segments they belong to.

Authentication

  • API Key

Headers

Authorization
string
default: Bearer <<YOUR_API_KEY_HERE>>
required

Path Parameters

segment_id
string
default: None
required

Responses

object
object
errors
array[object]
message
string

the error message

required
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

required
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

required
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
required
field
string
required
object
errors
array[object]
required
message
string
required
Loading Code Sample...
        
        

        Delete Segment

        Rate this page:

        Need some help?

        We all do sometimes. Get help now from the Twilio SendGrid Support Team.

        Running into a coding hurdle? Lean on the wisdom of the crowd by browsing the SendGrid tag on Stack Overflow or visiting Twilio's Stack Overflow Collective.

        Loading Code Sample...
              
              
              

              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!

              thanks-feedback-gif