Back to APIs

Send emails & React emails using Resend's email service.

Using our official Resend integration

Create any tasks possible with the Resend API.

Use io.runTask() and the official SDK or fetch.

Resend integration docs

Example code using Resend

Below are some working code examples of how you can use Resend with Trigger.dev. These samples are open source and maintained by the community, you can copy and paste them into your own projects.

1
import { TriggerClient, eventTrigger } from "@trigger.dev/sdk";
2
import { Resend } from "@trigger.dev/resend";
3
import { z } from "zod";
4
5
const resend = new Resend({
6
id: "resend",
7
apiKey: process.env.RESEND_API_KEY!,
8
});
9
10
// This job sends a basic email to a 'to' email address, a 'subject', a 'text' field and a 'from' email address.
11
client.defineJob({
12
id: "resend-send-basic-email",
13
name: "Resend: send basic email",
14
version: "1.0.0",
15
trigger: eventTrigger({
16
name: "send.email",
17
schema: z.object({
18
to: z.union([z.string(), z.array(z.string())]),
19
subject: z.string(),
20
text: z.string(),
21
// The 'from' email address must be a verified domain in your Resend account.
22
from: z.string(),
23
}),
24
}),
25
integrations: {
26
resend,
27
},
28
run: async (payload, io, ctx) => {
29
await io.resend.sendEmail("send-email", {
30
to: payload.to,
31
subject: payload.subject,
32
text: payload.text,
33
from: payload.from,
34
});
35
},
36
});