Skip to main content

TypeScript SDK

The simpleemailapi package provides a fully typed, backend-first SDK for Node.js workflows.

Installation

npm install simpleemailapi

Usage

Initialize the client with your API key and use the client.send method.
import { createClient } from 'simpleemailapi';

const client = createClient({ apiKey: 'sea_live_...' });

const result = await client.send({
  from: '[email protected]', // Must be verified
  to: ['[email protected]'],
  subject: 'Welcome aboard!',
  text: 'Thanks for signing up.', // inferred from 'body' in proto but 'text' is common alias, let's stick to proto 'body' for accuracy
  body: 'Thanks for signing up.',
  html: '<p>Thanks for signing up.</p>'
});

console.log('Email ID:', result.id);
The from address must belong to a domain you have verified.

Client Configuration

The createClient function accepts the following options:
apiKey
string
required
Your API Key, starting with sea_live_.
baseUrl
string
API endpoint URL. Defaults to https://api.simpleemailapi.dev.

arguments

The client.send method accepts an object with the following properties:
from
string
required
Sender email address. Must be from a verified domain.
to
string[]
required
List of primary recipient email addresses.
subject
string
required
Email subject line.
body
string
Plain text content of the email.
html
string
HTML content of the email.
cc
string[]
List of CC recipient email addresses.
bcc
string[]
List of BCC recipient email addresses.
attachments
Attachment[]
List of files to attach.
replyTo
string
Email address to use for the Reply-To header. // Actually proto has inReplyTo for threading, but standard email APIs usually have replyTo. Proto has inReplyTo. Let’s stick to exact types from SendEmailRequest.
inReplyTo
string
Message-ID of the email being replied to (for threading).
references
string[]
List of message IDs for threading context.
headers
Record<string, string>
Custom headers. // Proto has metadata, effectively custom headers/metadata.
metadata
Record<string, string>
Custom key-value metadata.
scheduledAt
Date
Schedule the email for future delivery.
async
boolean
If true, queue for async processing (we handle retries). If false, send synchronously. Emails with attachments are always async.