Skip to contentSkip to navigationSkip to topbar
Page toolsOn this page
Looking for more inspiration?Visit the

Filter all messages


API Overview

api-overview page anchor

GET/v3/messages

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

Filter all messages to search your Email Activity. All queries must be URL encoded(link takes you to an external page), and use the following format:

query={query_type}="{query_content}"

Once URL encoded, the previous query will look like this:

query=type%3D%22query_content%22

For example, to filter by a specific email, use the following query:

query=to_email%3D%22example%40example.com%22

Visit our Query Reference section to see a full list of basic query types and examples.


Authentication

authentication page anchor
Property nameTypeRequiredDescription
Authorizationstring
required
Default: Bearer <<YOUR_API_KEY_HERE>>
Property nameTypeRequiredDescription
querystring
required

Use the query syntax to filter your email activity. Combine up to 160 filter conditions per request.


limitnumber

Optional

The number of messages returned. This parameter must be greater than 0 and less than or equal to 1000

Default: 10Minimum: 1Maximum: 1000
200400429
SchemaExample
Property nameTypeRequiredDescriptionChild properties
messagesarray[Abbv. Message]

Optional

Filter all messagesLink to code sample: Filter all messages
1
const client = require("@sendgrid/client");
2
client.setApiKey(process.env.SENDGRID_API_KEY);
3
4
const queryParams = {
5
limit: 10,
6
query: 'from_email="email@example.com"',
7
};
8
9
const request = {
10
url: `/v3/messages`,
11
method: "GET",
12
qs: queryParams,
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
});