SKILL.md
$2c
if (error) {
console.error('Failed:', error.message);
return;
}
console.log('Sent:', data.id);
**Key gotcha:** The Resend Node.js SDK does NOT throw exceptions — it returns `{ data, error }`. Always check `error` explicitly instead of using try/catch for API errors.
## Quick Send — Python
import resend
import os
resend.api_key = os.environ["RESEND_API_KEY"]
email = resend.Emails.send({
"from": "Acme <onboarding@resend.dev>",
"to": ["delivered@resend.dev"],
"subject": "Hello World",
"html": "<p>Email body here</p>",
}, idempotency_key=f"welcome-email/{user_id}")
### Single vs Batch Decision
Choose
When
**Single** (`POST /emails`)
1 email, needs attachments, needs scheduling
**Batch** (`POST /emails/batch`)
2-100 distinct emails, no attachments, no scheduling
Batch is atomic — if one email fails validation, the entire batch fails. Always validate before sending. Batch does NOT support attachments or `scheduled_at`.
### Idempotency Keys (Critical for Retries)
Prevent duplicate emails when retrying failed requests:
Key Facts
**Format (single)**
`<event-type>/<entity-id>` (e.g., `welcome-email/user-123`)
**Format (batch)**
`batch-<event-type>/<batch-id>` (e.g., `batch-orders/batch-456`)
**Expiration**
24 hours
**Max length**
256 characters
**Same key + same payload**
Returns original response without resending
**Same key + different payload**
Returns 409 error
## Quick Receive (Node.js)
import { Resend } from 'resend';
const resend = new Resend(process.env.RESEND_API_KEY);
export async function POST(req: Request) {
const payload = await req.text(); // Must use raw text, not req.json()
const event = resend.webhooks.verify({
payload,
headers: {
'svix-id': req.headers.get('svix-id'),
'svix-timestamp': req.headers.get('svix-timestamp'),
'svix-signature': req.headers.get('svix-signature'),
},
secret: process.env.RESEND_WEBHOOK_SECRET,
});
if (event.type === 'email.received') {
// Webhook has metadata only — call API for body
const { data: email } = await resend.emails.receiving.get(
event.data.email_id
);
console.log(email.text);
}
return new Response('OK', { status: 200 });
}
**Key gotcha:** Webhook payloads do NOT contain the email body. You must call `resend.emails.receiving.get()` separately.
## What Do You Need?
Task
Reference
**Send a single email**
[sending/overview.md](https://github.com/resend/resend-skills/blob/HEAD/skills/resend/references/sending/overview.md) — parameters, deliverability, testing
**Send batch emails**
[sending/overview.md](https://github.com/resend/resend-skills/blob/HEAD/skills/resend/references/sending/overview.md) → [sending/batch-email-examples.md](https://github.com/resend/resend-skills/blob/HEAD/skills/resend/references/sending/batch-email-examples.md)
**Full SDK examples** (Node.js, Python, Go, cURL)
[sending/single-email-examples.md](https://github.com/resend/resend-skills/blob/HEAD/skills/resend/references/sending/single-email-examples.md)
**Idempotency, retries, error handling**
[sending/best-practices.md](https://github.com/resend/resend-skills/blob/HEAD/skills/resend/references/sending/best-practices.md)
**Get, list, reschedule, cancel emails**
[sending/email-management.md](https://github.com/resend/resend-skills/blob/HEAD/skills/resend/references/sending/email-management.md)
**Receive inbound emails**
[receiving.md](https://github.com/resend/resend-skills/blob/HEAD/skills/resend/references/receiving.md) — domain setup, webhooks, attachments
**Manage templates** (CRUD, variables)
[templates.md](https://github.com/resend/resend-skills/blob/HEAD/skills/resend/references/templates.md) — lifecycle, aliases, pagination
**Set up webhooks** (events, verification)
[webhooks.md](https://github.com/resend/resend-skills/blob/HEAD/skills/resend/references/webhooks.md) — verification, CRUD, retry schedule, IP allowlist
**Manage domains** (create, verify, DNS)
[domains.md](https://github.com/resend/resend-skills/blob/HEAD/skills/resend/references/domains.md) — regions, TLS, tracking, capabilities
**Manage contacts** (CRUD, properties)
[contacts.md](https://github.com/resend/resend-skills/blob/HEAD/skills/resend/references/contacts.md) — segments, topics, custom properties
**Send broadcasts** (marketing campaigns)
[broadcasts.md](https://github.com/resend/resend-skills/blob/HEAD/skills/resend/references/broadcasts.md) — lifecycle, scheduling, template variables
**Manage API keys**
[api-keys.md](https://github.com/resend/resend-skills/blob/HEAD/skills/resend/references/api-keys.md) — permission scoping, domain restrictions
**View API request logs**
[logs.md](https://github.com/resend/resend-skills/blob/HEAD/skills/resend/references/logs.md) — list and retrieve API call history, debugging
**Define contact properties**
[contact-properties.md](https://github.com/resend/resend-skills/blob/HEAD/skills/resend/references/contact-properties.md) — custom fields for contacts
**Manage segments** (contact groups)
[segments.md](https://github.com/resend/resend-skills/blob/HEAD/skills/resend/references/segments.md) — broadcast targeting, contact grouping
**Manage topics** (subscriptions)
[topics.md](https://github.com/resend/resend-skills/blob/HEAD/skills/resend/references/topics.md) — opt-in/out preferences, broadcast filtering
**Create automations** (event-driven workflows)
[automations.md](https://github.com/resend/resend-skills/blob/HEAD/skills/resend/references/automations.md) — steps, connections, runs, conditions
**Define and send events** (automation triggers)
[events.md](https://github.com/resend/resend-skills/blob/HEAD/skills/resend/references/events.md) — schemas, payloads, contact association
**Install SDK** (8+ languages)
[installation.md](https://github.com/resend/resend-skills/blob/HEAD/skills/resend/references/installation.md)
**Set up an AI agent inbox**
Install the `agent-email-inbox` skill — covers security levels for untrusted input
## SDK Version Requirements
Always install the latest SDK version. These are the minimum versions for full functionality (sending, receiving, webhook verification):
Language
Package
Min Version
Install
Node.js
`resend`
>= 6.9.2
`npm install resend`
Python
`resend`
>= 2.21.0
`pip install resend`
Go
`resend-go/v3`
>= 3.1.0
`go get github.com/resend/resend-go/v3`
Ruby
`resend`
>= 1.0.0
`gem install resend`
PHP
`resend/resend-php`
>= 1.1.0
`composer require resend/resend-php`
Rust
`resend-rs`
>= 0.20.0
`cargo add resend-rs`
Java
`resend-java`
>= 4.11.0
See [installation.md](https://github.com/resend/resend-skills/blob/HEAD/skills/resend/references/installation.md)
.NET
`Resend`
>= 0.2.1
`dotnet add package Resend`
**If the project already has a Resend SDK installed**, check the version and upgrade if it's below the minimum. Older SDKs may be missing `webhooks.verify()` or `emails.receiving.get()`.
See [installation.md](https://github.com/resend/resend-skills/blob/HEAD/skills/resend/references/installation.md) for full installation commands, language detection, and cURL fallback.
## Common Setup
### API Key
Store in environment variable — never hardcode:
export RESEND_API_KEY=re_xxxxxxxxx