https://github.com/lettermint/lettermint-node
Official Lettermint Node.js SDK
https://github.com/lettermint/lettermint-node
Last synced: about 2 months ago
JSON representation
Official Lettermint Node.js SDK
- Host: GitHub
- URL: https://github.com/lettermint/lettermint-node
- Owner: lettermint
- Created: 2025-05-24T10:56:03.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2026-05-11T06:21:51.000Z (about 2 months ago)
- Last Synced: 2026-05-11T08:29:32.453Z (about 2 months ago)
- Language: TypeScript
- Homepage: https://docs.lettermint.co/guides/send-email-with-nodejs
- Size: 700 KB
- Stars: 10
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Lettermint Node.js SDK


[](https://lettermint.co/r/discord)
The official Node.js SDK for [Lettermint](https://lettermint.co).
## Installation
```bash
npm install lettermint
```
## Usage
### Initialize the SDK
```typescript
import { Lettermint } from "lettermint";
const lettermint = new Lettermint({
apiToken: "your-api-token"
});
```
### Sending Emails
The SDK provides a fluent interface for sending emails:
```typescript
const response = await lettermint.email
.from('sender@acme.com')
.to('recipient@acme.com')
.subject('Hello from Lettermint')
.text('This is a test email sent using the Lettermint Node.js SDK.')
.send();
console.log(`Email sent with ID: ${response.message_id}`);
console.log(`Status: ${response.status}`);
```
#### Advanced Email Options
```typescript
const response = await lettermint.email
.from('John Doe ')
.to('recipient1@acme.com', 'recipient2@acme.com')
.cc('cc@acme.com')
.bcc('bcc@acme.com')
.replyTo('reply@acme.com')
.subject('Hello from Lettermint')
.html('
Hello
This is an HTML email.
')
.text('This is a plain text version of the email.')
.headers({
'X-Custom-Header': 'Custom Value',
})
.attach('attachment.txt', Buffer.from('Hello World').toString('base64'))
.attach('logo.png', Buffer.from('...').toString('base64'), 'logo') // Inline attachment
.idempotencyKey('unique-id-123')
.metadata({
foo: 'bar',
})
.tag('campaign-123')
.send();
```
## API Reference
### Lettermint Class
The main entry point for the SDK.
```typescript
const lettermint = new Lettermint({
apiToken: 'your-api-key',
baseUrl: 'https://api.lettermint.co/v1', // Optional
timeout: 30000, // Optional, in milliseconds
});
```
### Email Endpoint
Methods for sending emails:
- `from(email: string)`: Set the sender email address
- `to(...emails: string[])`: Set one or more recipient email addresses
- `subject(subject: string)`: Set the email subject
- `html(html: string | null)`: Set the HTML body of the email
- `text(text: string | null)`: Set the plain text body of the email
- `cc(...emails: string[])`: Set one or more CC email addresses
- `bcc(...emails: string[])`: Set one or more BCC email addresses
- `replyTo(...emails: string[])`: Set one or more Reply-To email addresses
- `headers(headers: Record)`: Set custom headers for the email
- `attach(filename: string, base64Content: string, content_id?: string)`: Attach a file to the email. Optional `content_id` for inline attachments.
- `route(route: string)`: Set the routing key for the email
- `idempotencyKey(key: string)`: Set an idempotency key to prevent duplicate email sends
- `metadata(metadata: Record)`: Set metadata for the email
- `tag(tag: string)`: Set a tag for the email
- `send()`: Send the email and return a promise with the response
## License
MIT