mailtea-sdk 0.1.1

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 Mailtea
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 ADDED
@@ -0,0 +1,80 @@
1
+ # mailtea-sdk
2
+
3
+ The official Node.js SDK for [Mailtea](https://mailtea.app) — a thin, typed
4
+ wrapper over the [REST API](https://api.mailtea.app). Works in Node.js 18+, Bun,
5
+ Deno, and edge runtimes with a global `fetch`.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install mailtea-sdk
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```ts
16
+ import { Mailtea } from "mailtea-sdk";
17
+
18
+ const mailtea = new Mailtea(process.env.MAILTEA_API_KEY);
19
+
20
+ const { id } = await mailtea.emails.send({
21
+ from: "you@yourdomain.com",
22
+ to: "recipient@example.com",
23
+ subject: "Hello from Mailtea",
24
+ html: "<p>Your first email, sent with <strong>Mailtea</strong>.</p>"
25
+ });
26
+
27
+ console.log(id);
28
+ ```
29
+
30
+ The API key can be passed as a string, inside an options object
31
+ (`new Mailtea({ apiKey })`), or omitted entirely to read `MAILTEA_API_KEY` from
32
+ the environment. Override the base URL for self-hosted or local instances:
33
+
34
+ ```ts
35
+ const mailtea = new Mailtea(apiKey, { baseUrl: "http://localhost:8787" });
36
+ ```
37
+
38
+ ## API
39
+
40
+ | Method | Description |
41
+ | --- | --- |
42
+ | `emails.send(input)` | Send a transactional email → `{ id }` |
43
+ | `emails.batch(inputs)` | Send up to 100 emails → `{ data: [{ id }] }` |
44
+ | `emails.get(id)` | Retrieve an email and its delivery status |
45
+ | `emails.list(params?)` | List emails → `{ data, total, limit, offset, has_more }` |
46
+ | `emails.analytics(params?)` | Aggregate metrics → `{ total, sent, delivered, opened, clicked, rates }` |
47
+ | `emails.update(id, { scheduled_at })` | Reschedule a scheduled email |
48
+ | `emails.reschedule(id, scheduledAt)` | Convenience wrapper over `update` |
49
+ | `emails.cancel(id)` | Cancel a scheduled email |
50
+ | `contacts.create / list / get / update / delete` | Manage audience contacts |
51
+ | `segments.create / list / get / update / delete` | Manage segments |
52
+ | `tags.create / list / get / update / delete` | Manage tags |
53
+ | `domains.create / list / get / verify / update / delete` | Manage sending domains (add, read DNS records, verify) |
54
+ | `domains.tracking.create / list / verify / delete` | Manage CNAME tracking sub-domains under a domain |
55
+ | `webhooks.create / list / get / update / delete` | Manage outbound event subscriptions |
56
+ | `contactProperties.create / list / update / delete` | Manage custom contact fields (team-scoped) |
57
+ | `apiKeys.create / list / revoke` | Manage API keys (`settings:write`) |
58
+
59
+ The audience resources are scoped to a publication — pass `publication_id`:
60
+
61
+ ```ts
62
+ const contact = await mailtea.contacts.create({
63
+ publication_id: "pub_123",
64
+ email: "subscriber@example.com"
65
+ });
66
+
67
+ const { data } = await mailtea.contacts.list({ publication_id: "pub_123", limit: 50 });
68
+
69
+ await mailtea.tags.create({
70
+ publication_id: "pub_123",
71
+ name: "VIP",
72
+ default_subscription: "opt_in"
73
+ });
74
+ ```
75
+
76
+ Errors are thrown as `MailteaError` with `status`, `details`, and `requestId`.
77
+
78
+ ## License
79
+
80
+ MIT — embed it freely in your apps.