Refresh Segment
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 V2 API allows you to create, edit, and delete segments as well as retrieve a list of segments or an individual segment by ID.
Segments built using engagement data such as "was sent" or "clicked" will take approximately 30 minutes to begin populating.
Segment samples and counts refresh on a schedule that ranges from 1 to 24 hours. Segments with active automations or that are used as exclusion lists for scheduled Single Sends refresh every hour. Segments that aren't actively used refresh less frequently, up to every 24 hours, to optimize processing resources. Samples and counts displayed in the UI don't update immediately when segment criteria are modified or when contacts are added or updated. Instead, they update according to the segment's refresh schedule.
The Refresh Segment operation allows customers with Marketing Campaigns Basic or Advanced plans to manually refresh segments. You can refresh a segment twice per day. Refreshes will be reset at midnight in the timezone stored for the segment. A segment cannot be refreshed more than once within one hour, and the endpoint has a rate limit of 10 requests per day that is reset at 0:00 UTC. Manually refreshing a segment does not affect the segment's backoff.
POST/v3/marketing/segments/2.0/refresh/{segment_id}
Base url: https://api.sendgrid.com (The Twilio SendGrid v3 API)
Manually refresh a segment by segment ID.
Bearer <<YOUR_API_KEY_HERE>>36Max length: 36application/jsonThe user's timezone. The timezone is used to reset the refresh count at midnight in the user's local time. Only IANA time zone format is accepted.
The refresh was accepted and a request was sent to process.
Optional
The ID of the manual refresh job. Used only for internal purposes.
1const client = require("@sendgrid/client");2client.setApiKey(process.env.SENDGRID_API_KEY);34const segment_id = "f15982c1-a82c-4e87-a6b2-a4a63b4b7644";5const data = {6user_time_zone: "America/Chicago",7};89const request = {10url: `/v3/marketing/segments/2.0/refresh/${segment_id}`,11method: "POST",12body: data,13};1415client16.request(request)17.then(([response, body]) => {18console.log(response.statusCode);19console.log(response.body);20})21.catch((error) => {22console.error(error);23});