sendgridsendgrid-api-v2

How can I search for past sent emails with Sendgrid?


As Sendgrid's documentation makes clear, their web GUI activity page is only searchable for the past 7 days.

How do I search for activity from farther in the past?

Web API documentation is here, but I can't find anything about just plain searching for info on sent emails. All I see are endpoints for seeing particular categories of emails' various fates, like blocks, bounces, invalid emails, and "filters", which seem like actions and not like filters.

It's got to be possible to just find info about some particular sent email, right?


Solution

  • It's not possible. As you noted, the documentation clearly states that:

    Email activity only shows the most recent 7 days. To access data in real time, we recommend that you consider implementing our Event Webhook.

    If you want to record all the history associated with your account you should record and save it yourself. You can record all the emails you send provided you have an endpoint to do so. See here: https://sendgrid.com/docs/User_Guide/Settings/parse.html

    Later Edit:

    1. "real time" means "as it happens", it does not mean "history searchable at any point in time".

    2. When you use an API, as a developer, the responsibility to log all API calls and responses lies with you. While it's true that bounces aren't necessarily reported in the API call response, the SendGrid API offers several ways in which you can be notified. Personal opinion: I know this functionality is often omitted in the MVP because you need to go to market as soon as possible, but an ELK stack is not that hard to set up.

    3. There are several ways you can look for bounces and other events as you can see here: https://sendgrid.com/docs/Classroom/Track/Bounces/bounce_reports_how_can_i_be_notified.html

    4. If you really need to find out what happened on day X with email send Y, you can contact their Support team. They can probably look it up for you.

    Personal opinion: That 7 days is not a random number. I'm willing to bet that SendGrid does in fact log all calls you made but it can't provide them for an earlier time. When you use Facebook API, Twitter API, etc. You don't expect them to provide you with historical data of every API call you made. This is an ungodly amount of data. We're talking about an API that is used to send probably upwards of millions of emails per day, maybe even more. I believe they actually did the math and recalling historical data from earlier would put an unnecessary strain on the system, it would take a long time to answer such a request.

    I'm sorry if I went on a bit of a rant but people often don't think about the volume of data needed to store such things and how much it would cost to search it.