# README
Go API client for
The Twilio SendGrid 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 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.
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.
You can also manage your Segments with the Marketing Campaigns application user interface. See Segmenting Your Contacts for more information.
Overview
This API client was generated by the OpenAPI Generator project from the OpenAPI specs located at twilio/sendgrid-oai. By using the OpenAPI-spec from a remote server, you can easily generate an API client.
- API version: 1.0.0
- Package version:
- Build date: 2025-08-18T08:58:25.578131Z[Etc/UTC]
- Build package: com.sendgrid.oai.go.SendgridGoGenerator For more information, please visit https://support.sendgrid.com/hc/en-us
Installation
Install the following dependencies:
go get github.com/stretchr/testify/assert
go get golang.org/x/net/context
Put the package under your project folder and add the following in import:
import "./"
Documentation for API Endpoints
All URIs are relative to https://api.sendgrid.com
Class | Method | HTTP request | Description |
---|---|---|---|
CreateSegment | CreateSegment | Post /v3/marketing/segments/2.0 | Create Segment |
DeleteSegment | DeleteSegment | Delete /v3/marketing/segments/2.0/{SegmentId} | Delete segment |
GetSegment | GetSegment | Get /v3/marketing/segments/2.0/{SegmentId} | Get Segment by ID |
ListSegment | ListSegment | Get /v3/marketing/segments/2.0 | Get List of Segments |
RefreshSegment | RefreshSegment | Post /v3/marketing/segments/2.0/refresh/{SegmentId} | Manually refresh a segment |
UpdateSegment | UpdateSegment | Patch /v3/marketing/segments/2.0/{SegmentId} | Update Segment |
Documentation For Models
- AllSegments200
- ContactResponse
- ContactResponseCustomFields
- ErrorsSegmentV2
- ErrorsSegmentV2ErrorsInner
- Metadata
- Segment2xx
- SegmentError
- SegmentRefresh202
- SegmentRefreshRequest
- SegmentStatusResponse
- SegmentUpdate
- SegmentWriteV2
Documentation For Authorization
BearerAuth
- Type: HTTP basic authentication
Example
auth := context.WithValue(context.Background(), sw.ContextBasicAuth, sw.BasicAuth{
UserName: "username",
Password: "password",
})
r, err := client.Service.Operation(auth, args)