Skip to documentation

Quickstarts

Send with Node.js

Send your first email from Node.js.

Prerequisites

You need a running installation, a verified sending domain, and an API key with sending or full access. Set OPENSEND_API_KEY and OPENSEND_BASE_URL on the server. The base URL is your installation’s API origin (the public Convex HTTP origin), such as https://api.example.com, without an /api suffix.

Install

bash
pnpm add @opensendcc/sdk

Send

typescript
import { Opensend } from "@opensendcc/sdk";

const opensend = new Opensend(process.env.OPENSEND_API_KEY!, {
  baseUrl: process.env.OPENSEND_BASE_URL!, // https://api.example.com
});

const { data, error } = await opensend.emails.send({
  from: "Acme <hello@example.com>",
  to: ["you@example.net"],
  subject: "Hello from Opensend",
  html: "<p>Your first email is on its way.</p>",
});
if (error) throw new Error(error.message);
console.log(data?.id);

Try it

Run the server-side example or call your protected route. Open Emails in Opensend to inspect the message. An ID means the email entered the durable queue; it does not prove inbox delivery. Inspect delivery events and failures there.

Keep the key on the server. SES sandbox restrictions still apply. The HTTP equivalent is:

bash
curl "$OPENSEND_BASE_URL/emails" \
  -H "Authorization: Bearer $OPENSEND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"from":"Acme <hello@example.com>","to":["you@example.net"],"subject":"Hello from Opensend","html":"<p>Your first email is on its way.</p>"}'