Node.js Quickstart
Send transactional and marketing email from Node.js. Works on every runtime โ Node 18+, Bun, Deno, and edge environments (Vercel, Cloudflare Workers, etc.).
1. Install
This guide uses fetch, which is built into Node 18+, so there is
nothing to install. Prefer a package? See the
Node.js SDK.
2. Set your API key
bash
export SPLASHIFY_API_KEY="pk_live_..."3. Send your first email
javascript
const res = await fetch(
"https://api.splashifypro.com/api/v1/partner/email/send",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.SPLASHIFY_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
from: "[email protected]",
to: ["[email protected]"],
subject: "Welcome to our app",
html_body: "<h1>Welcome ๐</h1><p>Your account is ready.</p>",
text_body: "Welcome. Your account is ready.",
}),
},
);
if (res.ok) {
const data = await res.json();
console.log(data.results[0].message_id);
}4. Handle errors
javascript
if (!res.ok) {
const err = await res.json();
switch (err.error) {
case "INVALID_REQUEST":
// Bad input โ read err.message
break;
case "FROM_NOT_VERIFIED":
// Verify your domain at /identities first
break;
case "INSUFFICIENT_BALANCE":
// Recharge your wallet
break;
default:
console.error(err.message);
}
}A suppressed recipient is not an error. The call succeeds and that
recipient comes back in results with status: "rejected" and
reason: "suppressed".
5. With React Email
React Email renders HTML email from React
components. You author your template as JSX, render it server-side,
and pass the HTML to /send.
bash
npm install @react-email/components @react-email/renderjsx
import { Html, Button, Text } from "@react-email/components";
import { render } from "@react-email/render";
function Welcome({ name }) {
return (
<Html>
<Text>Hi {name},</Text>
<Button href="https://yourapp.com/dashboard">Open dashboard</Button>
</Html>
);
}
const html = await render(<Welcome name="Alex" />);
await fetch("https://api.splashifypro.com/api/v1/partner/email/send", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.SPLASHIFY_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
from: "[email protected]",
to: ["[email protected]"],
subject: "Welcome",
html_body: html,
}),
});What's next
- Verify your domain โ required before sending in production
- Set up webhooks โ listen to delivery events
- Use templates โ reusable bodies with variables
- Send in bulk โ up to 500 recipients per request