Skip to contentSkip to navigationSkip to topbar
On this page

Get Contacts by Identifiers



Operation overview

operation-overview page anchor

POST/v3/marketing/contacts/search/identifiers/{identifier_type}

Base url: https://api.sendgrid.com (The Twilio SendGrid v3 API)

Use this endpoint to retrieve up to 100 contacts that match the requested identifier values for a single identifier type.

identifier_type must be a valid identifier type: email, phone_number_id, external_id, or anonymous_id.

Use this endpoint instead of the Search Contacts endpoint when you can provide exact identifiers and do not need to include other Segmentation Query Language (SGQL) filters when searching.

This endpoint returns a 200 status code when any contacts match the identifiers you supplied. When searching multiple identifier values in a single request, it is possible that some will match a contact while others will not. When a partially successful search like this is made, the matching contacts are returned in an object and an error message is returned for the identifier values that are not found.

This endpoint returns a 404 status code when no contacts are found for the provided identifiers.

This endpoint returns a 400 status code if any searched addresses are invalid.

Twilio SendGrid recommends exporting your contacts regularly as a backup to avoid issues or lost data.


Authentication

authentication page anchor
Property nameTypeRequiredDescription
Authorizationstringrequired
Default: Bearer <<YOUR_API_KEY_HERE>>
Property nameTypeRequiredDescription
identifier_typeenum<string>required

The type of identifier to search for. You can use only one type of identifier per search.

Possible values:
emailphone_number_idexternal_idanonymous_id
Encoding type:application/json
SchemaExample
Property nameTypeRequiredDescriptionChild properties
identifiersarray[string]required

One or more more identifier values of the given identifier type to search for in your Marketing Campaigns contacts.

200400401403404500

An object containing the contacts that match the searched identifier values.

SchemaExample
Property nameTypeRequiredDescriptionChild properties
resultobject
Get Contacts by IdentifiersLink to code sample: Get Contacts by Identifiers
1
const client = require("@sendgrid/client");
2
client.setApiKey(process.env.SENDGRID_API_KEY);
3
4
const identifier_type = "email";
5
const data = {
6
identifiers: ["contact@example.com"],
7
};
8
9
const request = {
10
url: `/v3/marketing/contacts/search/identifiers/${identifier_type}`,
11
method: "POST",
12
body: data,
13
};
14
15
client
16
.request(request)
17
.then(([response, body]) => {
18
console.log(response.statusCode);
19
console.log(response.body);
20
})
21
.catch((error) => {
22
console.error(error);
23
});