@productcraft/mail 0.3.0 → 1.0.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/dist/index.cjs CHANGED
@@ -1,16 +1,3844 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var core = require('@productcraft/core');
4
6
 
5
- // src/index.ts
6
- var Mail = class {
7
- /** The underlying typed client. v0 surface — every endpoint reachable. */
8
- client;
9
- constructor(config = {}) {
10
- this.client = core.makeClient(core.PC_BASE_URL.mail, config);
7
+ // src/_generated/client.ts
8
+
9
+ // src/_generated/resources.ts
10
+ var APIResource = class {
11
+ _client;
12
+ /** Path parameters (and `actor_id`) bound by the enclosing scope. */
13
+ _b;
14
+ constructor(client, bound = {}) {
15
+ this._client = client;
16
+ this._b = bound;
17
+ }
18
+ };
19
+ var BrandResource = class extends APIResource {
20
+ /**
21
+ * Remove all brand customizations and revert to platform defaults.
22
+ *
23
+ * @param options - Per-request options.
24
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
25
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
26
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
27
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
28
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
29
+ * @see DELETE /v1/workspaces/{workspace_id}/brand
30
+ * @see https://productcraft.co/docs/mail/api-reference#delete-v1-workspaces-workspace-id-brand
31
+ * @example
32
+ * ```ts
33
+ * await mail.brand.reset();
34
+ * ```
35
+ */
36
+ reset(options) {
37
+ return this._client.request({ method: "DELETE", path: "/v1/workspaces/{workspace_id}/brand" }, options);
38
+ }
39
+ /**
40
+ * Get the resolved brand tokens for the workspace. Always returns a complete object, with platform defaults filling in any unset fields.
41
+ *
42
+ * @param options - Per-request options.
43
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
44
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
45
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
46
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
47
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
48
+ * @see GET /v1/workspaces/{workspace_id}/brand
49
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-brand
50
+ * @example
51
+ * ```ts
52
+ * const brand = await mail.brand.retrieve();
53
+ * ```
54
+ */
55
+ retrieve(options) {
56
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/brand" }, options);
57
+ }
58
+ /**
59
+ * Replace the workspace brand. Any field omitted from the body is reset to the platform default for that field. To partially-update, send back what GET returned with the desired diff applied.
60
+ *
61
+ * @param params - `Mail.BrandUpdateParams`.
62
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
63
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Validation failure on the brand payload.
64
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
65
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
66
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
67
+ * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `IDEMPOTENCY_KEY_REUSE`: the `Idempotency-Key` was already used with a different request body or on a different route. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
68
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
69
+ * @see PUT /v1/workspaces/{workspace_id}/brand
70
+ * @see https://productcraft.co/docs/mail/api-reference#put-v1-workspaces-workspace-id-brand
71
+ * @example
72
+ * ```ts
73
+ * const brand = await mail.brand.update({ background_color: "string" });
74
+ * ```
75
+ */
76
+ update(params, options) {
77
+ return this._client.request({ method: "PUT", path: "/v1/workspaces/{workspace_id}/brand", body: params, idempotent: true }, options);
78
+ }
79
+ };
80
+ var BroadcastsClickedLinksResource = class extends APIResource {
81
+ /**
82
+ * Links clicked in a broadcast
83
+ *
84
+ * Most clicked first. Empty until click tracking is enabled.
85
+ *
86
+ * @param broadcastId - Id of the broadcast.
87
+ * @param options - Per-request options.
88
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
89
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
90
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
91
+ * @throws {NotFoundError} 404 NOT_FOUND, BROADCAST_NOT_FOUND: No such broadcast (`BROADCAST_NOT_FOUND`).
92
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
93
+ * @see GET /v1/workspaces/{workspace_id}/broadcasts/{broadcast_id}/clicked-links
94
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-broadcasts-broadcast-id-clicked-links
95
+ * @example
96
+ * ```ts
97
+ * const clickedLinks = await mail.broadcasts.clickedLinks.list("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
98
+ * ```
99
+ */
100
+ list(broadcastId, options) {
101
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/broadcasts/{broadcast_id}/clicked-links", pathParams: { broadcast_id: broadcastId } }, options);
102
+ }
103
+ };
104
+ var BroadcastsRecipientsResource = class extends APIResource {
105
+ /**
106
+ * List a broadcast's recipients
107
+ *
108
+ * In send order, with each message status.
109
+ *
110
+ * @param broadcastId - Id of the broadcast.
111
+ * @param params - `Mail.BroadcastRecipientListParams`.
112
+ * @param options - Per-request options.
113
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
114
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
115
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
116
+ * @throws {NotFoundError} 404 NOT_FOUND, BROADCAST_NOT_FOUND: No such broadcast (`BROADCAST_NOT_FOUND`).
117
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
118
+ * @see GET /v1/workspaces/{workspace_id}/broadcasts/{broadcast_id}/recipients
119
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-broadcasts-broadcast-id-recipients
120
+ * @example
121
+ * ```ts
122
+ * for await (const recipient of mail.broadcasts.recipients.list("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b")) {
123
+ * console.log(recipient);
124
+ * }
125
+ * const page = await mail.broadcasts.recipients.list("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", {}, { timeout: 5_000 });
126
+ * ```
127
+ */
128
+ list(broadcastId, params, options) {
129
+ return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/broadcasts/{broadcast_id}/recipients", pathParams: { broadcast_id: broadcastId }, query: params }, options);
130
+ }
131
+ };
132
+ var BroadcastsSettingsResource = class extends APIResource {
133
+ /**
134
+ * Get the broadcast settings
135
+ *
136
+ * The messages-per-minute pace broadcasts go out at.
137
+ *
138
+ * @param options - Per-request options.
139
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
140
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
141
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
142
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
143
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
144
+ * @see GET /v1/workspaces/{workspace_id}/broadcast-settings
145
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-broadcast-settings
146
+ * @example
147
+ * ```ts
148
+ * const broadcastSettings = await mail.broadcasts.settings.retrieve();
149
+ * ```
150
+ */
151
+ retrieve(options) {
152
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/broadcast-settings" }, options);
153
+ }
154
+ /**
155
+ * Update the broadcast settings
156
+ *
157
+ * Set the workspace campaign pace (1 to 300 messages per minute; null for the default, 120). It never affects transactional sends, which have their own limit.
158
+ *
159
+ * @param params - `Mail.BroadcastSettingsUpdateParams`.
160
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
161
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
162
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
163
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
164
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
165
+ * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `IDEMPOTENCY_KEY_REUSE`: the `Idempotency-Key` was already used with a different request body or on a different route. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
166
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
167
+ * @see PUT /v1/workspaces/{workspace_id}/broadcast-settings
168
+ * @see https://productcraft.co/docs/mail/api-reference#put-v1-workspaces-workspace-id-broadcast-settings
169
+ * @example
170
+ * ```ts
171
+ * const broadcastSettings = await mail.broadcasts.settings.update({ rate_per_minute: 1 });
172
+ * ```
173
+ */
174
+ update(params, options) {
175
+ return this._client.request({ method: "PUT", path: "/v1/workspaces/{workspace_id}/broadcast-settings", body: params, idempotent: true }, options);
176
+ }
177
+ };
178
+ var BroadcastsResource = class extends APIResource {
179
+ #clickedLinks;
180
+ #recipients;
181
+ #settings;
182
+ get clickedLinks() {
183
+ return this.#clickedLinks ??= new BroadcastsClickedLinksResource(this._client, this._b);
184
+ }
185
+ get recipients() {
186
+ return this.#recipients ??= new BroadcastsRecipientsResource(this._client, this._b);
187
+ }
188
+ get settings() {
189
+ return this.#settings ??= new BroadcastsSettingsResource(this._client, this._b);
190
+ }
191
+ /**
192
+ * Count a broadcast audience
193
+ *
194
+ * How many contacts a broadcast to this segment and/or topic would reach if it were sent now: members of the segment, subscribed to the topic, minus anyone unsubscribed or on the suppression list.
195
+ *
196
+ * @param params - `Mail.BroadcastAudienceParams`.
197
+ * @param options - Per-request options.
198
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
199
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
200
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
201
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
202
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, AUDIENCE_REQUIRED, SEGMENT_NOT_FOUND, TOPIC_NOT_FOUND: Neither given (`AUDIENCE_REQUIRED`), or one does not exist in this workspace (`SEGMENT_NOT_FOUND` / `TOPIC_NOT_FOUND`).
203
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
204
+ * @see GET /v1/workspaces/{workspace_id}/broadcasts/audience
205
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-broadcasts-audience
206
+ * @example
207
+ * ```ts
208
+ * const broadcastAudience = await mail.broadcasts.audience();
209
+ * ```
210
+ */
211
+ audience(params, options) {
212
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/broadcasts/audience", query: params }, options);
213
+ }
214
+ /**
215
+ * Cancel a scheduled or sending broadcast
216
+ *
217
+ * Recipients not sent yet are marked `canceled`; messages already handed off are not recalled.
218
+ *
219
+ * @param broadcastId - Id of the broadcast.
220
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
221
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
222
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
223
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
224
+ * @throws {NotFoundError} 404 NOT_FOUND, BROADCAST_NOT_FOUND: No such broadcast (`BROADCAST_NOT_FOUND`).
225
+ * @throws {ConflictError} 409 CONFLICT, BROADCAST_NOT_CANCELABLE, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: Draft, sent or already canceled (`BROADCAST_NOT_CANCELABLE`), or `IDEMPOTENCY_KEY_REUSE`. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
226
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
227
+ * @see POST /v1/workspaces/{workspace_id}/broadcasts/{broadcast_id}/cancel
228
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-broadcasts-broadcast-id-cancel
229
+ * @example
230
+ * ```ts
231
+ * const broadcast = await mail.broadcasts.cancel("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
232
+ * ```
233
+ */
234
+ cancel(broadcastId, options) {
235
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/broadcasts/{broadcast_id}/cancel", pathParams: { broadcast_id: broadcastId }, idempotent: true }, options);
236
+ }
237
+ /**
238
+ * Create a broadcast (draft)
239
+ *
240
+ * Content is a saved template (`template_name`) or inline Handlebars (`html`, `subject`, optional `text`). The audience is a segment, a topic, or both. Nothing is sent until `POST .../send`.
241
+ *
242
+ * @param params - `Mail.BroadcastCreateParams`.
243
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
244
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
245
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
246
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
247
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
248
+ * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `IDEMPOTENCY_KEY_REUSE`: the `Idempotency-Key` was already used with a different request body or on a different route. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
249
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, SEGMENT_NOT_FOUND, TOPIC_NOT_FOUND, BROADCAST_CONTENT_CONFLICT: `segment_id` or `topic_id` does not name one of this workspace's (`SEGMENT_NOT_FOUND` / `TOPIC_NOT_FOUND`), or both `template_name` and `html` were given (`BROADCAST_CONTENT_CONFLICT`).
250
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
251
+ * @see POST /v1/workspaces/{workspace_id}/broadcasts
252
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-broadcasts
253
+ * @example
254
+ * ```ts
255
+ * const broadcast = await mail.broadcasts.create({ name: "October product update" });
256
+ * ```
257
+ */
258
+ create(params, options) {
259
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/broadcasts", body: params, idempotent: true }, options);
260
+ }
261
+ /**
262
+ * Delete a broadcast
263
+ *
264
+ * Drafts, sent and canceled broadcasts, with their recipient list. The messages themselves stay in the message log.
265
+ *
266
+ * @param broadcastId - Id of the broadcast.
267
+ * @param options - Per-request options.
268
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
269
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
270
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
271
+ * @throws {NotFoundError} 404 NOT_FOUND, BROADCAST_NOT_FOUND: No such broadcast (`BROADCAST_NOT_FOUND`).
272
+ * @throws {ConflictError} 409 CONFLICT, BROADCAST_NOT_DELETABLE: Scheduled or sending: cancel it first (`BROADCAST_NOT_DELETABLE`).
273
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
274
+ * @see DELETE /v1/workspaces/{workspace_id}/broadcasts/{broadcast_id}
275
+ * @see https://productcraft.co/docs/mail/api-reference#delete-v1-workspaces-workspace-id-broadcasts-broadcast-id
276
+ * @example
277
+ * ```ts
278
+ * await mail.broadcasts.delete("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
279
+ * ```
280
+ */
281
+ delete(broadcastId, options) {
282
+ return this._client.request({ method: "DELETE", path: "/v1/workspaces/{workspace_id}/broadcasts/{broadcast_id}", pathParams: { broadcast_id: broadcastId } }, options);
283
+ }
284
+ /**
285
+ * Duplicate a broadcast
286
+ *
287
+ * A new draft with the same content and audience.
288
+ *
289
+ * @param broadcastId - Id of the broadcast.
290
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
291
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
292
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
293
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
294
+ * @throws {NotFoundError} 404 NOT_FOUND, BROADCAST_NOT_FOUND: No such broadcast (`BROADCAST_NOT_FOUND`).
295
+ * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `IDEMPOTENCY_KEY_REUSE`: the `Idempotency-Key` was already used with a different request body or on a different route. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
296
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
297
+ * @see POST /v1/workspaces/{workspace_id}/broadcasts/{broadcast_id}/duplicate
298
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-broadcasts-broadcast-id-duplicate
299
+ * @example
300
+ * ```ts
301
+ * const broadcast = await mail.broadcasts.duplicate("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
302
+ * ```
303
+ */
304
+ duplicate(broadcastId, options) {
305
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/broadcasts/{broadcast_id}/duplicate", pathParams: { broadcast_id: broadcastId }, idempotent: true }, options);
306
+ }
307
+ /**
308
+ * List broadcasts, newest first
309
+ *
310
+ * @param params - `Mail.BroadcastListParams`.
311
+ * @param options - Per-request options.
312
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
313
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
314
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
315
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
316
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
317
+ * @see GET /v1/workspaces/{workspace_id}/broadcasts
318
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-broadcasts
319
+ * @example
320
+ * ```ts
321
+ * for await (const broadcast of mail.broadcasts.list()) {
322
+ * console.log(broadcast);
323
+ * }
324
+ * const page = await mail.broadcasts.list({}, { timeout: 5_000 });
325
+ * ```
326
+ */
327
+ list(params, options) {
328
+ return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/broadcasts", query: params }, options);
329
+ }
330
+ /**
331
+ * Get a broadcast
332
+ *
333
+ * Includes `counts` once sending has started: recipients, sent, delivered, bounced, complained, opened, clicked, unsubscribed.
334
+ *
335
+ * @param broadcastId - Id of the broadcast.
336
+ * @param options - Per-request options.
337
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
338
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
339
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
340
+ * @throws {NotFoundError} 404 NOT_FOUND, BROADCAST_NOT_FOUND: No such broadcast (`BROADCAST_NOT_FOUND`).
341
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
342
+ * @see GET /v1/workspaces/{workspace_id}/broadcasts/{broadcast_id}
343
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-broadcasts-broadcast-id
344
+ * @example
345
+ * ```ts
346
+ * const broadcast = await mail.broadcasts.retrieve("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
347
+ * ```
348
+ */
349
+ retrieve(broadcastId, options) {
350
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/broadcasts/{broadcast_id}", pathParams: { broadcast_id: broadcastId } }, options);
351
+ }
352
+ /**
353
+ * Send or schedule a broadcast
354
+ *
355
+ * Now, or at `scheduled_at`. When sending starts the audience is frozen (segment ∩ topic subscribers − unsubscribed − suppression list) and the messages go out at the broadcast rate (default 120 per minute; separate from the transactional limit), on the marketing stream, each with a one-click unsubscribe link and `List-Unsubscribe` headers. The send survives restarts: it continues from the recipients not yet sent.
356
+ *
357
+ * @param broadcastId - Id of the broadcast.
358
+ * @param params - `Mail.BroadcastSendParams`.
359
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
360
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
361
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
362
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
363
+ * @throws {NotFoundError} 404 NOT_FOUND, BROADCAST_NOT_FOUND: No such broadcast (`BROADCAST_NOT_FOUND`).
364
+ * @throws {ConflictError} 409 CONFLICT, BROADCAST_NOT_DRAFT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: Not a draft (`BROADCAST_NOT_DRAFT`), or `IDEMPOTENCY_KEY_REUSE`. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
365
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, UNSUBSCRIBE_LINK_REQUIRED, BROADCAST_NOT_READY, BROADCAST_AUDIENCE_EMPTY, INVALID_FROM_ADDRESS, from_domain_not_verified: Not ready: `UNSUBSCRIBE_LINK_REQUIRED` (the body does not contain `{{{unsubscribe_url}}}`) or `BROADCAST_NOT_READY` (`details.problems`: no audience, no content, no subject, missing template, no From); `BROADCAST_AUDIENCE_EMPTY` (nobody to send to); `INVALID_FROM_ADDRESS`; or `from_domain_not_verified` (`details: { fqdn, reason }`).
366
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
367
+ * @see POST /v1/workspaces/{workspace_id}/broadcasts/{broadcast_id}/send
368
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-broadcasts-broadcast-id-send
369
+ * @example
370
+ * ```ts
371
+ * const broadcast = await mail.broadcasts.send("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", { scheduled_at: "2026-11-02T09:00:00Z" });
372
+ * ```
373
+ */
374
+ send(broadcastId, params, options) {
375
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/broadcasts/{broadcast_id}/send", pathParams: { broadcast_id: broadcastId }, body: params, idempotent: true }, options);
376
+ }
377
+ /**
378
+ * Update a draft broadcast
379
+ *
380
+ * Only drafts can change; null clears an optional field.
381
+ *
382
+ * @param broadcastId - Id of the broadcast.
383
+ * @param params - `Mail.BroadcastUpdateParams`.
384
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
385
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
386
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
387
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
388
+ * @throws {NotFoundError} 404 NOT_FOUND, BROADCAST_NOT_FOUND: No such broadcast (`BROADCAST_NOT_FOUND`).
389
+ * @throws {ConflictError} 409 CONFLICT, BROADCAST_NOT_DRAFT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: Not a draft any more (`BROADCAST_NOT_DRAFT`, `details.status`), or `IDEMPOTENCY_KEY_REUSE`. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
390
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, SEGMENT_NOT_FOUND, TOPIC_NOT_FOUND, BROADCAST_CONTENT_CONFLICT: `segment_id` or `topic_id` does not name one of this workspace's (`SEGMENT_NOT_FOUND` / `TOPIC_NOT_FOUND`), or both `template_name` and `html` were given (`BROADCAST_CONTENT_CONFLICT`).
391
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
392
+ * @see PATCH /v1/workspaces/{workspace_id}/broadcasts/{broadcast_id}
393
+ * @see https://productcraft.co/docs/mail/api-reference#patch-v1-workspaces-workspace-id-broadcasts-broadcast-id
394
+ * @example
395
+ * ```ts
396
+ * const broadcast = await mail.broadcasts.update("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", { from: "string" });
397
+ * ```
398
+ */
399
+ update(broadcastId, params, options) {
400
+ return this._client.request({ method: "PATCH", path: "/v1/workspaces/{workspace_id}/broadcasts/{broadcast_id}", pathParams: { broadcast_id: broadcastId }, body: params, idempotent: true }, options);
401
+ }
402
+ };
403
+ var ContactsImportsResource = class extends APIResource {
404
+ /**
405
+ * Import contacts from a CSV file
406
+ *
407
+ * Queues the file and returns the import (`status: queued`); poll `GET .../contacts/imports/{id}` for progress. At most 10 MB and 100,000 rows, two imports running per workspace. Rows that assert consent (`consent` true or a `consented_at` date) are recorded with it and opted in to `topic_ids`; every other row starts without consent. An import emits no per-contact webhook events.
408
+ *
409
+ * @param params - `Mail.ContactImportCreateParams`.
410
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
411
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
412
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
413
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
414
+ * @throws {NotFoundError} 404 NOT_FOUND, TOPIC_NOT_FOUND: A `topic_ids` entry is not a topic of this workspace (`TOPIC_NOT_FOUND`).
415
+ * @throws {ConflictError} 409 CONFLICT, IMPORT_IN_PROGRESS, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: Two imports are already running (`IMPORT_IN_PROGRESS`), or `IDEMPOTENCY_KEY_REUSE`: the `Idempotency-Key` was already used with a different body or route. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
416
+ * @throws {APIError} 413 PAYLOAD_TOO_LARGE, IMPORT_TOO_LARGE: The CSV is larger than 10 MB (`IMPORT_TOO_LARGE`).
417
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, INVALID_CSV: Empty file, or no header line with an `email` column (`INVALID_CSV`).
418
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
419
+ * @see POST /v1/workspaces/{workspace_id}/contacts/imports
420
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-contacts-imports
421
+ * @example
422
+ * ```ts
423
+ * const contactImport = await mail.contacts.imports.create({
424
+ * csv: "email,first_name,consent,consented_at\nada@example.com,Ada,true,2026-10-01T09:00:00Z\n",
425
+ * on_conflict: "upsert",
426
+ * });
427
+ * ```
428
+ */
429
+ create(params, options) {
430
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/contacts/imports", body: params, idempotent: true }, options);
431
+ }
432
+ /**
433
+ * List contact imports, newest first
434
+ *
435
+ * @param params - `Mail.ContactImportListParams`.
436
+ * @param options - Per-request options.
437
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
438
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
439
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
440
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
441
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
442
+ * @see GET /v1/workspaces/{workspace_id}/contacts/imports
443
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-contacts-imports
444
+ * @example
445
+ * ```ts
446
+ * for await (const importItem of mail.contacts.imports.list()) {
447
+ * console.log(importItem);
448
+ * }
449
+ * const page = await mail.contacts.imports.list({}, { timeout: 5_000 });
450
+ * ```
451
+ */
452
+ list(params, options) {
453
+ return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/contacts/imports", query: params }, options);
454
+ }
455
+ /**
456
+ * Get a contact import and its progress
457
+ *
458
+ * @param importId - Id of the import.
459
+ * @param options - Per-request options.
460
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
461
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
462
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
463
+ * @throws {NotFoundError} 404 NOT_FOUND, IMPORT_NOT_FOUND: No such import in this workspace (`IMPORT_NOT_FOUND`).
464
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
465
+ * @see GET /v1/workspaces/{workspace_id}/contacts/imports/{import_id}
466
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-contacts-imports-import-id
467
+ * @example
468
+ * ```ts
469
+ * const contactImport = await mail.contacts.imports.retrieve("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
470
+ * ```
471
+ */
472
+ retrieve(importId, options) {
473
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/contacts/imports/{import_id}", pathParams: { import_id: importId } }, options);
474
+ }
475
+ };
476
+ var ContactsPropertiesResource = class extends APIResource {
477
+ /**
478
+ * Define a contact property
479
+ *
480
+ * At most 50 per workspace.
481
+ *
482
+ * @param params - `Mail.ContactPropertyCreateParams`.
483
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
484
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
485
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
486
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
487
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
488
+ * @throws {ConflictError} 409 CONFLICT, CONTACT_PROPERTY_EXISTS, CONTACT_PROPERTY_LIMIT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: The key exists (`CONTACT_PROPERTY_EXISTS`), the workspace has 50 properties (`CONTACT_PROPERTY_LIMIT`), or `IDEMPOTENCY_KEY_REUSE`. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
489
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, RESERVED_PROPERTY_KEY, INVALID_CONTACT_PROPERTY_VALUE: The key is a contact field (`RESERVED_PROPERTY_KEY`) or the fallback does not match the type (`INVALID_CONTACT_PROPERTY_VALUE`).
490
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
491
+ * @see POST /v1/workspaces/{workspace_id}/contact-properties
492
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-contact-properties
493
+ * @example
494
+ * ```ts
495
+ * const contactProperty = await mail.contacts.properties.create({ key: "company", type: "string" });
496
+ * ```
497
+ */
498
+ create(params, options) {
499
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/contact-properties", body: params, idempotent: true }, options);
500
+ }
501
+ /**
502
+ * Delete a contact property
503
+ *
504
+ * Values already stored on contacts stay, but are no longer validated; define the key again to use it.
505
+ *
506
+ * @param propertyId - Id of the property.
507
+ * @param options - Per-request options.
508
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
509
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
510
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
511
+ * @throws {NotFoundError} 404 NOT_FOUND, CONTACT_PROPERTY_NOT_FOUND: No such property (`CONTACT_PROPERTY_NOT_FOUND`).
512
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
513
+ * @see DELETE /v1/workspaces/{workspace_id}/contact-properties/{property_id}
514
+ * @see https://productcraft.co/docs/mail/api-reference#delete-v1-workspaces-workspace-id-contact-properties-property-id
515
+ * @example
516
+ * ```ts
517
+ * await mail.contacts.properties.delete("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
518
+ * ```
519
+ */
520
+ delete(propertyId, options) {
521
+ return this._client.request({ method: "DELETE", path: "/v1/workspaces/{workspace_id}/contact-properties/{property_id}", pathParams: { property_id: propertyId } }, options);
522
+ }
523
+ /**
524
+ * List contact properties, newest first
525
+ *
526
+ * @param params - `Mail.ContactPropertyListParams`.
527
+ * @param options - Per-request options.
528
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
529
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
530
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
531
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
532
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
533
+ * @see GET /v1/workspaces/{workspace_id}/contact-properties
534
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-contact-properties
535
+ * @example
536
+ * ```ts
537
+ * for await (const property of mail.contacts.properties.list()) {
538
+ * console.log(property);
539
+ * }
540
+ * const page = await mail.contacts.properties.list({}, { timeout: 5_000 });
541
+ * ```
542
+ */
543
+ list(params, options) {
544
+ return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/contact-properties", query: params }, options);
545
+ }
546
+ /**
547
+ * Get a contact property
548
+ *
549
+ * @param propertyId - Id of the property.
550
+ * @param options - Per-request options.
551
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
552
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
553
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
554
+ * @throws {NotFoundError} 404 NOT_FOUND, CONTACT_PROPERTY_NOT_FOUND: No such property (`CONTACT_PROPERTY_NOT_FOUND`).
555
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
556
+ * @see GET /v1/workspaces/{workspace_id}/contact-properties/{property_id}
557
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-contact-properties-property-id
558
+ * @example
559
+ * ```ts
560
+ * const contactProperty = await mail.contacts.properties.retrieve("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
561
+ * ```
562
+ */
563
+ retrieve(propertyId, options) {
564
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/contact-properties/{property_id}", pathParams: { property_id: propertyId } }, options);
565
+ }
566
+ /**
567
+ * Change a contact property's fallback value
568
+ *
569
+ * The key and type are fixed once created.
570
+ *
571
+ * @param propertyId - Id of the property.
572
+ * @param params - `Mail.ContactPropertyUpdateParams`.
573
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
574
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
575
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
576
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
577
+ * @throws {NotFoundError} 404 NOT_FOUND, CONTACT_PROPERTY_NOT_FOUND: No such property (`CONTACT_PROPERTY_NOT_FOUND`).
578
+ * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `IDEMPOTENCY_KEY_REUSE`: the `Idempotency-Key` was already used with a different request body or on a different route. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
579
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, INVALID_CONTACT_PROPERTY_VALUE: The fallback does not match the type (`INVALID_CONTACT_PROPERTY_VALUE`).
580
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
581
+ * @see PATCH /v1/workspaces/{workspace_id}/contact-properties/{property_id}
582
+ * @see https://productcraft.co/docs/mail/api-reference#patch-v1-workspaces-workspace-id-contact-properties-property-id
583
+ * @example
584
+ * ```ts
585
+ * const contactProperty = await mail.contacts.properties.update("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", { fallback_value: "string" });
586
+ * ```
587
+ */
588
+ update(propertyId, params, options) {
589
+ return this._client.request({ method: "PATCH", path: "/v1/workspaces/{workspace_id}/contact-properties/{property_id}", pathParams: { property_id: propertyId }, body: params, idempotent: true }, options);
590
+ }
591
+ };
592
+ var ContactsSegmentsResource = class extends APIResource {
593
+ /**
594
+ * Add a contact to a static segment
595
+ *
596
+ * Adds the contact. Adding a contact that is already a member changes nothing and answers the same way, with `added_at` from the first time.
597
+ *
598
+ * @param contact - The contact id, or its email address (URL-encoded).
599
+ * @param segmentId - Id of the segment.
600
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
601
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
602
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
603
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
604
+ * @throws {NotFoundError} 404 NOT_FOUND, CONTACT_NOT_FOUND, SEGMENT_NOT_FOUND: No such contact (`CONTACT_NOT_FOUND`) or segment (`SEGMENT_NOT_FOUND`).
605
+ * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `IDEMPOTENCY_KEY_REUSE`: the `Idempotency-Key` was already used with a different request body or on a different route. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
606
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, SEGMENT_RULE_BASED: The segment is rule-based: its members follow the rule (`SEGMENT_RULE_BASED`).
607
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
608
+ * @see POST /v1/workspaces/{workspace_id}/contacts/{contact}/segments/{segment_id}
609
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-contacts-contact-segments-segment-id
610
+ * @example
611
+ * ```ts
612
+ * const segmentMembership = await mail.contacts.segments.add("ada@example.com", "5d1e2f3a-4b5c-4d6e-8f70-8192a3b4c5d6");
613
+ * ```
614
+ */
615
+ add(contact, segmentId, options) {
616
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/contacts/{contact}/segments/{segment_id}", pathParams: { contact, segment_id: segmentId }, idempotent: true }, options);
617
+ }
618
+ /**
619
+ * Remove a contact from a static segment
620
+ *
621
+ * 204 whether or not it was a member.
622
+ *
623
+ * @param contact - The contact id, or its email address (URL-encoded).
624
+ * @param segmentId - Id of the segment.
625
+ * @param options - Per-request options.
626
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
627
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
628
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
629
+ * @throws {NotFoundError} 404 NOT_FOUND, CONTACT_NOT_FOUND, SEGMENT_NOT_FOUND: No such contact (`CONTACT_NOT_FOUND`) or segment (`SEGMENT_NOT_FOUND`).
630
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, SEGMENT_RULE_BASED: The segment is rule-based (`SEGMENT_RULE_BASED`).
631
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
632
+ * @see DELETE /v1/workspaces/{workspace_id}/contacts/{contact}/segments/{segment_id}
633
+ * @see https://productcraft.co/docs/mail/api-reference#delete-v1-workspaces-workspace-id-contacts-contact-segments-segment-id
634
+ * @example
635
+ * ```ts
636
+ * await mail.contacts.segments.delete("ada@example.com", "5d1e2f3a-4b5c-4d6e-8f70-8192a3b4c5d6");
637
+ * ```
638
+ */
639
+ delete(contact, segmentId, options) {
640
+ return this._client.request({ method: "DELETE", path: "/v1/workspaces/{workspace_id}/contacts/{contact}/segments/{segment_id}", pathParams: { contact, segment_id: segmentId } }, options);
641
+ }
642
+ /**
643
+ * List a contact's segments
644
+ *
645
+ * Static segments it was added to and rule segments it matches now.
646
+ *
647
+ * @param contact - The contact id, or its email address (URL-encoded).
648
+ * @param options - Per-request options.
649
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
650
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
651
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
652
+ * @throws {NotFoundError} 404 NOT_FOUND, CONTACT_NOT_FOUND: No such contact (`CONTACT_NOT_FOUND`).
653
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
654
+ * @see GET /v1/workspaces/{workspace_id}/contacts/{contact}/segments
655
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-contacts-contact-segments
656
+ * @example
657
+ * ```ts
658
+ * const contactSegments = await mail.contacts.segments.list("ada@example.com");
659
+ * ```
660
+ */
661
+ list(contact, options) {
662
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/contacts/{contact}/segments", pathParams: { contact } }, options);
663
+ }
664
+ };
665
+ var ContactsTopicsResource = class extends APIResource {
666
+ /**
667
+ * List a contact's topic subscriptions
668
+ *
669
+ * Every topic of the workspace, with the contact's own choice and whether a topic send would reach it now (and why).
670
+ *
671
+ * @param contact - The contact id, or its email address (URL-encoded).
672
+ * @param options - Per-request options.
673
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
674
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
675
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
676
+ * @throws {NotFoundError} 404 NOT_FOUND, CONTACT_NOT_FOUND: No such contact (`CONTACT_NOT_FOUND`).
677
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
678
+ * @see GET /v1/workspaces/{workspace_id}/contacts/{contact}/topics
679
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-contacts-contact-topics
680
+ * @example
681
+ * ```ts
682
+ * const contactTopics = await mail.contacts.topics.list("ada@example.com");
683
+ * ```
684
+ */
685
+ list(contact, options) {
686
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/contacts/{contact}/topics", pathParams: { contact } }, options);
687
+ }
688
+ /**
689
+ * Opt a contact in to or out of topics
690
+ *
691
+ * Records the contact's choice per topic (an explicit `opt_in` is consent for that topic). A global unsubscribe still wins: clear it with `PATCH .../contacts/{contact}` `unsubscribed: false`. Emits `contact.updated`.
692
+ *
693
+ * @param contact - The contact id, or its email address (URL-encoded).
694
+ * @param params - `Mail.ContactTopicUpdateParams`.
695
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
696
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
697
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
698
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
699
+ * @throws {NotFoundError} 404 NOT_FOUND, CONTACT_NOT_FOUND, TOPIC_NOT_FOUND: No such contact (`CONTACT_NOT_FOUND`) or topic (`TOPIC_NOT_FOUND`).
700
+ * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `IDEMPOTENCY_KEY_REUSE`: the `Idempotency-Key` was already used with a different request body or on a different route. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
701
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
702
+ * @see PATCH /v1/workspaces/{workspace_id}/contacts/{contact}/topics
703
+ * @see https://productcraft.co/docs/mail/api-reference#patch-v1-workspaces-workspace-id-contacts-contact-topics
704
+ * @example
705
+ * ```ts
706
+ * const contactTopics = await mail.contacts.topics.update("ada@example.com", { topics: [{ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b", subscription: "opt_in" }] });
707
+ * ```
708
+ */
709
+ update(contact, params, options) {
710
+ return this._client.request({ method: "PATCH", path: "/v1/workspaces/{workspace_id}/contacts/{contact}/topics", pathParams: { contact }, body: params, idempotent: true }, options);
711
+ }
712
+ };
713
+ var ContactsResource = class extends APIResource {
714
+ #imports;
715
+ #properties;
716
+ #segments;
717
+ #topics;
718
+ get imports() {
719
+ return this.#imports ??= new ContactsImportsResource(this._client, this._b);
720
+ }
721
+ get properties() {
722
+ return this.#properties ??= new ContactsPropertiesResource(this._client, this._b);
723
+ }
724
+ get segments() {
725
+ return this.#segments ??= new ContactsSegmentsResource(this._client, this._b);
726
+ }
727
+ get topics() {
728
+ return this.#topics ??= new ContactsTopicsResource(this._client, this._b);
729
+ }
730
+ /**
731
+ * Create a contact
732
+ *
733
+ * Emits `contact.created`. Without `consent`, the contact receives only topics it is explicitly opted in to.
734
+ *
735
+ * @param params - `Mail.ContactCreateParams`.
736
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
737
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
738
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
739
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
740
+ * @throws {NotFoundError} 404 NOT_FOUND, TOPIC_NOT_FOUND: A `topics[].id` is not a topic of this workspace (`TOPIC_NOT_FOUND`).
741
+ * @throws {ConflictError} 409 CONFLICT, CONTACT_EXISTS, CONTACT_LIMIT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: A contact with this email exists (`CONTACT_EXISTS`), the workspace has 100,000 contacts (`CONTACT_LIMIT`), or `IDEMPOTENCY_KEY_REUSE`. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
742
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, UNKNOWN_CONTACT_PROPERTY, INVALID_CONTACT_PROPERTY_VALUE: A `properties` key is not a defined property (`UNKNOWN_CONTACT_PROPERTY`) or its value has the wrong type (`INVALID_CONTACT_PROPERTY_VALUE`).
743
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
744
+ * @see POST /v1/workspaces/{workspace_id}/contacts
745
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-contacts
746
+ * @example
747
+ * ```ts
748
+ * const contact = await mail.contacts.create({ email: "ada@example.com" });
749
+ * ```
750
+ */
751
+ create(params, options) {
752
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/contacts", body: params, idempotent: true }, options);
753
+ }
754
+ /**
755
+ * Delete a contact
756
+ *
757
+ * Removes the contact, its properties and its topic choices. Emits `contact.deleted`. To stop mailing someone, unsubscribe them instead: a deleted contact that later receives a topic send is refused (`no_consent`), but its opt-out is forgotten.
758
+ *
759
+ * @param contact - The contact id, or its email address (URL-encoded).
760
+ * @param options - Per-request options.
761
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
762
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
763
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
764
+ * @throws {NotFoundError} 404 NOT_FOUND, CONTACT_NOT_FOUND: No such contact (`CONTACT_NOT_FOUND`).
765
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
766
+ * @see DELETE /v1/workspaces/{workspace_id}/contacts/{contact}
767
+ * @see https://productcraft.co/docs/mail/api-reference#delete-v1-workspaces-workspace-id-contacts-contact
768
+ * @example
769
+ * ```ts
770
+ * await mail.contacts.delete("ada@example.com");
771
+ * ```
772
+ */
773
+ delete(contact, options) {
774
+ return this._client.request({ method: "DELETE", path: "/v1/workspaces/{workspace_id}/contacts/{contact}", pathParams: { contact } }, options);
775
+ }
776
+ /**
777
+ * List contacts, newest first
778
+ *
779
+ * @param params - `Mail.ContactListParams`.
780
+ * @param options - Per-request options.
781
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
782
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
783
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
784
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
785
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
786
+ * @see GET /v1/workspaces/{workspace_id}/contacts
787
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-contacts
788
+ * @example
789
+ * ```ts
790
+ * for await (const contact of mail.contacts.list()) {
791
+ * console.log(contact);
792
+ * }
793
+ * const page = await mail.contacts.list({}, { timeout: 5_000 });
794
+ * ```
795
+ */
796
+ list(params, options) {
797
+ return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/contacts", query: params }, options);
798
+ }
799
+ /**
800
+ * Get a contact by id or email
801
+ *
802
+ * @param contact - The contact id, or its email address (URL-encoded).
803
+ * @param options - Per-request options.
804
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
805
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
806
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
807
+ * @throws {NotFoundError} 404 NOT_FOUND, CONTACT_NOT_FOUND: No such contact (`CONTACT_NOT_FOUND`).
808
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
809
+ * @see GET /v1/workspaces/{workspace_id}/contacts/{contact}
810
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-contacts-contact
811
+ * @example
812
+ * ```ts
813
+ * const contact = await mail.contacts.retrieve("ada@example.com");
814
+ * ```
815
+ */
816
+ retrieve(contact, options) {
817
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/contacts/{contact}", pathParams: { contact } }, options);
818
+ }
819
+ /**
820
+ * Update a contact
821
+ *
822
+ * The email cannot change (delete and re-create). Emits `contact.updated` when something changed.
823
+ *
824
+ * @param contact - The contact id, or its email address (URL-encoded).
825
+ * @param params - `Mail.ContactUpdateParams`.
826
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
827
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
828
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
829
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
830
+ * @throws {NotFoundError} 404 NOT_FOUND, CONTACT_NOT_FOUND: No such contact (`CONTACT_NOT_FOUND`).
831
+ * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `IDEMPOTENCY_KEY_REUSE`: the `Idempotency-Key` was already used with a different request body or on a different route. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
832
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, UNKNOWN_CONTACT_PROPERTY, INVALID_CONTACT_PROPERTY_VALUE: `UNKNOWN_CONTACT_PROPERTY` or `INVALID_CONTACT_PROPERTY_VALUE`.
833
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
834
+ * @see PATCH /v1/workspaces/{workspace_id}/contacts/{contact}
835
+ * @see https://productcraft.co/docs/mail/api-reference#patch-v1-workspaces-workspace-id-contacts-contact
836
+ * @example
837
+ * ```ts
838
+ * const contact = await mail.contacts.update("ada@example.com", { consent: { consented_at: "2026-10-24T09:00:00Z", source: "signup-form-2026" } });
839
+ * ```
840
+ */
841
+ update(contact, params, options) {
842
+ return this._client.request({ method: "PATCH", path: "/v1/workspaces/{workspace_id}/contacts/{contact}", pathParams: { contact }, body: params, idempotent: true }, options);
843
+ }
844
+ };
845
+ var DeliverabilityResource = class extends APIResource {
846
+ /**
847
+ * Deliverability verdict for the workspace over a lookback window. `unconfirmed` means mail was handed off and nothing came back either way — it is not a synonym for healthy.
848
+ *
849
+ * @param params - `Mail.DeliverabilityRetrieveParams`.
850
+ * @param options - Per-request options.
851
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: window_days out of range.
852
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Not authenticated.
853
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: Missing mail.message.read, or the mail service is not enabled.
854
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
855
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
856
+ * @see GET /v1/workspaces/{workspace_id}/deliverability
857
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-deliverability
858
+ * @example
859
+ * ```ts
860
+ * const deliverability = await mail.deliverability.retrieve();
861
+ * ```
862
+ */
863
+ retrieve(params, options) {
864
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/deliverability", query: params }, options);
865
+ }
866
+ };
867
+ var DomainsDnsRecordsResource = class extends APIResource {
868
+ /**
869
+ * Set up the domain's DNS records in one step with a short-lived Cloudflare or DigitalOcean API token.
870
+ *
871
+ * Reads the zone through the provider's API and plans every record the domain needs: `create`, `update` (only ever an SPF merge into an existing SPF record, shown with `before`/`after`) or `skip` (already there). `dry_run: true` returns the plan and changes nothing; `dry_run: false` applies exactly that plan, runs a DNS check straight away and records `setup_method = provider_api`. Only names at or under the domain are written, nothing is ever deleted, and Cloudflare records are DNS-only (not proxied). The recommended DMARC record (`p=none`) is included when `include_dmarc` is true (the default) and no DMARC policy applies to the domain yet; an existing policy is never touched. Any blocking conflict refuses the whole apply with 409. The token is used for this request only: it is never stored, logged, queued or returned; revoke it afterwards (`warnings` says so when it could see more than this zone). Applies are limited to one per domain every 10 seconds; dry runs are not limited.
872
+ *
873
+ * @param domainId - Id of the domain.
874
+ * @param params - `Mail.DomainDnsRecordApplyParams`.
875
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
876
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR, IDEMPOTENCY_KEY_REQUIRED, INVALID_ZONE, PROVIDER_TOKEN_REJECTED, PROVIDER_PERMISSION_DENIED, PROVIDER_ZONE_NOT_FOUND: Validation failure; `Idempotency-Key` missing (`IDEMPOTENCY_KEY_REQUIRED`); `zone` not the domain or a parent (`INVALID_ZONE`); the provider rejected the token (`PROVIDER_TOKEN_REJECTED`), the token lacks DNS permissions (`PROVIDER_PERMISSION_DENIED`), or it cannot see a zone for the domain (`PROVIDER_ZONE_NOT_FOUND`).
877
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
878
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: Missing `mail.update`, or the mail service is not enabled for the workspace.
879
+ * @throws {NotFoundError} 404 NOT_FOUND: Domain not found in this workspace.
880
+ * @throws {ConflictError} 409 CONFLICT, DNS_CONFLICTS, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `DNS_CONFLICTS`: a blocking conflict (a second SPF record, a CNAME at the name, another DKIM key at our selector, other MX records at the MAIL FROM host or the domain, a merge over 10 SPF lookups). Nothing was written; the body carries the full `plan` and `conflicts`. Or `IDEMPOTENCY_KEY_REUSE`. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
881
+ * @throws {RateLimitError} 429 RATE_LIMITED: Applied less than 10 seconds ago (`RATE_LIMITED`). Per-IP limit: more than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
882
+ * @throws {InternalServerError} 502 BAD_GATEWAY, PROVIDER_UNAVAILABLE, PROVIDER_ERROR: The provider failed or did not answer (`PROVIDER_UNAVAILABLE`, `PROVIDER_ERROR`). Nothing was written unless the plan items say so.
883
+ * @see POST /v1/workspaces/{workspace_id}/domains/{domain_id}/dns-records/apply
884
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-domains-domain-id-dns-records-apply
885
+ * @example
886
+ * ```ts
887
+ * const dnsApplyResult = await mail.domains.dnsRecords.apply("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", { dry_run: true, provider: "cloudflare", token: "dop_v1_EXAMPLE_TOKEN_DO_NOT_USE" });
888
+ * ```
889
+ */
890
+ apply(domainId, params, options) {
891
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/domains/{domain_id}/dns-records/apply", pathParams: { domain_id: domainId }, body: params, idempotent: true }, options);
892
+ }
893
+ /**
894
+ * Check the domain's DNS records now.
895
+ *
896
+ * Queries the zone's authoritative nameservers and a public resolver for every record, stores the result, flips a pending domain whose required records pass to `active`, and returns the same body as `GET .../dns-records`. Never fails because records are missing: their states say so. Limited to one call per domain every 10 seconds. Safe to retry: it changes nothing but the stored check result, so it takes no Idempotency-Key.
897
+ *
898
+ * @param domainId - Id of the domain.
899
+ * @param params - `Mail.DomainDnsRecordCheckParams`.
900
+ * @param options - Per-request options.
901
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR, INVALID_ZONE: `zone` is not the domain or one of its parents (`INVALID_ZONE`).
902
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
903
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
904
+ * @throws {NotFoundError} 404 NOT_FOUND: Domain not found in this workspace.
905
+ * @throws {RateLimitError} 429 RATE_LIMITED: Checked less than 10 seconds ago (`RATE_LIMITED`). Per-IP limit: more than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
906
+ * @see POST /v1/workspaces/{workspace_id}/domains/{domain_id}/dns-records/check
907
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-domains-domain-id-dns-records-check
908
+ * @example
909
+ * ```ts
910
+ * const domainDnsRecords = await mail.domains.dnsRecords.check("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
911
+ * ```
912
+ */
913
+ check(domainId, params, options) {
914
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/domains/{domain_id}/dns-records/check", pathParams: { domain_id: domainId }, query: params }, options);
915
+ }
916
+ /**
917
+ * Download the domain's DNS records as a BIND zone fragment or a CSV.
918
+ *
919
+ * `format=bind`: a zone-file fragment (`$ORIGIN <zone>.`, `$TTL 3600`, names relative to the zone, MX with priority, TXT split into ≤255-byte quoted strings, a comment per record with its purpose, required/recommended and any conflict) that Cloudflare and Route 53 import directly. `format=csv`: `type,name,value,priority,ttl,purpose,required` (the common DNS-import columns plus two), RFC 4180 quoting, fully qualified names. By default only records not yet verified; `all=true` for every record. Served as an attachment.
920
+ *
921
+ * @param domainId - Id of the domain.
922
+ * @param params - `Mail.DomainDnsRecordExportParams`.
923
+ * @param options - Per-request options.
924
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `format` missing or not `bind`/`csv`, or `zone` is not the domain or one of its parents.
925
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
926
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
927
+ * @throws {NotFoundError} 404 NOT_FOUND: Domain not found in this workspace.
928
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
929
+ * @see GET /v1/workspaces/{workspace_id}/domains/{domain_id}/dns-records/export
930
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-domains-domain-id-dns-records-export
931
+ * @example
932
+ * ```ts
933
+ * const response = await mail.domains.dnsRecords.export("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", { format: "bind" });
934
+ * const text = await response.text();
935
+ * ```
936
+ */
937
+ export(domainId, params, options) {
938
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/domains/{domain_id}/dns-records/export", pathParams: { domain_id: domainId }, query: params, raw: true }, options);
939
+ }
940
+ /**
941
+ * Per-record DNS status for a domain.
942
+ *
943
+ * Every record the domain needs for its intent, with its state (`missing`, `mismatch`, `conflict`, `propagating`, `verified`), what was found, a propagation hint and timestamps, as of the last check (the verifier re-checks pending domains every 5 minutes and active ones hourly). Does not run a DNS lookup; use `POST .../dns-records/check` for that.
944
+ *
945
+ * @param domainId - Id of the domain.
946
+ * @param params - `Mail.DomainDnsRecordListParams`.
947
+ * @param options - Per-request options.
948
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR, INVALID_ZONE: `zone` is not the domain or one of its parents (`INVALID_ZONE`).
949
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
950
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
951
+ * @throws {NotFoundError} 404 NOT_FOUND: Domain not found in this workspace.
952
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
953
+ * @see GET /v1/workspaces/{workspace_id}/domains/{domain_id}/dns-records
954
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-domains-domain-id-dns-records
955
+ * @example
956
+ * ```ts
957
+ * const domainDnsRecords = await mail.domains.dnsRecords.list("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
958
+ * ```
959
+ */
960
+ list(domainId, params, options) {
961
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/domains/{domain_id}/dns-records", pathParams: { domain_id: domainId }, query: params }, options);
962
+ }
963
+ };
964
+ var DomainsDomainConnectResource = class extends APIResource {
965
+ /**
966
+ * Start one-click DNS setup at the domain's DNS provider (Domain Connect).
967
+ *
968
+ * Returns a signed Domain Connect URL for the provider that hosts the domain's zone (Cloudflare, GoDaddy, IONOS, Vercel and the others that have onboarded ProductCraft's template). Open it in the browser: the user signs in at their provider and confirms, the provider writes the DKIM key at `productcraft._domainkey.<domain>` and the MAIL FROM records at `bounce.<domain>` (MX to the regional feedback host, SPF merged into any existing SPF there), and then redirects to `GET /v1/domain-connect/callback`, which records `setup_method = domain_connect`, checks the records and returns the user to the domain in the console. With `include_dmarc` and no DMARC policy in place yet, a second confirmation adds `v=DMARC1; p=none;` at `_dmarc.<domain>`. The URL is valid for 10 minutes and works once. ProductCraft never receives a DNS credential. For sending domains whose MAIL FROM label is `bounce` (the default). Not available while ProductCraft has Domain Connect switched off (`domain_connect.available` in `GET .../domains/lookup` says whether it is).
969
+ *
970
+ * @param domainId - Id of the domain.
971
+ * @param params - `Mail.DomainDomainConnectStartParams`.
972
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
973
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Validation failure, or an id is not a UUID.
974
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
975
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: Missing `mail.update`, or the mail service is not enabled for the workspace.
976
+ * @throws {NotFoundError} 404 NOT_FOUND: Domain not found in this workspace.
977
+ * @throws {ConflictError} 409 CONFLICT, DOMAIN_CONNECT_DISABLED, DOMAIN_CONNECT_UNAVAILABLE, DOMAIN_CONNECT_NOT_SENDING, DOMAIN_CONNECT_MAIL_FROM_LABEL, DKIM_KEY_MISSING, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: One-click setup is not possible for this domain; nothing was started. `DOMAIN_CONNECT_DISABLED`: ProductCraft has not switched Domain Connect on. `DOMAIN_CONNECT_UNAVAILABLE`: the DNS provider does not run Domain Connect or has not onboarded our template (`details.reason`: `no_record`, `settings_unreachable`, `template_not_onboarded` or `lookup_failed`; `details.provider_name`). `DOMAIN_CONNECT_NOT_SENDING`: a receive-only domain. `DOMAIN_CONNECT_MAIL_FROM_LABEL`: the MAIL FROM label is not `bounce` or MAIL FROM is off. `DKIM_KEY_MISSING`: no DKIM key to publish. Or `IDEMPOTENCY_KEY_REUSE`. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
978
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
979
+ * @see POST /v1/workspaces/{workspace_id}/domains/{domain_id}/domain-connect/start
980
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-domains-domain-id-domain-connect-start
981
+ * @example
982
+ * ```ts
983
+ * const domainConnectStart = await mail.domains.domainConnect.start("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", { include_dmarc: true });
984
+ * ```
985
+ */
986
+ start(domainId, params, options) {
987
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/domains/{domain_id}/domain-connect/start", pathParams: { domain_id: domainId }, body: params, idempotent: true }, options);
988
+ }
989
+ };
990
+ var DomainsEventsResource = class extends APIResource {
991
+ /**
992
+ * List a domain's events (its timeline), newest first, cursor-paginated.
993
+ *
994
+ * Added, records found, verified, degraded, failing, recovered, MAIL FROM verified, DMARC detected, check failed. An event is written only when something changed, so a domain checked every few minutes does not grow a row per check.
995
+ *
996
+ * @param domainId - Id of the domain.
997
+ * @param params - `Mail.DomainEventListParams`.
998
+ * @param options - Per-request options.
999
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Invalid cursor, or `domain_id` is not a UUID.
1000
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1001
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1002
+ * @throws {NotFoundError} 404 NOT_FOUND: Domain not found in this workspace.
1003
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1004
+ * @see GET /v1/workspaces/{workspace_id}/domains/{domain_id}/events
1005
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-domains-domain-id-events
1006
+ * @example
1007
+ * ```ts
1008
+ * for await (const event of mail.domains.events.list("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b")) {
1009
+ * console.log(event);
1010
+ * }
1011
+ * const page = await mail.domains.events.list("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", {}, { timeout: 5_000 });
1012
+ * ```
1013
+ */
1014
+ list(domainId, params, options) {
1015
+ return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/domains/{domain_id}/events", pathParams: { domain_id: domainId }, query: params }, options);
1016
+ }
1017
+ };
1018
+ var DomainsShareLinksResource = class extends APIResource {
1019
+ /**
1020
+ * Create a share link: a read-only DNS setup page for whoever manages the domain's DNS.
1021
+ *
1022
+ * Returns a link (valid 1–7 days, default 7) to a public page that shows the domain name, its DNS records with copy-ready values, their live status and zone-file / CSV downloads, without an account. The page shows nothing else about the workspace. The link is shown only in this response (only its hash is stored); revoke it with `DELETE .../share-links/{link_id}`. Optionally emails it from ProductCraft to up to 5 recipients per domain per day (20 per workspace). Requires `mail.update` on the domain.
1023
+ *
1024
+ * @param domainId - Id of the domain.
1025
+ * @param params - `Mail.DomainShareLinkCreateParams`.
1026
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
1027
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Validation failure: `expires_in_days` outside 1–7, more than 5 `email_to` entries, or an invalid address.
1028
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1029
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1030
+ * @throws {NotFoundError} 404 NOT_FOUND: Domain not found in this workspace.
1031
+ * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `IDEMPOTENCY_KEY_REUSE`: the key was used with a different body. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
1032
+ * @throws {RateLimitError} 429 RATE_LIMITED: The daily email cap for the domain (5 recipients) or the workspace (20) would be exceeded (`RATE_LIMITED`). No link is created. Per-IP limit: more than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1033
+ * @throws {InternalServerError} 503 SERVICE_UNAVAILABLE, EMAIL_UNAVAILABLE: `EMAIL_UNAVAILABLE`: `email_to` was given but the email cap cannot be checked right now. No link is created; retry, or create it without `email_to`.
1034
+ * @see POST /v1/workspaces/{workspace_id}/domains/{domain_id}/share-links
1035
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-domains-domain-id-share-links
1036
+ * @example
1037
+ * ```ts
1038
+ * const createdShareLink = await mail.domains.shareLinks.create("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", { email_to: ["it@example.com"] });
1039
+ * ```
1040
+ */
1041
+ create(domainId, params, options) {
1042
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/domains/{domain_id}/share-links", pathParams: { domain_id: domainId }, body: params, idempotent: true }, options);
1043
+ }
1044
+ /**
1045
+ * Revoke a share link.
1046
+ *
1047
+ * The public page and its downloads answer 404 from now on. Revoking an already revoked or expired link succeeds and changes nothing.
1048
+ *
1049
+ * @param domainId - Id of the domain.
1050
+ * @param linkId - Id of the link.
1051
+ * @param options - Per-request options.
1052
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: An id is not a UUID.
1053
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1054
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1055
+ * @throws {NotFoundError} 404 NOT_FOUND: Domain or share link not found in this workspace.
1056
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1057
+ * @see DELETE /v1/workspaces/{workspace_id}/domains/{domain_id}/share-links/{link_id}
1058
+ * @see https://productcraft.co/docs/mail/api-reference#delete-v1-workspaces-workspace-id-domains-domain-id-share-links-link-id
1059
+ * @example
1060
+ * ```ts
1061
+ * await mail.domains.shareLinks.delete("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", "5d1e2f3a-4b5c-4d6e-8f70-8192a3b4c5d6");
1062
+ * ```
1063
+ */
1064
+ delete(domainId, linkId, options) {
1065
+ return this._client.request({ method: "DELETE", path: "/v1/workspaces/{workspace_id}/domains/{domain_id}/share-links/{link_id}", pathParams: { domain_id: domainId, link_id: linkId } }, options);
1066
+ }
1067
+ /**
1068
+ * List the domain's share links (newest first, including expired and revoked), cursor-paginated.
1069
+ *
1070
+ * The links themselves are not returned: they are shown once, at creation.
1071
+ *
1072
+ * @param domainId - Id of the domain.
1073
+ * @param params - `Mail.DomainShareLinkListParams`.
1074
+ * @param options - Per-request options.
1075
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Invalid cursor, or an id is not a UUID.
1076
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1077
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1078
+ * @throws {NotFoundError} 404 NOT_FOUND: Domain not found in this workspace.
1079
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1080
+ * @see GET /v1/workspaces/{workspace_id}/domains/{domain_id}/share-links
1081
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-domains-domain-id-share-links
1082
+ * @example
1083
+ * ```ts
1084
+ * for await (const shareLink of mail.domains.shareLinks.list("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b")) {
1085
+ * console.log(shareLink);
1086
+ * }
1087
+ * const page = await mail.domains.shareLinks.list("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", {}, { timeout: 5_000 });
1088
+ * ```
1089
+ */
1090
+ list(domainId, params, options) {
1091
+ return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/domains/{domain_id}/share-links", pathParams: { domain_id: domainId }, query: params }, options);
1092
+ }
1093
+ };
1094
+ var DomainsSmtpConfigResource = class extends APIResource {
1095
+ /**
1096
+ * Drop the per-domain override; sends from this domain fall back to the workspace default (or ProductCraft Mail's own sending).
1097
+ *
1098
+ * @param domainId - Id of the domain.
1099
+ * @param options - Per-request options.
1100
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
1101
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1102
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1103
+ * @throws {NotFoundError} 404 NOT_FOUND: No per-domain override to delete
1104
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1105
+ * @see DELETE /v1/workspaces/{workspace_id}/domains/{domain_id}/smtp-config
1106
+ * @see https://productcraft.co/docs/mail/api-reference#delete-v1-workspaces-workspace-id-domains-domain-id-smtp-config
1107
+ * @example
1108
+ * ```ts
1109
+ * await mail.domains.smtpConfig.reset("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
1110
+ * ```
1111
+ */
1112
+ reset(domainId, options) {
1113
+ return this._client.request({ method: "DELETE", path: "/v1/workspaces/{workspace_id}/domains/{domain_id}/smtp-config", pathParams: { domain_id: domainId } }, options);
1114
+ }
1115
+ /**
1116
+ * Get the per-domain SMTP override (returns null if unset; the workspace default applies in that case).
1117
+ *
1118
+ * @param domainId - Id of the domain.
1119
+ * @param options - Per-request options.
1120
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
1121
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1122
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1123
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
1124
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1125
+ * @see GET /v1/workspaces/{workspace_id}/domains/{domain_id}/smtp-config
1126
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-domains-domain-id-smtp-config
1127
+ * @example
1128
+ * ```ts
1129
+ * const getSmtpConfig = await mail.domains.smtpConfig.retrieve("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
1130
+ * ```
1131
+ */
1132
+ retrieve(domainId, options) {
1133
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/domains/{domain_id}/smtp-config", pathParams: { domain_id: domainId } }, options);
1134
+ }
1135
+ /**
1136
+ * Create or update the per-domain SMTP override (resets verification)
1137
+ *
1138
+ * @param domainId - Id of the domain.
1139
+ * @param params - `Mail.DomainSmtpConfigUpdateParams`.
1140
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
1141
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Validation failure or username/password mismatch.
1142
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1143
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1144
+ * @throws {NotFoundError} 404 NOT_FOUND: Domain not found in this workspace.
1145
+ * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `IDEMPOTENCY_KEY_REUSE`: the `Idempotency-Key` was already used with a different request body or on a different route. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
1146
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1147
+ * @see PUT /v1/workspaces/{workspace_id}/domains/{domain_id}/smtp-config
1148
+ * @see https://productcraft.co/docs/mail/api-reference#put-v1-workspaces-workspace-id-domains-domain-id-smtp-config
1149
+ * @example
1150
+ * ```ts
1151
+ * const smtpConfig = await mail.domains.smtpConfig.update("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", {
1152
+ * from_email: "noreply@acme.com",
1153
+ * from_name: "Acme Notifications",
1154
+ * host: "smtp.sendgrid.net",
1155
+ * port: 587,
1156
+ * secure: false,
1157
+ * });
1158
+ * ```
1159
+ */
1160
+ update(domainId, params, options) {
1161
+ return this._client.request({ method: "PUT", path: "/v1/workspaces/{workspace_id}/domains/{domain_id}/smtp-config", pathParams: { domain_id: domainId }, body: params, idempotent: true }, options);
1162
+ }
1163
+ /**
1164
+ * Test the per-domain SMTP override; updates status
1165
+ *
1166
+ * @param domainId - Id of the domain.
1167
+ * @param options - Per-request options.
1168
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
1169
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1170
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1171
+ * @throws {NotFoundError} 404 NOT_FOUND: No per-domain override saved
1172
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1173
+ * @see POST /v1/workspaces/{workspace_id}/domains/{domain_id}/smtp-config/verify-saved
1174
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-domains-domain-id-smtp-config-verify-saved
1175
+ * @example
1176
+ * ```ts
1177
+ * const smtpVerifyResult = await mail.domains.smtpConfig.verifySaved("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
1178
+ * ```
1179
+ */
1180
+ verifySaved(domainId, options) {
1181
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/domains/{domain_id}/smtp-config/verify-saved", pathParams: { domain_id: domainId } }, options);
1182
+ }
1183
+ };
1184
+ var DomainsResource = class extends APIResource {
1185
+ #dnsRecords;
1186
+ #domainConnect;
1187
+ #events;
1188
+ #shareLinks;
1189
+ #smtpConfig;
1190
+ get dnsRecords() {
1191
+ return this.#dnsRecords ??= new DomainsDnsRecordsResource(this._client, this._b);
1192
+ }
1193
+ get domainConnect() {
1194
+ return this.#domainConnect ??= new DomainsDomainConnectResource(this._client, this._b);
1195
+ }
1196
+ get events() {
1197
+ return this.#events ??= new DomainsEventsResource(this._client, this._b);
1198
+ }
1199
+ get shareLinks() {
1200
+ return this.#shareLinks ??= new DomainsShareLinksResource(this._client, this._b);
1201
+ }
1202
+ get smtpConfig() {
1203
+ return this.#smtpConfig ??= new DomainsSmtpConfigResource(this._client, this._b);
1204
+ }
1205
+ /**
1206
+ * Register a domain for a workspace
1207
+ *
1208
+ * Accepts Resend's create-domain body as well as ours: `name` for `fqdn`, `capabilities` for `intent`, `custom_return_path` for the MAIL FROM label, and `region`, `tls`, `open_tracking`, `click_tracking`, `tracking_subdomain`. Defaults to sending only (`intent: send`), as Resend does. Options we do not offer yet are refused with 422 rather than ignored.
1209
+ *
1210
+ * @param params - `Mail.DomainCreateParams`.
1211
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
1212
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR, INVALID_CAPABILITIES, MAIL_FROM_NOT_SENDING: Validation failure on the request body: no `fqdn`/`name`, `fqdn` and `name` disagree, `intent` and `capabilities` disagree or enable nothing (`INVALID_CAPABILITIES`), or `custom_return_path` on a receive-only domain (`MAIL_FROM_NOT_SENDING`).
1213
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1214
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1215
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
1216
+ * @throws {ConflictError} 409 CONFLICT, MAIL_FROM_HOST_IN_USE, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: Domain already registered (globally unique); `MAIL_FROM_HOST_IN_USE`: the `custom_return_path` host already has records that are not ours (listed in `details.found`); or `IDEMPOTENCY_KEY_REUSE`: the `Idempotency-Key` was already used with a different body or route. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
1217
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, REGION_NOT_AVAILABLE, TLS_ENFORCED_NOT_AVAILABLE, TRACKING_NOT_AVAILABLE: `REGION_NOT_AVAILABLE`: `region` is not the region this deployment sends from (`details.available`); `TLS_ENFORCED_NOT_AVAILABLE`: `tls: enforced`; `TRACKING_NOT_AVAILABLE`: open/click tracking or a tracking subdomain.
1218
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1219
+ * @see POST /v1/workspaces/{workspace_id}/domains
1220
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-domains
1221
+ * @example
1222
+ * ```ts
1223
+ * const domain = await mail.domains.create({ capabilities: { receiving: "enabled", sending: "enabled" } });
1224
+ * ```
1225
+ */
1226
+ create(params, options) {
1227
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/domains", body: params, idempotent: true }, options);
1228
+ }
1229
+ /**
1230
+ * Delete a domain (must have no active mailboxes left).
1231
+ *
1232
+ * Permanently deletes the domain, its DNS record set and its Amazon SES sending identity. Mailboxes you already deleted on it are erased with it, together with the mail they still held and its stored files; this cannot be undone. Refused with 409 `DOMAIN_HAS_MAILBOXES` while any mailbox on it is active.
1233
+ *
1234
+ * @param domainId - Id of the domain.
1235
+ * @param options - Per-request options.
1236
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
1237
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1238
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1239
+ * @throws {NotFoundError} 404 NOT_FOUND: Domain not found in this workspace.
1240
+ * @throws {ConflictError} 409 CONFLICT, DOMAIN_HAS_MAILBOXES: `DOMAIN_HAS_MAILBOXES`: the domain still has active mailboxes. `details.count` is how many; `details.mailboxes` lists them (`id`, `address`, first 100). Delete them, then try again.
1241
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1242
+ * @throws {InternalServerError} 503 SERVICE_UNAVAILABLE, SES_IDENTITY_DELETE_FAILED: `SES_IDENTITY_DELETE_FAILED`: the domain's Amazon SES identity could not be removed. Nothing was deleted; retry.
1243
+ * @see DELETE /v1/workspaces/{workspace_id}/domains/{domain_id}
1244
+ * @see https://productcraft.co/docs/mail/api-reference#delete-v1-workspaces-workspace-id-domains-domain-id
1245
+ * @example
1246
+ * ```ts
1247
+ * await mail.domains.delete("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
1248
+ * ```
1249
+ */
1250
+ delete(domainId, options) {
1251
+ return this._client.request({ method: "DELETE", path: "/v1/workspaces/{workspace_id}/domains/{domain_id}", pathParams: { domain_id: domainId } }, options);
1252
+ }
1253
+ /**
1254
+ * List domains registered to this workspace (newest first), cursor-paginated.
1255
+ *
1256
+ * @param params - `Mail.DomainListParams`.
1257
+ * @param options - Per-request options.
1258
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Invalid cursor, search term, or status filter.
1259
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1260
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1261
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
1262
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1263
+ * @see GET /v1/workspaces/{workspace_id}/domains
1264
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-domains
1265
+ * @example
1266
+ * ```ts
1267
+ * for await (const domain of mail.domains.list()) {
1268
+ * console.log(domain);
1269
+ * }
1270
+ * const page = await mail.domains.list({}, { timeout: 5_000 });
1271
+ * ```
1272
+ */
1273
+ list(params, options) {
1274
+ return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/domains", query: params }, options);
1275
+ }
1276
+ /**
1277
+ * Look up a domain before adding it: zone, DNS provider, Domain Connect support, a better subdomain, existing records.
1278
+ *
1279
+ * Creates nothing. Resolves only names at or under `fqdn` and its zone apex, plus the Domain Connect endpoints the zone advertises (fetched through the SSRF guard; cached per zone for an hour). Limited to 30 lookups per workspace per minute.
1280
+ *
1281
+ * @param params - `Mail.DomainLookupParams`.
1282
+ * @param options - Per-request options.
1283
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `fqdn` missing or not a domain name.
1284
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1285
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1286
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
1287
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 30 lookups this minute (`RATE_LIMITED`). Per-IP limit: more than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1288
+ * @see GET /v1/workspaces/{workspace_id}/domains/lookup
1289
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-domains-lookup
1290
+ * @example
1291
+ * ```ts
1292
+ * const domainLookup = await mail.domains.lookup({ fqdn: "acme.com" });
1293
+ * ```
1294
+ */
1295
+ lookup(params, options) {
1296
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/domains/lookup", query: params }, options);
1297
+ }
1298
+ /**
1299
+ * Get a single domain (with DNS instructions and its latest events).
1300
+ *
1301
+ * The domain with `verification_status`, `region`, the effective `dns_provider`, `recommended_pending`, its DNS instructions, and `events`: the latest 20 domain events, newest first.
1302
+ *
1303
+ * @param domainId - Id of the domain.
1304
+ * @param options - Per-request options.
1305
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `domain_id` is not a UUID.
1306
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1307
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1308
+ * @throws {NotFoundError} 404 NOT_FOUND: Domain not found in this workspace.
1309
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1310
+ * @see GET /v1/workspaces/{workspace_id}/domains/{domain_id}
1311
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-domains-domain-id
1312
+ * @example
1313
+ * ```ts
1314
+ * const domainDetail = await mail.domains.retrieve("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
1315
+ * ```
1316
+ */
1317
+ retrieve(domainId, options) {
1318
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/domains/{domain_id}", pathParams: { domain_id: domainId } }, options);
1319
+ }
1320
+ /**
1321
+ * Retrieve until `status` is `active`, `disabled`.
1322
+ *
1323
+ * @param options - `intervalMs` (default 2 000), `timeoutMs` (default 300 000, then `APITimeoutError`), `signal`, and request options.
1324
+ * @example
1325
+ * ```ts
1326
+ * const done = await mail.domains.poll("…");
1327
+ * ```
1328
+ */
1329
+ poll(domainId, options) {
1330
+ return this._client.poll({ method: "GET", path: "/v1/workspaces/{workspace_id}/domains/{domain_id}", pathParams: { domain_id: domainId } }, { field: "status", terminal: ["active", "disabled"] }, options);
1331
+ }
1332
+ /**
1333
+ * Create, then poll until `status` is terminal. The Idempotency-Key goes on the create only.
1334
+ *
1335
+ * @param options - Poll options (`intervalMs`, `timeoutMs`, `signal`) and request options for the create.
1336
+ */
1337
+ createAndPoll(params, options) {
1338
+ return this._client.createAndPoll(
1339
+ { method: "POST", path: "/v1/workspaces/{workspace_id}/domains", body: params, idempotent: true },
1340
+ (created) => ({ method: "GET", path: "/v1/workspaces/{workspace_id}/domains/{domain_id}", pathParams: { domain_id: created.id } }),
1341
+ { field: "status", terminal: ["active", "disabled"] },
1342
+ options
1343
+ );
1344
+ }
1345
+ /**
1346
+ * Send a built-in test email from this domain, no template needed.
1347
+ *
1348
+ * Sends a fixed message (subject `[TEST] Sending from <domain> works`, a short body naming the domain and the From address) so a freshly verified domain can be tried before any template exists. The From address defaults to `test@<domain>` and must be at this exact domain. Like a template test send it skips the suppression list and the ordinary send limits, counts against the workspace test-send limit (30 per hour), and is recorded with `source: test_send`.
1349
+ *
1350
+ * @param domainId - Id of the domain.
1351
+ * @param params - `Mail.DomainTestSendParams`.
1352
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
1353
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `domain_id` is not a UUID, or the body is malformed (bad `to` or `from`).
1354
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1355
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1356
+ * @throws {NotFoundError} 404 NOT_FOUND, DOMAIN_NOT_FOUND: `DOMAIN_NOT_FOUND`: no such domain in this workspace.
1357
+ * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `IDEMPOTENCY_KEY_REUSE`: the `Idempotency-Key` was already used with a different body or route. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
1358
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, FROM_DOMAIN_MISMATCH, from_domain_not_verified, domain_not_verified_by_provider: `FROM_DOMAIN_MISMATCH`: the From address is not at this domain; or `from_domain_not_verified` (body `code`, `details: { fqdn, reason }`): the domain is receive-only (`reason: not_registered`) or not verified yet (`reason: not_verified`); or `domain_not_verified_by_provider`: its DNS records have been broken for over 72 h (`health: failing`). Refused before anything is recorded or queued.
1359
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 30 test sends this hour in this workspace: `RATE_LIMITED` with `details: { window, limit, retry_after }`. Per-IP limit: more than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1360
+ * @see POST /v1/workspaces/{workspace_id}/domains/{domain_id}/test-send
1361
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-domains-domain-id-test-send
1362
+ * @example
1363
+ * ```ts
1364
+ * const sendAccepted = await mail.domains.testSend("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", { to: "you@acme.com" });
1365
+ * ```
1366
+ */
1367
+ testSend(domainId, params, options) {
1368
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/domains/{domain_id}/test-send", pathParams: { domain_id: domainId }, body: params, idempotent: true }, options);
1369
+ }
1370
+ /**
1371
+ * Update domain settings: capabilities, DNS provider hint, custom MAIL FROM subdomain, DMARC recommendation.
1372
+ *
1373
+ * `intent` (or Resend's `capabilities`) changes what the domain is used for. A pending domain just changes; a verified domain gaining sending or receiving has the new records checked live and is refused with 409 `CAPABILITY_NOT_VERIFIED` (the records to publish in `details.records`) until they pass. Turning receiving off is refused while active mailboxes exist (409 `DOMAIN_HAS_MAILBOXES`, the mailboxes in `details.mailboxes`; deleted mailboxes do not count); turning sending off also turns the custom MAIL FROM off. `tls`, `open_tracking`, `click_tracking` and `tracking_subdomain` are accepted for Resend compatibility; only the values in effect today pass (422 otherwise). `dns_provider` is the provider the setup wizard renders host names for. `mail_from_subdomain` sets the custom MAIL FROM label (`bounce` → `bounce.<fqdn>`; `null` turns it off): the domain's record set gains the MAIL FROM MX + SPF records, and once the domain is verified its MAIL FROM is pointed there (the default return address stays in use until the MX record is found, so mail never stops). Refused with 409 when that host already carries records that are not ours. `dmarc_managed: false` hides the `_dmarc` recommendation for domains whose DMARC is managed elsewhere (the policy is still detected and graded).
1374
+ *
1375
+ * @param domainId - Id of the domain.
1376
+ * @param params - `Mail.DomainUpdateParams`.
1377
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
1378
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR, INVALID_CAPABILITIES, MAIL_FROM_NOT_SENDING: Validation failure on the request body; `intent` and `capabilities` disagree or enable nothing (`INVALID_CAPABILITIES`); or `mail_from_subdomain` on a receive-only domain (`MAIL_FROM_NOT_SENDING`).
1379
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1380
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1381
+ * @throws {NotFoundError} 404 NOT_FOUND: Domain not found in this workspace.
1382
+ * @throws {ConflictError} 409 CONFLICT, CAPABILITY_NOT_VERIFIED, DOMAIN_HAS_MAILBOXES, MAIL_FROM_HOST_IN_USE, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `CAPABILITY_NOT_VERIFIED`: a verified domain cannot gain sending or receiving until the new records verify (`details.failing`, `details.records`); `DOMAIN_HAS_MAILBOXES`: receiving cannot be turned off while active mailboxes exist (`details.count`, `details.mailboxes[].id|address`); `MAIL_FROM_HOST_IN_USE`: the MAIL FROM host already has a CNAME, a foreign MX or a foreign SPF record (listed in `details.found`); or `IDEMPOTENCY_KEY_REUSE`. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
1383
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, TLS_ENFORCED_NOT_AVAILABLE, TRACKING_NOT_AVAILABLE: `TLS_ENFORCED_NOT_AVAILABLE`: `tls: enforced`; `TRACKING_NOT_AVAILABLE`: open/click tracking or a tracking subdomain.
1384
+ * @throws {RateLimitError} 429 RATE_LIMITED: `mail_from_subdomain` or `intent` changed less than 10 seconds ago (`RATE_LIMITED`). Per-IP limit: more than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1385
+ * @see PATCH /v1/workspaces/{workspace_id}/domains/{domain_id}
1386
+ * @see https://productcraft.co/docs/mail/api-reference#patch-v1-workspaces-workspace-id-domains-domain-id
1387
+ * @example
1388
+ * ```ts
1389
+ * const domain = await mail.domains.update("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", { capabilities: { receiving: "enabled", sending: "enabled" } });
1390
+ * ```
1391
+ */
1392
+ update(domainId, params, options) {
1393
+ return this._client.request({ method: "PATCH", path: "/v1/workspaces/{workspace_id}/domains/{domain_id}", pathParams: { domain_id: domainId }, body: params, idempotent: true }, options);
1394
+ }
1395
+ /**
1396
+ * Run a synchronous DNS check against this domain; flips status to active when the required record set passes.
1397
+ *
1398
+ * Legacy shape, kept as an alias of `POST .../dns-records/check`: returns the domain on success and a 400 with `dns_check_results` when a required record fails. New integrations should use `POST .../dns-records/check`, which returns per-record states.
1399
+ *
1400
+ * @param domainId - Id of the domain.
1401
+ * @param options - Per-request options.
1402
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Verification failed — one or more required records are still missing or wrong.
1403
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1404
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1405
+ * @throws {NotFoundError} 404 NOT_FOUND: Domain not found in this workspace.
1406
+ * @throws {RateLimitError} 429 RATE_LIMITED: Verified less than 10 seconds ago (`RATE_LIMITED`). Per-IP limit: more than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1407
+ * @see POST /v1/workspaces/{workspace_id}/domains/{domain_id}/verify
1408
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-domains-domain-id-verify
1409
+ * @example
1410
+ * ```ts
1411
+ * const domain = await mail.domains.verify("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
1412
+ * ```
1413
+ */
1414
+ verify(domainId, options) {
1415
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/domains/{domain_id}/verify", pathParams: { domain_id: domainId } }, options);
1416
+ }
1417
+ };
1418
+ var EmailsResource = class extends APIResource {
1419
+ /**
1420
+ * Send up to 100 emails in one request
1421
+ *
1422
+ * Each row is a `POST /emails` body plus an optional `idempotency_key`, processed independently: the response reports `accepted` (with the email `id`) or `rejected` (with `error.code`) per row. An `Idempotency-Key` header covers the whole request; a row `idempotency_key` covers one row, in the same dedupe namespace (so the header must differ from every row key).
1423
+ *
1424
+ * @param params - `Mail.EmailBatchParams`.
1425
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
1426
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR, IDEMPOTENCY_KEY_CONFLICTS_WITH_ROW: Validation failure (malformed row, more than 100 rows), or `IDEMPOTENCY_KEY_CONFLICTS_WITH_ROW`: the `Idempotency-Key` header equals a row `idempotency_key`.
1427
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1428
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1429
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
1430
+ * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `IDEMPOTENCY_KEY_REUSE`: the `Idempotency-Key` was already used with a different request body or on a different route. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
1431
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, from_domain_not_verified, domain_not_verified_by_provider, INVALID_FROM_ADDRESS: For any row: `from_domain_not_verified` (body `code`, `details: { fqdn, reason }`): the domain of the From address is not itself an active sending domain of this workspace (`reason: not_registered` or `not_verified`); refused before anything is recorded or queued. Or `domain_not_verified_by_provider`: the from-domain's DNS records have been broken for over 72 h, so the email provider no longer sends for it. Or `INVALID_FROM_ADDRESS`. The whole batch is refused; no row is sent.
1432
+ * @throws {RateLimitError} 429 RATE_LIMITED: The workspace send limits never 429 a batch: a row over one is rejected in the 200 body with `RATE_LIMITED`, and the other rows are unaffected. Per-IP limit: more than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1433
+ * @see POST /v1/workspaces/{workspace_id}/emails/batch
1434
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-emails-batch
1435
+ * @example
1436
+ * ```ts
1437
+ * const sendBatchOpenApi = await mail.emails.batch({
1438
+ * emails: [{ from: "Acme <hello@mail.acme.com>", to: ["success@simulator.amazonses.com"] }],
1439
+ * });
1440
+ * ```
1441
+ */
1442
+ batch(params, options) {
1443
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/emails/batch", body: params, idempotent: true }, options);
1444
+ }
1445
+ /**
1446
+ * List emails
1447
+ *
1448
+ * One entry per email (send call), newest first, with its recipients and `last_event`, the worst status across its messages. Filter by tags with `tag[name]=value` (repeat for several; all must match). Emails sent before 2026-11-06 appear as one-recipient emails.
1449
+ *
1450
+ * @param params - `Mail.EmailListParams`.
1451
+ * @param options - Per-request options.
1452
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Invalid cursor or tag filter.
1453
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1454
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1455
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
1456
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1457
+ * @see GET /v1/workspaces/{workspace_id}/emails
1458
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-emails
1459
+ * @example
1460
+ * ```ts
1461
+ * for await (const email of mail.emails.list()) {
1462
+ * console.log(email);
1463
+ * }
1464
+ * const page = await mail.emails.list({}, { timeout: 5_000 });
1465
+ * ```
1466
+ */
1467
+ list(params, options) {
1468
+ return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/emails", query: params }, options);
1469
+ }
1470
+ /**
1471
+ * Email metrics for a workspace
1472
+ *
1473
+ * Outbound email counts and rates over a range of up to 30 days, in hourly or daily buckets in your time zone, optionally per sending domain, filtered by domain, API key or source. Read-only.
1474
+ *
1475
+ * - **Emails** (`sent`): messages that left the queue.
1476
+ * - **Deliverability rate**: delivered / emails sent with delivery tracking. Emails sent before delivery tracking started, or through a custom SMTP relay, are confirmed at hand-off only, so for them `delivered` is not measured and the rate is `null` (`measured.delivery = false`), never 0.
1477
+ * - **Bounce rate**: bounced / emails. Suppressed recipients never count.
1478
+ * - **Complaint rate**: complained / delivered, from mailbox providers' feedback loops.
1479
+ *
1480
+ * Rates are numbers from 0 to 1, or `null` when unmeasured or when the denominator is zero. Template test sends are excluded. Cached for up to 60 seconds.
1481
+ *
1482
+ * @param params - `Mail.EmailMetricsParams`.
1483
+ * @param options - Per-request options.
1484
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A parameter is invalid: `domain_id` or `api_key_id` is not a UUID; more than 100 `domain_id`; an unknown `timezone`, `granularity`, `source` or dimension; a date that does not parse; `end_date` not after `start_date`; a range longer than 30 days or starting before the 30-day retention; or `granularity=hourly` over more than 7 days. The reason is in `message`.
1485
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: No valid credential.
1486
+ * @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED: Caller lacks `mail.message.read` on the workspace (including non-members), or Mail is not enabled on it (`SERVICE_NOT_ENABLED`).
1487
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403.
1488
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1489
+ * @see GET /v1/workspaces/{workspace_id}/emails/metrics
1490
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-emails-metrics
1491
+ * @example
1492
+ * ```ts
1493
+ * const emailMetrics = await mail.emails.metrics();
1494
+ * ```
1495
+ */
1496
+ metrics(params, options) {
1497
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/emails/metrics", query: params }, options);
1498
+ }
1499
+ /**
1500
+ * Retrieve an email
1501
+ *
1502
+ * The email as sent (from, to, cc, bcc, reply_to, subject, tags, custom headers) with one entry per recipient message and `last_event`, the worst status across them. Bodies are on `GET /messages/{id}/body`.
1503
+ *
1504
+ * @param id - Id of the email.
1505
+ * @param options - Per-request options.
1506
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
1507
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1508
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1509
+ * @throws {NotFoundError} 404 NOT_FOUND, EMAIL_NOT_FOUND: `EMAIL_NOT_FOUND`: no email with this id in this workspace.
1510
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1511
+ * @see GET /v1/workspaces/{workspace_id}/emails/{id}
1512
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-emails-id
1513
+ * @example
1514
+ * ```ts
1515
+ * const emailDetail = await mail.emails.retrieve("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
1516
+ * ```
1517
+ */
1518
+ retrieve(id, options) {
1519
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/emails/{id}", pathParams: { id } }, options);
1520
+ }
1521
+ /**
1522
+ * Send an email
1523
+ *
1524
+ * Send your own `html` and/or `text`, or a saved `template`, to up to 50 recipients across `to`, `cc` and `bcc`, with `reply_to`, custom `headers` and `tags`. Every recipient gets its own copy (its own message in `GET /messages`, suppression check and delivery status) showing the same `To` and `Cc` headers; `bcc` recipients appear in no header. A recipient on the suppression list (or unsubscribed, for a template with an unsubscribe link) is left out with a `suppressed` message, and the email is still accepted. Counts one send per recipient against the workspace limits. Pass an `Idempotency-Key` header to make retries safe.
1525
+ *
1526
+ * @param params - `Mail.EmailSendParams`.
1527
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
1528
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR, EMAIL_CONTENT_CONFLICT, RECIPIENT_LIMIT, MAIL_HEADER_NOT_ALLOWED: Validation failure; `EMAIL_CONTENT_CONFLICT` (both or neither of `html`/`text` and `template`); `RECIPIENT_LIMIT` (more than 50 recipients); `MAIL_HEADER_NOT_ALLOWED` (`details.headers` names the refused headers).
1529
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1530
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1531
+ * @throws {NotFoundError} 404 NOT_FOUND, TEMPLATE_NOT_FOUND: `TEMPLATE_NOT_FOUND`: the `template.name` is not a template of this workspace.
1532
+ * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `IDEMPOTENCY_KEY_REUSE`: the `Idempotency-Key` was already used with a different request body or on a different route. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
1533
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, from_domain_not_verified, domain_not_verified_by_provider, INVALID_FROM_ADDRESS, TEMPLATE_RENDER_FAILED, TEMPLATE_DATA_INVALID: `from_domain_not_verified` (body `code`, `details: { fqdn, reason }`): the domain of the From address is not itself an active sending domain of this workspace (`reason: not_registered` or `not_verified`); refused before anything is recorded or queued. Or `domain_not_verified_by_provider`: the from-domain's DNS records have been broken for over 72 h, so the email provider no longer sends for it. Or `INVALID_FROM_ADDRESS`. Or `TEMPLATE_RENDER_FAILED` / `TEMPLATE_DATA_INVALID` for a template send.
1534
+ * @throws {RateLimitError} 429 RATE_LIMITED: Over a workspace send limit (60 per minute, 600 per hour, 10,000 per day; each recipient counts): `RATE_LIMITED` with `details: { window, limit, retry_after }`. Nothing is recorded or queued. Per-IP limit: more than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1535
+ * @see POST /v1/workspaces/{workspace_id}/emails
1536
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-emails
1537
+ * @example
1538
+ * ```ts
1539
+ * const sendEmail = await mail.emails.send({ from: "Acme <hello@mail.acme.com>", to: ["success@simulator.amazonses.com"] });
1540
+ * ```
1541
+ */
1542
+ send(params, options) {
1543
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/emails", body: params, idempotent: true }, options);
1544
+ }
1545
+ };
1546
+ var IntegrationsGithubReposBranchesResource = class extends APIResource {
1547
+ /**
1548
+ * List branches for the given repo.
1549
+ *
1550
+ * @param owner - Owner (user or organisation) of the GitHub repository.
1551
+ * @param repo - Name of the GitHub repository.
1552
+ * @param options - Per-request options.
1553
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
1554
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1555
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1556
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
1557
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1558
+ * @see GET /v1/workspaces/{workspace_id}/integrations/github/repos/{owner}/{repo}/branches
1559
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-integrations-github-repos-owner-repo-branches
1560
+ * @example
1561
+ * ```ts
1562
+ * const result = await mail.integrations.github.repos.branches.list("owner", "repo");
1563
+ * ```
1564
+ */
1565
+ list(owner, repo, options) {
1566
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/integrations/github/repos/{owner}/{repo}/branches", pathParams: { owner, repo } }, options);
1567
+ }
1568
+ };
1569
+ var IntegrationsGithubReposResource = class extends APIResource {
1570
+ #branches;
1571
+ get branches() {
1572
+ return this.#branches ??= new IntegrationsGithubReposBranchesResource(this._client, this._b);
1573
+ }
1574
+ /**
1575
+ * List repos visible to the connected GitHub account.
1576
+ *
1577
+ * @param options - Per-request options.
1578
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
1579
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1580
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1581
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
1582
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1583
+ * @see GET /v1/workspaces/{workspace_id}/integrations/github/repos
1584
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-integrations-github-repos
1585
+ * @example
1586
+ * ```ts
1587
+ * const result = await mail.integrations.github.repos.list();
1588
+ * ```
1589
+ */
1590
+ list(options) {
1591
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/integrations/github/repos" }, options);
1592
+ }
1593
+ };
1594
+ var IntegrationsGithubSettingsResource = class extends APIResource {
1595
+ /**
1596
+ * Set the repo + branch + templates path to sync from.
1597
+ *
1598
+ * @param params - `Mail.IntegrationGithubSettingsUpdateParams`.
1599
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
1600
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
1601
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1602
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1603
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
1604
+ * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `IDEMPOTENCY_KEY_REUSE`: the `Idempotency-Key` was already used with a different request body or on a different route. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
1605
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1606
+ * @see PUT /v1/workspaces/{workspace_id}/integrations/github/settings
1607
+ * @see https://productcraft.co/docs/mail/api-reference#put-v1-workspaces-workspace-id-integrations-github-settings
1608
+ * @example
1609
+ * ```ts
1610
+ * await mail.integrations.github.settings.update({ branch: "main", repo_full_name: "octocat/templates", templates_path: "/" });
1611
+ * ```
1612
+ */
1613
+ update(params, options) {
1614
+ return this._client.request({ method: "PUT", path: "/v1/workspaces/{workspace_id}/integrations/github/settings", body: params, idempotent: true }, options);
1615
+ }
1616
+ };
1617
+ var IntegrationsGithubSyncResource = class extends APIResource {
1618
+ /**
1619
+ * Trigger an immediate sync from GitHub. Returns a sync id to poll.
1620
+ *
1621
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
1622
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
1623
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1624
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1625
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
1626
+ * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `IDEMPOTENCY_KEY_REUSE`: the `Idempotency-Key` was already used with a different request body or on a different route. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
1627
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1628
+ * @see POST /v1/workspaces/{workspace_id}/integrations/github/sync
1629
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-integrations-github-sync
1630
+ * @example
1631
+ * ```ts
1632
+ * const startSync = await mail.integrations.github.sync.create();
1633
+ * ```
1634
+ */
1635
+ create(options) {
1636
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/integrations/github/sync", idempotent: true }, options);
1637
+ }
1638
+ /**
1639
+ * Poll a sync run's status.
1640
+ *
1641
+ * @param syncId - Id of the sync.
1642
+ * @param options - Per-request options.
1643
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
1644
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1645
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1646
+ * @throws {NotFoundError} 404 NOT_FOUND: Run not found or expired.
1647
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1648
+ * @see GET /v1/workspaces/{workspace_id}/integrations/github/sync/{sync_id}
1649
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-integrations-github-sync-sync-id
1650
+ * @example
1651
+ * ```ts
1652
+ * const syncStatus = await mail.integrations.github.sync.retrieve("sync");
1653
+ * ```
1654
+ */
1655
+ retrieve(syncId, options) {
1656
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/integrations/github/sync/{sync_id}", pathParams: { sync_id: syncId } }, options);
1657
+ }
1658
+ };
1659
+ var IntegrationsGithubResource = class extends APIResource {
1660
+ #repos;
1661
+ #settings;
1662
+ #sync;
1663
+ get repos() {
1664
+ return this.#repos ??= new IntegrationsGithubReposResource(this._client, this._b);
1665
+ }
1666
+ get settings() {
1667
+ return this.#settings ??= new IntegrationsGithubSettingsResource(this._client, this._b);
1668
+ }
1669
+ get sync() {
1670
+ return this.#sync ??= new IntegrationsGithubSyncResource(this._client, this._b);
1671
+ }
1672
+ /**
1673
+ * Mint a GitHub OAuth state token and return the authorize URL.
1674
+ *
1675
+ * The frontend redirects the user to `authorize_url`; GitHub bounces back to the `/callback` endpoint with a `code` + `state` pair. state is single-use, 5-minute TTL.
1676
+ *
1677
+ * @param params - `Mail.IntegrationGithubConnectParams`.
1678
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
1679
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
1680
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1681
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1682
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
1683
+ * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `IDEMPOTENCY_KEY_REUSE`: the `Idempotency-Key` was already used with a different request body or on a different route. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
1684
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1685
+ * @see POST /v1/workspaces/{workspace_id}/integrations/github/connect
1686
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-integrations-github-connect
1687
+ * @example
1688
+ * ```ts
1689
+ * const connectGitHub = await mail.integrations.github.connect({ return_to: "https://console.productcraft.co/mail/workspaces/acme/integrations" });
1690
+ * ```
1691
+ */
1692
+ connect(params, options) {
1693
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/integrations/github/connect", body: params, idempotent: true }, options);
1694
+ }
1695
+ };
1696
+ var IntegrationsResource = class extends APIResource {
1697
+ #github;
1698
+ get github() {
1699
+ return this.#github ??= new IntegrationsGithubResource(this._client, this._b);
1700
+ }
1701
+ /**
1702
+ * Disconnect an integration. Deletes the credential row.
1703
+ *
1704
+ * Hard delete — the encrypted blob is removed. The customer must reconnect via the provider-specific OAuth flow to restore access.
1705
+ *
1706
+ * @param provider - The integration provider (`github`).
1707
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
1708
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
1709
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1710
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1711
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
1712
+ * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `IDEMPOTENCY_KEY_REUSE`: the `Idempotency-Key` was already used with a different request body or on a different route. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
1713
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1714
+ * @see DELETE /v1/workspaces/{workspace_id}/integrations/{provider}
1715
+ * @see https://productcraft.co/docs/mail/api-reference#delete-v1-workspaces-workspace-id-integrations-provider
1716
+ * @example
1717
+ * ```ts
1718
+ * await mail.integrations.delete("provider");
1719
+ * ```
1720
+ */
1721
+ delete(provider, options) {
1722
+ return this._client.request({ method: "DELETE", path: "/v1/workspaces/{workspace_id}/integrations/{provider}", pathParams: { provider }, idempotent: true }, options);
1723
+ }
1724
+ /**
1725
+ * List connected workspace integrations.
1726
+ *
1727
+ * Returns one entry per connected provider (GitHub, …). No secrets in the response — only public identifiers + status + sync stamps.
1728
+ *
1729
+ * @param options - Per-request options.
1730
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
1731
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1732
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1733
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
1734
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1735
+ * @see GET /v1/workspaces/{workspace_id}/integrations
1736
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-integrations
1737
+ * @example
1738
+ * ```ts
1739
+ * const listIntegrations = await mail.integrations.list();
1740
+ * ```
1741
+ */
1742
+ list(options) {
1743
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/integrations" }, options);
1744
+ }
1745
+ /**
1746
+ * Get a single integration detail with redacted credentials.
1747
+ *
1748
+ * Includes the provider's `credentials_redacted` view. Secret fields (access tokens, signing keys) are never included.
1749
+ *
1750
+ * @param provider - The integration provider (`github`).
1751
+ * @param options - Per-request options.
1752
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
1753
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1754
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1755
+ * @throws {NotFoundError} 404 NOT_FOUND: No integration of the requested provider for this workspace.
1756
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1757
+ * @see GET /v1/workspaces/{workspace_id}/integrations/{provider}
1758
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-integrations-provider
1759
+ * @example
1760
+ * ```ts
1761
+ * const integrationDetail = await mail.integrations.retrieve("provider");
1762
+ * ```
1763
+ */
1764
+ retrieve(provider, options) {
1765
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/integrations/{provider}", pathParams: { provider } }, options);
1766
+ }
1767
+ };
1768
+ var MailboxesMessagesAttachmentsResource = class extends APIResource {
1769
+ /**
1770
+ * Stream a single attachment by its position. Gated by `mail.message.body.read`: an attachment is message content, and /:mid already names it without handing over the bytes.
1771
+ *
1772
+ * @param id - Id of the mailboxe.
1773
+ * @param mid - Id of the message in the mailbox.
1774
+ * @param position - Position of the attachment in the message, starting at 0.
1775
+ * @param options - Per-request options.
1776
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
1777
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1778
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: Policy denies `mail.message.body.read`.
1779
+ * @throws {NotFoundError} 404 NOT_FOUND: Attachment not found
1780
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1781
+ * @see GET /v1/workspaces/{workspace_id}/mailboxes/{id}/messages/{mid}/attachments/{position}
1782
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-mailboxes-id-messages-mid-attachments-position
1783
+ * @example
1784
+ * ```ts
1785
+ * const response = await mail.mailboxes.messages.attachments.retrieve("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", "5d1e2f3a-4b5c-4d6e-8f70-8192a3b4c5d6", "position");
1786
+ * const text = await response.text();
1787
+ * ```
1788
+ */
1789
+ retrieve(id, mid, position, options) {
1790
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/mailboxes/{id}/messages/{mid}/attachments/{position}", pathParams: { id, mid, position }, raw: true }, options);
1791
+ }
1792
+ };
1793
+ var MailboxesMessagesResource = class extends APIResource {
1794
+ #attachments;
1795
+ get attachments() {
1796
+ return this.#attachments ??= new MailboxesMessagesAttachmentsResource(this._client, this._b);
1797
+ }
1798
+ /**
1799
+ * Soft-delete a message
1800
+ *
1801
+ * @param id - Id of the mailboxe.
1802
+ * @param mid - Id of the message in the mailbox.
1803
+ * @param options - Per-request options.
1804
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
1805
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1806
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1807
+ * @throws {NotFoundError} 404 NOT_FOUND: Message not found
1808
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1809
+ * @see DELETE /v1/workspaces/{workspace_id}/mailboxes/{id}/messages/{mid}
1810
+ * @see https://productcraft.co/docs/mail/api-reference#delete-v1-workspaces-workspace-id-mailboxes-id-messages-mid
1811
+ * @example
1812
+ * ```ts
1813
+ * await mail.mailboxes.messages.delete("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", "5d1e2f3a-4b5c-4d6e-8f70-8192a3b4c5d6");
1814
+ * ```
1815
+ */
1816
+ delete(id, mid, options) {
1817
+ return this._client.request({ method: "DELETE", path: "/v1/workspaces/{workspace_id}/mailboxes/{id}/messages/{mid}", pathParams: { id, mid } }, options);
1818
+ }
1819
+ /**
1820
+ * List messages in a mailbox
1821
+ *
1822
+ * @param id - Id of the mailboxe.
1823
+ * @param params - `Mail.MailboxMessageListParams`.
1824
+ * @param options - Per-request options.
1825
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Invalid filter or cursor.
1826
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1827
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1828
+ * @throws {NotFoundError} 404 NOT_FOUND: Mailbox not found in this workspace.
1829
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1830
+ * @see GET /v1/workspaces/{workspace_id}/mailboxes/{id}/messages
1831
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-mailboxes-id-messages
1832
+ * @example
1833
+ * ```ts
1834
+ * for await (const message of mail.mailboxes.messages.list("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b")) {
1835
+ * console.log(message);
1836
+ * }
1837
+ * const page = await mail.mailboxes.messages.list("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", {}, { timeout: 5_000 });
1838
+ * ```
1839
+ */
1840
+ list(id, params, options) {
1841
+ return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/mailboxes/{id}/messages", pathParams: { id }, query: params }, options);
1842
+ }
1843
+ /**
1844
+ * Stream the raw RFC5322 .eml for a message. Gated by `mail.message.body.read` (admin+ by default; not granted to plain members) — the outbound lane's /messages/:id/body action.
1845
+ *
1846
+ * @param id - Id of the mailboxe.
1847
+ * @param mid - Id of the message in the mailbox.
1848
+ * @param options - Per-request options.
1849
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
1850
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1851
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: Policy denies `mail.message.body.read`.
1852
+ * @throws {NotFoundError} 404 NOT_FOUND: Message not found
1853
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1854
+ * @see GET /v1/workspaces/{workspace_id}/mailboxes/{id}/messages/{mid}/raw
1855
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-mailboxes-id-messages-mid-raw
1856
+ * @example
1857
+ * ```ts
1858
+ * const response = await mail.mailboxes.messages.raw("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", "5d1e2f3a-4b5c-4d6e-8f70-8192a3b4c5d6");
1859
+ * const text = await response.text();
1860
+ * ```
1861
+ */
1862
+ raw(id, mid, options) {
1863
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/mailboxes/{id}/messages/{mid}/raw", pathParams: { id, mid }, raw: true }, options);
1864
+ }
1865
+ /**
1866
+ * Mark a message as read
1867
+ *
1868
+ * @param id - Id of the mailboxe.
1869
+ * @param mid - Id of the message in the mailbox.
1870
+ * @param options - Per-request options.
1871
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
1872
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1873
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1874
+ * @throws {NotFoundError} 404 NOT_FOUND: Message not found
1875
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1876
+ * @see POST /v1/workspaces/{workspace_id}/mailboxes/{id}/messages/{mid}/read
1877
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-mailboxes-id-messages-mid-read
1878
+ * @example
1879
+ * ```ts
1880
+ * await mail.mailboxes.messages.read("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", "5d1e2f3a-4b5c-4d6e-8f70-8192a3b4c5d6");
1881
+ * ```
1882
+ */
1883
+ read(id, mid, options) {
1884
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/mailboxes/{id}/messages/{mid}/read", pathParams: { id, mid } }, options);
1885
+ }
1886
+ /**
1887
+ * Get a single message (metadata + attachment manifest; `body_preview` is null without `mail.message.body.read`). Use /:mid/raw for content.
1888
+ *
1889
+ * @param id - Id of the mailboxe.
1890
+ * @param mid - Id of the message in the mailbox.
1891
+ * @param options - Per-request options.
1892
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
1893
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1894
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1895
+ * @throws {NotFoundError} 404 NOT_FOUND: Message not found
1896
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1897
+ * @see GET /v1/workspaces/{workspace_id}/mailboxes/{id}/messages/{mid}
1898
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-mailboxes-id-messages-mid
1899
+ * @example
1900
+ * ```ts
1901
+ * const messageDetail = await mail.mailboxes.messages.retrieve("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", "5d1e2f3a-4b5c-4d6e-8f70-8192a3b4c5d6");
1902
+ * ```
1903
+ */
1904
+ retrieve(id, mid, options) {
1905
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/mailboxes/{id}/messages/{mid}", pathParams: { id, mid } }, options);
1906
+ }
1907
+ };
1908
+ var MailboxesResource = class extends APIResource {
1909
+ #messages;
1910
+ get messages() {
1911
+ return this.#messages ??= new MailboxesMessagesResource(this._client, this._b);
1912
+ }
1913
+ /**
1914
+ * Create a mailbox under a verified domain. Local-part + domain combination must be globally unique.
1915
+ *
1916
+ * @param params - `Mail.MailboxCreateParams`.
1917
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
1918
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Validation failure (invalid local part, retention out of range).
1919
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1920
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: Caller lacks `mail.create` permission, or workspace has not enabled the `mail` service.
1921
+ * @throws {NotFoundError} 404 NOT_FOUND: Domain not found in this workspace.
1922
+ * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: Mailbox local-part already exists on this domain, or the domain is not yet verified, or `IDEMPOTENCY_KEY_REUSE`: the `Idempotency-Key` was already used with a different body or route. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
1923
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY: Local part or retention rejected by service-layer validation.
1924
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1925
+ * @see POST /v1/workspaces/{workspace_id}/mailboxes
1926
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-mailboxes
1927
+ * @example
1928
+ * ```ts
1929
+ * const mailbox = await mail.mailboxes.create({ domain_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b", local_part: "claude-qa-alpha" });
1930
+ * ```
1931
+ */
1932
+ create(params, options) {
1933
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/mailboxes", body: params, idempotent: true }, options);
1934
+ }
1935
+ /**
1936
+ * Soft-delete a mailbox: its status becomes `disabled` and it stops accepting new mail; existing messages are kept until retention purges them, and `PATCH` with `status: active` restores it. A deleted mailbox no longer blocks deleting its domain, and deleting the domain erases it and its remaining mail.
1937
+ *
1938
+ * @param id - Id of the mailboxe.
1939
+ * @param options - Per-request options.
1940
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
1941
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1942
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1943
+ * @throws {NotFoundError} 404 NOT_FOUND: Mailbox not found in this workspace.
1944
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1945
+ * @see DELETE /v1/workspaces/{workspace_id}/mailboxes/{id}
1946
+ * @see https://productcraft.co/docs/mail/api-reference#delete-v1-workspaces-workspace-id-mailboxes-id
1947
+ * @example
1948
+ * ```ts
1949
+ * await mail.mailboxes.delete("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
1950
+ * ```
1951
+ */
1952
+ delete(id, options) {
1953
+ return this._client.request({ method: "DELETE", path: "/v1/workspaces/{workspace_id}/mailboxes/{id}", pathParams: { id } }, options);
1954
+ }
1955
+ /**
1956
+ * List mailboxes in this workspace. 20 per page by default (max 200) — paginate with the cursor returned in `pagination.next_cursor` while `pagination.has_more` is true.
1957
+ *
1958
+ * @param params - `Mail.MailboxListParams`.
1959
+ * @param options - Per-request options.
1960
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
1961
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1962
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: Caller lacks `mail.read` permission, or workspace has not enabled the `mail` service.
1963
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
1964
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1965
+ * @see GET /v1/workspaces/{workspace_id}/mailboxes
1966
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-mailboxes
1967
+ * @example
1968
+ * ```ts
1969
+ * for await (const mailbox of mail.mailboxes.list()) {
1970
+ * console.log(mailbox);
1971
+ * }
1972
+ * const page = await mail.mailboxes.list({}, { timeout: 5_000 });
1973
+ * ```
1974
+ */
1975
+ list(params, options) {
1976
+ return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/mailboxes", query: params }, options);
1977
+ }
1978
+ /**
1979
+ * Get one mailbox by id.
1980
+ *
1981
+ * @param id - Id of the mailboxe.
1982
+ * @param options - Per-request options.
1983
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
1984
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
1985
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
1986
+ * @throws {NotFoundError} 404 NOT_FOUND: Mailbox not found in this workspace.
1987
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
1988
+ * @see GET /v1/workspaces/{workspace_id}/mailboxes/{id}
1989
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-mailboxes-id
1990
+ * @example
1991
+ * ```ts
1992
+ * const mailbox = await mail.mailboxes.retrieve("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
1993
+ * ```
1994
+ */
1995
+ retrieve(id, options) {
1996
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/mailboxes/{id}", pathParams: { id } }, options);
1997
+ }
1998
+ /**
1999
+ * Update mailbox display name, retention, or status. Status transitions are restricted (active ↔ suspended; archived is terminal).
2000
+ *
2001
+ * @param id - Id of the mailboxe.
2002
+ * @param params - `Mail.MailboxUpdateParams`.
2003
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
2004
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Validation failure or invalid status transition.
2005
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2006
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2007
+ * @throws {NotFoundError} 404 NOT_FOUND: Mailbox not found in this workspace.
2008
+ * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `IDEMPOTENCY_KEY_REUSE`: the `Idempotency-Key` was already used with a different request body or on a different route. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
2009
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY: Retention or status rejected by service-layer validation.
2010
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2011
+ * @see PATCH /v1/workspaces/{workspace_id}/mailboxes/{id}
2012
+ * @see https://productcraft.co/docs/mail/api-reference#patch-v1-workspaces-workspace-id-mailboxes-id
2013
+ * @example
2014
+ * ```ts
2015
+ * const mailbox = await mail.mailboxes.update("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", { display_name: "string" });
2016
+ * ```
2017
+ */
2018
+ update(id, params, options) {
2019
+ return this._client.request({ method: "PATCH", path: "/v1/workspaces/{workspace_id}/mailboxes/{id}", pathParams: { id }, body: params, idempotent: true }, options);
2020
+ }
2021
+ };
2022
+ var MessagesSettingsResource = class extends APIResource {
2023
+ /**
2024
+ * Read this workspace's outbound-message settings. Absent → defaults (redact_bodies: false).
2025
+ *
2026
+ * @param options - Per-request options.
2027
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
2028
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2029
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2030
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
2031
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2032
+ * @see GET /v1/workspaces/{workspace_id}/messages/settings
2033
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-messages-settings
2034
+ * @example
2035
+ * ```ts
2036
+ * const outboundMessageSettings = await mail.messages.settings.retrieve();
2037
+ * ```
2038
+ */
2039
+ retrieve(options) {
2040
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/messages/settings" }, options);
2041
+ }
2042
+ /**
2043
+ * Update this workspace's outbound-message settings. Gated on `mail.message.delete` — same privilege bar as RTBF, since both touch the PII boundary.
2044
+ *
2045
+ * @param params - `Mail.MessageSettingsUpdateParams`.
2046
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
2047
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Invalid payload.
2048
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2049
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2050
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
2051
+ * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `IDEMPOTENCY_KEY_REUSE`: the `Idempotency-Key` was already used with a different request body or on a different route. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
2052
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2053
+ * @see PATCH /v1/workspaces/{workspace_id}/messages/settings
2054
+ * @see https://productcraft.co/docs/mail/api-reference#patch-v1-workspaces-workspace-id-messages-settings
2055
+ * @example
2056
+ * ```ts
2057
+ * const outboundMessageSettings = await mail.messages.settings.update({ redact_bodies: true });
2058
+ * ```
2059
+ */
2060
+ update(params, options) {
2061
+ return this._client.request({ method: "PATCH", path: "/v1/workspaces/{workspace_id}/messages/settings", body: params, idempotent: true }, options);
2062
+ }
2063
+ };
2064
+ var MessagesResource = class extends APIResource {
2065
+ #settings;
2066
+ get settings() {
2067
+ return this.#settings ??= new MessagesSettingsResource(this._client, this._b);
2068
+ }
2069
+ /**
2070
+ * Get the cleartext body of an outbound message. Gated by `mail.message.body.read` (admin+ by default; not granted to plain members).
2071
+ *
2072
+ * @param id - Id of the message.
2073
+ * @param options - Per-request options.
2074
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
2075
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2076
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2077
+ * @throws {NotFoundError} 404 NOT_FOUND: Not found.
2078
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2079
+ * @see GET /v1/workspaces/{workspace_id}/messages/{id}/body
2080
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-messages-id-body
2081
+ * @example
2082
+ * ```ts
2083
+ * const outboundMessageWithBody = await mail.messages.body("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
2084
+ * ```
2085
+ */
2086
+ body(id, options) {
2087
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/messages/{id}/body", pathParams: { id } }, options);
2088
+ }
2089
+ /**
2090
+ * RTBF: delete every message log row for `recipient` (case-insensitive). Returns the deleted-row count.
2091
+ *
2092
+ * The bulk GDPR erase (`messages.erase` in the SDKs): removes every delivery-log row sent to one recipient address in this workspace (with its stored body and events), and strips the address from the cc, bcc and reply-to lists of other rows, in one transaction. Repeating it is harmless (the second call deletes 0 rows).
2093
+ *
2094
+ * @param params - `Mail.MessageEraseParams`.
2095
+ * @param options - Per-request options.
2096
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Missing or invalid recipient.
2097
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2098
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2099
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
2100
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2101
+ * @see DELETE /v1/workspaces/{workspace_id}/messages
2102
+ * @see https://productcraft.co/docs/mail/api-reference#delete-v1-workspaces-workspace-id-messages
2103
+ * @example
2104
+ * ```ts
2105
+ * const deleteByRecipient = await mail.messages.erase({ recipient: "ada@example.com" });
2106
+ * ```
2107
+ */
2108
+ erase(params, options) {
2109
+ return this._client.request({ method: "DELETE", path: "/v1/workspaces/{workspace_id}/messages", query: params }, options);
2110
+ }
2111
+ /**
2112
+ * Stream the filtered message log as CSV. Same filters as GET /messages. Body columns are intentionally omitted; bodies remain gated by `mail.message.body.read`. Rate-limited 1 concurrent + 5/hour per workspace.
2113
+ *
2114
+ * Columns: id, created_at, sent_at, delivered_at, deferred_at, deferral_count, from_address, to_address, subject, template_name, status, spf_result, dkim_result, dmarc_result, bounce_code, bounce_detail, api_key_id, source, domain. The filters are resolved by the same code as `GET /messages`, so the same query string exports exactly the rows the list pages through. A rejected filter (400) does not count against the hourly cap.
2115
+ *
2116
+ * @param params - `Mail.MessageExportParams`.
2117
+ * @param options - Per-request options.
2118
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Invalid filter: an unknown status or source, a malformed uuid or date-time, `q` over 200 characters, `created_after` not earlier than `created_before`, or a window wider than 30 days. The reason is in `message`.
2119
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2120
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2121
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
2122
+ * @throws {RateLimitError} 429 RATE_LIMITED: Another export is already running, or this workspace has hit the hourly export cap. Per-IP limit: more than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2123
+ * @see GET /v1/workspaces/{workspace_id}/messages/export
2124
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-messages-export
2125
+ * @example
2126
+ * ```ts
2127
+ * const response = await mail.messages.export();
2128
+ * const text = await response.text();
2129
+ * ```
2130
+ */
2131
+ export(params, options) {
2132
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/messages/export", query: params, raw: true }, options);
2133
+ }
2134
+ /**
2135
+ * List outbound messages with cursor pagination
2136
+ *
2137
+ * One row per recipient delivery, newest first. Filters combine with AND: `q` (free text over recipient, from, subject, message id and Message-ID), `status` (any of, repeatable), `domain_id`, `api_key_id`, `source`, `template`, `created_after` / `created_before` (at most 30 days apart), plus the legacy `recipient` and `subject_contains`. `GET /messages/export` takes exactly the same filters and returns the same rows.
2138
+ *
2139
+ * @param params - `Mail.MessageListParams`.
2140
+ * @param options - Per-request options.
2141
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Invalid filter or cursor: an unknown status or source, a malformed uuid or date-time, `q` over 200 characters, `created_after` not earlier than `created_before`, or a window wider than 30 days. The reason is in `message`.
2142
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2143
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2144
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
2145
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2146
+ * @see GET /v1/workspaces/{workspace_id}/messages
2147
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-messages
2148
+ * @example
2149
+ * ```ts
2150
+ * for await (const message of mail.messages.list()) {
2151
+ * console.log(message);
2152
+ * }
2153
+ * const page = await mail.messages.list({}, { timeout: 5_000 });
2154
+ * ```
2155
+ */
2156
+ list(params, options) {
2157
+ return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/messages", query: params }, options);
2158
+ }
2159
+ /**
2160
+ * Get a single outbound message (metadata + delivery verdicts; body not included) with its event timeline: `events[]` oldest first, `last_event`, `transport`, `bounce_type`, `bounce_subtype`. Use /:id/body for cleartext content.
2161
+ *
2162
+ * @param id - Id of the message.
2163
+ * @param options - Per-request options.
2164
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
2165
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2166
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2167
+ * @throws {NotFoundError} 404 NOT_FOUND: Not found.
2168
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2169
+ * @see GET /v1/workspaces/{workspace_id}/messages/{id}
2170
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-messages-id
2171
+ * @example
2172
+ * ```ts
2173
+ * const outboundMessageDetail = await mail.messages.retrieve("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
2174
+ * ```
2175
+ */
2176
+ retrieve(id, options) {
2177
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/messages/{id}", pathParams: { id } }, options);
2178
+ }
2179
+ /**
2180
+ * Day-bucketed inbound message volume for a workspace
2181
+ *
2182
+ * Counts INBOUND mail only: messages received by the workspace's mailboxes, in dense day buckets in [since, until). `metric=sent` (default, a historical name) counts received messages, not outbound sends; `metric=bounced` counts MX-time rejections matched to this workspace by envelope-to. For outbound counts and rates use `GET /emails/metrics`.
2183
+ *
2184
+ * @param params - `Mail.MessageTimelineParams`.
2185
+ * @param options - Per-request options.
2186
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
2187
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2188
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2189
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
2190
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2191
+ * @see GET /v1/workspaces/{workspace_id}/messages/timeline
2192
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-messages-timeline
2193
+ * @example
2194
+ * ```ts
2195
+ * const messageTimeline = await mail.messages.timeline({ granularity: "day", since: "2026-04-01T00:00:00Z", until: "2026-05-01T00:00:00Z" });
2196
+ * ```
2197
+ */
2198
+ timeline(params, options) {
2199
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/messages/timeline", query: params }, options);
2200
+ }
2201
+ };
2202
+ var ReceivedAttachmentsResource = class extends APIResource {
2203
+ /**
2204
+ * Download one attachment of a received email
2205
+ *
2206
+ * By its `position` from the detail's attachment manifest. Unscanned, untrusted bytes from a third party. Gated by `mail.message.body.read`.
2207
+ *
2208
+ * @param id - Received email id.
2209
+ * @param position - Attachment position (0-based).
2210
+ * @param options - Per-request options.
2211
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `id` is not a uuid or `position` is not an integer.
2212
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2213
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The policy does not grant `mail.message.body.read`.
2214
+ * @throws {NotFoundError} 404 NOT_FOUND: No such email in this workspace, or no attachment at that position.
2215
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2216
+ * @see GET /v1/workspaces/{workspace_id}/received/{id}/attachments/{position}
2217
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-received-id-attachments-position
2218
+ * @example
2219
+ * ```ts
2220
+ * const response = await mail.received.attachments.retrieve("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", "position");
2221
+ * const text = await response.text();
2222
+ * ```
2223
+ */
2224
+ retrieve(id, position, options) {
2225
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/received/{id}/attachments/{position}", pathParams: { id, position }, raw: true }, options);
2226
+ }
2227
+ };
2228
+ var ReceivedResource = class extends APIResource {
2229
+ #attachments;
2230
+ get attachments() {
2231
+ return this.#attachments ??= new ReceivedAttachmentsResource(this._client, this._b);
2232
+ }
2233
+ /**
2234
+ * Delete a received email
2235
+ *
2236
+ * Soft delete: it disappears from every list at once; retention purges the stored message later.
2237
+ *
2238
+ * @param id - Received email id.
2239
+ * @param options - Per-request options.
2240
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `id` is not a uuid.
2241
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2242
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The policy does not grant `mail.delete` on every mailbox.
2243
+ * @throws {NotFoundError} 404 NOT_FOUND: No such email in this workspace (or it was already deleted).
2244
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2245
+ * @see DELETE /v1/workspaces/{workspace_id}/received/{id}
2246
+ * @see https://productcraft.co/docs/mail/api-reference#delete-v1-workspaces-workspace-id-received-id
2247
+ * @example
2248
+ * ```ts
2249
+ * await mail.received.delete("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
2250
+ * ```
2251
+ */
2252
+ delete(id, options) {
2253
+ return this._client.request({ method: "DELETE", path: "/v1/workspaces/{workspace_id}/received/{id}", pathParams: { id } }, options);
2254
+ }
2255
+ /**
2256
+ * Stream the filtered received email as CSV. Same filters as GET /received. Rate-limited 1 concurrent + 5/hour per workspace.
2257
+ *
2258
+ * Columns: id, received_at, mailbox, from, to (`; `-separated), subject, spam_verdict, spf, dkim, dmarc, size_bytes, attachments (count). No body content. A cell starting with `=`, `+`, `-` or `@` is prefixed with `'` so a spreadsheet does not run it as a formula. A rejected filter (400) does not count against the hourly cap, which is separate from the sent-email export's.
2259
+ *
2260
+ * @param params - `Mail.ReceivedExportParams`.
2261
+ * @param options - Per-request options.
2262
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Invalid filter or cursor: a malformed uuid, boolean or date-time, `q` over 200 characters, `received_after` not earlier than `received_before`, or a window wider than 30 days. The reason is in `message`.
2263
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2264
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The policy does not grant `mail.list` on every mailbox, or Mail is not enabled for this workspace.
2265
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
2266
+ * @throws {RateLimitError} 429 RATE_LIMITED: Another received-email export is already running, or this workspace has hit the hourly cap (5). Per-IP limit: more than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2267
+ * @see GET /v1/workspaces/{workspace_id}/received/export
2268
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-received-export
2269
+ * @example
2270
+ * ```ts
2271
+ * const response = await mail.received.export();
2272
+ * const text = await response.text();
2273
+ * ```
2274
+ */
2275
+ export(params, options) {
2276
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/received/export", query: params, raw: true }, options);
2277
+ }
2278
+ /**
2279
+ * List received email across every mailbox in the workspace
2280
+ *
2281
+ * Newest first, cursor-paged, deleted email excluded. Filters combine with AND: `q` (sender, subject, envelope recipient or To address as a substring; or an exact id or Message-ID), `mailbox_id`, `domain_id`, `received_after` / `received_before` (at most 30 days apart), `spam`, `unread`. `GET /received/export` takes exactly the same filters and returns the same rows. No body content.
2282
+ *
2283
+ * @param params - `Mail.ReceivedListParams`.
2284
+ * @param options - Per-request options.
2285
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Invalid filter or cursor: a malformed uuid, boolean or date-time, `q` over 200 characters, `received_after` not earlier than `received_before`, or a window wider than 30 days. The reason is in `message`.
2286
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2287
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The policy does not grant `mail.list` on every mailbox, or Mail is not enabled for this workspace.
2288
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
2289
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2290
+ * @see GET /v1/workspaces/{workspace_id}/received
2291
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-received
2292
+ * @example
2293
+ * ```ts
2294
+ * for await (const received of mail.received.list()) {
2295
+ * console.log(received);
2296
+ * }
2297
+ * const page = await mail.received.list({}, { timeout: 5_000 });
2298
+ * ```
2299
+ */
2300
+ list(params, options) {
2301
+ return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/received", query: params }, options);
2302
+ }
2303
+ /**
2304
+ * Download the raw RFC 5322 message (.eml)
2305
+ *
2306
+ * Every header, the full body and every attachment inline. Gated by `mail.message.body.read` (admin and up by default), like `/mailboxes/{id}/messages/{mid}/raw`.
2307
+ *
2308
+ * @param id - Received email id.
2309
+ * @param options - Per-request options.
2310
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `id` is not a uuid.
2311
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2312
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The policy does not grant `mail.message.body.read`.
2313
+ * @throws {NotFoundError} 404 NOT_FOUND: No such email in this workspace (or it was deleted).
2314
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2315
+ * @see GET /v1/workspaces/{workspace_id}/received/{id}/raw
2316
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-received-id-raw
2317
+ * @example
2318
+ * ```ts
2319
+ * const response = await mail.received.raw("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
2320
+ * const text = await response.text();
2321
+ * ```
2322
+ */
2323
+ raw(id, options) {
2324
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/received/{id}/raw", pathParams: { id }, raw: true }, options);
2325
+ }
2326
+ /**
2327
+ * Mark a received email as read
2328
+ *
2329
+ * @param id - Received email id.
2330
+ * @param options - Per-request options.
2331
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `id` is not a uuid.
2332
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2333
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The policy does not grant `mail.read` on every mailbox.
2334
+ * @throws {NotFoundError} 404 NOT_FOUND: No such email in this workspace (or it was deleted).
2335
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2336
+ * @see POST /v1/workspaces/{workspace_id}/received/{id}/read
2337
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-received-id-read
2338
+ * @example
2339
+ * ```ts
2340
+ * await mail.received.read("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
2341
+ * ```
2342
+ */
2343
+ read(id, options) {
2344
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/received/{id}/read", pathParams: { id } }, options);
2345
+ }
2346
+ /**
2347
+ * Get one received email
2348
+ *
2349
+ * Metadata, the authentication results, the envelope recipient and the attachment manifest. `body_preview` is null without `mail.message.body.read`; the full message is at `/received/{id}/raw`.
2350
+ *
2351
+ * @param id - Received email id.
2352
+ * @param options - Per-request options.
2353
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `id` is not a uuid.
2354
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2355
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The policy does not grant `mail.read` on every mailbox.
2356
+ * @throws {NotFoundError} 404 NOT_FOUND: No such email in this workspace (or it was deleted).
2357
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2358
+ * @see GET /v1/workspaces/{workspace_id}/received/{id}
2359
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-received-id
2360
+ * @example
2361
+ * ```ts
2362
+ * const receivedEmailDetail = await mail.received.retrieve("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
2363
+ * ```
2364
+ */
2365
+ retrieve(id, options) {
2366
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/received/{id}", pathParams: { id } }, options);
2367
+ }
2368
+ };
2369
+ var SegmentsContactsResource = class extends APIResource {
2370
+ /**
2371
+ * List a segment's contacts
2372
+ *
2373
+ * Newest contact first. For a rule segment, the contacts matching its rule right now.
2374
+ *
2375
+ * @param segmentId - Id of the segment.
2376
+ * @param params - `Mail.SegmentContactListParams`.
2377
+ * @param options - Per-request options.
2378
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
2379
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2380
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2381
+ * @throws {NotFoundError} 404 NOT_FOUND, SEGMENT_NOT_FOUND: No such segment (`SEGMENT_NOT_FOUND`).
2382
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2383
+ * @see GET /v1/workspaces/{workspace_id}/segments/{segment_id}/contacts
2384
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-segments-segment-id-contacts
2385
+ * @example
2386
+ * ```ts
2387
+ * for await (const contact of mail.segments.contacts.list("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b")) {
2388
+ * console.log(contact);
2389
+ * }
2390
+ * const page = await mail.segments.contacts.list("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", {}, { timeout: 5_000 });
2391
+ * ```
2392
+ */
2393
+ list(segmentId, params, options) {
2394
+ return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/segments/{segment_id}/contacts", pathParams: { segment_id: segmentId }, query: params }, options);
2395
+ }
2396
+ };
2397
+ var SegmentsResource = class extends APIResource {
2398
+ #contacts;
2399
+ get contacts() {
2400
+ return this.#contacts ??= new SegmentsContactsResource(this._client, this._b);
2401
+ }
2402
+ /**
2403
+ * Create a segment
2404
+ *
2405
+ * Without `rule`, a static segment: add and remove contacts one at a time. With `rule`, a rule segment: its members are the contacts whose fields and properties match, evaluated every time it is read. At most 100 segments per workspace.
2406
+ *
2407
+ * @param params - `Mail.SegmentCreateParams`.
2408
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
2409
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
2410
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2411
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2412
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
2413
+ * @throws {ConflictError} 409 CONFLICT, SEGMENT_EXISTS, SEGMENT_LIMIT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: A segment with this name exists (`SEGMENT_EXISTS`), the workspace has 100 segments (`SEGMENT_LIMIT`), or `IDEMPOTENCY_KEY_REUSE`. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
2414
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, INVALID_SEGMENT_RULE: The rule is invalid (`INVALID_SEGMENT_RULE`; `details.problems` lists each one with its condition index): an unknown field, `contains` on a number property, a missing or mistyped `value`, a `value` on `exists`.
2415
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2416
+ * @see POST /v1/workspaces/{workspace_id}/segments
2417
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-segments
2418
+ * @example
2419
+ * ```ts
2420
+ * const segment = await mail.segments.create({ name: "Pro customers" });
2421
+ * ```
2422
+ */
2423
+ create(params, options) {
2424
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/segments", body: params, idempotent: true }, options);
2425
+ }
2426
+ /**
2427
+ * Delete a segment
2428
+ *
2429
+ * Contacts are not touched; a static segment's member list goes with it.
2430
+ *
2431
+ * @param segmentId - Id of the segment.
2432
+ * @param options - Per-request options.
2433
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
2434
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2435
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2436
+ * @throws {NotFoundError} 404 NOT_FOUND, SEGMENT_NOT_FOUND: No such segment (`SEGMENT_NOT_FOUND`).
2437
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2438
+ * @see DELETE /v1/workspaces/{workspace_id}/segments/{segment_id}
2439
+ * @see https://productcraft.co/docs/mail/api-reference#delete-v1-workspaces-workspace-id-segments-segment-id
2440
+ * @example
2441
+ * ```ts
2442
+ * await mail.segments.delete("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
2443
+ * ```
2444
+ */
2445
+ delete(segmentId, options) {
2446
+ return this._client.request({ method: "DELETE", path: "/v1/workspaces/{workspace_id}/segments/{segment_id}", pathParams: { segment_id: segmentId } }, options);
2447
+ }
2448
+ /**
2449
+ * List segments, newest first
2450
+ *
2451
+ * @param params - `Mail.SegmentListParams`.
2452
+ * @param options - Per-request options.
2453
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
2454
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2455
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2456
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
2457
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2458
+ * @see GET /v1/workspaces/{workspace_id}/segments
2459
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-segments
2460
+ * @example
2461
+ * ```ts
2462
+ * for await (const segment of mail.segments.list()) {
2463
+ * console.log(segment);
2464
+ * }
2465
+ * const page = await mail.segments.list({}, { timeout: 5_000 });
2466
+ * ```
2467
+ */
2468
+ list(params, options) {
2469
+ return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/segments", query: params }, options);
2470
+ }
2471
+ /**
2472
+ * A segment's size and unsubscribed share
2473
+ *
2474
+ * Counted on request.
2475
+ *
2476
+ * @param segmentId - Id of the segment.
2477
+ * @param options - Per-request options.
2478
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
2479
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2480
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2481
+ * @throws {NotFoundError} 404 NOT_FOUND, SEGMENT_NOT_FOUND: No such segment (`SEGMENT_NOT_FOUND`).
2482
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2483
+ * @see GET /v1/workspaces/{workspace_id}/segments/{segment_id}/metrics
2484
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-segments-segment-id-metrics
2485
+ * @example
2486
+ * ```ts
2487
+ * const segmentMetrics = await mail.segments.metrics("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
2488
+ * ```
2489
+ */
2490
+ metrics(segmentId, options) {
2491
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/segments/{segment_id}/metrics", pathParams: { segment_id: segmentId } }, options);
2492
+ }
2493
+ /**
2494
+ * Preview a segment rule
2495
+ *
2496
+ * Counts the contacts a rule selects and returns the newest few, without saving anything.
2497
+ *
2498
+ * @param params - `Mail.SegmentPreviewParams`.
2499
+ * @param options - Per-request options.
2500
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
2501
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2502
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2503
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
2504
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, INVALID_SEGMENT_RULE: The rule is invalid (`INVALID_SEGMENT_RULE`; `details.problems` lists each one with its condition index): an unknown field, `contains` on a number property, a missing or mistyped `value`, a `value` on `exists`.
2505
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2506
+ * @see POST /v1/workspaces/{workspace_id}/segments/preview
2507
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-segments-preview
2508
+ * @example
2509
+ * ```ts
2510
+ * const segmentPreview = await mail.segments.preview({ rule: { conditions: [{ field: "plan", operator: "equals" }], match: "all" } });
2511
+ * ```
2512
+ */
2513
+ preview(params, options) {
2514
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/segments/preview", body: params }, options);
2515
+ }
2516
+ /**
2517
+ * Get a segment
2518
+ *
2519
+ * @param segmentId - Id of the segment.
2520
+ * @param options - Per-request options.
2521
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
2522
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2523
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2524
+ * @throws {NotFoundError} 404 NOT_FOUND, SEGMENT_NOT_FOUND: No such segment (`SEGMENT_NOT_FOUND`).
2525
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2526
+ * @see GET /v1/workspaces/{workspace_id}/segments/{segment_id}
2527
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-segments-segment-id
2528
+ * @example
2529
+ * ```ts
2530
+ * const segment = await mail.segments.retrieve("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
2531
+ * ```
2532
+ */
2533
+ retrieve(segmentId, options) {
2534
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/segments/{segment_id}", pathParams: { segment_id: segmentId } }, options);
2535
+ }
2536
+ /**
2537
+ * Update a segment
2538
+ *
2539
+ * Rename it, or change a rule segment's rule. A segment's type (static or rule) is fixed.
2540
+ *
2541
+ * @param segmentId - Id of the segment.
2542
+ * @param params - `Mail.SegmentUpdateParams`.
2543
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
2544
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
2545
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2546
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2547
+ * @throws {NotFoundError} 404 NOT_FOUND, SEGMENT_NOT_FOUND: No such segment (`SEGMENT_NOT_FOUND`).
2548
+ * @throws {ConflictError} 409 CONFLICT, SEGMENT_EXISTS, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: Another segment has this name (`SEGMENT_EXISTS`), or `IDEMPOTENCY_KEY_REUSE`. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
2549
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, INVALID_SEGMENT_RULE, SEGMENT_TYPE_FIXED: The rule is invalid (`INVALID_SEGMENT_RULE`; `details.problems` lists each one with its condition index): an unknown field, `contains` on a number property, a missing or mistyped `value`, a `value` on `exists`. Or a rule on a static segment (`SEGMENT_TYPE_FIXED`).
2550
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2551
+ * @see PATCH /v1/workspaces/{workspace_id}/segments/{segment_id}
2552
+ * @see https://productcraft.co/docs/mail/api-reference#patch-v1-workspaces-workspace-id-segments-segment-id
2553
+ * @example
2554
+ * ```ts
2555
+ * const segment = await mail.segments.update("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", { description: "string" });
2556
+ * ```
2557
+ */
2558
+ update(segmentId, params, options) {
2559
+ return this._client.request({ method: "PATCH", path: "/v1/workspaces/{workspace_id}/segments/{segment_id}", pathParams: { segment_id: segmentId }, body: params, idempotent: true }, options);
2560
+ }
2561
+ };
2562
+ var SendingDefaultsResource = class extends APIResource {
2563
+ /**
2564
+ * Get the workspace default sender
2565
+ *
2566
+ * The From used by template sends that name none, with the live verification status of its domain. `default_sender` is null when none is set.
2567
+ *
2568
+ * @param options - Per-request options.
2569
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
2570
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2571
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2572
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
2573
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2574
+ * @see GET /v1/workspaces/{workspace_id}/sending-defaults
2575
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-sending-defaults
2576
+ * @example
2577
+ * ```ts
2578
+ * const sendingDefaults = await mail.sendingDefaults.retrieve();
2579
+ * ```
2580
+ */
2581
+ retrieve(options) {
2582
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/sending-defaults" }, options);
2583
+ }
2584
+ /**
2585
+ * Set or clear the workspace default sender
2586
+ *
2587
+ * Replaces the default sender (`address: null` clears it). The change applies to the next send of every product at once, and emits a `sending_defaults.updated` webhook event. Repeating the same request changes nothing, so it takes no `Idempotency-Key`.
2588
+ *
2589
+ * @param params - `Mail.SendingDefaultUpdateParams`.
2590
+ * @param options - Per-request options.
2591
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
2592
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2593
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2594
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
2595
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, sender_domain_not_in_workspace, INVALID_FROM_ADDRESS: `sender_domain_not_in_workspace` (`details: { fqdn }`): the address is not on a sending domain of this workspace (unknown, another workspace's, or receive-only). `INVALID_FROM_ADDRESS`: the address could not be parsed.
2596
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2597
+ * @see PUT /v1/workspaces/{workspace_id}/sending-defaults
2598
+ * @see https://productcraft.co/docs/mail/api-reference#put-v1-workspaces-workspace-id-sending-defaults
2599
+ * @example
2600
+ * ```ts
2601
+ * const sendingDefaults = await mail.sendingDefaults.update({ address: "Acme <hello@acme.com>" });
2602
+ * ```
2603
+ */
2604
+ update(params, options) {
2605
+ return this._client.request({ method: "PUT", path: "/v1/workspaces/{workspace_id}/sending-defaults", body: params }, options);
2606
+ }
2607
+ };
2608
+ var SmtpConfigResource = class extends APIResource {
2609
+ /**
2610
+ * List every SMTP config in the workspace (default + per-domain overrides)
2611
+ *
2612
+ * @param options - Per-request options.
2613
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
2614
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2615
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2616
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
2617
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2618
+ * @see GET /v1/workspaces/{workspace_id}/smtp-configs
2619
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-smtp-configs
2620
+ * @example
2621
+ * ```ts
2622
+ * const listSmtpConfigs = await mail.smtpConfig.list();
2623
+ * ```
2624
+ */
2625
+ list(options) {
2626
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/smtp-configs" }, options);
2627
+ }
2628
+ /**
2629
+ * Revert the workspace to ProductCraft Mail's own sending
2630
+ *
2631
+ * @param options - Per-request options.
2632
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
2633
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2634
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2635
+ * @throws {NotFoundError} 404 NOT_FOUND: No SMTP config to delete
2636
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2637
+ * @see DELETE /v1/workspaces/{workspace_id}/smtp-config
2638
+ * @see https://productcraft.co/docs/mail/api-reference#delete-v1-workspaces-workspace-id-smtp-config
2639
+ * @example
2640
+ * ```ts
2641
+ * await mail.smtpConfig.reset();
2642
+ * ```
2643
+ */
2644
+ reset(options) {
2645
+ return this._client.request({ method: "DELETE", path: "/v1/workspaces/{workspace_id}/smtp-config" }, options);
2646
+ }
2647
+ /**
2648
+ * Get the workspace-default SMTP config (returns null if unset). Per-domain overrides live under /workspaces/:id/domains/:domainId/smtp-config.
2649
+ *
2650
+ * @param options - Per-request options.
2651
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
2652
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2653
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2654
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
2655
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2656
+ * @see GET /v1/workspaces/{workspace_id}/smtp-config
2657
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-smtp-config
2658
+ * @example
2659
+ * ```ts
2660
+ * const getSmtpConfig = await mail.smtpConfig.retrieve();
2661
+ * ```
2662
+ */
2663
+ retrieve(options) {
2664
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/smtp-config" }, options);
2665
+ }
2666
+ /**
2667
+ * Create or update the workspace-default SMTP config (resets verification)
2668
+ *
2669
+ * @param params - `Mail.SmtpConfigUpdateParams`.
2670
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
2671
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Validation failure or username/password mismatch.
2672
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2673
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2674
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
2675
+ * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `IDEMPOTENCY_KEY_REUSE`: the `Idempotency-Key` was already used with a different request body or on a different route. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
2676
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2677
+ * @see PUT /v1/workspaces/{workspace_id}/smtp-config
2678
+ * @see https://productcraft.co/docs/mail/api-reference#put-v1-workspaces-workspace-id-smtp-config
2679
+ * @example
2680
+ * ```ts
2681
+ * const smtpConfig = await mail.smtpConfig.update({
2682
+ * from_email: "noreply@acme.com",
2683
+ * from_name: "Acme Notifications",
2684
+ * host: "smtp.sendgrid.net",
2685
+ * port: 587,
2686
+ * secure: false,
2687
+ * });
2688
+ * ```
2689
+ */
2690
+ update(params, options) {
2691
+ return this._client.request({ method: "PUT", path: "/v1/workspaces/{workspace_id}/smtp-config", body: params, idempotent: true }, options);
2692
+ }
2693
+ /**
2694
+ * Test arbitrary SMTP creds without persisting
2695
+ *
2696
+ * @param params - `Mail.SmtpConfigVerifyParams`.
2697
+ * @param options - Per-request options.
2698
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Validation failure on the request body.
2699
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2700
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2701
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
2702
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2703
+ * @see POST /v1/workspaces/{workspace_id}/smtp-config/verify
2704
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-smtp-config-verify
2705
+ * @example
2706
+ * ```ts
2707
+ * const smtpVerifyResult = await mail.smtpConfig.verify({
2708
+ * from_email: "noreply@acme.com",
2709
+ * from_name: "Acme Notifications",
2710
+ * host: "smtp.sendgrid.net",
2711
+ * port: 587,
2712
+ * secure: false,
2713
+ * });
2714
+ * ```
2715
+ */
2716
+ verify(params, options) {
2717
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/smtp-config/verify", body: params }, options);
2718
+ }
2719
+ /**
2720
+ * Test the persisted workspace-default SMTP config; updates status
2721
+ *
2722
+ * @param options - Per-request options.
2723
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
2724
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2725
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2726
+ * @throws {NotFoundError} 404 NOT_FOUND: No SMTP config saved
2727
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2728
+ * @see POST /v1/workspaces/{workspace_id}/smtp-config/verify-saved
2729
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-smtp-config-verify-saved
2730
+ * @example
2731
+ * ```ts
2732
+ * const smtpVerifyResult = await mail.smtpConfig.verifySaved();
2733
+ * ```
2734
+ */
2735
+ verifySaved(options) {
2736
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/smtp-config/verify-saved" }, options);
2737
+ }
2738
+ };
2739
+ var StatsResource = class extends APIResource {
2740
+ /**
2741
+ * Mail stats for a workspace
2742
+ *
2743
+ * Outbound sent, delivered, bounced, complained, deferred, suppressed and unconfirmed counts in the window, the deliverability, bounce and complaint rates, domain totals, the last send time and a daily sent series. For ranges, buckets, filters and a per-domain breakdown use `GET /emails/metrics`; the rates here use its definitions.
2744
+ *
2745
+ * `delivered` means the recipient's mail server confirmed the message; `unconfirmed` means the message was handed off and nothing came back either way, which is not the same as delivered. Days are UTC. Rates are 0 to 1, or null when not measured: delivery and complaints are only reported for mail with delivery tracking. Outbound messages are kept for 30 days, so 30d is the longest window. Cached for up to 60 seconds (`generated_at`).
2746
+ *
2747
+ * @param params - `Mail.StatsRetrieveParams`.
2748
+ * @param options - Per-request options.
2749
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `window` is not one of 1d, 7d, 30d.
2750
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2751
+ * @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED: Caller lacks `mail.message.read` on the workspace (including non-members), or Mail is not enabled on it (`SERVICE_NOT_ENABLED`).
2752
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403.
2753
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2754
+ * @see GET /v1/workspaces/{workspace_id}/stats
2755
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-stats
2756
+ * @example
2757
+ * ```ts
2758
+ * const mailWorkspaceStats = await mail.stats.retrieve();
2759
+ * ```
2760
+ */
2761
+ retrieve(params, options) {
2762
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/stats", query: params }, options);
2763
+ }
2764
+ };
2765
+ var SuppressionResource = class extends APIResource {
2766
+ /**
2767
+ * Add an email to the workspace suppression list
2768
+ *
2769
+ * @param params - `Mail.SuppressionCreateParams`.
2770
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
2771
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Invalid payload (missing or malformed email).
2772
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2773
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2774
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
2775
+ * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `IDEMPOTENCY_KEY_REUSE`: the `Idempotency-Key` was already used with a different request body or on a different route. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
2776
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY: Email address rejected as invalid by the service layer.
2777
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2778
+ * @see POST /v1/workspaces/{workspace_id}/suppression
2779
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-suppression
2780
+ * @example
2781
+ * ```ts
2782
+ * const suppressionEntry = await mail.suppression.create({ email: "bounced@example.com" });
2783
+ * ```
2784
+ */
2785
+ create(params, options) {
2786
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/suppression", body: params, idempotent: true }, options);
2787
+ }
2788
+ /**
2789
+ * Remove an address from the workspace suppression list.
2790
+ *
2791
+ * @param email - The suppressed address (URL-encoded).
2792
+ * @param options - Per-request options.
2793
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
2794
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2795
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2796
+ * @throws {NotFoundError} 404 NOT_FOUND: Email is not on this workspace suppression list.
2797
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2798
+ * @see DELETE /v1/workspaces/{workspace_id}/suppression/{email}
2799
+ * @see https://productcraft.co/docs/mail/api-reference#delete-v1-workspaces-workspace-id-suppression-email
2800
+ * @example
2801
+ * ```ts
2802
+ * await mail.suppression.delete("email");
2803
+ * ```
2804
+ */
2805
+ delete(email, options) {
2806
+ return this._client.request({ method: "DELETE", path: "/v1/workspaces/{workspace_id}/suppression/{email}", pathParams: { email } }, options);
2807
+ }
2808
+ /**
2809
+ * List suppressed recipients in the workspace (most-recent first), cursor-paginated.
2810
+ *
2811
+ * @param params - `Mail.SuppressionListParams`.
2812
+ * @param options - Per-request options.
2813
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Invalid cursor, search term, or source filter.
2814
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2815
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2816
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
2817
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2818
+ * @see GET /v1/workspaces/{workspace_id}/suppression
2819
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-suppression
2820
+ * @example
2821
+ * ```ts
2822
+ * for await (const suppression of mail.suppression.list()) {
2823
+ * console.log(suppression);
2824
+ * }
2825
+ * const page = await mail.suppression.list({}, { timeout: 5_000 });
2826
+ * ```
2827
+ */
2828
+ list(params, options) {
2829
+ return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/suppression", query: params }, options);
2830
+ }
2831
+ };
2832
+ var TemplatesTagsResource = class extends APIResource {
2833
+ /**
2834
+ * Distinct tag list across all templates in this workspace (for autocomplete)
2835
+ *
2836
+ * @param options - Per-request options.
2837
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
2838
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2839
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2840
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
2841
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2842
+ * @see GET /v1/workspaces/{workspace_id}/templates/tags
2843
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-templates-tags
2844
+ * @example
2845
+ * ```ts
2846
+ * const listTemplateTags = await mail.templates.tags.list();
2847
+ * ```
2848
+ */
2849
+ list(options) {
2850
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/templates/tags" }, options);
2851
+ }
2852
+ };
2853
+ var TemplatesVariablesResource = class extends APIResource {
2854
+ /**
2855
+ * Variables auto-detected from the saved template body + subject (Handlebars expressions, dotted paths preserved, dedup'd in first-occurrence order).
2856
+ *
2857
+ * @param name - Name of the template.
2858
+ * @param options - Per-request options.
2859
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
2860
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2861
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2862
+ * @throws {NotFoundError} 404 NOT_FOUND: Template not found in this workspace.
2863
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2864
+ * @see GET /v1/workspaces/{workspace_id}/templates/{name}/variables
2865
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-templates-name-variables
2866
+ * @example
2867
+ * ```ts
2868
+ * const templateVariables = await mail.templates.variables.list("name");
2869
+ * ```
2870
+ */
2871
+ list(name, options) {
2872
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/templates/{name}/variables", pathParams: { name } }, options);
2873
+ }
2874
+ };
2875
+ var TemplatesResource = class extends APIResource {
2876
+ #tags;
2877
+ #variables;
2878
+ get tags() {
2879
+ return this.#tags ??= new TemplatesTagsResource(this._client, this._b);
2880
+ }
2881
+ get variables() {
2882
+ return this.#variables ??= new TemplatesVariablesResource(this._client, this._b);
2883
+ }
2884
+ /**
2885
+ * Create or update a template, layout, or partial. Idempotent on (workspace_id, name); `kind` cannot change after the first upsert.
2886
+ *
2887
+ * @param params - `Mail.TemplateCreateParams`.
2888
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
2889
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Validation failure (bad name / payload).
2890
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2891
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2892
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
2893
+ * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `IDEMPOTENCY_KEY_REUSE`: the `Idempotency-Key` was already used with a different request body or on a different route. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
2894
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2895
+ * @see POST /v1/workspaces/{workspace_id}/templates
2896
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-templates
2897
+ * @example
2898
+ * ```ts
2899
+ * const template = await mail.templates.create({ body_html: "string", name: "order-confirmation", subject: "string" });
2900
+ * ```
2901
+ */
2902
+ create(params, options) {
2903
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/templates", body: params, idempotent: true }, options);
2904
+ }
2905
+ /**
2906
+ * Delete a template, layout, or partial by name.
2907
+ *
2908
+ * @param name - Name of the template.
2909
+ * @param options - Per-request options.
2910
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
2911
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2912
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2913
+ * @throws {NotFoundError} 404 NOT_FOUND: Template not found in this workspace.
2914
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2915
+ * @see DELETE /v1/workspaces/{workspace_id}/templates/{name}
2916
+ * @see https://productcraft.co/docs/mail/api-reference#delete-v1-workspaces-workspace-id-templates-name
2917
+ * @example
2918
+ * ```ts
2919
+ * await mail.templates.delete("name");
2920
+ * ```
2921
+ */
2922
+ delete(name, options) {
2923
+ return this._client.request({ method: "DELETE", path: "/v1/workspaces/{workspace_id}/templates/{name}", pathParams: { name } }, options);
2924
+ }
2925
+ /**
2926
+ * Lint a draft for deliverability red flags. Same render pipeline as /preview; returns a 0-100 score (higher is better) and a sorted list of findings (errors first). Self-developed heuristic linter, no external classifier — runs in-process.
2927
+ *
2928
+ * @param params - `Mail.TemplateLintParams`.
2929
+ * @param options - Per-request options.
2930
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
2931
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2932
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2933
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
2934
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY: Underlying render failed.
2935
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2936
+ * @see POST /v1/workspaces/{workspace_id}/templates/lint
2937
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-templates-lint
2938
+ * @example
2939
+ * ```ts
2940
+ * const lintResult = await mail.templates.lint({ body_html: "string" });
2941
+ * ```
2942
+ */
2943
+ lint(params, options) {
2944
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/templates/lint", body: params }, options);
2945
+ }
2946
+ /**
2947
+ * List templates / layouts / partials in a workspace, name-ascending and cursor-paginated. Filter via ?kind=template|layout|partial (default: all), ?tags=foo,bar (comma-separated), ?search=<substring of the name>.
2948
+ *
2949
+ * @param params - `Mail.TemplateListParams`.
2950
+ * @param options - Per-request options.
2951
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Invalid cursor or search term.
2952
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2953
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2954
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
2955
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2956
+ * @see GET /v1/workspaces/{workspace_id}/templates
2957
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-templates
2958
+ * @example
2959
+ * ```ts
2960
+ * for await (const template of mail.templates.list()) {
2961
+ * console.log(template);
2962
+ * }
2963
+ * const page = await mail.templates.list({}, { timeout: 5_000 });
2964
+ * ```
2965
+ */
2966
+ list(params, options) {
2967
+ return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/templates", query: params }, options);
2968
+ }
2969
+ /**
2970
+ * Preview an unsaved draft. Renders subject + bodyHtml against the workspace brand tokens + supplied data, with all workspace layouts/partials registered. Used by the editor for live preview.
2971
+ *
2972
+ * @param params - `Mail.TemplatePreviewParams`.
2973
+ * @param options - Per-request options.
2974
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
2975
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2976
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2977
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
2978
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY: Render failed (compile or runtime error).
2979
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2980
+ * @see POST /v1/workspaces/{workspace_id}/templates/preview
2981
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-templates-preview
2982
+ * @example
2983
+ * ```ts
2984
+ * const renderedMessage = await mail.templates.preview({ body_html: "string" });
2985
+ * ```
2986
+ */
2987
+ preview(params, options) {
2988
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/templates/preview", body: params }, options);
2989
+ }
2990
+ /**
2991
+ * Render a saved template against a data payload. Returns subject + html + text without sending.
2992
+ *
2993
+ * @param name - Name of the template.
2994
+ * @param params - `Mail.TemplateRenderParams`.
2995
+ * @param options - Per-request options.
2996
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
2997
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
2998
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
2999
+ * @throws {NotFoundError} 404 NOT_FOUND: Template not found in this workspace.
3000
+ * @throws {ConflictError} 409 CONFLICT: Cannot render a layout/partial — only sendable templates.
3001
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY: Render or schema validation failed.
3002
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
3003
+ * @see POST /v1/workspaces/{workspace_id}/templates/{name}/render
3004
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-templates-name-render
3005
+ * @example
3006
+ * ```ts
3007
+ * const renderedMessage = await mail.templates.render("name", { data: { name: "Alice", order_id: "ord_123" } });
3008
+ * ```
3009
+ */
3010
+ render(name, params, options) {
3011
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/templates/{name}/render", pathParams: { name }, body: params }, options);
3012
+ }
3013
+ /**
3014
+ * Get a template, layout, or partial by name.
3015
+ *
3016
+ * @param name - Name of the template.
3017
+ * @param options - Per-request options.
3018
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
3019
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
3020
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
3021
+ * @throws {NotFoundError} 404 NOT_FOUND: Template not found in this workspace.
3022
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
3023
+ * @see GET /v1/workspaces/{workspace_id}/templates/{name}
3024
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-templates-name
3025
+ * @example
3026
+ * ```ts
3027
+ * const template = await mail.templates.retrieve("name");
3028
+ * ```
3029
+ */
3030
+ retrieve(name, options) {
3031
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/templates/{name}", pathParams: { name } }, options);
3032
+ }
3033
+ /**
3034
+ * Send a template-rendered message. Pass an `Idempotency-Key` header (1..256 chars, [A-Za-z0-9_\-:]) to make retries safe — replays return the original response with `Idempotent-Replay: true` for 24h. Same key + different request body returns 409 IDEMPOTENCY_KEY_REUSE.
3035
+ *
3036
+ * @param name - Name of the template.
3037
+ * @param params - `Mail.TemplateSendParams`.
3038
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
3039
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Validation failure (malformed body or recipient).
3040
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
3041
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
3042
+ * @throws {NotFoundError} 404 NOT_FOUND: Template not found in this workspace.
3043
+ * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: IDEMPOTENCY_KEY_REUSE — same key, different body. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
3044
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, RECIPIENT_SUPPRESSED, TOPIC_NOT_FOUND, from_domain_not_verified, domain_not_verified_by_provider, no_default_sender: Recipient suppressed (`RECIPIENT_SUPPRESSED`; with a `topic_id`, or a template rendering `{{{unsubscribe_url}}}`, also when the recipient unsubscribed or never opted in: `details.reason` is `unsubscribe` or `no_consent`), `TOPIC_NOT_FOUND`, render failure, or invalid from address; or `from_domain_not_verified` (body `code`, `details: { fqdn, reason }`): the domain of the From address is not itself an active sending domain of this workspace — `reason: not_registered` (unknown, registered to another workspace, or only a subdomain such as `mail.example.com` is verified; a verified subdomain does not cover its parent) or `reason: not_verified` (registered, DNS not verified yet). Refused before anything is recorded or queued; or `domain_not_verified_by_provider` (body `code`): the from-domain's DNS records have been broken for over 72 h (`health: failing`), so the email provider no longer sends for it; or `no_default_sender` (body `code`): the body has no `from` and the workspace has no default sender set (nothing is queued; an `email.skipped` webhook event is logged).
3045
+ * @throws {RateLimitError} 429 RATE_LIMITED: Over a workspace send limit (60 per minute, 600 per hour, 10,000 per day): `RATE_LIMITED` with `details: { window, limit, retry_after }`. Nothing is recorded or queued. Per-IP limit: more than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
3046
+ * @see POST /v1/workspaces/{workspace_id}/templates/{name}/send
3047
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-templates-name-send
3048
+ * @example
3049
+ * ```ts
3050
+ * const sendAccepted = await mail.templates.send("name", { data: { name: "Alice", order_id: "ord_123" }, to: "user@example.com" });
3051
+ * ```
3052
+ */
3053
+ send(name, params, options) {
3054
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/templates/{name}/send", pathParams: { name }, body: params, idempotent: true }, options);
3055
+ }
3056
+ /**
3057
+ * Send up to 100 messages with the same template in one request. Per-row partial-success: each row carries its own status (`accepted` | `rejected`).
3058
+ *
3059
+ * Two ways to make retries safe. An `Idempotency-Key` header covers the whole request: a retry with the same key and body within 24 h returns the first response (with `Idempotent-Replay: true`) and sends nothing. A per-row `idempotency_key` covers one message: a later batch, or a `/send`, that repeats a row key replays that row instead of sending it again. Both share one dedupe namespace, so the header key must differ from every row key (400 otherwise).
3060
+ *
3061
+ * @param name - Name of the template.
3062
+ * @param params - `Mail.TemplateSendBatchParams`.
3063
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
3064
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR, IDEMPOTENCY_KEY_CONFLICTS_WITH_ROW: Validation failure (malformed body, batch too large), or the `Idempotency-Key` header equals a row `idempotency_key` (`IDEMPOTENCY_KEY_CONFLICTS_WITH_ROW`).
3065
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
3066
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
3067
+ * @throws {NotFoundError} 404 NOT_FOUND: Template not found in this workspace.
3068
+ * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `IDEMPOTENCY_KEY_REUSE`: the `Idempotency-Key` was already used with a different request body or on a different route. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
3069
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, from_domain_not_verified, domain_not_verified_by_provider: For any row: `from_domain_not_verified` (body `code`, `details: { fqdn, reason }`): the domain of the From address is not itself an active sending domain of this workspace — `reason: not_registered` (unknown, registered to another workspace, or only a subdomain such as `mail.example.com` is verified; a verified subdomain does not cover its parent) or `reason: not_verified` (registered, DNS not verified yet). Refused before anything is recorded or queued (the whole batch is refused); or `domain_not_verified_by_provider` (body `code`): the from-domain's DNS records have been broken for over 72 h (`health: failing`), so the email provider no longer sends for it. The whole batch is refused; no row is sent.
3070
+ * @throws {RateLimitError} 429 RATE_LIMITED: The workspace send limits (60 per minute, 600 per hour, 10,000 per day) never 429 a batch: a row over one is rejected in the 200 body with `RATE_LIMITED`, and the other rows are unaffected. Per-IP limit: more than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
3071
+ * @see POST /v1/workspaces/{workspace_id}/templates/{name}/send-batch
3072
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-templates-name-send-batch
3073
+ * @example
3074
+ * ```ts
3075
+ * const sendBatchOpenApi = await mail.templates.sendBatch("name", {
3076
+ * messages: [
3077
+ * {
3078
+ * data: { code: "A1B2C3", name: "Alice" },
3079
+ * from: "Acme <noreply@acme.com>",
3080
+ * to: "alice@example.com",
3081
+ * },
3082
+ * ],
3083
+ * });
3084
+ * ```
3085
+ */
3086
+ sendBatch(name, params, options) {
3087
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/templates/{name}/send-batch", pathParams: { name }, body: params, idempotent: true }, options);
3088
+ }
3089
+ /**
3090
+ * Send a test rendering of the template to an arbitrary recipient. Bypasses the suppression list and the ordinary send limits (test sends have their own: 30 per hour per workspace); subject is auto-prefixed with [TEST]; missing variables render as [varname] placeholders.
3091
+ *
3092
+ * @param name - Name of the template.
3093
+ * @param params - `Mail.TemplateTestSendParams`.
3094
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
3095
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
3096
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
3097
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: From-address domain is not registered to this workspace.
3098
+ * @throws {NotFoundError} 404 NOT_FOUND: Template not found in this workspace.
3099
+ * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: Cannot test-send a layout/partial, or `IDEMPOTENCY_KEY_REUSE`: the `Idempotency-Key` was already used with a different body or route. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
3100
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, from_domain_not_verified, domain_not_verified_by_provider: Invalid from address or render failure; or `from_domain_not_verified` (body `code`, `details: { fqdn, reason }`): the domain of the From address is not itself an active sending domain of this workspace — `reason: not_registered` (unknown, registered to another workspace, or only a subdomain such as `mail.example.com` is verified; a verified subdomain does not cover its parent) or `reason: not_verified` (registered, DNS not verified yet). Refused before anything is recorded or queued; or `domain_not_verified_by_provider` (body `code`): the from-domain's DNS records have been broken for over 72 h (`health: failing`), so the email provider no longer sends for it.
3101
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 30 test sends this hour in this workspace: `RATE_LIMITED` with `details: { window, limit, retry_after }`. Per-IP limit: more than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
3102
+ * @see POST /v1/workspaces/{workspace_id}/templates/{name}/test-send
3103
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-templates-name-test-send
3104
+ * @example
3105
+ * ```ts
3106
+ * const sendAccepted = await mail.templates.testSend("name", { from: "Acme <hello@acme.com>", to: "ada@example.com" });
3107
+ * ```
3108
+ */
3109
+ testSend(name, params, options) {
3110
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/templates/{name}/test-send", pathParams: { name }, body: params, idempotent: true }, options);
3111
+ }
3112
+ };
3113
+ var TopicsResource = class extends APIResource {
3114
+ /**
3115
+ * Create a topic
3116
+ *
3117
+ * Send on a topic with `topic_id` on a template send. Recipients manage their topics on the hosted unsubscribe page. At most 50 topics per workspace.
3118
+ *
3119
+ * @param params - `Mail.TopicCreateParams`.
3120
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
3121
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
3122
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
3123
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
3124
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
3125
+ * @throws {ConflictError} 409 CONFLICT, TOPIC_EXISTS, TOPIC_LIMIT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: A topic with this name exists (`TOPIC_EXISTS`), the workspace has 50 topics (`TOPIC_LIMIT`), or `IDEMPOTENCY_KEY_REUSE`. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
3126
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
3127
+ * @see POST /v1/workspaces/{workspace_id}/topics
3128
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-topics
3129
+ * @example
3130
+ * ```ts
3131
+ * const topic = await mail.topics.create({ default_subscription: "opt_in", name: "Product updates" });
3132
+ * ```
3133
+ */
3134
+ create(params, options) {
3135
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/topics", body: params, idempotent: true }, options);
3136
+ }
3137
+ /**
3138
+ * Delete a topic
3139
+ *
3140
+ * Also deletes every contact's choice for it. Sends naming it are refused afterwards (`TOPIC_NOT_FOUND`).
3141
+ *
3142
+ * @param topicId - Id of the topic.
3143
+ * @param options - Per-request options.
3144
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
3145
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
3146
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
3147
+ * @throws {NotFoundError} 404 NOT_FOUND, TOPIC_NOT_FOUND: No such topic (`TOPIC_NOT_FOUND`).
3148
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
3149
+ * @see DELETE /v1/workspaces/{workspace_id}/topics/{topic_id}
3150
+ * @see https://productcraft.co/docs/mail/api-reference#delete-v1-workspaces-workspace-id-topics-topic-id
3151
+ * @example
3152
+ * ```ts
3153
+ * await mail.topics.delete("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
3154
+ * ```
3155
+ */
3156
+ delete(topicId, options) {
3157
+ return this._client.request({ method: "DELETE", path: "/v1/workspaces/{workspace_id}/topics/{topic_id}", pathParams: { topic_id: topicId } }, options);
3158
+ }
3159
+ /**
3160
+ * List topics, newest first
3161
+ *
3162
+ * @param params - `Mail.TopicListParams`.
3163
+ * @param options - Per-request options.
3164
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
3165
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
3166
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
3167
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
3168
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
3169
+ * @see GET /v1/workspaces/{workspace_id}/topics
3170
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-topics
3171
+ * @example
3172
+ * ```ts
3173
+ * for await (const topic of mail.topics.list()) {
3174
+ * console.log(topic);
3175
+ * }
3176
+ * const page = await mail.topics.list({}, { timeout: 5_000 });
3177
+ * ```
3178
+ */
3179
+ list(params, options) {
3180
+ return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/topics", query: params }, options);
3181
+ }
3182
+ /**
3183
+ * Get a topic
3184
+ *
3185
+ * @param topicId - Id of the topic.
3186
+ * @param options - Per-request options.
3187
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
3188
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
3189
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
3190
+ * @throws {NotFoundError} 404 NOT_FOUND, TOPIC_NOT_FOUND: No such topic (`TOPIC_NOT_FOUND`).
3191
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
3192
+ * @see GET /v1/workspaces/{workspace_id}/topics/{topic_id}
3193
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-topics-topic-id
3194
+ * @example
3195
+ * ```ts
3196
+ * const topic = await mail.topics.retrieve("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
3197
+ * ```
3198
+ */
3199
+ retrieve(topicId, options) {
3200
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/topics/{topic_id}", pathParams: { topic_id: topicId } }, options);
3201
+ }
3202
+ /**
3203
+ * Update a topic
3204
+ *
3205
+ * `default_subscription` cannot change: flipping it would silently subscribe or unsubscribe everyone who never chose.
3206
+ *
3207
+ * @param topicId - Id of the topic.
3208
+ * @param params - `Mail.TopicUpdateParams`.
3209
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
3210
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
3211
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
3212
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
3213
+ * @throws {NotFoundError} 404 NOT_FOUND, TOPIC_NOT_FOUND: No such topic (`TOPIC_NOT_FOUND`).
3214
+ * @throws {ConflictError} 409 CONFLICT, TOPIC_EXISTS, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: Another topic has this name (`TOPIC_EXISTS`), or `IDEMPOTENCY_KEY_REUSE`. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
3215
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
3216
+ * @see PATCH /v1/workspaces/{workspace_id}/topics/{topic_id}
3217
+ * @see https://productcraft.co/docs/mail/api-reference#patch-v1-workspaces-workspace-id-topics-topic-id
3218
+ * @example
3219
+ * ```ts
3220
+ * const topic = await mail.topics.update("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", { description: "string" });
3221
+ * ```
3222
+ */
3223
+ update(topicId, params, options) {
3224
+ return this._client.request({ method: "PATCH", path: "/v1/workspaces/{workspace_id}/topics/{topic_id}", pathParams: { topic_id: topicId }, body: params, idempotent: true }, options);
3225
+ }
3226
+ };
3227
+ var WebhooksAttemptsResource = class extends APIResource {
3228
+ /**
3229
+ * Delivery attempts across all of this workspace's webhook endpoints, newest first, cursor-paginated, optionally for one event or one endpoint. Includes status code, latency, response body (truncated to 1KB), and error if any.
3230
+ *
3231
+ * @param params - `Mail.WebhookAttemptListParams`.
3232
+ * @param options - Per-request options.
3233
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Invalid `limit`, `cursor`, `event_id` or `endpoint_id`.
3234
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
3235
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
3236
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
3237
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
3238
+ * @see GET /v1/workspaces/{workspace_id}/webhooks/attempts
3239
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-webhooks-attempts
3240
+ * @example
3241
+ * ```ts
3242
+ * for await (const attempt of mail.webhooks.attempts.list()) {
3243
+ * console.log(attempt);
3244
+ * }
3245
+ * const page = await mail.webhooks.attempts.list({}, { timeout: 5_000 });
3246
+ * ```
3247
+ */
3248
+ list(params, options) {
3249
+ return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/webhooks/attempts", query: params }, options);
3250
+ }
3251
+ };
3252
+ var WebhooksEndpointsResource = class extends APIResource {
3253
+ /**
3254
+ * Add a webhook endpoint. Returns its signing secret once.
3255
+ *
3256
+ * Deliveries are signed with the Standard Webhooks headers `webhook-id`, `webhook-timestamp` and `webhook-signature` (`v1,<base64 HMAC-SHA256 of "<id>.<timestamp>.<body>">`); the returned `whsec_…` secret works unchanged with any Standard Webhooks library. Failed deliveries are retried after 1 min, 5 min, 30 min, 2 h, 6 h and 24 h.
3257
+ *
3258
+ * @param params - `Mail.WebhookEndpointCreateParams`.
3259
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
3260
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR, WEBHOOK_EVENT_TYPE_UNKNOWN: Validation failure: URL not https with a public host, or an unknown event type (`WEBHOOK_EVENT_TYPE_UNKNOWN`).
3261
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
3262
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
3263
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
3264
+ * @throws {ConflictError} 409 CONFLICT, WEBHOOK_ENDPOINT_LIMIT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: Already 10 endpoints (`WEBHOOK_ENDPOINT_LIMIT`), or Idempotency-Key reused with a different body (`IDEMPOTENCY_KEY_REUSE`). Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
3265
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY: The URL points at a private, loopback or internal address.
3266
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
3267
+ * @see POST /v1/workspaces/{workspace_id}/webhooks/endpoints
3268
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-webhooks-endpoints
3269
+ * @example
3270
+ * ```ts
3271
+ * const webhookEndpointWithSecret = await mail.webhooks.endpoints.create({ url: "https://api.acme.com/webhooks" });
3272
+ * ```
3273
+ */
3274
+ create(params, options) {
3275
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/webhooks/endpoints", body: params, idempotent: true }, options);
3276
+ }
3277
+ /**
3278
+ * Delete a webhook endpoint.
3279
+ *
3280
+ * Queued retries are dropped. Its past attempts stay in the event log until the events expire.
3281
+ *
3282
+ * @param endpointId - Id of the endpoint.
3283
+ * @param options - Per-request options.
3284
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `endpoint_id` is not a UUID.
3285
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
3286
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
3287
+ * @throws {NotFoundError} 404 NOT_FOUND, WEBHOOK_ENDPOINT_NOT_FOUND: No such endpoint here (`WEBHOOK_ENDPOINT_NOT_FOUND`).
3288
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
3289
+ * @see DELETE /v1/workspaces/{workspace_id}/webhooks/endpoints/{endpoint_id}
3290
+ * @see https://productcraft.co/docs/mail/api-reference#delete-v1-workspaces-workspace-id-webhooks-endpoints-endpoint-id
3291
+ * @example
3292
+ * ```ts
3293
+ * await mail.webhooks.endpoints.delete("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
3294
+ * ```
3295
+ */
3296
+ delete(endpointId, options) {
3297
+ return this._client.request({ method: "DELETE", path: "/v1/workspaces/{workspace_id}/webhooks/endpoints/{endpoint_id}", pathParams: { endpoint_id: endpointId } }, options);
3298
+ }
3299
+ /**
3300
+ * List webhook endpoints, oldest first.
3301
+ *
3302
+ * At most 10, so this is always one page. Signing secrets are never returned here, only their last 4 characters.
3303
+ *
3304
+ * @param options - Per-request options.
3305
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: The scope id in the path is malformed.
3306
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
3307
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
3308
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
3309
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
3310
+ * @see GET /v1/workspaces/{workspace_id}/webhooks/endpoints
3311
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-webhooks-endpoints
3312
+ * @example
3313
+ * ```ts
3314
+ * for await (const endpoint of mail.webhooks.endpoints.list()) {
3315
+ * console.log(endpoint);
3316
+ * }
3317
+ * ```
3318
+ */
3319
+ list(options) {
3320
+ return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/webhooks/endpoints" }, options);
3321
+ }
3322
+ /**
3323
+ * Get one webhook endpoint (without its secret).
3324
+ *
3325
+ * The endpoint's URL, subscription, on/off state, failure streak and the last 4 characters of its signing secret. The full secret is only returned when the endpoint is created or its secret is rotated.
3326
+ *
3327
+ * @param endpointId - Id of the endpoint.
3328
+ * @param options - Per-request options.
3329
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `endpoint_id` is not a UUID.
3330
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
3331
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
3332
+ * @throws {NotFoundError} 404 NOT_FOUND, WEBHOOK_ENDPOINT_NOT_FOUND: No such endpoint here (`WEBHOOK_ENDPOINT_NOT_FOUND`).
3333
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
3334
+ * @see GET /v1/workspaces/{workspace_id}/webhooks/endpoints/{endpoint_id}
3335
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-webhooks-endpoints-endpoint-id
3336
+ * @example
3337
+ * ```ts
3338
+ * const webhookEndpoint = await mail.webhooks.endpoints.retrieve("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
3339
+ * ```
3340
+ */
3341
+ retrieve(endpointId, options) {
3342
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/webhooks/endpoints/{endpoint_id}", pathParams: { endpoint_id: endpointId } }, options);
3343
+ }
3344
+ /**
3345
+ * Rotate the signing secret. The new one is returned once.
3346
+ *
3347
+ * For `grace_hours` (default 24) the previous secret keeps signing too: `webhook-signature` then lists one `v1,` signature per secret, so receivers can switch over without dropping a delivery.
3348
+ *
3349
+ * @param endpointId - Id of the endpoint.
3350
+ * @param params - `Mail.WebhookEndpointRotateSecretParams`.
3351
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
3352
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `grace_hours` out of range, or `endpoint_id` is not a UUID.
3353
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
3354
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
3355
+ * @throws {NotFoundError} 404 NOT_FOUND, WEBHOOK_ENDPOINT_NOT_FOUND: No such endpoint here (`WEBHOOK_ENDPOINT_NOT_FOUND`).
3356
+ * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: Idempotency-Key reused with a different body (`IDEMPOTENCY_KEY_REUSE`). Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
3357
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
3358
+ * @see POST /v1/workspaces/{workspace_id}/webhooks/endpoints/{endpoint_id}/rotate-secret
3359
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-webhooks-endpoints-endpoint-id-rotate-secret
3360
+ * @example
3361
+ * ```ts
3362
+ * const webhookEndpointWithSecret = await mail.webhooks.endpoints.rotateSecret("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", { grace_hours: 24 });
3363
+ * ```
3364
+ */
3365
+ rotateSecret(endpointId, params, options) {
3366
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/webhooks/endpoints/{endpoint_id}/rotate-secret", pathParams: { endpoint_id: endpointId }, body: params, idempotent: true }, options);
3367
+ }
3368
+ /**
3369
+ * Send a test event to this endpoint now and return the result.
3370
+ *
3371
+ * Delivers the catalogue example of `event_type`, signed like any delivery, with `"test": true` in the body. Works while the endpoint is switched off or not subscribed to that type, is logged in the event log, and is never retried or counted toward an automatic disable. Waits up to 15 s for your receiver.
3372
+ *
3373
+ * @param endpointId - Id of the endpoint.
3374
+ * @param params - `Mail.WebhookEndpointTestParams`.
3375
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
3376
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Unknown `event_type`, or `endpoint_id` is not a UUID.
3377
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
3378
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
3379
+ * @throws {NotFoundError} 404 NOT_FOUND, WEBHOOK_ENDPOINT_NOT_FOUND: No such endpoint here (`WEBHOOK_ENDPOINT_NOT_FOUND`).
3380
+ * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: Idempotency-Key reused with a different body (`IDEMPOTENCY_KEY_REUSE`). Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
3381
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
3382
+ * @see POST /v1/workspaces/{workspace_id}/webhooks/endpoints/{endpoint_id}/test
3383
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-webhooks-endpoints-endpoint-id-test
3384
+ * @example
3385
+ * ```ts
3386
+ * const webhookDeliveryAttempt = await mail.webhooks.endpoints.test("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", { event_type: "email.sent" });
3387
+ * ```
3388
+ */
3389
+ test(endpointId, params, options) {
3390
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/webhooks/endpoints/{endpoint_id}/test", pathParams: { endpoint_id: endpointId }, body: params, idempotent: true }, options);
3391
+ }
3392
+ /**
3393
+ * Change a webhook endpoint: URL, description, events, on/off.
3394
+ *
3395
+ * Only the fields sent change. `enabled: true` (or a new URL) also clears an automatic disable. Switching off cancels queued retries. The secret is unchanged; rotate it with `POST …/rotate-secret`.
3396
+ *
3397
+ * @param endpointId - Id of the endpoint.
3398
+ * @param params - `Mail.WebhookEndpointUpdateParams`.
3399
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
3400
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Validation failure, or `endpoint_id` is not a UUID.
3401
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
3402
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
3403
+ * @throws {NotFoundError} 404 NOT_FOUND, WEBHOOK_ENDPOINT_NOT_FOUND: No such endpoint here (`WEBHOOK_ENDPOINT_NOT_FOUND`).
3404
+ * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: Idempotency-Key reused with a different body (`IDEMPOTENCY_KEY_REUSE`). Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
3405
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY: The new URL points at a private, loopback or internal address.
3406
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
3407
+ * @see PATCH /v1/workspaces/{workspace_id}/webhooks/endpoints/{endpoint_id}
3408
+ * @see https://productcraft.co/docs/mail/api-reference#patch-v1-workspaces-workspace-id-webhooks-endpoints-endpoint-id
3409
+ * @example
3410
+ * ```ts
3411
+ * const webhookEndpoint = await mail.webhooks.endpoints.update("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", { description: "Production receiver" });
3412
+ * ```
3413
+ */
3414
+ update(endpointId, params, options) {
3415
+ return this._client.request({ method: "PATCH", path: "/v1/workspaces/{workspace_id}/webhooks/endpoints/{endpoint_id}", pathParams: { endpoint_id: endpointId }, body: params, idempotent: true }, options);
3416
+ }
3417
+ };
3418
+ var WebhooksEventTypesResource = class extends APIResource {
3419
+ /**
3420
+ * List the events an endpoint can subscribe to.
3421
+ *
3422
+ * Each type with a plain description, its group and an example `data` object (what "Send test" delivers).
3423
+ *
3424
+ * @param options - Per-request options.
3425
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: A resource id in the path is not a UUID, or the request failed validation (`BAD_REQUEST` / `VALIDATION_ERROR`).
3426
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
3427
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
3428
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
3429
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
3430
+ * @see GET /v1/workspaces/{workspace_id}/webhooks/event-types
3431
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-webhooks-event-types
3432
+ * @example
3433
+ * ```ts
3434
+ * const listWebhookEventTypes = await mail.webhooks.eventTypes.list();
3435
+ * ```
3436
+ */
3437
+ list(options) {
3438
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/webhooks/event-types" }, options);
3439
+ }
3440
+ };
3441
+ var WebhooksEventsResource = class extends APIResource {
3442
+ /**
3443
+ * List webhook events, newest first (kept for 30 days).
3444
+ *
3445
+ * Every event logged while at least one endpoint existed, with the latest state per endpoint and when the next retry is due.
3446
+ *
3447
+ * @param params - `Mail.WebhookEventListParams`.
3448
+ * @param options - Per-request options.
3449
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Invalid filter value or cursor.
3450
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
3451
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
3452
+ * @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this `workspaceId`, or it is not a UUID (`NOT_FOUND`). A workspace the caller is not a member of answers 403. Routes that read a resource also answer 404 when the resource is missing.
3453
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
3454
+ * @see GET /v1/workspaces/{workspace_id}/webhooks/events
3455
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-webhooks-events
3456
+ * @example
3457
+ * ```ts
3458
+ * for await (const event of mail.webhooks.events.list()) {
3459
+ * console.log(event);
3460
+ * }
3461
+ * const page = await mail.webhooks.events.list({}, { timeout: 5_000 });
3462
+ * ```
3463
+ */
3464
+ list(params, options) {
3465
+ return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/webhooks/events", query: params }, options);
3466
+ }
3467
+ /**
3468
+ * Send a logged event again, to its endpoints or to one endpoint.
3469
+ *
3470
+ * Same body and `webhook-id`, freshly signed, to every switched-on endpoint that receives this event type now, or only to `endpoint_id`. Waits for the receivers (up to 15 s each) and returns the attempts. A success cancels a retry still queued for that endpoint.
3471
+ *
3472
+ * @param eventId - The event id, `evt_<uuid>`.
3473
+ * @param params - `Mail.WebhookEventReplayParams`.
3474
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
3475
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `event_id` is not `evt_<uuid>`, or `endpoint_id` is not a UUID.
3476
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
3477
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
3478
+ * @throws {NotFoundError} 404 NOT_FOUND, WEBHOOK_EVENT_NOT_FOUND, WEBHOOK_ENDPOINT_NOT_FOUND: No such event here (`WEBHOOK_EVENT_NOT_FOUND`); events are kept for 30 days. Or No such endpoint here (`WEBHOOK_ENDPOINT_NOT_FOUND`).
3479
+ * @throws {ConflictError} 409 CONFLICT, WEBHOOK_ENDPOINT_NOT_SUBSCRIBED, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `endpoint_id` is switched off or does not receive this event type (`WEBHOOK_ENDPOINT_NOT_SUBSCRIBED`), or Idempotency-Key reused with a different body (`IDEMPOTENCY_KEY_REUSE`). Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
3480
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
3481
+ * @see POST /v1/workspaces/{workspace_id}/webhooks/events/{event_id}/replay
3482
+ * @see https://productcraft.co/docs/mail/api-reference#post-v1-workspaces-workspace-id-webhooks-events-event-id-replay
3483
+ * @example
3484
+ * ```ts
3485
+ * const replayWebhookEvent = await mail.webhooks.events.replay("event");
3486
+ * ```
3487
+ */
3488
+ replay(eventId, params, options) {
3489
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/webhooks/events/{event_id}/replay", pathParams: { event_id: eventId }, query: params, idempotent: true }, options);
3490
+ }
3491
+ /**
3492
+ * Get one webhook event with every delivery attempt.
3493
+ *
3494
+ * The event as it was sent (`type`, `data`) and every delivery attempt to every endpoint, with its trigger, HTTP status, error and the start of the response body. Use it to debug a receiver, then `replay` to send it again.
3495
+ *
3496
+ * @param eventId - The event id, `evt_<uuid>`.
3497
+ * @param options - Per-request options.
3498
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `event_id` is not `evt_<uuid>`.
3499
+ * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token.
3500
+ * @throws {PermissionDeniedError} 403 FORBIDDEN: The caller lacks the action this route requires on the resource, or Mail is not enabled for the workspace.
3501
+ * @throws {NotFoundError} 404 NOT_FOUND, WEBHOOK_EVENT_NOT_FOUND: No such event here (`WEBHOOK_EVENT_NOT_FOUND`); events are kept for 30 days.
3502
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
3503
+ * @see GET /v1/workspaces/{workspace_id}/webhooks/events/{event_id}
3504
+ * @see https://productcraft.co/docs/mail/api-reference#get-v1-workspaces-workspace-id-webhooks-events-event-id
3505
+ * @example
3506
+ * ```ts
3507
+ * const webhookEventDetail = await mail.webhooks.events.retrieve("event");
3508
+ * ```
3509
+ */
3510
+ retrieve(eventId, options) {
3511
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/webhooks/events/{event_id}", pathParams: { event_id: eventId } }, options);
3512
+ }
3513
+ };
3514
+ var WebhooksResource = class extends APIResource {
3515
+ #attempts;
3516
+ #endpoints;
3517
+ #eventTypes;
3518
+ #events;
3519
+ get attempts() {
3520
+ return this.#attempts ??= new WebhooksAttemptsResource(this._client, this._b);
3521
+ }
3522
+ get endpoints() {
3523
+ return this.#endpoints ??= new WebhooksEndpointsResource(this._client, this._b);
3524
+ }
3525
+ get eventTypes() {
3526
+ return this.#eventTypes ??= new WebhooksEventTypesResource(this._client, this._b);
3527
+ }
3528
+ get events() {
3529
+ return this.#events ??= new WebhooksEventsResource(this._client, this._b);
3530
+ }
3531
+ /**
3532
+ * Verify a webhook's signature and parse it (Standard Webhooks, and the legacy `t=…,v1=…` scheme).
3533
+ *
3534
+ * @param params - The raw body, the request headers and optionally the secret.
3535
+ * @throws {WebhookVerificationError} The signature, timestamp or payload is invalid.
3536
+ * @throws {ConfigurationError} No secret was passed or configured.
3537
+ */
3538
+ unwrap(params) {
3539
+ return this._client.unwrapWebhook(params, "PRODUCTCRAFT_MAIL_WEBHOOK_SECRET");
3540
+ }
3541
+ };
3542
+ var MailResources = class extends APIResource {
3543
+ #brand;
3544
+ #broadcasts;
3545
+ #contacts;
3546
+ #deliverability;
3547
+ #domains;
3548
+ #emails;
3549
+ #integrations;
3550
+ #mailboxes;
3551
+ #messages;
3552
+ #received;
3553
+ #segments;
3554
+ #sendingDefaults;
3555
+ #smtpConfig;
3556
+ #stats;
3557
+ #suppression;
3558
+ #templates;
3559
+ #topics;
3560
+ #webhooks;
3561
+ get brand() {
3562
+ return this.#brand ??= new BrandResource(this._client, this._b);
3563
+ }
3564
+ get broadcasts() {
3565
+ return this.#broadcasts ??= new BroadcastsResource(this._client, this._b);
3566
+ }
3567
+ get contacts() {
3568
+ return this.#contacts ??= new ContactsResource(this._client, this._b);
3569
+ }
3570
+ get deliverability() {
3571
+ return this.#deliverability ??= new DeliverabilityResource(this._client, this._b);
3572
+ }
3573
+ get domains() {
3574
+ return this.#domains ??= new DomainsResource(this._client, this._b);
3575
+ }
3576
+ get emails() {
3577
+ return this.#emails ??= new EmailsResource(this._client, this._b);
3578
+ }
3579
+ get integrations() {
3580
+ return this.#integrations ??= new IntegrationsResource(this._client, this._b);
3581
+ }
3582
+ get mailboxes() {
3583
+ return this.#mailboxes ??= new MailboxesResource(this._client, this._b);
3584
+ }
3585
+ get messages() {
3586
+ return this.#messages ??= new MessagesResource(this._client, this._b);
3587
+ }
3588
+ get received() {
3589
+ return this.#received ??= new ReceivedResource(this._client, this._b);
3590
+ }
3591
+ get segments() {
3592
+ return this.#segments ??= new SegmentsResource(this._client, this._b);
3593
+ }
3594
+ get sendingDefaults() {
3595
+ return this.#sendingDefaults ??= new SendingDefaultsResource(this._client, this._b);
3596
+ }
3597
+ get smtpConfig() {
3598
+ return this.#smtpConfig ??= new SmtpConfigResource(this._client, this._b);
3599
+ }
3600
+ get stats() {
3601
+ return this.#stats ??= new StatsResource(this._client, this._b);
3602
+ }
3603
+ get suppression() {
3604
+ return this.#suppression ??= new SuppressionResource(this._client, this._b);
3605
+ }
3606
+ get templates() {
3607
+ return this.#templates ??= new TemplatesResource(this._client, this._b);
3608
+ }
3609
+ get topics() {
3610
+ return this.#topics ??= new TopicsResource(this._client, this._b);
3611
+ }
3612
+ get webhooks() {
3613
+ return this.#webhooks ??= new WebhooksResource(this._client, this._b);
3614
+ }
3615
+ };
3616
+
3617
+ // src/_generated/types.ts
3618
+ var BounceSource = { values: ["relay", "ses", "mixed", "none"] };
3619
+ var BounceType = { values: ["Permanent", "Transient", "Undetermined"] };
3620
+ var BroadcastRecipientStatus = { values: ["pending", "sending", "sent", "skipped", "failed", "canceled"] };
3621
+ var BroadcastStatus = { values: ["draft", "scheduled", "sending", "sent", "canceled"] };
3622
+ var ContactCreatedVia = { values: ["api", "dashboard", "import", "unsubscribe"] };
3623
+ var ContactImportConflictMode = { values: ["upsert", "skip"] };
3624
+ var ContactImportStatus = { values: ["queued", "processing", "completed", "failed"] };
3625
+ var ContactPropertyType = { values: ["string", "number"] };
3626
+ var DeliverabilityVerdict = { values: ["no_data", "healthy", "unconfirmed", "degraded", "blocked"] };
3627
+ var DmarcAlignmentMode = { values: ["r", "s"] };
3628
+ var DmarcPolicy = { values: ["none", "quarantine", "reject"] };
3629
+ var DmarcRecordLocation = { values: ["subdomain", "organizational", "none"] };
3630
+ var DnsApplyAction = { values: ["create", "update", "skip"] };
3631
+ var DnsApplyProvider = { values: ["cloudflare", "digitalocean"] };
3632
+ var DnsApplyRecordResult = { values: ["created", "updated", "unchanged", "failed"] };
3633
+ var DnsApplyWarning = { values: ["token_scope_broader_than_zone", "dmarc_lookup_failed", "partially_applied"] };
3634
+ var DnsConflictCode = { values: ["spf_multiple", "spf_merge", "spf_lookup_limit", "cname_at_host", "mail_from_mx_multiple", "dmarc_duplicate", "dkim_selector_taken", "mx_foreign"] };
3635
+ var DnsConflictSeverity = { values: ["blocking", "warning"] };
3636
+ var DnsProviderId = { values: ["cloudflare", "digitalocean", "namecheap", "godaddy", "squarespace", "route53", "porkbun", "vercel", "netlify", "gandi", "hover", "other"] };
3637
+ var DnsProviderLookupSource = { values: ["ns", "domain_connect"] };
3638
+ var DnsProviderSource = { values: ["user", "detected"] };
3639
+ var DnsRecordPurpose = { values: ["dkim", "mx", "verification", "spf", "mail_from_mx", "mail_from_spf", "dmarc"] };
3640
+ var DnsRecordState = { values: ["missing", "mismatch", "conflict", "propagating", "verified"] };
3641
+ var DnsRecordType = { values: ["TXT", "MX"] };
3642
+ var DomainCapabilityState = { values: ["enabled", "disabled"] };
3643
+ var DomainConnectUnavailableReason = { values: ["no_record", "settings_unreachable", "template_not_onboarded", "lookup_failed", "disabled"] };
3644
+ var DomainEventType = { values: ["added", "records_found", "verified", "degraded", "failing", "recovered", "mail_from_verified", "dmarc_detected", "check_failed", "deleted"] };
3645
+ var DomainHealth = { values: ["ok", "degraded", "failing"] };
3646
+ var DomainIntent = { values: ["receive", "send", "both"] };
3647
+ var DomainRecordKind = { values: ["DKIM", "SPF", "MX", "DMARC", "Verification"] };
3648
+ var DomainRecordStatus = { values: ["not_started", "pending", "verified", "failed", "temporary_failure"] };
3649
+ var DomainSetupMethod = { values: ["manual", "domain_connect", "provider_api"] };
3650
+ var DomainStatus = { values: ["pending", "active", "disabled"] };
3651
+ var DomainTlsMode = { values: ["opportunistic"] };
3652
+ var DomainVerificationStatus = { values: ["not_started", "pending", "partially_verified", "verified", "temporary_failure", "failed", "disabled"] };
3653
+ var EmailMetricsGranularity = { values: ["hourly", "daily"] };
3654
+ var EmailMetricsObject = { values: ["metrics"] };
3655
+ var IntegrationStatus = { values: ["active", "error", "revoked"] };
3656
+ var IntegrationSyncState = { values: ["running", "completed", "failed"] };
3657
+ var LintSeverity = { values: ["error", "warn", "info"] };
3658
+ var MailboxStatus = { values: ["active", "disabled"] };
3659
+ var MessageEventType = { values: ["queued", "sent", "delivered", "deferred", "bounced", "complained", "failed", "suppressed"] };
3660
+ var MessageSource = { values: ["api_key", "dashboard", "platform", "test_send"] };
3661
+ var MessageStatus = { values: ["queued", "sent", "delivered", "bounced", "complained", "failed", "suppressed", "deferred"] };
3662
+ var MessageTransport = { values: ["smtp", "ses"] };
3663
+ var SegmentMatch = { values: ["all", "any"] };
3664
+ var SegmentOperator = { values: ["equals", "contains", "exists"] };
3665
+ var SegmentType = { values: ["static", "rule"] };
3666
+ var SendBatchRowState = { values: ["accepted", "rejected"] };
3667
+ var SenderDomainStatus = { values: ["not_started", "pending", "partially_verified", "verified", "temporary_failure", "failed", "disabled", "deleted", "not_found"] };
3668
+ var SesDkimStatus = { values: ["PENDING", "SUCCESS", "FAILED", "TEMPORARY_FAILURE", "NOT_STARTED", "not_enabled"] };
3669
+ var SesMailFromStatus = { values: ["PENDING", "SUCCESS", "FAILED", "TEMPORARY_FAILURE"] };
3670
+ var ShareLinkStatus = { values: ["active", "expired", "revoked"] };
3671
+ var SmtpConfigStatus = { values: ["pending", "active", "failed"] };
3672
+ var SpamVerdict = { values: ["ham", "junk", "reject"] };
3673
+ var StatsGranularity = { values: ["day"] };
3674
+ var StatsSeriesMetric = { values: ["sent"] };
3675
+ var StatsWindow = { values: ["1d", "7d", "30d"] };
3676
+ var Subscription = { values: ["opt_in", "opt_out"] };
3677
+ var SubscriptionReason = { values: ["opted_in", "default_with_consent", "unsubscribed", "opted_out", "no_consent", "not_opted_in"] };
3678
+ var SuppressionSource = { values: ["manual", "bounce", "complaint"] };
3679
+ var TemplateKind = { values: ["template", "layout", "partial"] };
3680
+ var TemplateSource = { values: ["manual", "github"] };
3681
+ var TimelineMetric = { values: ["sent", "bounced"] };
3682
+ var TopicVisibility = { values: ["public", "private"] };
3683
+ var WebhookAttemptTrigger = { values: ["automatic", "replay", "test"] };
3684
+ var WebhookEndpointDisabledReason = { values: ["manual", "failing"] };
3685
+ var WebhookEndpointLegacySlot = { values: ["default", "domain"] };
3686
+ var WebhookEndpointStatus = { values: ["enabled", "disabled", "auto_disabled"] };
3687
+ var WebhookEventStatus = { values: ["pending", "delivered", "failed", "not_sent"] };
3688
+ var WebhookEventType = { values: ["email.sent", "email.delivered", "email.delivery_delayed", "email.bounced", "email.complained", "email.failed", "email.suppressed", "email.skipped", "email.scheduled", "email.canceled", "email.opened", "email.clicked", "email.received", "domain.created", "domain.updated", "domain.verified", "domain.deleted", "suppression.added", "suppression.removed", "sending_defaults.updated", "contact.created", "contact.updated", "contact.deleted"] };
3689
+
3690
+ // src/_generated/client.ts
3691
+ var VERSION = "1.0.0" ;
3692
+ exports.default = class Mail extends MailResources {
3693
+ #openapi;
3694
+ constructor(options = {}) {
3695
+ super(new core.APIClient(options, core.PC_BASE_URL.mail, { name: "mail", version: VERSION }));
3696
+ }
3697
+ /** The typed `openapi-fetch` escape hatch over the same credential and base URL. It does not retry. */
3698
+ get client() {
3699
+ return this.#openapi ??= core.createOpenAPIClient(this._client);
11
3700
  }
12
3701
  };
3702
+ ((Mail2) => {
3703
+ Mail2.BounceSource = BounceSource;
3704
+ Mail2.BounceType = BounceType;
3705
+ Mail2.BroadcastRecipientStatus = BroadcastRecipientStatus;
3706
+ Mail2.BroadcastStatus = BroadcastStatus;
3707
+ Mail2.ContactCreatedVia = ContactCreatedVia;
3708
+ Mail2.ContactImportConflictMode = ContactImportConflictMode;
3709
+ Mail2.ContactImportStatus = ContactImportStatus;
3710
+ Mail2.ContactPropertyType = ContactPropertyType;
3711
+ Mail2.DeliverabilityVerdict = DeliverabilityVerdict;
3712
+ Mail2.DmarcAlignmentMode = DmarcAlignmentMode;
3713
+ Mail2.DmarcPolicy = DmarcPolicy;
3714
+ Mail2.DmarcRecordLocation = DmarcRecordLocation;
3715
+ Mail2.DnsApplyAction = DnsApplyAction;
3716
+ Mail2.DnsApplyProvider = DnsApplyProvider;
3717
+ Mail2.DnsApplyRecordResult = DnsApplyRecordResult;
3718
+ Mail2.DnsApplyWarning = DnsApplyWarning;
3719
+ Mail2.DnsConflictCode = DnsConflictCode;
3720
+ Mail2.DnsConflictSeverity = DnsConflictSeverity;
3721
+ Mail2.DnsProviderId = DnsProviderId;
3722
+ Mail2.DnsProviderLookupSource = DnsProviderLookupSource;
3723
+ Mail2.DnsProviderSource = DnsProviderSource;
3724
+ Mail2.DnsRecordPurpose = DnsRecordPurpose;
3725
+ Mail2.DnsRecordState = DnsRecordState;
3726
+ Mail2.DnsRecordType = DnsRecordType;
3727
+ Mail2.DomainCapabilityState = DomainCapabilityState;
3728
+ Mail2.DomainConnectUnavailableReason = DomainConnectUnavailableReason;
3729
+ Mail2.DomainEventType = DomainEventType;
3730
+ Mail2.DomainHealth = DomainHealth;
3731
+ Mail2.DomainIntent = DomainIntent;
3732
+ Mail2.DomainRecordKind = DomainRecordKind;
3733
+ Mail2.DomainRecordStatus = DomainRecordStatus;
3734
+ Mail2.DomainSetupMethod = DomainSetupMethod;
3735
+ Mail2.DomainStatus = DomainStatus;
3736
+ Mail2.DomainTlsMode = DomainTlsMode;
3737
+ Mail2.DomainVerificationStatus = DomainVerificationStatus;
3738
+ Mail2.EmailMetricsGranularity = EmailMetricsGranularity;
3739
+ Mail2.EmailMetricsObject = EmailMetricsObject;
3740
+ Mail2.IntegrationStatus = IntegrationStatus;
3741
+ Mail2.IntegrationSyncState = IntegrationSyncState;
3742
+ Mail2.LintSeverity = LintSeverity;
3743
+ Mail2.MailboxStatus = MailboxStatus;
3744
+ Mail2.MessageEventType = MessageEventType;
3745
+ Mail2.MessageSource = MessageSource;
3746
+ Mail2.MessageStatus = MessageStatus;
3747
+ Mail2.MessageTransport = MessageTransport;
3748
+ Mail2.SegmentMatch = SegmentMatch;
3749
+ Mail2.SegmentOperator = SegmentOperator;
3750
+ Mail2.SegmentType = SegmentType;
3751
+ Mail2.SendBatchRowState = SendBatchRowState;
3752
+ Mail2.SenderDomainStatus = SenderDomainStatus;
3753
+ Mail2.SesDkimStatus = SesDkimStatus;
3754
+ Mail2.SesMailFromStatus = SesMailFromStatus;
3755
+ Mail2.ShareLinkStatus = ShareLinkStatus;
3756
+ Mail2.SmtpConfigStatus = SmtpConfigStatus;
3757
+ Mail2.SpamVerdict = SpamVerdict;
3758
+ Mail2.StatsGranularity = StatsGranularity;
3759
+ Mail2.StatsSeriesMetric = StatsSeriesMetric;
3760
+ Mail2.StatsWindow = StatsWindow;
3761
+ Mail2.Subscription = Subscription;
3762
+ Mail2.SubscriptionReason = SubscriptionReason;
3763
+ Mail2.SuppressionSource = SuppressionSource;
3764
+ Mail2.TemplateKind = TemplateKind;
3765
+ Mail2.TemplateSource = TemplateSource;
3766
+ Mail2.TimelineMetric = TimelineMetric;
3767
+ Mail2.TopicVisibility = TopicVisibility;
3768
+ Mail2.WebhookAttemptTrigger = WebhookAttemptTrigger;
3769
+ Mail2.WebhookEndpointDisabledReason = WebhookEndpointDisabledReason;
3770
+ Mail2.WebhookEndpointLegacySlot = WebhookEndpointLegacySlot;
3771
+ Mail2.WebhookEndpointStatus = WebhookEndpointStatus;
3772
+ Mail2.WebhookEventStatus = WebhookEventStatus;
3773
+ Mail2.WebhookEventType = WebhookEventType;
3774
+ })(exports.default || (exports.default = {}));
3775
+ var MailErrorCode = { values: ["BAD_REQUEST", "VALIDATION_ERROR", "UNAUTHORIZED", "PAYMENT_REQUIRED", "FORBIDDEN", "NOT_FOUND", "METHOD_NOT_ALLOWED", "NOT_ACCEPTABLE", "REQUEST_TIMEOUT", "CONFLICT", "GONE", "PRECONDITION_FAILED", "PAYLOAD_TOO_LARGE", "UNSUPPORTED_MEDIA_TYPE", "UNPROCESSABLE_ENTITY", "PRECONDITION_REQUIRED", "RATE_LIMITED", "INTERNAL_SERVER_ERROR", "NOT_IMPLEMENTED", "BAD_GATEWAY", "SERVICE_UNAVAILABLE", "GATEWAY_TIMEOUT", "SERVICE_NOT_ENABLED", "INVALID_CREDENTIALS", "SESSION_REVOKED", "MCP_NOT_PERMITTED", "MCP_WORKSPACE_MISMATCH", "PAK_NOT_PERMITTED", "ACTIONS_NOT_GRANTABLE", "IDEMPOTENCY_KEY_REUSE", "IDEMPOTENCY_KEY_REQUIRED", "IDEMPOTENCY_IN_PROGRESS", "WEBHOOK_ENDPOINT_LIMIT", "WEBHOOK_ENDPOINT_NOT_FOUND", "WEBHOOK_ENDPOINT_NOT_SUBSCRIBED", "WEBHOOK_EVENT_NOT_FOUND", "WEBHOOK_EVENT_TYPE_UNKNOWN", "AUDIENCE_REQUIRED", "BROADCAST_AUDIENCE_EMPTY", "BROADCAST_CONTENT_CONFLICT", "BROADCAST_NOT_CANCELABLE", "BROADCAST_NOT_DELETABLE", "BROADCAST_NOT_DRAFT", "BROADCAST_NOT_FOUND", "BROADCAST_NOT_READY", "CAPABILITY_NOT_VERIFIED", "CONTACT_EXISTS", "CONTACT_LIMIT", "CONTACT_NOT_FOUND", "CONTACT_PROPERTY_EXISTS", "CONTACT_PROPERTY_LIMIT", "CONTACT_PROPERTY_NOT_FOUND", "DATE_RANGE_BEYOND_RETENTION", "DATE_RANGE_TOO_WIDE", "DATE_WINDOW_TOO_WIDE", "DKIM_KEY_MISSING", "DNS_CONFLICTS", "DOMAIN_CONNECT_DISABLED", "DOMAIN_CONNECT_MAIL_FROM_LABEL", "DOMAIN_CONNECT_NOT_SENDING", "DOMAIN_CONNECT_UNAVAILABLE", "DOMAIN_HAS_MAILBOXES", "DOMAIN_NOT_FOUND", "EMAIL_CONTENT_CONFLICT", "EMAIL_NOT_FOUND", "EMAIL_UNAVAILABLE", "FROM_DOMAIN_MISMATCH", "IDEMPOTENCY_KEY_CONFLICTS_WITH_ROW", "IMPORT_IN_PROGRESS", "IMPORT_NOT_FOUND", "IMPORT_TOO_LARGE", "INVALID_CAPABILITIES", "INVALID_CONTACT_PROPERTY_VALUE", "INVALID_CSV", "INVALID_DATE", "INVALID_DATE_RANGE", "INVALID_DATE_WINDOW", "INVALID_FORMAT", "INVALID_FROM_ADDRESS", "INVALID_SEGMENT_RULE", "INVALID_TIMEZONE", "INVALID_ZONE", "MAIL_FROM_HOST_IN_USE", "MAIL_FROM_NOT_SENDING", "MAIL_HEADER_NOT_ALLOWED", "PROVIDER_ERROR", "PROVIDER_PERMISSION_DENIED", "PROVIDER_TOKEN_REJECTED", "PROVIDER_UNAVAILABLE", "PROVIDER_ZONE_NOT_FOUND", "RECIPIENT_LIMIT", "RECIPIENT_SUPPRESSED", "REGION_NOT_AVAILABLE", "RESERVED_PROPERTY_KEY", "SEGMENT_EXISTS", "SEGMENT_LIMIT", "SEGMENT_NOT_FOUND", "SEGMENT_RULE_BASED", "SEGMENT_TYPE_FIXED", "SES_IDENTITY_DELETE_FAILED", "SHARE_LINK_NOT_FOUND", "SMTP_AUTH_PARTIAL", "SMTP_CONFIG_NOT_FOUND", "SMTP_PASSWORD_REQUIRED", "TEMPLATE_DATA_INVALID", "TEMPLATE_KIND_NOT_SENDABLE", "TEMPLATE_NOT_FOUND", "TEMPLATE_RENDER_FAILED", "TLS_ENFORCED_NOT_AVAILABLE", "TOPIC_EXISTS", "TOPIC_LIMIT", "TOPIC_NOT_FOUND", "TRACKING_NOT_AVAILABLE", "UNKNOWN_CONTACT_PROPERTY", "UNSUBSCRIBE_LINK_REQUIRED", "domain_not_verified_by_provider", "from_domain_not_verified", "no_default_sender", "sender_domain_not_in_workspace"] };
13
3776
 
14
- exports.Mail = Mail;
3777
+ Object.defineProperty(exports, "APIConnectionError", {
3778
+ enumerable: true,
3779
+ get: function () { return core.APIConnectionError; }
3780
+ });
3781
+ Object.defineProperty(exports, "APIError", {
3782
+ enumerable: true,
3783
+ get: function () { return core.APIError; }
3784
+ });
3785
+ Object.defineProperty(exports, "APITimeoutError", {
3786
+ enumerable: true,
3787
+ get: function () { return core.APITimeoutError; }
3788
+ });
3789
+ Object.defineProperty(exports, "APIUserAbortError", {
3790
+ enumerable: true,
3791
+ get: function () { return core.APIUserAbortError; }
3792
+ });
3793
+ Object.defineProperty(exports, "AuthenticationError", {
3794
+ enumerable: true,
3795
+ get: function () { return core.AuthenticationError; }
3796
+ });
3797
+ Object.defineProperty(exports, "BadRequestError", {
3798
+ enumerable: true,
3799
+ get: function () { return core.BadRequestError; }
3800
+ });
3801
+ Object.defineProperty(exports, "ConfigurationError", {
3802
+ enumerable: true,
3803
+ get: function () { return core.ConfigurationError; }
3804
+ });
3805
+ Object.defineProperty(exports, "ConflictError", {
3806
+ enumerable: true,
3807
+ get: function () { return core.ConflictError; }
3808
+ });
3809
+ Object.defineProperty(exports, "IdempotencyKeyReuseError", {
3810
+ enumerable: true,
3811
+ get: function () { return core.IdempotencyKeyReuseError; }
3812
+ });
3813
+ Object.defineProperty(exports, "InternalServerError", {
3814
+ enumerable: true,
3815
+ get: function () { return core.InternalServerError; }
3816
+ });
3817
+ Object.defineProperty(exports, "NotFoundError", {
3818
+ enumerable: true,
3819
+ get: function () { return core.NotFoundError; }
3820
+ });
3821
+ Object.defineProperty(exports, "PermissionDeniedError", {
3822
+ enumerable: true,
3823
+ get: function () { return core.PermissionDeniedError; }
3824
+ });
3825
+ Object.defineProperty(exports, "ProductCraftError", {
3826
+ enumerable: true,
3827
+ get: function () { return core.ProductCraftError; }
3828
+ });
3829
+ Object.defineProperty(exports, "RateLimitError", {
3830
+ enumerable: true,
3831
+ get: function () { return core.RateLimitError; }
3832
+ });
3833
+ Object.defineProperty(exports, "UnprocessableEntityError", {
3834
+ enumerable: true,
3835
+ get: function () { return core.UnprocessableEntityError; }
3836
+ });
3837
+ Object.defineProperty(exports, "WebhookVerificationError", {
3838
+ enumerable: true,
3839
+ get: function () { return core.WebhookVerificationError; }
3840
+ });
3841
+ exports.Mail = exports.default;
3842
+ exports.MailErrorCode = MailErrorCode;
15
3843
  //# sourceMappingURL=index.cjs.map
16
3844
  //# sourceMappingURL=index.cjs.map