List Sent Emails Endpoint

List sent emails from your account.

The emails page shows all emails you've sent from your account with several filters and sorting options.

Emails page

Today, we've added a new endpoint to the Resend API to list sent emails to give you a more programmatic way to access emails sent from your account.

How to use it

By default, the list will return the last 20 emails sent from your account using the GET /emails endpoint or any SDK equivalent.

import { Resend } from 'resend';
const resend = new Resend('re_xxxxxxxxx');
const { data, error } = await resend.emails.list();

The response will be a list of emails with the following structure:

{
"object": "list",
"has_more": false,
"data": [
{
"id": "4ef9a417-02e9-4d39-ad75-9611e0fcc33c",
"to": ["delivered@resend.dev"],
"from": "Acme <onboarding@resend.dev>",
"created_at": "2023-04-03T22:13:42.674981+00:00",
"subject": "Hello World",
"bcc": null,
"cc": null,
"reply_to": null,
"last_event": "delivered",
"scheduled_at": null
},
{
"id": "3a9f8c2b-1e5d-4f8a-9c7b-2d6e5f8a9c7b",
"to": ["user@example.com"],
"from": "Acme <onboarding@resend.dev>",
"created_at": "2023-04-03T21:45:12.345678+00:00",
"subject": "Welcome to Acme",
"bcc": null,
"cc": null,
"reply_to": null,
"last_event": "opened",
"scheduled_at": null
}
]
}

Pagination

The following query parameters are supported when calling the GET /emails endpoint:

  • limit: The number of emails to return. Maximum is 100. Minimum is 1. Default is 20.
  • after: The cursor after which to start retrieving emails. To get the next page, use the ID of the last email from the current page. This will return the page that starts after the email with this ID (excluding the passed ID itself).
  • before: The cursor before which to start retrieving emails. To get the previous page, use the ID of the first email from the current page. This will return the page that ends before the email with this ID (excluding the passed ID itself).

To retrieve additional pages, use the before or after params to go through the list.

Forward pagination

To paginate forward through results (newer to older items), use the after parameter with the ID of the last item from the current page:

const resend = new Resend('re_xxxxxxxxx');
// First page
const { data: firstPage } = await resend.emails.list({ limit: 10 });
// Second page (if has_more is true)
if (firstPage.has_more) {
const lastId = firstPage.data[firstPage.data.length - 1].id;
const { data: secondPage } = await resend.emails.list({
limit: 10,
after: lastId
});
}

Backwards pagination

To paginate backward through results (older to newer items), use the before parameter with the ID of the first item from the current page (or the most recent ID you have in your system):

const resend = new Resend('re_xxxxxxxxx');
// Start from a specific point and go backward
const page = await resend.emails.list({
limit: 10,
before: 'some-email-id'
});
if (page.data.has_more) {
const firstId = page.data.data[0].id;
const previousPage = await resend.emails.list({
limit: 10,
before: firstId
});
}

You can safely navigate lists with guaranteed stability, even if new objects are created or deleted while you’re still requesting pages.

Getting email content

The list returns references to individual emails, but not the email content. If needed, you can use the id of an email to retrieve the email HTML to plain text using the Retrieve Email endpoint.

Conclusion

You should have quick access to your data where you need it. We hope you find this new endpoint helpful for retrieving your data.

For more details, view our API Reference docs.