Send emails at a specific time without additional complexity.
While some emails need to be delivered as soon as possible, like password resets or magic links, others can be scheduled for a specific time.
Here are some examples of when you might want to schedule an email:
Before, you had to use external services to handle the scheduling logic, but now you can use the new Resend API to schedule emails.
You can use the various Resend SDKs to schedule emails.
import { Resend } from 'resend';const resend = new Resend('re_123456789');const oneMinuteFromNow = new Date(Date.now() + 1000 * 60).toISOString();await resend.emails.send({from: 'Acme <onboarding@resend.dev>',to: ['delivered@resend.dev'],subject: 'hello world',html: '<p>it works!</p>',scheduledAt: oneMinuteFromNow,});
The date must be in ISO 8601 format (e.g: 2024-08-05T11:52:01.858Z
).
Once you schedule an email, you can see the scheduled time in the Resend dashboard.
After scheduling an email, you might need to update the scheduled time.
You can do so with the following method:
const oneMinuteFromNow = new Date(Date.now() + 1000 * 60).toISOString();resend.emails.update({id: '49a3999c-0ce1-4ea6-ab68-afcd6dc2e794',scheduledAt: oneMinuteFromNow,});
You can also reschedule an email directly in the Resend dashboard.
If you need to cancel a scheduled email, you can do so with the following code:
resend.emails.cancel('49a3999c-0ce1-4ea6-ab68-afcd6dc2e794');
You can also cancel a scheduled email in the Resend dashboard.
There are some limitations to keep in mind when scheduling emails:
We hope this new endpoint makes it easier for you to schedule emails in your application without having to introduce additional complexity.
You can see the Resend OpenAPI spec or the Postman collection for all parameters.
Feel free to check the documentation for more details.