Node.js
Official Node.js / TypeScript SDK for Keplars
Installation
Install the package
npm install keplarsyarn add keplarsbun add keplarspnpm add keplarsSet your API key
KEPLARS_API_KEY=kms_your_workspace_id.live_your_secretSend 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
| Method | Delivery | Use case |
|---|---|---|
sendInstant | 0–5 seconds | OTP, 2FA, password reset |
sendHigh | 0–30 seconds | Transactional confirmations |
sendAsync / send | 0–5 minutes | Welcome emails, notifications |
sendBulk | Background | Newsletters, 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
- Admin API - Contacts, audiences, automations, domains
- Send Emails - API reference
- Email Templates - Build reusable templates
- Schedule Emails - Delayed delivery