Create a Segment
POST https://api.sendgrid.com/v3/contactdb/segments
Create a segment using search conditions.
Body contains a JSON object with conditions
, a list of conditions as described below, a unique name
, and an optional list_id
, which is a valid list ID for a list to limit the search on.
Valid operators for create and update depend on the type of the field for which you are searching.
- Dates:
- "eq", "ne", "lt" (before), "gt" (after)
- You may use MM/DD/YYYY for day granularity or an epoch for second granularity.
- "empty", "not_empty"
- "is within"
- You may use an ISO 8601 date format or the # of days.
- "eq", "ne", "lt" (before), "gt" (after)
- Text: "contains", "eq" (is - matches the full field), "ne" (is not - matches any field where the entire field is not the condition value), "empty", "not_empty"
- Numbers: "eq", "lt", "gt", "empty", "not_empty"
- Email Clicks and Opens: "eq" (opened), "ne" (not opened)
Field values must all be a string.
Conditions using "eq" or "ne" for email clicks and opens should provide a "field" of either clicks.campaign_identifier
or opens.campaign_identifier
.
The condition value should be a string containing the id of a completed campaign.
The conditions list may contain multiple conditions, joined by an "and" or "or" in the "and_or" field. The first condition in the conditions list must have an empty "and_or", and subsequent conditions must all specify an "and_or".
HEADERS
Key | Datatype | Required | Description |
---|---|---|---|
Accept | string | ||
Content-Type | string |