Skip to contentSkip to navigationSkip to topbar
Page tools
Useful for sharing or LLM
Accelerate development with AI

On this page
Looking for more inspiration?Visit the

Filter all messages


API Overview

api-overview page anchor

Use this endpoint to search processed email messages and identify specific messages of interest sent from your account. The response returns a list of messages that match your filter criteria, including each message's sg_message_id and key delivery attributes such as sender, recipient, subject, and status. Pass the sg_message_id to the Filter Messages by ID endpoint to retrieve full event-level details for that message.


POST/v3/logs

Base url: https://api.sendgrid.com (for global users and subusers)

Base url: https://api.eu.sendgrid.com (for EU regional subusers)

List recent messages within Email Logs, or search for messages using a filter.


Authentication

authentication page anchor
Property nameTypeRequiredDescription
Authorizationstring
required
Default: Bearer <<YOUR_API_KEY_HERE>>
Encoding type:application/json
Schema
Property nameTypeRequiredDescriptionChild properties
querystring

Optional

Allowed event fields and operators

  • sg_message_id: =
  • subject: =
  • to_email: =
  • status: IN
  • reason: =
  • categories: IN
  • sg_message_id_created_at: >, <, >=, <=

Notes:

  • multiple conditions (up to 160) can be combined with AND
  • nesting is not allowed
  • IN operator accepts a list of string values: field IN ('value1', 'value2')
Example: sg_message_id_created_at > TIMESTAMP "2025-01-01T00:00:00Z" AND sg_message_id_created_at < TIMESTAMP "2025-02-01T00:00:00Z" AND status IN ('delivered', 'processed') AND categories IN ('newsletter', 'marketing')

limitinteger

Optional

Number of messages to return (1–1000).

Default: 10Minimum: 1Maximum: 1000

subusersarray[string<^\d+$>]

Optional

For requests authenticated as the parent account, this argument must be passed if the desired messages belong to a subuser. You can only call this endpoint for 1 subuser at a time.

Example: ["20223230"]Max items: 1
200400403429default

A page of messages matching the filter.

Schema
Property nameTypeRequiredDescriptionChild properties
messagesarray[object]

Optional

List of messages matching the filter query.

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 data = {
5
query: "query",
6
};
7
8
const request = {
9
url: `/v3/logs`,
10
method: "POST",
11
body: data,
12
};
13
14
client
15
.request(request)
16
.then(([response, body]) => {
17
console.log(response.statusCode);
18
console.log(response.body);
19
})
20
.catch((error) => {
21
console.error(error);
22
});