unione 0.0.0-stage → 1.1.3

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.
Files changed (104) hide show
  1. package/AGENTS.md +96 -0
  2. package/LICENSE +21 -0
  3. package/README.md +332 -2
  4. package/docs/ConfirmedEmail.md +107 -0
  5. package/docs/Domain.md +252 -0
  6. package/docs/Email.md +124 -0
  7. package/docs/EmailValidation.md +53 -0
  8. package/docs/EventDump.md +154 -0
  9. package/docs/Obsolete.md +116 -0
  10. package/docs/Project.md +170 -0
  11. package/docs/Suppression.md +159 -0
  12. package/docs/System.md +73 -0
  13. package/docs/Tag.md +72 -0
  14. package/docs/Template.md +160 -0
  15. package/docs/Webhook.md +178 -0
  16. package/package.json +90 -4
  17. package/src/UniOneClient.d.ts +101 -0
  18. package/src/UniOneClient.js +103 -0
  19. package/src/api/confirmed-email/ConfirmedEmailApi.d.ts +36 -0
  20. package/src/api/confirmed-email/ConfirmedEmailApi.js +48 -0
  21. package/src/api/confirmed-email/index.d.ts +2 -0
  22. package/src/api/confirmed-email/index.js +2 -0
  23. package/src/api/confirmed-email/models.d.ts +142 -0
  24. package/src/api/confirmed-email/models.js +205 -0
  25. package/src/api/domain/DomainApi.d.ts +112 -0
  26. package/src/api/domain/DomainApi.js +136 -0
  27. package/src/api/domain/index.d.ts +2 -0
  28. package/src/api/domain/index.js +2 -0
  29. package/src/api/domain/models.d.ts +455 -0
  30. package/src/api/domain/models.js +643 -0
  31. package/src/api/email/EmailApi.d.ts +45 -0
  32. package/src/api/email/EmailApi.js +54 -0
  33. package/src/api/email/index.d.ts +2 -0
  34. package/src/api/email/index.js +2 -0
  35. package/src/api/email/models.d.ts +594 -0
  36. package/src/api/email/models.js +588 -0
  37. package/src/api/email-validation/EmailValidationApi.d.ts +26 -0
  38. package/src/api/email-validation/EmailValidationApi.js +31 -0
  39. package/src/api/email-validation/index.d.ts +2 -0
  40. package/src/api/email-validation/index.js +2 -0
  41. package/src/api/email-validation/models.d.ts +147 -0
  42. package/src/api/email-validation/models.js +172 -0
  43. package/src/api/event-dump/EventDumpApi.d.ts +55 -0
  44. package/src/api/event-dump/EventDumpApi.js +71 -0
  45. package/src/api/event-dump/index.d.ts +2 -0
  46. package/src/api/event-dump/index.js +2 -0
  47. package/src/api/event-dump/models.d.ts +540 -0
  48. package/src/api/event-dump/models.js +564 -0
  49. package/src/api/obsolete/ObsoleteApi.d.ts +45 -0
  50. package/src/api/obsolete/ObsoleteApi.js +58 -0
  51. package/src/api/obsolete/index.d.ts +2 -0
  52. package/src/api/obsolete/index.js +2 -0
  53. package/src/api/obsolete/models.d.ts +247 -0
  54. package/src/api/obsolete/models.js +326 -0
  55. package/src/api/project/ProjectApi.d.ts +58 -0
  56. package/src/api/project/ProjectApi.js +75 -0
  57. package/src/api/project/index.d.ts +2 -0
  58. package/src/api/project/index.js +2 -0
  59. package/src/api/project/models.d.ts +624 -0
  60. package/src/api/project/models.js +679 -0
  61. package/src/api/suppression/SuppressionApi.d.ts +50 -0
  62. package/src/api/suppression/SuppressionApi.js +67 -0
  63. package/src/api/suppression/index.d.ts +2 -0
  64. package/src/api/suppression/index.js +2 -0
  65. package/src/api/suppression/models.d.ts +466 -0
  66. package/src/api/suppression/models.js +513 -0
  67. package/src/api/system/SystemApi.d.ts +25 -0
  68. package/src/api/system/SystemApi.js +32 -0
  69. package/src/api/system/index.d.ts +2 -0
  70. package/src/api/system/index.js +2 -0
  71. package/src/api/system/models.d.ts +212 -0
  72. package/src/api/system/models.js +258 -0
  73. package/src/api/tag/TagApi.d.ts +32 -0
  74. package/src/api/tag/TagApi.js +40 -0
  75. package/src/api/tag/index.d.ts +2 -0
  76. package/src/api/tag/index.js +2 -0
  77. package/src/api/tag/models.d.ts +83 -0
  78. package/src/api/tag/models.js +127 -0
  79. package/src/api/template/TemplateApi.d.ts +53 -0
  80. package/src/api/template/TemplateApi.js +70 -0
  81. package/src/api/template/index.d.ts +2 -0
  82. package/src/api/template/index.js +2 -0
  83. package/src/api/template/models.d.ts +642 -0
  84. package/src/api/template/models.js +722 -0
  85. package/src/api/webhook/WebhookApi.d.ts +75 -0
  86. package/src/api/webhook/WebhookApi.js +95 -0
  87. package/src/api/webhook/index.d.ts +2 -0
  88. package/src/api/webhook/index.js +2 -0
  89. package/src/api/webhook/models.d.ts +1069 -0
  90. package/src/api/webhook/models.js +1094 -0
  91. package/src/client/ApiClient.d.ts +24 -0
  92. package/src/client/ApiClient.js +208 -0
  93. package/src/client/ApiError.d.ts +20 -0
  94. package/src/client/ApiError.js +21 -0
  95. package/src/client/Configuration.d.ts +66 -0
  96. package/src/client/Configuration.js +57 -0
  97. package/src/client/index.d.ts +5 -0
  98. package/src/client/index.js +3 -0
  99. package/src/common/index.d.ts +1 -0
  100. package/src/common/index.js +1 -0
  101. package/src/common/models.d.ts +288 -0
  102. package/src/common/models.js +311 -0
  103. package/src/index.d.ts +4 -0
  104. package/src/index.js +2 -0
