How to Use Resend API for Email: Complete Guide (2026)
Send transactional emails with Resend's developer-friendly API
Hypereal로 구축 시작하기
단일 API를 통해 Kling, Flux, Sora, Veo 등에 액세스하세요. 무료 크레딧으로 시작하고 수백만으로 확장하세요.
신용카드 불필요 • 10만 명 이상의 개발자 • 엔터프라이즈 지원
How to Use Resend API for Email: Complete Guide (2026)
Resend is a modern email API built for developers who are tired of fighting legacy email infrastructure. Created by the team behind React Email, Resend offers a clean API, excellent deliverability, and first-class support for frameworks like Next.js, Node.js, and Python.
This guide walks you through everything you need to start sending transactional emails with Resend, from account setup to production-ready code examples.
Why Resend?
Before diving in, here is how Resend compares to the alternatives:
| Feature | Resend | SendGrid | Amazon SES | Postmark |
|---|---|---|---|---|
| Free tier | 3,000 emails/month | 100 emails/day | 62,000/month (12 months) | 100 emails/month |
| Pricing starts at | $20/month | $19.95/month | $0.10 per 1,000 | $15/month |
| React Email support | Native | No | No | No |
| API simplicity | Excellent | Moderate | Complex | Good |
| Webhook support | Yes | Yes | Yes (via SNS) | Yes |
| Custom domains | Yes | Yes | Yes | Yes |
Resend stands out for its developer experience. The API is minimal, the documentation is excellent, and it integrates natively with React Email for building beautiful templates with JSX.
Prerequisites
Before you start, make sure you have:
- A Resend account (sign up at resend.com)
- A verified domain (or use the sandbox
onboarding@resend.devfor testing) - Node.js 18+ or Python 3.7+ installed
- An API key from the Resend dashboard
Step 1: Get Your API Key
- Log in to the Resend dashboard at resend.com.
- Navigate to API Keys in the sidebar.
- Click Create API Key.
- Give it a name like "Production" and select the appropriate permissions.
- Copy the key immediately. It starts with
re_and will not be shown again.
# Store your API key as an environment variable
export RESEND_API_KEY="re_your_api_key_here"
Step 2: Verify Your Domain
To send emails from your own domain instead of the sandbox, you need to verify DNS records.
- Go to Domains in the Resend dashboard.
- Click Add Domain and enter your domain (e.g.,
mail.yourdomain.com). - Add the DNS records Resend provides to your domain registrar:
| Record Type | Name | Value |
|---|---|---|
| TXT | _resend.yourdomain.com |
Verification string |
| MX | bounce.yourdomain.com |
Provided by Resend |
| TXT | bounce.yourdomain.com |
SPF record |
| CNAME | resend._domainkey.yourdomain.com |
DKIM record |
- Click Verify once the DNS records have propagated (usually 5-30 minutes).
Step 3: Send Your First Email
Using cURL
The simplest way to test the API:
curl -X POST 'https://api.resend.com/emails' \
-H 'Authorization: Bearer re_your_api_key_here' \
-H 'Content-Type: application/json' \
-d '{
"from": "You <hello@yourdomain.com>",
"to": ["recipient@example.com"],
"subject": "Hello from Resend",
"html": "<h1>Welcome!</h1><p>Your first email via Resend API.</p>"
}'
A successful response returns a 200 status with the email ID:
{
"id": "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794"
}
Using Node.js
Install the official SDK:
npm install resend
Send an email:
import { Resend } from 'resend';
const resend = new Resend(process.env.RESEND_API_KEY);
async function sendEmail() {
const { data, error } = await resend.emails.send({
from: 'You <hello@yourdomain.com>',
to: ['recipient@example.com'],
subject: 'Hello from Resend',
html: '<h1>Welcome!</h1><p>Your first email via Resend.</p>',
});
if (error) {
console.error('Failed to send email:', error);
return;
}
console.log('Email sent:', data.id);
}
sendEmail();
Using Python
Install the Python SDK:
pip install resend
Send an email:
import resend
import os
resend.api_key = os.environ["RESEND_API_KEY"]
params: resend.Emails.SendParams = {
"from": "You <hello@yourdomain.com>",
"to": ["recipient@example.com"],
"subject": "Hello from Resend",
"html": "<h1>Welcome!</h1><p>Your first email via Resend.</p>",
}
email = resend.Emails.send(params)
print(f"Email sent: {email['id']}")
Step 4: Use React Email Templates
One of Resend's biggest advantages is native React Email support. You can build email templates with JSX components instead of writing raw HTML tables.
Install React Email:
npm install @react-email/components
Create a template:
// emails/welcome.tsx
import { Html, Head, Body, Container, Text, Button } from '@react-email/components';
export default function WelcomeEmail({ name }: { name: string }) {
return (
<Html>
<Head />
<Body style={{ fontFamily: 'Arial, sans-serif', backgroundColor: '#f4f4f5' }}>
<Container style={{ maxWidth: '600px', margin: '0 auto', padding: '20px' }}>
<Text style={{ fontSize: '24px', fontWeight: 'bold' }}>
Welcome, {name}!
</Text>
<Text>
Thank you for signing up. We are excited to have you on board.
</Text>
<Button
href="https://yourdomain.com/dashboard"
style={{
backgroundColor: '#000',
color: '#fff',
padding: '12px 24px',
borderRadius: '6px',
textDecoration: 'none',
}}
>
Go to Dashboard
</Button>
</Container>
</Body>
</Html>
);
}
Send the template with Resend:
import { Resend } from 'resend';
import WelcomeEmail from './emails/welcome';
const resend = new Resend(process.env.RESEND_API_KEY);
await resend.emails.send({
from: 'You <hello@yourdomain.com>',
to: ['recipient@example.com'],
subject: 'Welcome to Our Platform',
react: WelcomeEmail({ name: 'Alice' }),
});
Step 5: Handle Webhooks
Resend can notify your server about email events like delivery, bounces, and opens.
- Go to Webhooks in the Resend dashboard.
- Add your endpoint URL (e.g.,
https://yourdomain.com/api/webhooks/resend). - Select the events you want to receive.
Handle the webhook in your API route:
// app/api/webhooks/resend/route.ts (Next.js App Router)
import { NextRequest, NextResponse } from 'next/server';
export async function POST(req: NextRequest) {
const body = await req.json();
switch (body.type) {
case 'email.delivered':
console.log(`Email ${body.data.email_id} delivered to ${body.data.to}`);
break;
case 'email.bounced':
console.log(`Email ${body.data.email_id} bounced`);
// Remove invalid email from your database
break;
case 'email.complained':
console.log(`Spam complaint for ${body.data.email_id}`);
// Unsubscribe the user
break;
}
return NextResponse.json({ received: true });
}
Common Webhook Events
| Event | Description |
|---|---|
email.sent |
Email accepted by Resend |
email.delivered |
Email delivered to recipient's mail server |
email.bounced |
Email bounced (invalid address) |
email.complained |
Recipient marked as spam |
email.opened |
Recipient opened the email |
email.clicked |
Recipient clicked a link |
Step 6: Batch Sending
Need to send multiple emails at once? Use the batch endpoint:
const { data, error } = await resend.batch.send([
{
from: 'You <hello@yourdomain.com>',
to: ['user1@example.com'],
subject: 'Your weekly report',
html: '<p>Here is your report...</p>',
},
{
from: 'You <hello@yourdomain.com>',
to: ['user2@example.com'],
subject: 'Your weekly report',
html: '<p>Here is your report...</p>',
},
]);
The batch endpoint supports up to 100 emails per request.
Error Handling Best Practices
Always handle errors gracefully when working with the Resend API:
import { Resend } from 'resend';
const resend = new Resend(process.env.RESEND_API_KEY);
async function sendWithRetry(params, maxRetries = 3) {
for (let attempt = 1; attempt <= maxRetries; attempt++) {
const { data, error } = await resend.emails.send(params);
if (!error) return data;
if (error.statusCode === 429) {
// Rate limited - wait and retry
const delay = Math.pow(2, attempt) * 1000;
console.log(`Rate limited. Retrying in ${delay}ms...`);
await new Promise(resolve => setTimeout(resolve, delay));
continue;
}
// Non-retryable error
throw new Error(`Resend API error: ${error.message}`);
}
throw new Error('Max retries exceeded');
}
Rate Limits
| Plan | Rate Limit |
|---|---|
| Free | 2 emails/second |
| Pro | 50 emails/second |
| Enterprise | Custom |
Quick Reference: API Endpoints
| Endpoint | Method | Description |
|---|---|---|
/emails |
POST | Send a single email |
/emails/{id} |
GET | Retrieve email details |
/emails/{id} |
PATCH | Update a scheduled email |
/emails/batch |
POST | Send up to 100 emails |
/domains |
GET | List verified domains |
/domains |
POST | Add a new domain |
/api-keys |
POST | Create an API key |
Wrapping Up
Resend makes transactional email simple for developers. The clean API, React Email integration, and generous free tier make it an excellent choice for projects of any size. Start with the sandbox for testing, verify your domain for production, and use webhooks to track delivery.
If you are building applications that need media generation alongside email workflows, such as sending AI-generated images or video thumbnails in your emails, check out Hypereal AI. Hypereal provides simple APIs for AI image generation, video creation, and more that pair perfectly with transactional email pipelines.
