Skip to content

Commit 9f66569

Browse files
committed
docs: slim README to point to hosted docs
1 parent ce25972 commit 9f66569

2 files changed

Lines changed: 28 additions & 119 deletions

File tree

README.md

Lines changed: 9 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -6,119 +6,45 @@ Official Node.js SDK and CLI tools for the [Lettr](https://lettr.com) transactio
66

77
| Package | Description |
88
| --- | --- |
9-
| [`lettr`](./packages/lettr) | Core SDK — type-safe API client for sending emails, managing domains, templates, and webhooks |
9+
| [`lettr`](./packages/lettr) | Core SDK — type-safe API client for emails, templates, domains, webhooks, audience, and campaigns |
1010
| [`lettr-kit`](./packages/lettr-kit) | CLI tool for managing Lettr email templates locally |
1111

1212
## Quick Start
1313

14-
### Install
15-
1614
```bash
1715
npm install lettr
18-
# or
19-
bun add lettr
2016
```
2117

22-
### Send an Email
23-
2418
```typescript
2519
import { Lettr } from "lettr";
2620

27-
const client = new Lettr("lttr_your_api_key");
21+
const client = new Lettr(process.env.LETTR_API_KEY!);
2822

2923
const { data, error } = await client.emails.send({
3024
from: "sender@example.com",
3125
to: ["recipient@example.com"],
3226
subject: "Welcome!",
3327
html: "<h1>Hello!</h1>",
3428
});
35-
```
36-
37-
### Send with a Template
38-
39-
When using a template, `subject` is optional — the template's subject is used by default. You can pass `subject` to override it.
40-
41-
```typescript
42-
// Subject defined by the template
43-
const { data, error } = await client.emails.send({
44-
from: "sender@example.com",
45-
to: ["recipient@example.com"],
46-
template_slug: "welcome",
47-
substitution_data: { name: "John" },
48-
});
49-
50-
// Override the template's subject
51-
const { data, error } = await client.emails.send({
52-
from: "sender@example.com",
53-
to: ["recipient@example.com"],
54-
template_slug: "welcome",
55-
subject: "Custom Subject",
56-
substitution_data: { name: "John" },
57-
});
58-
```
59-
60-
### Error Handling
61-
62-
All methods return a `Result<T>` with discriminated `data` and `error` fields:
63-
64-
```typescript
65-
const { data, error } = await client.emails.send({ ... });
6629

6730
if (error) {
68-
// error.type is "validation" | "api" | "network"
69-
console.error(error.message);
70-
return;
31+
console.error(error.message); // error.type: "validation" | "api" | "network"
32+
} else {
33+
console.log(data.request_id);
7134
}
72-
73-
console.log(data.request_id);
7435
```
7536

76-
## API Reference
37+
Every method returns a `Result<T>` (`{ data, error }`) — the SDK never throws for API or network failures.
7738

78-
```typescript
79-
const client = new Lettr("lttr_...");
80-
81-
// Emails
82-
client.emails.send(request)
83-
client.emails.list(params?)
84-
client.emails.get(requestId)
85-
86-
// Domains
87-
client.domains.list()
88-
client.domains.create(domain)
89-
client.domains.get(domain)
90-
client.domains.delete(domain)
91-
client.domains.verify(domain)
92-
93-
// Templates
94-
client.templates.list(params?)
95-
client.templates.create(data)
96-
client.templates.get(slug, projectId?)
97-
client.templates.update(slug, data)
98-
client.templates.delete(slug, projectId?)
99-
client.templates.getMergeTags(slug, params?)
100-
101-
// Webhooks
102-
client.webhooks.list()
103-
client.webhooks.get(webhookId)
104-
105-
// Projects
106-
client.projects.list(params?)
107-
108-
// System
109-
client.health()
110-
client.authCheck()
111-
```
39+
## Documentation
40+
41+
📚 **[docs.lettr.com/quickstart/nodejs](https://docs.lettr.com/quickstart/nodejs/introduction)** — full guides for sending, templates, domains, webhooks, audience, and campaigns, plus the [API reference](https://docs.lettr.com/api-reference/introduction).
11242

11343
## CLI (`lettr-kit`)
11444

11545
```bash
11646
npm install -g lettr-kit
117-
# or
118-
bunx lettr-kit
119-
```
12047

121-
```bash
12248
lettr-kit init # Interactive setup — creates lettr.json
12349
lettr-kit list # List all templates with sync status
12450
lettr-kit pull # Pull templates as HTML files

packages/lettr/README.md

Lines changed: 19 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
# Lettr Node.js SDK
22

3-
Official Node.js SDK for the [Lettr](https://lettr.com) transactional email API.
3+
Official Node.js SDK for the [Lettr](https://lettr.com) transactional email API. Type-safe client that returns a `Result` (`{ data, error }`) instead of throwing — covers emails, templates, domains, webhooks, audience, and campaigns.
44

55
## Installation
66

77
```bash
8-
bun install lettr
8+
npm install lettr
9+
# or: pnpm add lettr / yarn add lettr / bun add lettr
910
```
1011

1112
## Usage
1213

1314
```typescript
1415
import { Lettr } from "lettr";
1516

16-
const client = new Lettr("your-api-key");
17+
const client = new Lettr(process.env.LETTR_API_KEY!);
1718

1819
const { data, error } = await client.emails.send({
1920
from: "sender@example.com",
@@ -23,49 +24,31 @@ const { data, error } = await client.emails.send({
2324
});
2425

2526
if (error) {
27+
// error.type is "validation" | "api" | "network"
2628
console.error(error.message);
2729
} else {
2830
console.log(data.request_id);
2931
}
3032
```
3133

32-
## Campaigns
34+
Every method returns a `Result<T>` — destructure `{ data, error }` and handle `error` before reading `data`. The SDK never throws for API or network failures.
3335

34-
List, retrieve, and act on campaigns under `client.campaigns`:
36+
## Documentation
3537

36-
```typescript
37-
// List sent campaigns
38-
const { data } = await client.campaigns.list({ status: "sent" });
39-
data?.campaigns.forEach((c) => console.log(c.name, c.stats.opens));
40-
41-
// Retrieve a single campaign (includes rendered HTML)
42-
const { data: campaign } = await client.campaigns.get(campaignId);
38+
Full guides for every resource, with complete request/response details, live in the docs:
4339

44-
// Engagement events with cursor-based pagination
45-
const { data: events } = await client.campaigns.listEvents(campaignId, {
46-
event_type: "open",
47-
limit: 50,
48-
});
49-
// keep paging while events.next_cursor is non-null
40+
📚 **[docs.lettr.com/quickstart/nodejs](https://docs.lettr.com/quickstart/nodejs/introduction)**
5041

51-
// Dispatch a draft, schedule a future send, or unschedule
52-
await client.campaigns.send(campaignId);
53-
await client.campaigns.schedule(campaignId, {
54-
scheduled_at: "2026-06-01T09:00:00+00:00",
55-
});
56-
await client.campaigns.unschedule(campaignId);
57-
```
58-
59-
The three action methods (`send` / `schedule` / `unschedule`) resolve to a
60-
`{ message, data? }` wrapper. Guard the optional `data` field — the API may
61-
omit it in a rare post-action race:
62-
63-
```typescript
64-
const { data, error } = await client.campaigns.send(campaignId);
65-
if (error) return handle(error);
66-
console.log(data.message); // always present
67-
if (data.data) console.log(data.data.status); // optional — guard first
68-
```
42+
| Topic | Guide |
43+
|-|-|
44+
| Install, client, the Result pattern | [Installation](https://docs.lettr.com/quickstart/nodejs/installation) |
45+
| HTML, text, templates, attachments, scheduling, errors | [Sending Emails](https://docs.lettr.com/quickstart/nodejs/sending-emails) |
46+
| Manage Lettr templates & merge tags | [Templates](https://docs.lettr.com/quickstart/nodejs/templates) |
47+
| Add, verify, and manage sending domains | [Domains](https://docs.lettr.com/quickstart/nodejs/domains) |
48+
| Webhook endpoints for delivery & engagement events | [Webhooks](https://docs.lettr.com/quickstart/nodejs/webhooks) |
49+
| Lists, contacts, topics, properties, segments | [Audience](https://docs.lettr.com/quickstart/nodejs/audience) |
50+
| List, send, and schedule campaigns | [Campaigns](https://docs.lettr.com/quickstart/nodejs/campaigns) |
51+
| Endpoint reference (params & schemas) | [API Reference](https://docs.lettr.com/api-reference/introduction) |
6952

7053
## License
7154

0 commit comments

Comments
 (0)