@kody/resend
Send transactional email and manage Resend domains, audiences, and templates with dry-run mutations.
Files
@kody/resend — agent notes
Human setup and intent live in README.md. This file is for
agents: imports, smoke/dryRun execute snippets, and edge cases. Secrets by
name only — never paste key values. Do not disable live webhooks or jobs
(this package declares none).
Auth
| Lane | Credential | Notes |
|---|---|---|
| A (default) | User secret resend | API key to api.resend.com. account: "work" → resend-work; or pass secretName. |
| B | Integration resend (or integration: "resend-work") | OAuth 2.1 + PKCE. Scope full_access for management; emails:send is send-only. |
Host: api.resend.com. Placeholder: {{secret:resend|scope=user}}.
Import paths
| Export | Import |
|---|---|
root dispatcher (default smoke-test) + helpers | kody:@kody/resend |
| emails | kody:@kody/resend/emails |
| domains | kody:@kody/resend/domains |
| contacts | kody:@kody/resend/contacts |
| templates | kody:@kody/resend/templates |
| broadcasts | kody:@kody/resend/broadcasts |
| account | kody:@kody/resend/account |
| smoke-test | kody:@kody/resend/smoke-test |
Prefer static kody:@kody/resend/... imports from execute. Do not lead with
packages.invoke. Import the official package as kody:@kody/resend — do not
invoke a personal resend kody id.
Low-level transport (resendRequest, resendCall, ResendApiError) stays
pinned to https://api.resend.com. Deprecated /audiences routes are not
wrapped — use contacts + segments.
Smoke test (read-only)
import { smokeTest } from 'kody:@kody/resend'
export default async function main() {
return await smokeTest()
// without creds => { ok: true, live: false, ...setup URLs }
// with creds => domains + recent sent email page (no writes)
}Or:
import smokeTest from 'kody:@kody/resend/smoke-test'
export default async function main() {
return await smokeTest()
}Common snippets
import resend from 'kody:@kody/resend'
export default async function main() {
return await resend({ action: 'list-domains' })
}import { sendEmail } from 'kody:@kody/resend/emails'
export default async function main() {
const preview = await sendEmail({
from: 'Name <hello@yourdomain.com>',
to: 'person@example.com',
subject: 'Hello from Kody',
html: '<p>It works!</p>',
dryRun: true,
})
return preview
}dryRun / confirm (writes)
- Pass
dryRun: trueon any mutation to return{ dryRun: true, method, path, body }without contacting Resend. sendEmail,sendBatch,sendBroadcast,cancelScheduledEmail,publishTemplate, and everydelete*helper also throw unlessconfirm: true.- Broadcasts are draft-first:
createBroadcastDraftnever sends. - POST helpers accept optional
idempotencyKeyso a retried send cannot double-deliver.
import { sendEmail } from 'kody:@kody/resend/emails'
export default async function main() {
return await sendEmail({
from: 'Name <hello@yourdomain.com>',
to: 'person@example.com',
subject: 'Hello from Kody',
html: '<p>It works!</p>',
confirm: true,
idempotencyKey: 'welcome/user-123',
})
}Edge cases / fork notes
frommust belong to a verified domain (or Resend’sonboarding@resend.devtest sender to your own account email).- 403
insufficient_scope→ reconnect OAuth withfull_access. - 429 → back off (default ~2 rps) or use
sendBatch. resendCallwrites default to dry-run until you passdryRun: false.- Never paste Resend API keys or OAuth tokens into chat or logs.