You are viewing the Legacy Marketing Campaigns API reference. For guidance migrating to the current version of Marketing Campaigns, see Migrating from Legacy Marketing Campaigns
For the most up-to-date information on the Contacts API, please visit the new Marketing Campaigns Contacts API.
The Contacts Recipients API allows you to manage your recipients. You can add, retrieve, update, and delete recipients, as well as get a count of all recipients and all billable recipients.
Search using segment conditions without actually creating a segment.
Body contains a JSON object with conditions
, a list of conditions as described below, 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.
"eq"
, "ne"
, "lt"
(before), "gt"
(after)
"empty"
, "not_empty"
"is within"
"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"
"eq"
, "lt"
, "gt"
, "empty"
, "not_empty"
"eq"
(opened), "ne"
(not opened)Field values must all be a string.
Search 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.
Search 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"
.
Bearer <<YOUR_API_KEY_HERE>>
application/json
The conditions by which this segment should be created.
1const client = require("@sendgrid/client");2client.setApiKey(process.env.SENDGRID_API_KEY);34const data = {5list_id: -27497588,6conditions: [7{8and_or: "",9field: "birthday",10value: "01/12/1985",11operator: "eq",12},13{14and_or: "",15field: "birthday",16value: "01/12/1985",17operator: "eq",18},19{20and_or: "",21field: "birthday",22value: "01/12/1985",23operator: "eq",24},25{26and_or: "",27field: "birthday",28value: "01/12/1985",29operator: "eq",30},31],32};3334const request = {35url: `/v3/contactdb/recipients/search`,36method: "POST",37body: data,38};3940client41.request(request)42.then(([response, body]) => {43console.log(response.statusCode);44console.log(response.body);45})46.catch((error) => {47console.error(error);48});