Skip to content
← Public packages

@kody/resend

Send transactional email and manage Resend domains, audiences, and templates with dry-run mutations.

FollowFork

Files

AGENTS.md

118 lines · 3.5 KB · Markdown

@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

LaneCredentialNotes
A (default)User secret resendAPI key to api.resend.com. account: "work" → resend-work; or pass secretName.
BIntegration 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

ExportImport
root dispatcher (default smoke-test) + helperskody:@kody/resend
emailskody:@kody/resend/emails
domainskody:@kody/resend/domains
contactskody:@kody/resend/contacts
templateskody:@kody/resend/templates
broadcastskody:@kody/resend/broadcasts
accountkody:@kody/resend/account
smoke-testkody:@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: true on any mutation to return { dryRun: true, method, path, body } without contacting Resend.
  • sendEmail, sendBatch, sendBroadcast, cancelScheduledEmail, publishTemplate, and every delete* helper also throw unless confirm: true.
  • Broadcasts are draft-first: createBroadcastDraft never sends.
  • POST helpers accept optional idempotencyKey so 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

  • from must belong to a verified domain (or Resend’s onboarding@resend.dev test sender to your own account email).
  • 403 insufficient_scope → reconnect OAuth with full_access.
  • 429 → back off (default ~2 rps) or use sendBatch.
  • resendCall writes default to dry-run until you pass dryRun: false.
  • Never paste Resend API keys or OAuth tokens into chat or logs.