Files

85 lines
1.5 KiB
Plaintext

---
title: Resend
---
<Snippet file="integration-getting-started.mdx" />
## Installation
<CodeGroup>
```bash npm
npm install @trigger.dev/resend@latest
```
```bash pnpm
pnpm install @trigger.dev/resend@latest
```
```bash yarn
yarn add @trigger.dev/resend@latest
```
</CodeGroup>
## Authentication
Resend supports API Keys
```ts
import { Resend } from "@trigger.dev/resend";
const resend = new Resend({
id: "resend",
apiKey: process.env.RESEND_API_KEY!,
});
```
## Example
In this example we use [Zod](/documentation/guides/zod), a TypeScript-first schema declaration and validation library.
```ts
import { Resend } from "@trigger.dev/resend";
import { Job, eventTrigger } from "@trigger.dev/sdk";
import { z } from "zod";
...
const resend = new Resend({
id: "resend",
apiKey: process.env.RESEND_API_KEY!,
});
client.defineJob({
id: "send-resend-email",
name: "Send Resend Email",
version: "0.1.0",
trigger: eventTrigger({
name: "send.email",
schema: z.object({
to: z.union([z.string(), z.array(z.string())]),
subject: z.string(),
text: z.string(),
}),
}),
integrations: {
resend,
},
run: async (payload, io, ctx) => {
await io.resend.sendEmail("send-email", {
to: payload.to,
subject: payload.subject,
text: payload.text,
from: "Trigger.dev <hello@email.trigger.dev>",
});
},
});
```
## Tasks
| Function Name | Description |
| ------------- | ------------- |
| `sendEmail` | Send an email |