package/AGENTS.md ADDED
@@ -0,0 +1,96 @@
1
+ # AGENTS.md
2
+
3
+ UniOne Node.js SDK — client for the UniOne transactional email Web API (Web API 1.90).
4
+
5
+ ## Working on this repository
6
+
7
+ - **Generated code.** The whole package is generated by the UniOne team from the UniOne Web API OpenAPI spec (Web API 1.90): sources, docs, README.md and this file. Do not hand-edit it: the next release replaces the content of this repository. Report problems and requests in the issues of this repository (https://github.com/unione-repo/unione-node-sdk).
8
+ - **Build and check:**
9
+
10
+ ```bash
11
+ npm install
12
+ npm pack --dry-run
13
+ ```
14
+
15
+ - **Source label.** Every request carries the query parameter `platform=node-sdk.1.1.3`, added in one place, the shared request client (`ApiClient`); a package built on this SDK puts its own label in front: `<package>.<version>,node-sdk.1.1.3`.
16
+ - **Tests.** Before a release the generator builds and lints the package and runs every example of docs/ and of this file against a mock of the API: no real API key, no real sends.
17
+ - **Release.** The version (1.1.3 in package.json) and the tag `v1.1.3` come from the generator; README.md states the Web API version the release was generated from.
18
+ - **Secrets.** Never commit API keys; the examples read `UNIONE_API_KEY` from the environment.
19
+
20
+ ## Integrating UniOne with this SDK
21
+
22
+ Full quickstart: [README.md](README.md). Install:
23
+
24
+ ```bash
25
+ npm install unione
26
+ ```
27
+
28
+ Requirements: Node.js 14+.
29
+
30
+ Rules that generated code must follow:
31
+
32
+ - Server-side only. Read the API key from `UNIONE_API_KEY`; never put it in browser or mobile code, never commit it.
33
+ - Base URL `https://api.unione.io/en/transactional/api/v1` (an account registered on another host uses that one: `eu1.unione.io`, `us1.unione.io`); every method is POST with a JSON body; auth header `X-API-KEY`. The SDK does all of it.
34
+ - First email without DNS: `domain/get-sandbox-domain` → `confirmed-email/create` (the user clicks the link within 48 hours) → `email/send` from `noreply@<sandbox-domain>` to the confirmed address. Account API key only; up to 10 confirmed addresses, 100 emails a day; the domain expires after 31 days.
35
+ - Never ship a sandbox domain as the production sender (it is not in `domain/list`); read `from_email` from config. Production needs a verified domain: `domain/get-dns-records` → DNS records → `domain/validate-verification-record`, `domain/validate-dkim` → `domain/list`.
36
+ - Set `message.idempotence_key` on retryable sends; retry network errors, `429` and `5xx` with backoff, not other errors unchanged. Up to 500 recipients and 10 MB per request, each attachment up to 7 MB; always `body.html` or `body.plaintext`.
37
+ - Delivery events via webhook (`webhook/set`) with a fast, idempotent HTTPS handler, not polling; check the `auth` field of every notification: the MD5 of the request body with the `auth` value replaced by the API key.
38
+ - Keep the default unsubscribe and tracking behaviour; changes go through UniOne support.
39
+ - Do not invent methods or fields. Check [docs/](docs/) of this package, the [API reference](https://docs.unione.io/en/web-api-ref) or [llms.txt](https://docs.unione.io/llms.txt).
40
+
41
+ ### Send an email
42
+
43
+ The client reads the API key from `UNIONE_API_KEY`:
44
+
45
+ ```javascript
46
+ import { UniOneClient } from "unione";
47
+ import { EmailSendRequest, MessageObject, MessageObjectRecipientsItem } from "unione/api/email";
48
+ import { BodyObject } from "unione/common";
49
+
50
+ const client = new UniOneClient(process.env.UNIONE_API_KEY);
51
+
52
+ const response = await client.email.send(new EmailSendRequest({
53
+ message: new MessageObject({
54
+ recipients: [
55
+ new MessageObjectRecipientsItem({
56
+ email: "user@example.com",
57
+ substitutions: {
58
+ "CustomerId": "12452",
59
+ "to_name": "John Smith",
60
+ },
61
+ }),
62
+ ],
63
+ body: new BodyObject({
64
+ html: "<b>Hello, {{to_name}}</b>",
65
+ plaintext: "Hello, {{to_name}}",
66
+ }),
67
+ subject: "UniOne test email ",
68
+ fromEmail: "email@example.com",
69
+ fromName: "John Smith",
70
+ }),
71
+ }));
72
+ console.log(response.jobId);
73
+ ```
74
+
75
+ ### Errors
76
+
77
+ Every method throws `ApiError` when the request fails: the HTTP status (0 for a network error or a timeout), the [API error code](https://docs.unione.io/en/web-api-ref#api-errors) and the message.
78
+
79
+ ```javascript
80
+ // client created as above
81
+ import { ApiError } from "unione";
82
+
83
+ try {
84
+ await client.system.ping();
85
+ } catch (error) {
86
+ if (!(error instanceof ApiError)) throw error;
87
+ // httpStatus is 0 for a network error or a timeout
88
+ console.error(error.httpStatus, error.errorCode, error.message);
89
+ }
90
+ ```
91
+
92
+ ### Reference
93
+
94
+ - Methods and models of every section: [Email](docs/Email.md), [EmailValidation](docs/EmailValidation.md), [ConfirmedEmail](docs/ConfirmedEmail.md), [Template](docs/Template.md), [Webhook](docs/Webhook.md), [Suppression](docs/Suppression.md), [Domain](docs/Domain.md), [EventDump](docs/EventDump.md), [Tag](docs/Tag.md), [Project](docs/Project.md), [System](docs/System.md), [Obsolete](docs/Obsolete.md)
95
+ - [API reference](https://docs.unione.io/en/web-api-ref)
96
+ - [Full API reference for LLMs](https://docs.unione.io/llms-full.txt)
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 UniOne
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,333 @@
1
- # Temporary Holding Version
1
+ # UniOne Node.js SDK 1.1.3
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
+ Web API 1.90
4
+
5
+ Official Node.js library for the [UniOne](https://unione.io) transactional email API.
6
+
7
+ Quickstart guide: [Send emails with Node.js](https://docs.unione.io/en/send-with-nodejs) · Docs for LLMs: [llms.txt](https://docs.unione.io/llms.txt) · [API reference](https://docs.unione.io/en/web-api-ref)
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install unione
13
+ ```
14
+
15
+ Requirements: Node.js 14+. No third-party dependencies.
16
+
17
+ This is the 1.x line (branch `1.x`) for Node.js 14. Newer runtimes: the 2.x line (branch `main`), the same API.
18
+
19
+ ## Get an API key
20
+
21
+ 1. Sign up at [cp.unione.io](https://cp.unione.io/en/user/registration/).
22
+ 2. Copy your API key from [Settings → Security → API](https://cp.unione.io/en/settings/security/api).
23
+ 3. Put it in an environment variable:
24
+
25
+ ```bash
26
+ export UNIONE_API_KEY="your-api-key"
27
+ ```
28
+
29
+ > **Server-side only.** Use this SDK in backend code: API routes, server functions, workers.
30
+ > Never ship the API key to a browser or a mobile app, and never commit it.
31
+
32
+ ## Send your first email — no DNS setup
33
+
34
+ Every account can send test email right away from a **sandbox domain**: pre-verified, DKIM and SPF already set.
35
+ It delivers only to addresses you confirm.
36
+
37
+ <!-- checked examples -->
38
+
39
+ **1. Get your sandbox domain** (`domain/get-sandbox-domain`). The call creates the domain on first use and returns the same one afterwards.
40
+
41
+ ```javascript
42
+ import { UniOneClient } from "unione";
43
+
44
+ const client = new UniOneClient(process.env.UNIONE_API_KEY);
45
+
46
+ const response = await client.domain.getSandboxDomain();
47
+ console.log(response.domain);
48
+ ```
49
+
50
+ **2. Confirm your inbox** (`confirmed-email/create`). UniOne sends a confirmation email; click the link in it within 48 hours.
51
+
52
+ ```javascript
53
+ import { UniOneClient } from "unione";
54
+ import { ConfirmedEmailRequest } from "unione/api/confirmed-email";
55
+
56
+ const client = new UniOneClient(process.env.UNIONE_API_KEY);
57
+
58
+ const response = await client.confirmedEmail.create(new ConfirmedEmailRequest({
59
+ email: "you@example.com",
60
+ }));
61
+ console.log(response.confirmedEmail);
62
+ ```
63
+
64
+ Check the status with `confirmed-email/list` — your address should show `"status": "confirmed"`.
65
+
66
+ **3. Send the email** (`email/send`) from any address on the sandbox domain to the confirmed address.
67
+
68
+ ```javascript
69
+ import { UniOneClient } from "unione";
70
+ import { EmailSendRequest, MessageObject, MessageObjectRecipientsItem } from "unione/api/email";
71
+ import { BodyObject } from "unione/common";
72
+
73
+ const client = new UniOneClient(process.env.UNIONE_API_KEY);
74
+
75
+ const response = await client.email.send(new EmailSendRequest({
76
+ message: new MessageObject({
77
+ recipients: [
78
+ new MessageObjectRecipientsItem({
79
+ email: "you@example.com",
80
+ }),
81
+ ],
82
+ body: new BodyObject({
83
+ html: "<p>It works!</p>",
84
+ }),
85
+ subject: "Hello from UniOne",
86
+ fromEmail: "noreply@<sandbox-domain>",
87
+ }),
88
+ }));
89
+ console.log(response.jobId);
90
+ ```
91
+
92
+ <!-- /checked examples -->
93
+
94
+ ### What you get back
95
+
96
+ ```json
97
+ {
98
+ "status": "success",
99
+ "job_id": "1ZymBc-00041N-9X",
100
+ "emails": [
101
+ "you@example.com"
102
+ ]
103
+ }
104
+ ```
105
+
106
+ On error the API returns `status: "error"`, a `message` and a numeric `code`:
107
+
108
+ ```json
109
+ {
110
+ "status": "error",
111
+ "code": 102,
112
+ "message": "Error ID:83274F98-C7D5-11F1-B221-6214FF8707B1. Can not decode key wrongkey"
113
+ }
114
+ ```
115
+
116
+ ### Same flow with curl
117
+
118
+ ```bash
119
+ BASE=https://api.unione.io/en/transactional/api/v1
120
+
121
+ curl -s -X POST $BASE/domain/get-sandbox-domain.json \
122
+ -H "Content-Type: application/json" -H "X-API-KEY: $UNIONE_API_KEY" -d '{}'
123
+
124
+ curl -s -X POST $BASE/confirmed-email/create.json \
125
+ -H "Content-Type: application/json" -H "X-API-KEY: $UNIONE_API_KEY" \
126
+ -d '{"email": "you@example.com"}'
127
+
128
+ curl -s -X POST $BASE/email/send.json \
129
+ -H "Content-Type: application/json" -H "X-API-KEY: $UNIONE_API_KEY" \
130
+ -d '{
131
+ "message": {
132
+ "recipients": [
133
+ {
134
+ "email": "you@example.com"
135
+ }
136
+ ],
137
+ "from_email": "noreply@<sandbox-domain>",
138
+ "subject": "Hello from UniOne",
139
+ "body": {
140
+ "html": "<p>It works!</p>"
141
+ }
142
+ }
143
+ }'
144
+ ```
145
+
146
+ ## Sandbox limits
147
+
148
+ - Sends only to confirmed addresses: up to 10 per account.
149
+ - Up to 100 emails a day.
150
+ - The sandbox domain expires after 31 days; call `domain/get-sandbox-domain` again to get a new one.
151
+ - Works only with the account API key, not a project key.
152
+ - Not listed in `domain/list`; the other `domain/*` methods do not apply to it.
153
+
154
+ The sandbox is for development and testing. Do not use a sandbox domain as the sender in production.
155
+
156
+ ## Before production: verify your domain
157
+
158
+ 1. `domain/get-dns-records` — returns the values for your DNS records.
159
+ 2. Add these records at your DNS provider (the domain page of the control panel shows them too):
160
+
161
+ | Type | Host | Value |
162
+ |---|---|---|
163
+ | TXT | `@` | the `verification-record` value (`unione-validate-hash=…`) |
164
+ | TXT | `<selector>._domainkey` (the selector is on the domain page of the control panel, e.g. `us`) | `v=DKIM1; k=rsa; p=<dkim>` |
165
+ | TXT | `@` | `v=spf1 include:spf.unione.io ~all` |
166
+ | CNAME | `_dmarc` | the `dmarc` value |
167
+
168
+ 3. `domain/validate-verification-record`, then `domain/validate-dkim`.
169
+ 4. `domain/list` — wait until the verification record is confirmed and DKIM is active.
170
+ 5. Read `from_email` from your config, so switching from the sandbox needs no code change.
171
+
172
+ ## Sending reliably
173
+
174
+ - **Retries:** set `message.idempotence_key` on sends that may be retried, so a repeated request does not send twice.
175
+ - **Limits:** up to 500 recipients and 10 MB per request; each attachment up to 7 MB.
176
+ - **Body:** always include `body.html` or `body.plaintext`.
177
+ - **Delivery status:** register a webhook (`webhook/set`) with a fast, idempotent HTTPS handler instead of polling.
178
+ - **Defaults:** keep the default unsubscribe footer and tracking; changing them requires UniOne support.
179
+ - **Errors:** retry `429` and `5xx` with backoff; do not retry other errors unchanged.
180
+
181
+ ## Links
182
+
183
+ - [Send emails with Node.js](https://docs.unione.io/en/send-with-nodejs) and other [integration guides](https://docs.unione.io/en/integrations/)
184
+ - [Web API reference](https://docs.unione.io/en/web-api-ref)
185
+ - [llms.txt](https://docs.unione.io/llms.txt) for AI coding agents
186
+ - [UniOne MCP server and agent setup](https://unione.io/en/agents)
187
+ - [Support](https://cp.unione.io/en/support)
188
+
189
+ ## For SDK contributors
190
+
191
+ See [AGENTS.md](AGENTS.md): how this SDK is generated from the OpenAPI spec, built, tested and released.
192
+
193
+ ---
194
+
195
+ # SDK reference
196
+
197
+ ## API host
198
+
199
+ The second argument selects the API host (datacenter) or a full base URL.
200
+
201
+ ```javascript
202
+ import { UniOneClient, Host } from "unione";
203
+
204
+ const client = new UniOneClient("YOUR_API_KEY", "us1.unione.io");
205
+ const other = new UniOneClient("YOUR_API_KEY", Host.US1, { timeout: 10000 });
206
+ ```
207
+
208
+ ## Error handling
209
+
210
+ Every method raises `ApiError` when the API returns an error; it carries the [API error code](https://docs.unione.io/en/web-api-ref#api-errors) and the HTTP status.
211
+
212
+ ## Custom HTTP client and headers
213
+
214
+ `headers` adds headers to every request; `fetch` replaces the function the requests go through (default: the built-in `http`/`https` modules): undici, node-fetch or a wrapper that adds retries, logging or a proxy. Network errors, timeouts and errors of reading the response raise `ApiError` (the original error is its `cause`).
215
+
216
+ ```javascript
217
+ import { UniOneClient, ApiError } from "unione";
218
+
219
+ // retries of network errors and HTTP 5xx, a log line per request
220
+ async function fetchWithRetries(url, init) {
221
+ for (let attempt = 1; ; attempt++) {
222
+ try {
223
+ const response = await fetch(url, init);
224
+ if (response.status < 500 || attempt === 3) {
225
+ console.log(`POST ${url} -> ${response.status}`);
226
+ return response;
227
+ }
228
+ } catch (error) {
229
+ if (attempt === 3) throw error;
230
+ }
231
+ }
232
+ }
233
+
234
+ const client = new UniOneClient("YOUR_API_KEY", {
235
+ headers: { "X-Request-Id": "42" },
236
+ fetch: fetchWithRetries,
237
+ });
238
+ try {
239
+ console.log(await client.confirmedEmail.list());
240
+ } catch (error) {
241
+ if (!(error instanceof ApiError)) throw error;
242
+ console.log(error.httpStatus, error.errorCode, error.message, error.cause);
243
+ }
244
+ ```
245
+
246
+ ## Models
247
+
248
+ Request models take an object of their fields; a nested model can be given as a model or as a plain object in the API format (the keys of the API: `global_language`, not `globalLanguage`), it is converted by `fromJSON()` of its class. A request may also be a plain object in the API format. Models that take any key (`HeadersObject`) keep the keys besides their named fields in the `extra` map: it is sent next to the fields (a named field wins over the same key of `extra`), and the keys of a response that are not named fields go there.
249
+
250
+ ```javascript
251
+ import { EmailSendRequest } from "unione/api/email";
252
+ import { HeadersObject } from "unione/common";
253
+
254
+ const headers = new HeadersObject({
255
+ extra: {
256
+ "X-MyHeader": "some data",
257
+ "CC": "copy@example.com",
258
+ "List-Unsubscribe": "<mailto:unsubscribe@example.com?subject=unsubscribe>",
259
+ },
260
+ });
261
+
262
+ const request = new EmailSendRequest({
263
+ message: {
264
+ "body": { html: "<b>Hello, {{to_name}}</b>" },
265
+ "subject": "Hello",
266
+ "from_email": "user@example.com",
267
+ "recipients": [{ email: "recipient@example.com" }],
268
+ "headers": headers,
269
+ },
270
+ });
271
+ console.log(JSON.stringify(request));
272
+ ```
273
+
274
+ ## TypeScript
275
+
276
+ The package has type declarations: the client, the API classes, the models (with their `...JSON` shape in the API format and `...Init` constructor options) and the enums (frozen objects and string literal types).
277
+
278
+ ```typescript
279
+ import { UniOneClient, type ConfigurationOptions } from "unione";
280
+ import { EmailSendRequest, MessageObject, MessageObjectRecipientsItem, type EmailSendResponse } from "unione/api/email";
281
+ import { TemplateEngine, BodyObject } from "unione/common";
282
+
283
+ const options: ConfigurationOptions = { timeout: 10000, headers: { "X-Request-Id": "42" } };
284
+ const client = new UniOneClient("YOUR_API_KEY", options);
285
+ const response: EmailSendResponse = await client.email.send(new EmailSendRequest({
286
+ message: new MessageObject({
287
+ recipients: [
288
+ new MessageObjectRecipientsItem({
289
+ email: "user@example.com",
290
+ substitutions: {
291
+ "CustomerId": "12452",
292
+ "to_name": "John Smith",
293
+ },
294
+ metadata: {
295
+ "campaign_id": "c77f4f4e-3561-49f7-9f07-c35be01b4f43",
296
+ "customer_hash": "b253ac7",
297
+ },
298
+ }),
299
+ ],
300
+ templateId: "00000000-0000-0000-0000-000000000000",
301
+ globalLanguage: "en",
302
+ templateEngine: TemplateEngine.VELOCITY,
303
+ body: new BodyObject({
304
+ html: "<b>Hello, {{to_name}}</b>",
305
+ plaintext: "Hello, {{to_name}}",
306
+ amp: "<!doctype html><html amp4email><head> <meta charset=\"utf-8\"><script async src=\"https://cdn.ampproject.org/v0.js\"></script> <style amp4email-boilerplate>body{visibility:hidden}</style></head><body> Hello, AMP4EMAIL world.</body></html>",
307
+ }),
308
+ subject: "UniOne test email ",
309
+ fromEmail: "email@example.com",
310
+ fromName: "John Smith",
311
+ replyTo: "email@example.com",
312
+ replyToName: "John Smith",
313
+ idempotenceKey: "SG1VsbG68sIH2dvc5mx890kIQ",
314
+ }),
315
+ }));
316
+ ```
317
+
318
+ ## Sections
319
+
320
+ | Section | Methods | Description |
321
+ |---|---|---|
322
+ | [Email](docs/Email.md) | `send`, `subscribe` | This group of methods is related with email sending. |
323
+ | [EmailValidation](docs/EmailValidation.md) | `single` | Email validation methods. As a result of the check, you’ll get detailed information on email validity. It will help eliminate nonexistent emails, decrease the number of complaints, clean up the subscribers list and eventually enhance your sender reputation score. For example, you may add validation to a subscription form on your site to let users know they’ve just entered an invalid address. |
324
+ | [ConfirmedEmail](docs/ConfirmedEmail.md) | `create`, `list`, `delete` | Manage email addresses confirmed for sandbox-domain sending. These methods are available only with a main account API key. |
325
+ | [Template](docs/Template.md) | `set`, `get`, `list`, `delete` | You have the option of storing a template on the UniOne side and then using it by id, which is highly recommended for sending repetitive messages or high volume traffic. UniOne supports two different [template engines](https://docs.unione.io/en/template-engines). |
326
+ | [Webhook](docs/Webhook.md) | `set`, `get`, `list`, `delete` | UniOne lets you recieve notifications about email status changes or spam blocks. You provide an URL and every time a watched event occurs we will notify you by submitting a request with JSON data to this URL. |
327
+ | [Suppression](docs/Suppression.md) | `set`, `get`, `list`, `delete` | Methods for managing suppression lists. An email can be added to suppression list because of unsubscription, bounce or complain. |
328
+ | [Domain](docs/Domain.md) | `getDnsRecords`, `validateVerificationRecord`, `validateDkim`, `list`, `getSandboxDomain`, `delete` | You can use these methods to setup sender domains and check their statuses. They might be useful in case you want to automate adding domains for your own clients. |
329
+ | [EventDump](docs/EventDump.md) | `create`, `get`, `list`, `delete` | These methods are used to obtain a list of events for a given period of time. The data is stored for up to 45 days, depending on your tariff, i. e. you may fetch all event data starting from 00:00:00 31 days ago and up to current time. For custom tarifs with big sending volumes event dumps are available only for the last 7 days. |
330
+ | [Tag](docs/Tag.md) | `list`, `delete` | This family of methods is used to manage user-defined tags. Tags are used to categorize letters based on your own criteria, e. g. to create a distinction between marketing and transactional letters or group together all notifications for a particular order type. UniOne allows you to assign tags to all outgoing emails, and the tags you’ve set may then be used to filter and analyze delivery statistics. |
331
+ | [Project](docs/Project.md) | `create`, `update`, `list`, `delete` | Projects allow you to group several independent domains, webhooks, templates, and unsubscription lists together. It's very useful if you have your own clients and manage their data from a single UniOne account. Each project receives its own API key, and all API calls with that API key only deal with the data of that project. This way, you can assign a separate project for each client and be sure that they won't conflict; e.g. unsubscribing from one project won't affect another. |
332
+ | [System](docs/System.md) | `ping`, `info` | System operations. |
333
+ | [Obsolete](docs/Obsolete.md) | `unsubscribedSet`, `unsubscribedCheck`, `unsubscribedList` | Obsolete methods dealing with unsubscribes. We recommend using the more flexible [suppression](https://docs.unione.io/en/web-api-ref#suppression) methods instead. Note that you can't resubscribe an unsubscribed recipient using WebAPI, but you can send him an email with subscription link using email/subscribe method. |
@@ -0,0 +1,107 @@
1
+ # ConfirmedEmail
2
+
3
+ [Back to the list of sections](../README.md)
4
+
5
+ Manage email addresses confirmed for sandbox-domain sending. These methods are available only with a main account API key.
6
+
7
+ `import { ConfirmedEmailApi } from "unione/api/confirmed-email"`, `client.confirmedEmail`
8
+
9
+ | Method | Endpoint | Description |
10
+ |---|---|---|
11
+ | [`create`](#create) | `POST /confirmed-email/create.json` | Adds an email address and sends a confirmation link. |
12
+ | [`list`](#list) | `POST /confirmed-email/list.json` | Lists confirmed and unconfirmed email addresses for the account. |
13
+ | [`delete`](#delete) | `POST /confirmed-email/delete.json` | Deletes an email address from the account's confirmed email list. |
14
+
15
+ ## create
16
+
17
+ `POST /confirmed-email/create.json` · [Documentation](https://docs.unione.io/en/web-api-ref#confirmed-email-create)
18
+
19
+ Adds an email address and sends a confirmation link.
20
+
21
+ ### Request: `ConfirmedEmailRequest`
22
+
23
+ | Field | Type | Required | Description |
24
+ |---|---|---|---|
25
+ | `email` | `string` | yes | Email address to add or delete. |
26
+
27
+ ### Response: `ConfirmedEmailCreateResponse`
28
+
29
+ | Field | Type | Description |
30
+ |---|---|---|
31
+ | `status` | `string` | "success" string (`success`) |
32
+ | `confirmedEmail` | `ConfirmedEmail` | |
33
+
34
+ ### Example
35
+
36
+ ```javascript
37
+ import { UniOneClient } from "unione";
38
+ import { ConfirmedEmailRequest } from "unione/api/confirmed-email";
39
+
40
+ const client = new UniOneClient("YOUR_API_KEY");
41
+
42
+ const response = await client.confirmedEmail.create(new ConfirmedEmailRequest({
43
+ email: "dev@example.com",
44
+ }));
45
+ console.log(response.confirmedEmail);
46
+ ```
47
+
48
+ ## list
49
+
50
+ `POST /confirmed-email/list.json` · [Documentation](https://docs.unione.io/en/web-api-ref#confirmed-email-list)
51
+
52
+ Lists confirmed and unconfirmed email addresses for the account.
53
+
54
+ ### Request
55
+
56
+ The method has no parameters.
57
+
58
+ ### Response: `ConfirmedEmailListResponse`
59
+
60
+ | Field | Type | Description |
61
+ |---|---|---|
62
+ | `status` | `string` | "success" string (`success`) |
63
+ | `confirmedEmails` | `ConfirmedEmail[]` | |
64
+
65
+ ### Example
66
+
67
+ ```javascript
68
+ import { UniOneClient } from "unione";
69
+
70
+ const client = new UniOneClient("YOUR_API_KEY");
71
+
72
+ const response = await client.confirmedEmail.list();
73
+ console.log(response.confirmedEmails);
74
+ ```
75
+
76
+ ## delete
77
+
78
+ `POST /confirmed-email/delete.json` · [Documentation](https://docs.unione.io/en/web-api-ref#confirmed-email-delete)
79
+
80
+ Deletes an email address from the account's confirmed email list.
81
+
82
+ ### Request: `ConfirmedEmailRequest`
83
+
84
+ | Field | Type | Required | Description |
85
+ |---|---|---|---|
86
+ | `email` | `string` | yes | Email address to add or delete. |
87
+
88
+ ### Response: `ConfirmedEmailDeleteResponse`
89
+
90
+ | Field | Type | Description |
91
+ |---|---|---|
92
+ | `status` | `string` | "success" string (`success`) |
93
+ | `message` | `string` | |
94
+
95
+ ### Example
96
+
97
+ ```javascript
98
+ import { UniOneClient } from "unione";
99
+ import { ConfirmedEmailRequest } from "unione/api/confirmed-email";
100
+
101
+ const client = new UniOneClient("YOUR_API_KEY");
102
+
103
+ const response = await client.confirmedEmail.delete(new ConfirmedEmailRequest({
104
+ email: "dev@example.com",
105
+ }));
106
+ console.log(response.message);
107
+ ```