smartletter 0.0.0-stage → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 THE DUG MEDIA LTD
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,102 @@
1
- # Temporary Holding Version
1
+ # smartletter
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Official Node.js SDK for [Smartletter](https://smartletter.ai). A drop-in replacement for the Resend SDK (`resend` 6.32): same method names, same `{ data, error, headers }` return shape. No runtime dependency. Works on Node 18+, Workers, Deno, Bun and the browser. ESM and CommonJS.
4
+
5
+ ```sh
6
+ npm install smartletter
7
+ ```
8
+
9
+ ## Send an email
10
+
11
+ ```ts
12
+ import { Smartletter } from "smartletter";
13
+
14
+ const smartletter = new Smartletter("sl_..."); // or set SMARTLETTER_API_KEY
15
+
16
+ const { data, error, headers } = await smartletter.emails.send({
17
+ from: "Acme <hello@acme.com>",
18
+ to: ["jane@example.com"],
19
+ subject: "Welcome",
20
+ html: "<p>Hello!</p>",
21
+ });
22
+ ```
23
+
24
+ `headers` holds the response headers (or `null`). Methods never throw on API errors: check `error`. Only the constructor (missing or `re_` key) and `webhooks.verify` throw.
25
+
26
+ ## Coming from Resend
27
+
28
+ Change the package and the key. Nothing else.
29
+
30
+ ```diff
31
+ - import { Resend } from "resend";
32
+ + import { Resend } from "smartletter";
33
+
34
+ - const resend = new Resend("re_...");
35
+ + const resend = new Resend("sl_...");
36
+ ```
37
+
38
+ `Resend` is an alias of `Smartletter`. `emails.create` / `batch.create` are aliases of `send`. `RESEND_API_KEY` is still read when it holds an `sl_` key. A `re_` key is refused with a clear error. Set `baseUrl` (or `SMARTLETTER_BASE_URL`) to target another API host.
39
+
40
+ Renamed concepts:
41
+
42
+ | Resend | Smartletter |
43
+ | --- | --- |
44
+ | `broadcasts` | `newsletters` |
45
+ | `automations` | `sequences` |
46
+ | `contactProperties` | `contactFields` |
47
+ | `receiving` | `inboxes` |
48
+
49
+ Resend methods with no Smartletter route, so absent from the client: `domains.update`, `domains.remove`, `domains.claims`, `emails.share`, `emails.metrics`, `emails.attachments`, `emails.receiving`, `webhooks.events`. Resend's raw HTTP methods on the client (`post`, `get`, `put`, `patch`, `delete`) are absent too.
50
+
51
+ `attachments[].filename` accepts `false` like Resend (the key is then left out of the request). That only makes sense with `path`.
52
+
53
+ Also supported, with the same call styles as Resend:
54
+
55
+ ```ts
56
+ // Aliases of send
57
+ await smartletter.emails.create({ from: "Acme <hello@acme.com>", to: "jane@example.com", subject: "Hi", html: "<p>Hi</p>" });
58
+ await smartletter.batch.create([{ from: "Acme <hello@acme.com>", to: "jane@example.com", subject: "Hi", html: "<p>Hi</p>" }]);
59
+
60
+ // Create a template and publish it in one chain
61
+ const { data: tpl, error: tplError } = await smartletter.templates
62
+ .create({ name: "Receipt", html: "<p>Thanks!</p>" })
63
+ .publish();
64
+
65
+ // Update an API key: (id, payload)
66
+ await smartletter.apiKeys.update("key_123", { name: "Renamed key" });
67
+ ```
68
+
69
+ `react` is rendered through the optional `@react-email/render` peer. `webhooks.verify` is synchronous and throws `WebhookVerificationError`.
70
+
71
+ ## Beyond Resend
72
+
73
+ Smartletter-only methods, for example importing contacts in bulk:
74
+
75
+ ```ts
76
+ const { data, error } = await smartletter.contacts.import({
77
+ segmentId: "seg_123",
78
+ consent: true, // you confirm these people agreed to receive your emails
79
+ contacts: [
80
+ { email: "jane@example.com", firstName: "Jane" },
81
+ { email: "john@example.com" },
82
+ ],
83
+ });
84
+ ```
85
+
86
+ ## Verify a webhook
87
+
88
+ ```ts
89
+ const event = smartletter.webhooks.verify({
90
+ payload: await request.text(), // the raw body, as a string
91
+ headers: {
92
+ id: request.headers.get("svix-id")!,
93
+ timestamp: request.headers.get("svix-timestamp")!,
94
+ signature: request.headers.get("svix-signature")!,
95
+ },
96
+ webhookSecret: process.env.WEBHOOK_SECRET!,
97
+ });
98
+ ```
99
+
100
+ ## License
101
+
102
+ MIT