Filter all messages
GET https://api.sendgrid.com/v3/messages?query={{query}}&limit=10
In order to gain access to the Email Activity Feed API, you must purchase additional email activity history.
Filter all messages to search your Email Activity.
Queries may need to be URL encoded. URL encoding depends on how you're using the API - if you are trying it out here, or using one of the Libraries, we handle the encoding for you. If you are using cURL, or your own implementation, you probably need to encode it.
Queries have this format:
query={query_type}="{query_content}"
encoded, this would look like this:
query=type%3D%22query_content%22
for example:
Filter by a specific email - query=to_email%3D%22example%40example.com%22
Filter by subject line - query=subject%3d%22A%20Great%20Subject%22
You can filter by other operators besides =
. We also accept !=
, <
, and >
.
For a tutorial on how to get started, check out Getting Started with the Email Activity API.
Full list of basic query types and examples: (replace the data in quotes with the information you want to query)
Query | Unencoded example (put this one into the try it out query - it'll automatically encode it for you) | Encoded example (use this one in your code) |
---|---|---|
msg_id | msg_id="filter0307p1las1-16816-5A023E36-1.0" | msg_id%3D%22filter0307p1las1-16816-5A023E36-1.0%22 |
from_email | from_email="testing@sendgrid.net" | from_email%3D%22testing%40sendgrid.net%22 |
subject | subject="This is a subject test" | subject%22This%20is%20a%20subject%20test%22 |
to_email | to_email="example@example.com" | to_email%3D%22example%40example.com%22 |
status | status="processed" | status%3D%22processed%22 |
template_id | template_id="8f0d27bc-cf8f-42d3-b951-3990af7d0619" | template_id%3D%228f0d27bc-cf8f-42d3-b951-3990af7d0619%22 |
template_name | template_name="example_template" | template_name%3D%22example_template%22 |
marketing_campaign_name | marketing_campaign_name="example_campaign" | marketing_campaign_name%3D%22example_campaign%22 |
marketing_campaign_id | marketing_campaign_id="1453849" | marketing_campaign_id%3D%221453849%22 |
api_key_id | api_key_id="-hVjtoFgGUNPq3DPPPkJN3mCIDIwrl3qdFZcqYKnlq94" (everything after the middle dot in the API key) | api_key_id%3D%22-hVjtoFgGUNPq3DPPPkJN3mCIDIwrl3qdFZcqYKnlq94%22 |
api_key_name | api_key_name="test_name" | api_key_name%3D%22test_name%22 |
events | events="processed" | events%3D%22processed%22 |
originating_ip - this is the IP address of the person sending the message | originating_ip="4.77.777.77" | originating_ip%3D%224.77.777.77%22 |
categories - custom tags that you create | (Contains(categories,"categories_example")) | (Contains(categories%2C%22categories_example%22)) |
unique_args - custom tracking arguments that you can attach to SMTP API calls | (unique_args['argument']="definition") | (unique_args%5B%27argument%27%5D%3D%22definition%22) |
outbound_ip - this is the SendGrid dedicated IP address used to send the email | outbound_ip="4.77.777.77" | outbound_ip%3D%224.77.777.77%22 |
last_event_time | last_event_time="2017-11-07T23:13:58Z" | last_event_time%3D%E2%80%9C2017-11-07T23%3A13%3A58Z%E2%80%9D |
clicks | clicks="0" | clicks%3D%220%22 |
unsubscribe_group_name | unsubscribe_group_name="Global Unsubscribes" | unsubscribe_group_name%3D%22Global%20Unsubscribes%22 |
unsubscribe_group_id | unsubscribe_group_id="1041" | unsubscribe_group_id%3D%221041%22 |
teammate - teamates username | teammate="my_username" | teammate%3D%22my_username%22 |
For information about building combined queries, see Building compound Email Activity queries.
Request Params
Key | Datatype | Required | Description |
---|---|---|---|
query | string | ||
limit | number |
HEADERS
Key | Datatype | Required | Description |
---|---|---|---|
X-Query-Id | string | ||
X-Cursor | string |