Skip to content
Splashify Pro
Email docsEmail

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

We don't ship a Node SDK yet โ€” use any HTTP client. fetch is built into Node 18+.

bash
# No install needed if you're on Node 18+

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.",
    }),
  },
);

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 "SUPPRESSED_RECIPIENT":
      // Recipient is on your suppression list
      break;
    case "INSUFFICIENT_BALANCE":
      // Recharge your wallet
      break;
    default:
      console.error(err.message);
  }
}

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/render
jsx
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 = 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