Keplars

Node.js

Official Node.js / TypeScript SDK for Keplars

Installation

Install the package

npm install keplars
yarn add keplars
bun add keplars
pnpm add keplars

Set your API key

KEPLARS_API_KEY=kms_your_workspace_id.live_your_secret

Send your first email

import { Keplars } from 'keplars';

const client = new Keplars({ apiKey: process.env.KEPLARS_API_KEY });

const response = await client.emails.sendInstant({
  from: '[email protected]',
  to: '[email protected]',
  subject: 'Hello!',
  body: '<h1>It works!</h1>',
  is_html: true,
});

console.log(response.id);

Priority Levels

MethodDeliveryUse case
sendInstant0–5 secondsOTP, 2FA, password reset
sendHigh0–30 secondsTransactional confirmations
sendAsync / send0–5 minutesWelcome emails, notifications
sendBulkBackgroundNewsletters, campaigns
await client.emails.sendInstant({ ... });
await client.emails.sendHigh({ ... });
await client.emails.sendAsync({ ... });
await client.emails.sendBulk({ ... });

Using Templates

const response = await client.emails.sendInstant({
  from: '[email protected]',
  to: '[email protected]',
  template_id: 'your-template-id',
  params: {
    user_name: 'Jane',
    verification_code: '123456',
  },
});

Schedule an Email

const response = await client.emails.schedule({
  from: '[email protected]',
  to: '[email protected]',
  subject: 'Weekly digest',
  body: '<p>Here is your digest.</p>',
  is_html: true,
  scheduled_for: '2026-02-01T09:00:00Z',
  timezone: 'America/New_York',
});

Error Handling

import { Keplars, AuthenticationError, RateLimitError } from 'keplars';

try {
  const response = await client.emails.sendInstant({ ... });
} catch (error) {
  if (error instanceof AuthenticationError) {
    console.error('Invalid API key');
  } else if (error instanceof RateLimitError) {
    console.error('Rate limit hit, retry after:', error.retryAfter);
  } else {
    throw error;
  }
}

Admin API

Need to manage contacts, audiences, automations, or domains? Use an admin key - same client, different key suffix:

const client = new Keplars({ apiKey: 'kms_xxx.adm_xxx' });

await client.contacts.add({ email: '[email protected]', name: 'Jane' });
await client.audiences.create('Newsletter');
await client.automations.enroll('auto_id', '[email protected]');
await client.domains.verify('domain_id');

See the full Admin API reference.

Next Steps

On this page