Skip to content

Node.js

Terminal window
npm install resend
import { Resend } from "resend";
const resend = new Resend(process.env.AMDY_API_KEY, {
baseUrl: "https://mail.3ava.com/api",
});
await resend.emails.send({
from: "Acme <[email protected]>",
subject: "Hello",
html: "<p>Hi.</p>",
});

Option 2: fetch (zero dependencies, Node 18+)

Section titled “Option 2: fetch (zero dependencies, Node 18+)”
async function sendEmail(payload) {
const res = await fetch("https://mail.3ava.com/api/emails", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.AMDY_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
});
if (!res.ok) {
throw new Error(`3AVA Mail error: ${res.status} ${await res.text()}`);
}
return res.json();
}
const result = await sendEmail({
from: "Acme <[email protected]>",
subject: "Hello",
html: "<p>Hi.</p>",
});
console.log(result.id);

If you’re using the Resend SDK, types are bundled. If you’re rolling your own, the minimum email shape:

interface AmdyEmail {
from: string;
to: string | string[];
subject: string;
html?: string;
text?: string;
cc?: string | string[];
bcc?: string | string[];
reply_to?: string;
headers?: Record<string, string>;
attachments?: Array<{
filename: string;
content: string; // base64
content_type?: string;
content_id?: string;
}>;
tags?: Array<{ name: string; value: string }>;
scheduled_at?: string; // ISO 8601
}
interface AmdyEmailResponse {
id: string;
status: "queued" | "sent" | "delivered" | "bounced" | "failed" | "suppressed";
created_at: string;
}
await fetch("https://mail.3ava.com/api/emails", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.AMDY_API_KEY}`,
"Idempotency-Key": `order-${orderId}-receipt`,
"Content-Type": "application/json",
},
body: JSON.stringify({...}),
});

A typical pattern — a server action that sends a magic link:

app/actions/sendMagicLink.ts
"use server";
import { Resend } from "resend";
const resend = new Resend(process.env.AMDY_API_KEY!, {
baseUrl: process.env.AMDY_API_URL!,
});
export async function sendMagicLink(to: string, token: string) {
const url = `https://app.acme.com/login?t=${token}`;
return resend.emails.send({
from: "Acme <[email protected]>",
to: [to],
subject: "Sign in to Acme",
html: `<p><a href="${url}">Click here to sign in</a></p>`,
});
}