Skip to main content

Node.js SDK

The jetemail package is the official Node.js SDK for JetEmail transactional email (MIT license, Node.js 18+, uses native fetch). Create a transactional API key in the dashboard: OutboundKeys → Add API key. Use that key with the SDK.

Installation

npm install jetemail
Package on npm: jetemail.

Quick start

import { JetEmail } from 'jetemail';

const client = new JetEmail('your-transactional-api-key');

await client.email.send({
  from: 'Your App <[email protected]>',
  to: '[email protected]',
  subject: 'Welcome!',
  html: '<h1>Welcome!</h1>'
});
Use a from address on a verified domain (see Getting started).

Constructor

// API key string
const client = new JetEmail('your-transactional-api-key');

// Or with options
const client = new JetEmail({
  apiKey: 'your-transactional-api-key',
  baseUrl: 'https://api.jetemail.com' // optional
});

client.email.send(options)

Send a single email.
FieldRequiredDescription
fromSender, e.g. "Name <[email protected]>"
toRecipient(s), string or array (max 50)
subjectSubject line
html*HTML body (need html and/or text)
text*Plain text (need html and/or text)
cc, bcc, reply_toRecipients (max 50 each)
headersCustom headers
attachmentsAttachments (max 40MB total)
Response shape: { id: string; response: string }.

client.batch.send(emails)

Send up to 100 emails in one request. Returns summary (total, successful, failed) and results per message (success with id, or error with error).

Error handling

import { JetEmail, JetEmailError } from 'jetemail';

try {
  await client.email.send({ /* ... */ });
} catch (error) {
  if (error instanceof JetEmailError) {
    console.error(error.statusCode, error.message, error.response);
  } else {
    throw error;
  }
}
Common status codes: 400 invalid request, 401 bad/missing API key, 500 server error.

TypeScript

Exported types include JetEmail, SendEmailOptions, SendEmailResponse, SendBatchResponse, JetEmailError, Attachment.
For batch examples, attachments (base64), custom headers, and the full option list, see the README on npm. REST details: API reference.