mailchannels-sdk 0.3.7 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,268 +11,279 @@ declare class MailChannelsClient {
11
11
  put<T>(path: string, options?: Omit<FetchOptions<"json">, "method">): Promise<T>;
12
12
  }
13
13
 
14
- interface EmailsSendRecipient {
15
- /**
16
- * The email address of the recipient.
17
- */
18
- email: string;
19
- /**
20
- * The name of the recipient.
21
- */
22
- name?: string;
23
- }
24
-
25
- interface EmailsSendAttachment {
26
- /**
27
- * The attachment data, encoded in base64.
28
- */
29
- content: string;
30
- /**
31
- * The name of the attachment file.
32
- */
33
- filename: string;
34
- /**
35
- * The MIME type of the attachment.
36
- */
37
- type: string;
38
- }
39
-
40
- interface EmailsSendTracking {
41
- /**
42
- * Track when a recipient clicks a link in your email.
43
- * @default false
44
- */
45
- click?: boolean;
46
- /**
47
- * Track when a recipient opens your email. Please note that some email clients may not support open tracking.
48
- * @default false
49
- */
50
- open?: boolean;
51
- }
52
-
53
- interface EmailsSendOptionsBase {
54
- /**
55
- * An array of attachments to be sent with the email.
56
- */
57
- attachments?: EmailsSendAttachment[];
58
- /**
59
- * The BCC recipients of the email. Can be an array of email addresses or an array of objects with email and name properties or a single email address string or an object with email and name properties.
60
- * @example
61
- * [
62
- * { email: 'email1@example.com', name: 'Example1' },
63
- * { email: 'email2@example.com', name: 'Example2' }
64
- * ]
65
- * @example
66
- * { email: 'email@example.com', name: 'Example' }
67
- * @example
68
- * ['email1@example.com', 'email2@example.com']
69
- * @example
70
- * 'email@example.com'
71
- * @example
72
- * 'Name <email@example.com>'
73
- */
74
- bcc?: EmailsSendRecipient[] | EmailsSendRecipient | string[] | string;
75
- /**
76
- * The CC recipients of the email. Can be an array of email addresses or an array of objects with email and name properties or a single email address string or an object with email and name properties.
77
- * @example
78
- * [
79
- * { email: 'email1@example.com', name: 'Example1' },
80
- * { email: 'email2@example.com', name: 'Example2' }
81
- * ]
82
- * @example
83
- * { email: 'email@example.com', name: 'Example' }
84
- * @example
85
- * ['email1@example.com', 'email2@example.com']
86
- * @example
87
- * 'email@example.com'
88
- * @example
89
- * 'Name <email@example.com>'
90
- */
91
- cc?: EmailsSendRecipient[] | EmailsSendRecipient | string[] | string;
92
- /**
93
- * The DKIM settings for the email.
94
- */
95
- dkim?: {
96
- /**
97
- * Domain used for DKIM signing.
98
- */
99
- domain: string;
100
- /**
101
- * DKIM private key encoded in Base64.
102
- */
103
- privateKey: string;
104
- /**
105
- * DKIM selector in the domain DNS records.
106
- */
107
- selector: string;
108
- };
109
- /**
110
- * The sender of the email. Can be a string or an object with email and name properties.
111
- * @example
112
- * { email: 'email@example.com', name: 'Example' }
113
- * @example
114
- * 'email@example.com'
115
- * @example
116
- * 'Name <email@example.com>'
117
- */
118
- from: EmailsSendRecipient | string;
119
- /**
120
- * The recipient of the email. Can be an array of email addresses or an array of objects with `email` and `name` properties or a single email address string or an object with `email` and `name` properties.
121
- * @example
122
- * [
123
- * { email: 'email1@example.com', name: 'Example1' },
124
- * { email: 'email2@example.com', name: 'Example2' },
125
- * ]
126
- * @example
127
- * { email: 'email@example.com', name: 'Example' }
128
- * @example
129
- * ['email1@example.com', 'email2@example.com']
130
- * @example
131
- * 'email@example.com'
132
- * @example
133
- * 'Name <email@example.com>'
134
- */
135
- to: EmailsSendRecipient[] | EmailsSendRecipient | string[] | string;
136
- /**
137
- * Adjust open and click tracking for the message. Please note that enabling tracking for your messages requires a subscription that supports open and click tracking.
138
- */
139
- tracking?: EmailsSendTracking;
140
- /**
141
- * A single `replyTo` recipient object, or a single email address.
142
- * @example
143
- * { email: 'email@example.com', name: 'Example' }
144
- * @example
145
- * 'email@example.com'
146
- * @example
147
- * 'Name <email@example.com>'
148
- */
149
- replyTo?: EmailsSendRecipient | string;
150
- /**
151
- * The subject of the email.
152
- */
153
- subject: string;
154
- /**
155
- * Data to be used if the email is a mustache template, key-value pairs of variables to set for template rendering. Keys must be strings.
156
- *
157
- * the values can be one of the following types:
158
- * - string
159
- * - number
160
- * - boolean
161
- * - list, whose values are all of permitted types
162
- * - map, whose keys must be strings, and whose values are all of permitted types
163
- */
164
- mustaches?: Record<string, unknown>;
165
- }
166
-
167
- type EmailsSendOptions = EmailsSendOptionsBase & (
168
- | {
169
- /**
170
- * The HTML content of the email
171
- * @example
172
- * '<p>Hello World</p>'
173
- */
174
- html: string;
175
- /**
176
- * The plain text content of the email (optional when html is provided)
177
- * @example
178
- * 'Hello World'
179
- */
180
- text?: string;
181
- }
182
- | {
183
- /**
184
- * The HTML content of the email (optional when text is provided)
185
- * @example
186
- * '<p>Hello World</p>'
187
- */
188
- html?: string;
189
- /**
190
- * The plain text content of the email
191
- * @example
192
- * 'Hello World'
193
- */
194
- text: string;
195
- }
196
- );
197
-
198
- interface EmailsSendResponse {
199
- /**
200
- * Indicates if the email was successfully sent
201
- */
202
- success: boolean;
203
- /**
204
- * Fully rendered message if `dryRun` was set to `true`
205
- */
206
- data?: string[];
207
- error: string | null;
208
- }
209
-
210
- interface EmailsCheckDomainDkim {
211
- /**
212
- * Domain used for DKIM signing.
213
- */
214
- domain: string;
215
- /**
216
- * DKIM private key encoded in Base64.
217
- */
218
- privateKey: string;
219
- /**
220
- * DKIM selector in the domain DNS records.
221
- */
222
- selector: string;
223
- }
224
-
225
- interface EmailsCheckDomainOptions {
226
- /**
227
- * Up to 10 DKIM checks are allowed.
228
- */
229
- dkim: EmailsCheckDomainDkim[] | EmailsCheckDomainDkim;
230
- /**
231
- * Domain used for sending emails.
232
- */
233
- domain: string;
234
- /**
235
- * `X-MailChannels-Sender-Id` header value in emails via MailChannels.
236
- */
237
- senderId: string;
238
- }
239
-
240
- type EmailsCheckDomainVerdict = "passed" | "failed" | "soft failed" | "temporary error" | "permanent error" | "neutral" | "none" | "unknown";
241
-
242
- interface EmailsCheckDomainResponse {
243
- /**
244
- * The results of the domain checks.
245
- */
246
- results: {
247
- dkim: {
248
- domain: string;
249
- selector: string;
250
- /**
251
- * A human-readable explanation of DKIM check.
252
- */
253
- reason?: string;
254
- verdict: Extract<EmailsCheckDomainVerdict, "passed" | "failed">;
255
- }[];
256
- domainLockdown: {
257
- /**
258
- * A human-readable explanation of Domain Lockdown check.
259
- */
260
- reason?: string;
261
- verdict: Extract<EmailsCheckDomainVerdict, "passed" | "failed">;
262
- };
263
- spf: {
264
- /**
265
- * A human-readable explanation of SPF check.
266
- */
267
- reason?: string;
268
- verdict: EmailsCheckDomainVerdict;
269
- };
270
- references?: string[];
271
- } | null;
272
- /**
273
- * Link to SPF, Domain Lockdown or DKIM references, displayed if any verdict is not passed.
274
- */
275
- error: string | null;
14
+ interface EmailsSendRecipient {
15
+ /**
16
+ * The email address of the recipient.
17
+ */
18
+ email: string;
19
+ /**
20
+ * The name of the recipient.
21
+ */
22
+ name?: string;
23
+ }
24
+
25
+ interface EmailsSendAttachment {
26
+ /**
27
+ * The attachment data, encoded in base64.
28
+ */
29
+ content: string;
30
+ /**
31
+ * The name of the attachment file.
32
+ */
33
+ filename: string;
34
+ /**
35
+ * The MIME type of the attachment.
36
+ */
37
+ type: string;
38
+ }
39
+
40
+ interface EmailsSendTracking {
41
+ /**
42
+ * Track when a recipient clicks a link in your email.
43
+ * @default false
44
+ */
45
+ click?: boolean;
46
+ /**
47
+ * Track when a recipient opens your email. Please note that some email clients may not support open tracking.
48
+ * @default false
49
+ */
50
+ open?: boolean;
51
+ }
52
+
53
+ interface EmailsSendOptionsBase {
54
+ /**
55
+ * An array of attachments to be sent with the email.
56
+ */
57
+ attachments?: EmailsSendAttachment[];
58
+ /**
59
+ * The campaign identifier. If specified, this ID will be included in all relevant webhooks. It can be up to 48 UTF-8 characters long and must not contain spaces.
60
+ */
61
+ campaignId?: string;
62
+ /**
63
+ * The BCC recipients of the email. Can be an array of email addresses or an array of objects with email and name properties or a single email address string or an object with email and name properties.
64
+ * @example
65
+ * [
66
+ * { email: 'email1@example.com', name: 'Example1' },
67
+ * { email: 'email2@example.com', name: 'Example2' }
68
+ * ]
69
+ * @example
70
+ * { email: 'email@example.com', name: 'Example' }
71
+ * @example
72
+ * ['email1@example.com', 'email2@example.com']
73
+ * @example
74
+ * 'email@example.com'
75
+ * @example
76
+ * 'Name <email@example.com>'
77
+ */
78
+ bcc?: EmailsSendRecipient[] | EmailsSendRecipient | string[] | string;
79
+ /**
80
+ * The CC recipients of the email. Can be an array of email addresses or an array of objects with email and name properties or a single email address string or an object with email and name properties.
81
+ * @example
82
+ * [
83
+ * { email: 'email1@example.com', name: 'Example1' },
84
+ * { email: 'email2@example.com', name: 'Example2' }
85
+ * ]
86
+ * @example
87
+ * { email: 'email@example.com', name: 'Example' }
88
+ * @example
89
+ * ['email1@example.com', 'email2@example.com']
90
+ * @example
91
+ * 'email@example.com'
92
+ * @example
93
+ * 'Name <email@example.com>'
94
+ */
95
+ cc?: EmailsSendRecipient[] | EmailsSendRecipient | string[] | string;
96
+ /**
97
+ * The DKIM settings for the email.
98
+ */
99
+ dkim?: {
100
+ /**
101
+ * Domain used for DKIM signing.
102
+ */
103
+ domain: string;
104
+ /**
105
+ * DKIM private key encoded in Base64.
106
+ */
107
+ privateKey: string;
108
+ /**
109
+ * DKIM selector in the domain DNS records.
110
+ */
111
+ selector: string;
112
+ };
113
+ /**
114
+ * The sender of the email. Can be a string or an object with email and name properties.
115
+ * @example
116
+ * { email: 'email@example.com', name: 'Example' }
117
+ * @example
118
+ * 'email@example.com'
119
+ * @example
120
+ * 'Name <email@example.com>'
121
+ */
122
+ from: EmailsSendRecipient | string;
123
+ /**
124
+ * The recipient of the email. Can be an array of email addresses or an array of objects with `email` and `name` properties or a single email address string or an object with `email` and `name` properties.
125
+ * @example
126
+ * [
127
+ * { email: 'email1@example.com', name: 'Example1' },
128
+ * { email: 'email2@example.com', name: 'Example2' },
129
+ * ]
130
+ * @example
131
+ * { email: 'email@example.com', name: 'Example' }
132
+ * @example
133
+ * ['email1@example.com', 'email2@example.com']
134
+ * @example
135
+ * 'email@example.com'
136
+ * @example
137
+ * 'Name <email@example.com>'
138
+ */
139
+ to: EmailsSendRecipient[] | EmailsSendRecipient | string[] | string;
140
+ /**
141
+ * Adjust open and click tracking for the message. Please note that enabling tracking for your messages requires a subscription that supports open and click tracking.
142
+ */
143
+ tracking?: EmailsSendTracking;
144
+ /**
145
+ * A single `replyTo` recipient object, or a single email address.
146
+ * @example
147
+ * { email: 'email@example.com', name: 'Example' }
148
+ * @example
149
+ * 'email@example.com'
150
+ * @example
151
+ * 'Name <email@example.com>'
152
+ */
153
+ replyTo?: EmailsSendRecipient | string;
154
+ /**
155
+ * The subject of the email.
156
+ */
157
+ subject: string;
158
+ /**
159
+ * Data to be used if the email is a mustache template, key-value pairs of variables to set for template rendering. Keys must be strings.
160
+ *
161
+ * the values can be one of the following types:
162
+ * - string
163
+ * - number
164
+ * - boolean
165
+ * - list, whose values are all of permitted types
166
+ * - map, whose keys must be strings, and whose values are all of permitted types
167
+ */
168
+ mustaches?: Record<string, unknown>;
169
+ /**
170
+ * Mark these messages as transactional or non-transactional. In order for a message to be marked as non-transactional, it must have exactly one recipient per personalization, and it must be DKIM signed. 400 Bad Request will be returned if there are more than one recipient in any personalization for non-transactional messages. If a message is marked as non-transactional, it changes the sending process as follows:
171
+ *
172
+ * List-Unsubscribe headers will be added.
173
+ * @default true
174
+ */
175
+ transactional?: boolean;
176
+ }
177
+
178
+ type EmailsSendOptions = EmailsSendOptionsBase & (
179
+ | {
180
+ /**
181
+ * The HTML content of the email
182
+ * @example
183
+ * '<p>Hello World</p>'
184
+ */
185
+ html: string;
186
+ /**
187
+ * The plain text content of the email (optional when html is provided)
188
+ * @example
189
+ * 'Hello World'
190
+ */
191
+ text?: string;
192
+ }
193
+ | {
194
+ /**
195
+ * The HTML content of the email (optional when text is provided)
196
+ * @example
197
+ * '<p>Hello World</p>'
198
+ */
199
+ html?: string;
200
+ /**
201
+ * The plain text content of the email
202
+ * @example
203
+ * 'Hello World'
204
+ */
205
+ text: string;
206
+ }
207
+ );
208
+
209
+ interface EmailsSendResponse {
210
+ /**
211
+ * Indicates if the email was successfully sent
212
+ */
213
+ success: boolean;
214
+ /**
215
+ * Fully rendered message if `dryRun` was set to `true`
216
+ */
217
+ data?: string[];
218
+ error: string | null;
219
+ }
220
+
221
+ interface EmailsCheckDomainDkim {
222
+ /**
223
+ * Domain used for DKIM signing.
224
+ */
225
+ domain: string;
226
+ /**
227
+ * DKIM private key encoded in Base64.
228
+ */
229
+ privateKey: string;
230
+ /**
231
+ * DKIM selector in the domain DNS records.
232
+ */
233
+ selector: string;
234
+ }
235
+
236
+ interface EmailsCheckDomainOptions {
237
+ /**
238
+ * Up to 10 DKIM checks are allowed.
239
+ */
240
+ dkim: EmailsCheckDomainDkim[] | EmailsCheckDomainDkim;
241
+ /**
242
+ * Domain used for sending emails.
243
+ */
244
+ domain: string;
245
+ /**
246
+ * `X-MailChannels-Sender-Id` header value in emails via MailChannels.
247
+ */
248
+ senderId: string;
249
+ }
250
+
251
+ type EmailsCheckDomainVerdict = "passed" | "failed" | "soft failed" | "temporary error" | "permanent error" | "neutral" | "none" | "unknown";
252
+
253
+ interface EmailsCheckDomainResponse {
254
+ /**
255
+ * The results of the domain checks.
256
+ */
257
+ results: {
258
+ dkim: {
259
+ domain: string;
260
+ selector: string;
261
+ /**
262
+ * A human-readable explanation of DKIM check.
263
+ */
264
+ reason?: string;
265
+ verdict: Extract<EmailsCheckDomainVerdict, "passed" | "failed">;
266
+ }[];
267
+ domainLockdown: {
268
+ /**
269
+ * A human-readable explanation of Domain Lockdown check.
270
+ */
271
+ reason?: string;
272
+ verdict: Extract<EmailsCheckDomainVerdict, "passed" | "failed">;
273
+ };
274
+ spf: {
275
+ /**
276
+ * A human-readable explanation of SPF check.
277
+ */
278
+ reason?: string;
279
+ verdict: EmailsCheckDomainVerdict;
280
+ };
281
+ references?: string[];
282
+ } | null;
283
+ /**
284
+ * Link to SPF, Domain Lockdown or DKIM references, displayed if any verdict is not passed.
285
+ */
286
+ error: string | null;
276
287
  }
277
288
 
278
289
  declare class Emails {
@@ -314,22 +325,56 @@ declare class Emails {
314
325
  checkDomain(options: EmailsCheckDomainOptions): Promise<EmailsCheckDomainResponse>;
315
326
  }
316
327
 
317
- interface SuccessResponse {
318
- /**
319
- * Whether the operation was successful.
320
- */
321
- success: boolean;
322
- error: string | null;
328
+ interface SuccessResponse {
329
+ /**
330
+ * Whether the operation was successful.
331
+ */
332
+ success: boolean;
333
+ error: string | null;
323
334
  }
324
335
 
325
- interface WebhooksListResponse {
326
- webhooks: string[];
327
- error: string | null;
336
+ interface WebhooksListResponse {
337
+ webhooks: string[];
338
+ error: string | null;
328
339
  }
329
340
 
330
- interface WebhooksSigningKeyResponse {
331
- key: string | null;
332
- error: string | null;
341
+ interface WebhooksSigningKeyResponse {
342
+ key: string | null;
343
+ error: string | null;
344
+ }
345
+
346
+ interface WebhooksValidateResponse {
347
+ /**
348
+ * Indicates whether all webhook validations passed
349
+ */
350
+ allPassed: boolean;
351
+ /**
352
+ * Detailed results for each tested webhook, including whether it returned a 2xx status code, along with its response status code and body.
353
+ */
354
+ results: {
355
+ /**
356
+ * Indicates whether the webhook responded with a 2xx HTTP status code
357
+ */
358
+ result: "passed" | "failed";
359
+ /**
360
+ * The webhook that was validated
361
+ */
362
+ webhook: string;
363
+ /**
364
+ * The HTTP response returned by the webhook, including status code and response body. A null value indicates no response was received. Possible reasons include timeouts, connection failures, or other network-related issues.
365
+ */
366
+ response: {
367
+ /**
368
+ * Response body from webhook. Returns an error if unprocessable or too large.
369
+ */
370
+ body?: string;
371
+ /**
372
+ * HTTP status code returned by the webhook
373
+ */
374
+ status: number;
375
+ } | null;
376
+ }[];
377
+ error: string | null;
333
378
  }
334
379
 
335
380
  declare class Webhooks {
@@ -337,7 +382,7 @@ declare class Webhooks {
337
382
  constructor(mailchannels: MailChannelsClient);
338
383
  /**
339
384
  * Enrolls the customer to receive event notifications via webhooks.
340
- * @param endpoint - The URL to receive event notifications.
385
+ * @param endpoint - The URL to receive event notifications. Must be no longer than `8000` characters.
341
386
  * @example
342
387
  * ```ts
343
388
  * const mailchannels = new MailChannels('your-api-key')
@@ -373,102 +418,149 @@ declare class Webhooks {
373
418
  * ```
374
419
  */
375
420
  getSigningKey(id: string): Promise<WebhooksSigningKeyResponse>;
421
+ /**
422
+ * Validates whether your enrolled webhook(s) respond with an HTTP `2xx` status code. Sends a test request to each webhook containing your customer handle, a hardcoded event type (`test`), a hardcoded sender email (`test@mailchannels.com`), a timestamp, a request ID (provided or generated), and an SMTP ID. The response includes the HTTP status code and body returned by each webhook.
423
+ * @param requestId - Optional identifier in the webhook payload. If not provided, a value will be automatically generated. Must not exceed 28 characters.
424
+ * @example
425
+ * ```ts
426
+ * const mailchannels = new MailChannels('your-api-key')
427
+ * const { allPassed, results } = await mailchannels.webhooks.validate('optional-request-id')
428
+ * ```
429
+ */
430
+ validate(requestId?: string): Promise<WebhooksValidateResponse>;
431
+ }
432
+
433
+ interface SubAccountsAccount {
434
+ /**
435
+ * The name of the company associated with the sub-account.
436
+ */
437
+ companyName: string;
438
+ /**
439
+ * If the sub-account is enabled.
440
+ */
441
+ enabled: boolean;
442
+ /**
443
+ * The handle for the sub-account.
444
+ */
445
+ handle: string;
446
+ }
447
+
448
+ interface SubAccountsCreateResponse {
449
+ account: SubAccountsAccount | null;
450
+ error: string | null;
451
+ }
452
+
453
+ interface SubAccountsListOptions {
454
+ /**
455
+ * Possible values are `1` to `1000`.
456
+ * @default 1000
457
+ */
458
+ limit?: number;
459
+ /**
460
+ * The offset for pagination.
461
+ * @default 0
462
+ */
463
+ offset?: number;
464
+ }
465
+
466
+ interface SubAccountsListResponse {
467
+ accounts: SubAccountsAccount[];
468
+ error: string | null;
469
+ }
470
+
471
+ interface SubAccountsApiKey {
472
+ /**
473
+ * The API key ID for the sub-account.
474
+ */
475
+ id: number;
476
+ /**
477
+ * API key for the sub-account.
478
+ */
479
+ value: string;
480
+ }
481
+
482
+ interface SubAccountsCreateApiKeyResponse {
483
+ key: SubAccountsApiKey | null;
484
+ error: string | null;
485
+ }
486
+
487
+ interface SubAccountsListApiKeyResponse {
488
+ keys: SubAccountsApiKey[];
489
+ error: string | null;
490
+ }
491
+
492
+ interface SubAccountsSmtpPassword {
493
+ /**
494
+ * Whether the SMTP password is enabled.
495
+ */
496
+ enabled: boolean;
497
+ /**
498
+ * The SMTP password ID for the sub-account.
499
+ */
500
+ id: number;
501
+ /**
502
+ * SMTP password for the sub-account.
503
+ */
504
+ value: string;
505
+ }
506
+
507
+ interface SubAccountsCreateSmtpPasswordResponse {
508
+ password: SubAccountsSmtpPassword | null;
509
+ error: string | null;
510
+ }
511
+
512
+ interface SubAccountsListSmtpPasswordResponse {
513
+ passwords: SubAccountsSmtpPassword[];
514
+ error: string | null;
515
+ }
516
+
517
+ interface SubAccountsLimit {
518
+ sends: number;
519
+ }
520
+
521
+ interface SubAccountsLimitResponse {
522
+ limit: SubAccountsLimit | null;
523
+ error: string | null;
524
+ }
525
+
526
+ interface SubAccountsUsage {
527
+ /**
528
+ * The end date of the current billing period (ISO 8601 format).
529
+ * @example "2025-04-11"
530
+ */
531
+ endDate?: string;
532
+ /**
533
+ * The start date of the current billing period (ISO 8601 format).
534
+ * @example "2025-03-12"
535
+ */
536
+ startDate?: string;
537
+ /**
538
+ * The total usage for the current billing period.
539
+ */
540
+ total: number;
376
541
  }
377
542
 
378
- interface SubAccountsAccount {
379
- /**
380
- * If the sub-account is enabled.
381
- */
382
- enabled: boolean;
383
- /**
384
- * The handle for the sub-account.
385
- */
386
- handle: string;
387
- }
388
-
389
- interface SubAccountsCreateResponse {
390
- account: SubAccountsAccount | null;
391
- error: string | null;
392
- }
393
-
394
- interface SubAccountsListOptions {
395
- /**
396
- * Possible values are `1` to `1000`.
397
- * @default 1000
398
- */
399
- limit?: number;
400
- /**
401
- * The offset for pagination.
402
- * @default 0
403
- */
404
- offset?: number;
405
- }
406
-
407
- interface SubAccountsListResponse {
408
- accounts: SubAccountsAccount[];
409
- error: string | null;
410
- }
411
-
412
- interface SubAccountsApiKey {
413
- /**
414
- * The API key ID for the sub-account.
415
- */
416
- id: number;
417
- /**
418
- * API key for the sub-account.
419
- */
420
- value: string;
421
- }
422
-
423
- interface SubAccountsCreateApiKeyResponse {
424
- key: SubAccountsApiKey | null;
425
- error: string | null;
426
- }
427
-
428
- interface SubAccountsListApiKeyResponse {
429
- keys: SubAccountsApiKey[];
430
- error: string | null;
431
- }
432
-
433
- interface SubAccountsSmtpPassword {
434
- /**
435
- * Whether the SMTP password is enabled.
436
- */
437
- enabled: boolean;
438
- /**
439
- * The SMTP password ID for the sub-account.
440
- */
441
- id: number;
442
- /**
443
- * SMTP password for the sub-account.
444
- */
445
- value: string;
446
- }
447
-
448
- interface SubAccountsCreateSmtpPasswordResponse {
449
- password: SubAccountsSmtpPassword | null;
450
- error: string | null;
451
- }
452
-
453
- interface SubAccountsListSmtpPasswordResponse {
454
- passwords: SubAccountsSmtpPassword[];
455
- error: string | null;
543
+ interface SubAccountsUsageResponse {
544
+ usage: SubAccountsUsage | null;
545
+ error: string | null;
456
546
  }
457
547
 
458
548
  declare class SubAccounts {
459
549
  protected mailchannels: MailChannelsClient;
550
+ private static readonly COMPANY_PATTERN;
460
551
  private static readonly HANDLE_PATTERN;
461
552
  constructor(mailchannels: MailChannelsClient);
462
553
  /**
463
- * Creates a new sub-account under the parent account. Each sub-account must have a unique handle composed solely of lowercase alphanumeric characters. If no handle is provided, a random handle will be generated.
464
- * @param handle - The handle of the sub-account to create. Sub-account handle must match the pattern `[a-z0-9]{3,128}`.
554
+ * Creates a new sub-account under the parent account. Each sub-account must have a unique handle composed solely of lowercase alphanumeric characters. If no handle is provided, a random handle will be generated. Note that Sub-accounts are only available to parent accounts on 100K and higher plans.
555
+ * @param companyName - The name of the company associated with the sub-account. This name is used for display purposes only and does not affect the functionality of the sub-account. The length must be between 3 and 128 characters.
556
+ * @param handle - A unique name for the sub-account to be created. The length must be between 3 and 128 characters, and it may contain only lowercase letters and numbers. If not provided, a random handle will be generated.
465
557
  * @example
466
558
  * ```ts
467
559
  * const mailchannels = new MailChannels('your-api-key')
468
- * const { account } = await mailchannels.subAccounts.create('validhandle123')
560
+ * const { account } = await mailchannels.subAccounts.create('My Company', 'validhandle123')
469
561
  * ```
470
562
  */
471
- create(handle?: string): Promise<SubAccountsCreateResponse>;
563
+ create(companyName: string, handle?: string): Promise<SubAccountsCreateResponse>;
472
564
  /**
473
565
  * Retrieves all sub-accounts associated with the parent account. The response is paginated with a default limit of 1000 sub-accounts per page and an offset of 0.
474
566
  * @param options - The options to filter the list of sub-accounts.
@@ -570,283 +662,615 @@ declare class SubAccounts {
570
662
  * ```
571
663
  */
572
664
  deleteSmtpPassword(handle: string, id: number): Promise<SuccessResponse>;
665
+ /**
666
+ * Retrieves the limit of a specified sub-account. A value of `-1` indicates that the sub-account inherits the parent account's limit, allowing the sub-account to utilize any remaining capacity within the parent account's allocation.
667
+ * @param handle - Handle of the sub-account to retrieve the limit for.
668
+ * @example
669
+ * ```ts
670
+ * const mailchannels = new MailChannels('your-api-key')
671
+ * const { limit } = await mailchannels.subAccounts.getLimit('validhandle123')
672
+ * ```
673
+ */
674
+ getLimit(handle: string): Promise<SubAccountsLimitResponse>;
675
+ /**
676
+ * Sets the limit for the specified sub-account.
677
+ * @param handle - Handle of the sub-account to set limit for.
678
+ * @param limit - The limits to set for the sub-account. The minimum allowed sends is `0`
679
+ * @example
680
+ * ```ts
681
+ * const mailchannels = new MailChannels('your-api-key')
682
+ * const { success } = await mailchannels.subAccounts.setLimit('validhandle123', { sends: 1000 })
683
+ * ```
684
+ */
685
+ setLimit(handle: string, limit: SubAccountsLimit): Promise<SuccessResponse>;
686
+ /**
687
+ * Deletes the limit for the specified sub-account. After a successful deletion, the specified sub-account will be limited to the parent account's limit.
688
+ * @param handle - Handle of the sub-account to delete limit for.
689
+ * @example
690
+ * ```ts
691
+ * const mailchannels = new MailChannels('your-api-key')
692
+ * const { success } = await mailchannels.subAccounts.deleteLimit('validhandle123')
693
+ * ```
694
+ */
695
+ deleteLimit(handle: string): Promise<SuccessResponse>;
696
+ /**
697
+ * Retrieves usage statistics for the specified sub-account during the current billing period.
698
+ * @param handle - Handle of the sub-account to query usage stats for.
699
+ * @example
700
+ * ```ts
701
+ * const mailchannels = new MailChannels('your-api-key')
702
+ * const { usage } = await mailchannels.subAccounts.getUsage('validhandle123')
703
+ * ```
704
+ */
705
+ getUsage(handle: string): Promise<SubAccountsUsageResponse>;
573
706
  }
574
707
 
575
- interface ServiceSubscriptionsResponse {
576
- subscriptions: {
577
- active: boolean;
578
- activeAccountsCount: number;
579
- handle: string;
580
- limits: {
581
- featureHandle: string;
582
- value: string;
583
- }[];
584
- plan: {
585
- handle: string;
586
- name: string;
587
- };
588
- }[];
589
- error: string | null;
590
- }
591
-
592
- interface ServiceReportOptions {
593
- /**
594
- * The report type. It can be either `false_negative` or `false_positive`.
595
- */
596
- type: "false_negative" | "false_positive";
597
- /**
598
- * The full, unaltered message content in accordance with the RFC 2822 specifications without dot stuffing.
599
- */
600
- messageContent: string;
601
- /**
602
- * The SMTP envelope information
603
- */
604
- smtpEnvelopeInformation?: {
605
- ehlo: string;
606
- mailFrom: string;
607
- rcptTo: string;
608
- };
609
- /**
610
- * The sending host information.
611
- */
612
- sendingHostInformation?: {
613
- name: string;
614
- };
708
+ interface MetricsEngagement {
709
+ buckets: {
710
+ click: MetricsBucket[];
711
+ clickTrackingDelivered: MetricsBucket[];
712
+ open: MetricsBucket[];
713
+ openTrackingDelivered: MetricsBucket[];
714
+ };
715
+ click: number;
716
+ clickTrackingDelivered: number;
717
+ endTime: string;
718
+ open: number;
719
+ openTrackingDelivered: number;
720
+ startTime: string;
615
721
  }
616
722
 
617
- declare class Service {
723
+ interface MetricsEngagementResponse {
724
+ engagement: MetricsEngagement | null;
725
+ error: string | null;
726
+ }
727
+
728
+ interface MetricsPerformance {
729
+ /**
730
+ * Count of messages bounced during the specified time range.
731
+ */
732
+ bounced: number;
733
+ buckets: {
734
+ bounced: MetricsBucket[];
735
+ delivered: MetricsBucket[];
736
+ processed: MetricsBucket[];
737
+ };
738
+ /**
739
+ * Count of messages delivered during the specified time range.
740
+ */
741
+ delivered: number;
742
+ /**
743
+ * The end of the time range for retrieving message performance metrics (exclusive).
744
+ */
745
+ endTime: string;
746
+ /**
747
+ * Count of messages processed during the specified time range.
748
+ */
749
+ processed: number;
750
+ /**
751
+ * The beginning of the time range for retrieving message performance metrics (inclusive).
752
+ */
753
+ startTime: string;
754
+ }
755
+
756
+ interface MetricsPerformanceResponse {
757
+ performance: MetricsPerformance | null;
758
+ error: string | null;
759
+ }
760
+
761
+ interface MetricsRecipientBehaviour {
762
+ buckets: {
763
+ unsubscribeDelivered: MetricsBucket[];
764
+ unsubscribed: MetricsBucket[];
765
+ };
766
+ /**
767
+ * The end of the time range for retrieving recipient behaviour metrics (exclusive).
768
+ */
769
+ endTime: string;
770
+ /**
771
+ * The beginning of the time range for retrieving recipient behaviour metrics (inclusive).
772
+ */
773
+ startTime: string;
774
+ /**
775
+ * Count of recipients of delivered messages that include at least one of the unsubscribe link or unsubscribe headers. Since the unsubscribe feature requires exactly one recipient per message, this count also represents the total number of delivered messages.
776
+ */
777
+ unsubscribeDelivered: number;
778
+ /**
779
+ * Count of unsubscribed events by recipients.
780
+ */
781
+ unsubscribed: number;
782
+ }
783
+
784
+ interface MetricsRecipientBehaviourResponse {
785
+ behaviour: MetricsRecipientBehaviour | null;
786
+ error: string | null;
787
+ }
788
+
789
+ interface MetricsVolume {
790
+ buckets: {
791
+ delivered: MetricsBucket[];
792
+ dropped: MetricsBucket[];
793
+ processed: MetricsBucket[];
794
+ };
795
+ /**
796
+ * Count of messages delivered during the specified time range.
797
+ */
798
+ delivered: number;
799
+ /**
800
+ * Count of messages dropped during the specified time range.
801
+ */
802
+ dropped: number;
803
+ /**
804
+ * The end of the time range for retrieving message volume metrics (exclusive).
805
+ */
806
+ endTime: string;
807
+ /**
808
+ * Count of messages processed during the specified time range.
809
+ */
810
+ processed: number;
811
+ /**
812
+ * The beginning of the time range for retrieving message volume metrics (inclusive).
813
+ */
814
+ startTime: string;
815
+ }
816
+
817
+ interface MetricsVolumeResponse {
818
+ volume: MetricsVolume | null;
819
+ error: string | null;
820
+ }
821
+
822
+ interface MetricsUsageResponse {
823
+ usage: {
824
+ /**
825
+ * The end date of the current billing period (ISO 8601 format).
826
+ * @example "2025-04-11"
827
+ */
828
+ endDate: string;
829
+ /**
830
+ * The start date of the current billing period (ISO 8601 format).
831
+ * @example "2025-03-12"
832
+ */
833
+ startDate: string;
834
+ /**
835
+ * The total usage for the current billing period.
836
+ */
837
+ total: number;
838
+ } | null;
839
+ error: string | null;
840
+ }
841
+
842
+ interface MetricsBucket {
843
+ /**
844
+ * The number of events or occurrences aggregated within this time period.
845
+ */
846
+ count: number;
847
+ /**
848
+ * The starting date and time of the time period this bucket represents.
849
+ */
850
+ periodStart: string;
851
+ }
852
+
853
+ interface MetricsOptions {
854
+ /**
855
+ * The beginning of the time range for retrieving message metrics (inclusive). Formats: `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SSZ`. Defaults to one month ago if not provided.
856
+ * @example "2025-05-26"
857
+ */
858
+ startTime?: string;
859
+ /**
860
+ * The end of the time range for retrieving message metrics (exclusive). Formats: `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SSZ`. Defaults to the current time if not provided.
861
+ * @example "2025-05-31T15:16:17Z"
862
+ */
863
+ endTime?: string;
864
+ /**
865
+ * The ID of the campaign to filter metrics by. If not provided, metrics for all campaigns will be returned.
866
+ */
867
+ campaignId?: string;
868
+ /**
869
+ * The interval for aggregating metrics data.
870
+ * @default "day"
871
+ */
872
+ interval?: "hour" | "day" | "week" | "month";
873
+ }
874
+
875
+ declare class Metrics {
618
876
  protected mailchannels: MailChannelsClient;
619
877
  constructor(mailchannels: MailChannelsClient);
620
878
  /**
621
- * Retrieve the condition of the service
879
+ * Retrieve engagement metrics for messages sent from your account, including counts of open and click events. Supports optional filters for time range, and campaign ID.
880
+ * @param options - Options to filter and customize the engagement metrics retrieval.
622
881
  * @example
623
882
  * ```ts
624
883
  * const mailchannels = new MailChannels('your-api-key')
625
- * const { success } = await mailchannels.service.status()
884
+ * const { engagement } = await mailchannels.metrics.engagement()
626
885
  * ```
627
886
  */
628
- status(): Promise<SuccessResponse>;
887
+ engagement(options?: MetricsOptions): Promise<MetricsEngagementResponse>;
629
888
  /**
630
- * Get a list of your subscriptions to MailChannels Inbound
889
+ * Retrieve performance metrics for messages sent from your account, including counts of processed, delivered, hard-bounced events. Supports optional filters for time range, and campaign ID.
890
+ * @param options - Options to filter and customize the performance metrics retrieval.
631
891
  * @example
632
892
  * ```ts
633
893
  * const mailchannels = new MailChannels('your-api-key')
634
- * const { subscriptions } = await mailchannels.service.subscriptions()
894
+ * const { performance } = await mailchannels.metrics.performance()
635
895
  * ```
636
896
  */
637
- subscriptions(): Promise<ServiceSubscriptionsResponse>;
897
+ performance(options?: MetricsOptions): Promise<MetricsPerformanceResponse>;
638
898
  /**
639
- * Submit a false negative or false positive report.
640
- * @param options - The report options
899
+ * Retrieve recipient behaviour metrics for messages sent from your account, including counts of unsubscribed events. Supports optional filters for time range, and campaign ID.
900
+ * @param options - Options to filter and customize the recipient behaviour metrics retrieval.
901
+ * @example
902
+ * ```ts
903
+ * const mailchannels = new MailChannels('your-api-key')
904
+ * const { behaviour } = await mailchannels.metrics.recipientBehaviour()
905
+ * ```
641
906
  */
642
- report(options: ServiceReportOptions): Promise<SuccessResponse>;
907
+ recipientBehaviour(options?: MetricsOptions): Promise<MetricsRecipientBehaviourResponse>;
908
+ /**
909
+ * Retrieve volume metrics for messages sent from your account, including counts of processed, delivered and dropped events. Supports optional filters for time range and campaign ID.
910
+ * @param options - Options to filter and customize the volume metrics retrieval.
911
+ * @example
912
+ * ```ts
913
+ * const mailchannels = new MailChannels('your-api-key')
914
+ * const { volume } = await mailchannels.metrics.volume()
915
+ * ```
916
+ */
917
+ volume(options?: MetricsOptions): Promise<MetricsVolumeResponse>;
918
+ /**
919
+ * Retrieves usage statistics during the current billing period.
920
+ * @example
921
+ * ```ts
922
+ * const mailchannels = new MailChannels('your-api-key')
923
+ * const { usage } = await mailchannels.metrics.usage()
924
+ * ```
925
+ */
926
+ usage(): Promise<MetricsUsageResponse>;
927
+ }
928
+
929
+ type SuppressionsTypes = "transactional" | "non-transactional";
930
+
931
+ interface SuppressionsCreateOptions {
932
+ /**
933
+ * If true, the parent account creates suppression entries for all associated sub-accounts. This field is only applicable to parent accounts. Sub-accounts cannot create entries for other sub-accounts.
934
+ * @default false
935
+ */
936
+ addToSubAccounts?: boolean;
937
+ /**
938
+ * The total number of suppression entries to create, for the parent and/or its sub-accounts, must not exceed `1000`.
939
+ */
940
+ entries: {
941
+ /**
942
+ * Must be less than `1024` characters.
943
+ */
944
+ notes?: string;
945
+ /**
946
+ * The email address to suppress. Must be a valid email address format and less than `255` characters.
947
+ */
948
+ recipient: string;
949
+ /**
950
+ * An array of types of suppression to apply to the recipient.
951
+ * @default ["non-transactional"]
952
+ */
953
+ types?: SuppressionsTypes[];
954
+ }[];
955
+ }
956
+
957
+ type SuppressionsSource = "api" | "unsubscribe_link" | "list_unsubscribe" | "hard_bounce" | "spam_complaint" | "all";
958
+
959
+ interface SuppressionsListOptions {
960
+ /**
961
+ * The email address of the suppression entry to search for. If provided, the search will return the suppression entry associated with this recipient. If not provided, the search will return all suppression entries for the account.
962
+ */
963
+ recipient?: string;
964
+ /**
965
+ * The source of the suppression entries to filter by. If not provided, suppression entries from all sources will be returned.
966
+ */
967
+ source?: Exclude<SuppressionsSource, "all">;
968
+ /**
969
+ * The date and/or time before which the suppression entries were created. Format: `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SSZ`
970
+ */
971
+ createdBefore?: string;
972
+ /**
973
+ * The date and/or time after which the suppression entries were created. Format: `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SSZ`
974
+ */
975
+ createdAfter?: string;
976
+ /**
977
+ * The maximum number of suppression entries to return. Must be between `1` and `1000`.
978
+ * @default 1000
979
+ */
980
+ limit?: number;
981
+ /**
982
+ * The number of suppression entries to skip before returning results.
983
+ * @default 0
984
+ */
985
+ offset?: number;
643
986
  }
644
987
 
645
- type ListNames = "blocklist" | "safelist" | "blacklist" | "whitelist";
646
-
647
- interface ListEntryOptions {
648
- /**
649
- * This can be a `blocklist`, `safelist`, `blacklist`, or `whitelist`.
650
- */
651
- listName: ListNames;
652
- /**
653
- * This can be a domain, email address, or IP address. The type of the entry is automatically determined based on the value.
654
- */
655
- item: string;
656
- }
657
-
658
- interface ListEntry {
659
- action: Extract<ListNames, "blocklist" | "safelist">;
660
- item: string;
661
- type: "domain" | "email_address" | "ip_address";
662
- }
663
-
664
- interface ListEntryResponse {
665
- entry: ListEntry | null;
666
- error: string | null;
667
- }
668
-
669
- interface ListEntriesResponse {
670
- entries: ListEntry[];
671
- error: string | null;
672
- }
673
-
674
- interface DomainsData {
675
- /**
676
- * The domain name.
677
- */
678
- domain: string;
679
- /**
680
- * The abuse policy settings for the domain. These settings determine how spam messages are handled.
681
- */
682
- settings?: Partial<{
683
- /**
684
- * The abuse policy.
685
- */
686
- abusePolicy: "block" | "flag" | "quarantine";
687
- /**
688
- * If `true`, this abuse policy overrides the recipient abuse policy.
689
- */
690
- abusePolicyOverride: boolean;
691
- /**
692
- * The spam header name to use if the abuse policy is set to `flag`.
693
- */
694
- spamHeaderName: string;
695
- /**
696
- * The spam header value to use if the abuse policy is set to `flag`.
697
- */
698
- spamHeaderValue: string;
699
- }>;
700
- /**
701
- * A list of email addresses that are the domain admins for the domain.
702
- */
703
- admins?: string[] | null;
704
- /**
705
- * The locations of mail servers to which messages will be delivered after filtering.
706
- */
707
- downstreamAddresses?: {
708
- /**
709
- * The priority of the downstream address. Only addresses with the highest priority (the lowest numerical value) are selected.
710
- */
711
- priority: number;
712
- /**
713
- * Downstream addresses are selected in proportion to their weights. For example, if there are two downstream addresses, A with weight 40, and B with weight 10, then A is selected 80% of the time and B is selected 20% of the time.
714
- */
715
- weight: number;
716
- /**
717
- * TCP port on which the downstream mail server is listening.
718
- */
719
- port: number;
720
- /**
721
- * The canonical hostname of the host providing the service, ending in a dot.
722
- */
723
- target: string;
724
- }[] | null;
725
- /**
726
- * A list of aliases for the domain. Mail is accepted for these domains and routed to the `downstreamAddresses` defined for the domain. Must be <= 255 characters
727
- */
728
- aliases?: string[] | null;
729
- /**
730
- * The subscription `handle` that identifies the subscription that this domain should be provisioned against. Subscription handles can be retrieved from the `subscriptions` service method.
731
- */
732
- subscriptionHandle: string;
733
- }
734
-
735
- interface DomainsProvisionOptions {
736
- /**
737
- * If present and set to true, the domain will be associated with the api-key that created it. This means that this api-key must be used for inbound-api actions involving this domain (for example adding safe/block list entries, etc).
738
- */
739
- associateKey?: boolean;
740
- /**
741
- * If present and set to true, the settings (domain settings, downstream addresses, aliases and admins) for the domain will be overwritten with the ones in the request if the domain already exists, unless a section is not included in the request or there is problem updating a setting in which case the previous settings are carried forward.
742
- */
743
- overwrite?: boolean;
744
- }
745
-
746
- type DomainsBulkProvisionOptions = DomainsProvisionOptions & Pick<DomainsData, "subscriptionHandle">;
747
-
748
- interface DomainsProvisionResponse {
749
- data: DomainsData | null;
750
- error: string | null;
751
- }
752
-
753
- interface DomainsBulkProvisionResponse {
754
- /**
755
- * If the request was processed successfully, this does not necessarily mean all the domains in the request were successfully provisioned.
756
- */
757
- results: {
758
- /**
759
- * Domains that were successfully provisioned or updated.
760
- */
761
- successes: {
762
- domain: DomainsData;
763
- code: number;
764
- comment?: string;
765
- }[];
766
- /**
767
- * Domains that were not successfully provisioned.
768
- */
769
- errors: {
770
- domain: DomainsData;
771
- code: number;
772
- comment?: string;
773
- }[];
774
- } | null;
775
- error: string | null;
776
- }
777
-
778
- interface DomainsListOptions {
779
- /**
780
- * A list of domains to fetch. If this parameter is present, only domains whose name matches an item in this list are returned.
781
- */
782
- domains?: string[];
783
- /**
784
- * The maximum number of domains included in the response. Possible values are 1 to 5000
785
- * @default 10
786
- */
787
- limit?: number;
788
- /**
789
- * Offset into the list of domains to return.
790
- * @default 0
791
- */
792
- offset?: number;
793
- }
794
-
795
- interface DomainsListResponse {
796
- /**
797
- * A list of domains
798
- */
799
- domains: DomainsData[];
800
- /**
801
- * The total number of domains that are accessible with the given API key that match the list of domains in the 'domains' parameter. If there is no 'domains' parameter, this field is the total number of domains that are accessible with with this API key. A domain is accessible with a given API key if it is associated with that API key, or if it is not associated with any API key.
802
- */
803
- total: number;
804
- error: string | null;
805
- }
806
-
807
- interface DomainsCreateLoginLinkResponse {
808
- /**
809
- * If a user browses to this URL, they will be automatically logged in as a domain admin.
810
- */
811
- link: string | null;
812
- error: string | null;
813
- }
814
-
815
- interface DomainsListDownstreamAddressesOptions {
816
- /**
817
- * The number of records to return.
818
- * @default 10
819
- */
820
- limit?: number;
821
- /**
822
- * The offset into the records to return.
823
- * @default 0
824
- */
825
- offset?: number;
826
- }
827
-
828
- interface DomainsDownstreamAddress {
829
- /**
830
- * TCP port on which the downstream mail server is listening.
831
- */
832
- port: number;
833
- /**
834
- * The priority of the downstream address. Only addresses with the highest priority (the lowest numerical value) are selected.
835
- */
836
- priority: number;
837
- /**
838
- * The canonical hostname of the host providing the service, ending in a dot.
839
- */
840
- target: string;
841
- /**
842
- * Downstream addresses are selected in proportion to their weights. For example, if there are two downstream addresses, A with weight 40, and B with weight 10, then A is selected 80% of the time and B is selected 20% of the time.
843
- */
844
- weight: number;
845
- }
846
-
847
- interface DomainsListDownstreamAddressesResponse {
848
- records: DomainsDownstreamAddress[];
849
- error: string | null;
988
+ interface SuppressionsListEntry {
989
+ createdAt: string;
990
+ notes?: string;
991
+ /**
992
+ * The email address that is suppressed.
993
+ */
994
+ recipient: string;
995
+ sender?: string;
996
+ source: SuppressionsSource;
997
+ types: SuppressionsTypes[];
998
+ }
999
+
1000
+ interface SuppressionsListResponse {
1001
+ list: SuppressionsListEntry[];
1002
+ error: string | null;
1003
+ }
1004
+
1005
+ declare class Suppressions {
1006
+ protected mailchannels: MailChannelsClient;
1007
+ constructor(mailchannels: MailChannelsClient);
1008
+ /**
1009
+ * Creates suppression entries for the specified account. Parent accounts can create suppression entries for all associated sub-accounts. If `types` is not provided, it defaults to `non-transactional`. The operation is atomic, meaning all entries are successfully added or none are added if an error occurs.
1010
+ * @param options - The details of the suppression entries to create.
1011
+ * @example
1012
+ * ```ts
1013
+ * const mailchannels = new MailChannels('your-api-key')
1014
+ * const { success } = await mailchannels.suppressions.create({
1015
+ * // ...
1016
+ * });
1017
+ */
1018
+ create(options: SuppressionsCreateOptions): Promise<SuccessResponse>;
1019
+ /**
1020
+ * Deletes suppression entry associated with the account based on the specified recipient and source.
1021
+ * @param recipient - The email address of the suppression entry to delete.
1022
+ * @param source - The source of the suppression entry to be deleted. If source is not provided, it defaults to `api`. If source is set to `all`, all suppression entries related to the specified recipient will be deleted.
1023
+ * @example
1024
+ * ```ts
1025
+ * const mailchannels = new MailChannels('your-api-key')
1026
+ * const { success } = await mailchannels.suppressions.delete('name@example.com', 'api');
1027
+ * ```
1028
+ */
1029
+ delete(recipient: string, source?: SuppressionsSource): Promise<SuccessResponse>;
1030
+ /**
1031
+ * Retrieve suppression entries associated with the specified account. Supports filtering by recipient, source and creation date range. The response is paginated, with a default limit of `1000` entries per page and an offset of `0`.
1032
+ * @example
1033
+ * ```ts
1034
+ * const mailchannels = new MailChannels('your-api-key')
1035
+ * const { list }= await mailchannels.suppressions.list();
1036
+ * ```
1037
+ * @param options - Options to filter and customize the suppression entries retrieval.
1038
+ */
1039
+ list(options?: SuppressionsListOptions): Promise<SuppressionsListResponse>;
1040
+ }
1041
+
1042
+ type ListNames = "blocklist" | "safelist" | "blacklist" | "whitelist";
1043
+
1044
+ interface ListEntryOptions {
1045
+ /**
1046
+ * This can be a `blocklist`, `safelist`, `blacklist`, or `whitelist`.
1047
+ */
1048
+ listName: ListNames;
1049
+ /**
1050
+ * This can be a domain, email address, or IP address. The type of the entry is automatically determined based on the value.
1051
+ */
1052
+ item: string;
1053
+ }
1054
+
1055
+ interface ListEntry {
1056
+ action: Extract<ListNames, "blocklist" | "safelist">;
1057
+ item: string;
1058
+ type: "domain" | "email_address" | "ip_address";
1059
+ }
1060
+
1061
+ interface ListEntryResponse {
1062
+ entry: ListEntry | null;
1063
+ error: string | null;
1064
+ }
1065
+
1066
+ interface ListEntriesResponse {
1067
+ entries: ListEntry[];
1068
+ error: string | null;
1069
+ }
1070
+
1071
+ interface DomainsData {
1072
+ /**
1073
+ * The domain name.
1074
+ */
1075
+ domain: string;
1076
+ /**
1077
+ * The abuse policy settings for the domain. These settings determine how spam messages are handled.
1078
+ */
1079
+ settings?: Partial<{
1080
+ /**
1081
+ * The abuse policy.
1082
+ */
1083
+ abusePolicy: "block" | "flag" | "quarantine";
1084
+ /**
1085
+ * If `true`, this abuse policy overrides the recipient abuse policy.
1086
+ */
1087
+ abusePolicyOverride: boolean;
1088
+ /**
1089
+ * The spam header name to use if the abuse policy is set to `flag`.
1090
+ */
1091
+ spamHeaderName: string;
1092
+ /**
1093
+ * The spam header value to use if the abuse policy is set to `flag`.
1094
+ */
1095
+ spamHeaderValue: string;
1096
+ }>;
1097
+ /**
1098
+ * A list of email addresses that are the domain admins for the domain.
1099
+ */
1100
+ admins?: string[] | null;
1101
+ /**
1102
+ * The locations of mail servers to which messages will be delivered after filtering.
1103
+ */
1104
+ downstreamAddresses?: {
1105
+ /**
1106
+ * The priority of the downstream address. Only addresses with the highest priority (the lowest numerical value) are selected.
1107
+ */
1108
+ priority: number;
1109
+ /**
1110
+ * Downstream addresses are selected in proportion to their weights. For example, if there are two downstream addresses, A with weight 40, and B with weight 10, then A is selected 80% of the time and B is selected 20% of the time.
1111
+ */
1112
+ weight: number;
1113
+ /**
1114
+ * TCP port on which the downstream mail server is listening.
1115
+ */
1116
+ port: number;
1117
+ /**
1118
+ * The canonical hostname of the host providing the service, ending in a dot.
1119
+ */
1120
+ target: string;
1121
+ }[] | null;
1122
+ /**
1123
+ * A list of aliases for the domain. Mail is accepted for these domains and routed to the `downstreamAddresses` defined for the domain. Must be <= 255 characters
1124
+ */
1125
+ aliases?: string[] | null;
1126
+ /**
1127
+ * The subscription `handle` that identifies the subscription that this domain should be provisioned against. Subscription handles can be retrieved from the `subscriptions` service method.
1128
+ */
1129
+ subscriptionHandle: string;
1130
+ }
1131
+
1132
+ interface DomainsProvisionOptions {
1133
+ /**
1134
+ * If present and set to true, the domain will be associated with the api-key that created it. This means that this api-key must be used for inbound-api actions involving this domain (for example adding safe/block list entries, etc).
1135
+ */
1136
+ associateKey?: boolean;
1137
+ /**
1138
+ * If present and set to true, the settings (domain settings, downstream addresses, aliases and admins) for the domain will be overwritten with the ones in the request if the domain already exists, unless a section is not included in the request or there is problem updating a setting in which case the previous settings are carried forward.
1139
+ */
1140
+ overwrite?: boolean;
1141
+ }
1142
+
1143
+ type DomainsBulkProvisionOptions = DomainsProvisionOptions & Pick<DomainsData, "subscriptionHandle">;
1144
+
1145
+ interface DomainsProvisionResponse {
1146
+ data: DomainsData | null;
1147
+ error: string | null;
1148
+ }
1149
+
1150
+ interface DomainsBulkProvisionResponse {
1151
+ /**
1152
+ * If the request was processed successfully, this does not necessarily mean all the domains in the request were successfully provisioned.
1153
+ */
1154
+ results: {
1155
+ /**
1156
+ * Domains that were successfully provisioned or updated.
1157
+ */
1158
+ successes: {
1159
+ domain: DomainsData;
1160
+ code: number;
1161
+ comment?: string;
1162
+ }[];
1163
+ /**
1164
+ * Domains that were not successfully provisioned.
1165
+ */
1166
+ errors: {
1167
+ domain: DomainsData;
1168
+ code: number;
1169
+ comment?: string;
1170
+ }[];
1171
+ } | null;
1172
+ error: string | null;
1173
+ }
1174
+
1175
+ interface DomainsListOptions {
1176
+ /**
1177
+ * A list of domains to fetch. If this parameter is present, only domains whose name matches an item in this list are returned.
1178
+ */
1179
+ domains?: string[];
1180
+ /**
1181
+ * The maximum number of domains included in the response. Possible values are 1 to 5000
1182
+ * @default 10
1183
+ */
1184
+ limit?: number;
1185
+ /**
1186
+ * Offset into the list of domains to return.
1187
+ * @default 0
1188
+ */
1189
+ offset?: number;
1190
+ }
1191
+
1192
+ interface DomainsListResponse {
1193
+ /**
1194
+ * A list of domains
1195
+ */
1196
+ domains: DomainsData[];
1197
+ /**
1198
+ * The total number of domains that are accessible with the given API key that match the list of domains in the 'domains' parameter. If there is no 'domains' parameter, this field is the total number of domains that are accessible with with this API key. A domain is accessible with a given API key if it is associated with that API key, or if it is not associated with any API key.
1199
+ */
1200
+ total: number;
1201
+ error: string | null;
1202
+ }
1203
+
1204
+ interface DomainsCreateLoginLinkResponse {
1205
+ /**
1206
+ * If a user browses to this URL, they will be automatically logged in as a domain admin.
1207
+ */
1208
+ link: string | null;
1209
+ error: string | null;
1210
+ }
1211
+
1212
+ interface DomainsListDownstreamAddressesOptions {
1213
+ /**
1214
+ * The number of records to return.
1215
+ * @default 10
1216
+ */
1217
+ limit?: number;
1218
+ /**
1219
+ * The offset into the records to return.
1220
+ * @default 0
1221
+ */
1222
+ offset?: number;
1223
+ }
1224
+
1225
+ interface DomainsDownstreamAddress {
1226
+ /**
1227
+ * TCP port on which the downstream mail server is listening.
1228
+ */
1229
+ port: number;
1230
+ /**
1231
+ * The priority of the downstream address. Only addresses with the highest priority (the lowest numerical value) are selected.
1232
+ */
1233
+ priority: number;
1234
+ /**
1235
+ * The canonical hostname of the host providing the service, ending in a dot.
1236
+ */
1237
+ target: string;
1238
+ /**
1239
+ * Downstream addresses are selected in proportion to their weights. For example, if there are two downstream addresses, A with weight 40, and B with weight 10, then A is selected 80% of the time and B is selected 20% of the time.
1240
+ */
1241
+ weight: number;
1242
+ }
1243
+
1244
+ interface DomainsListDownstreamAddressesResponse {
1245
+ records: DomainsDownstreamAddress[];
1246
+ error: string | null;
1247
+ }
1248
+
1249
+ interface DomainsBulkCreateLoginLinkResult {
1250
+ /**
1251
+ * The domain the request was for.
1252
+ */
1253
+ domain: string;
1254
+ code: 200 | 400 | 401 | 403 | 404 | 500;
1255
+ /**
1256
+ * More information about the result of creating the login link.
1257
+ */
1258
+ comment?: string;
1259
+ }
1260
+
1261
+ interface DomainsBulkCreateLoginLink {
1262
+ successes: DomainsBulkCreateLoginLinkResult & {
1263
+ /**
1264
+ * If a user browses to this URL, they will be automatically logged in as a domain admin.
1265
+ */
1266
+ loginLink: string;
1267
+ }[];
1268
+ errors: DomainsBulkCreateLoginLinkResult[];
1269
+ }
1270
+
1271
+ interface DomainsBulkCreateLoginLinksResponse {
1272
+ results: DomainsCreateLoginLink[];
1273
+ error: string | null;
850
1274
  }
851
1275
 
852
1276
  declare class Domains {
@@ -956,7 +1380,7 @@ declare class Domains {
956
1380
  */
957
1381
  createLoginLink(domain: string): Promise<DomainsCreateLoginLinkResponse>;
958
1382
  /**
959
- * Sets the list of downstream addreses for the domain. This action deletes any existing downstream address for the domain before creating new ones. If the `records` parameter is an empty array, all downstream address records will be deleted.
1383
+ * Sets the list of downstream addresses for the domain. This action deletes any existing downstream address for the domain before creating new ones. If the `records` parameter is an empty array, all downstream address records will be deleted.
960
1384
  * @param domain - The domain name.
961
1385
  * @param records - The list of records to set for the domain. A maximum of 10 records can be set.
962
1386
  * @example
@@ -995,43 +1419,94 @@ declare class Domains {
995
1419
  * ```
996
1420
  */
997
1421
  updateApiKey(domain: string, key: string): Promise<SuccessResponse>;
1422
+ /**
1423
+ * Generate a batch of links that allow a user to log in as a domain administrator to their different domains.
1424
+ * @param domains - The list of domain names. Maximum of `1000` links per request.
1425
+ * @example
1426
+ * ```ts
1427
+ * const mailchannels = new MailChannels('your-api-key')
1428
+ * const { results } = await mailchannels.domains.bulkCreateLoginLinks(['example.com', 'example2.com'])
1429
+ * ```
1430
+ */
1431
+ bulkCreateLoginLinks(domains: string[]): Promise<DomainsBulkCreateLoginLinksResponse>;
998
1432
  }
999
1433
 
1000
- interface UsersCreateOptions {
1001
- /**
1002
- * Flag to indicate if the user is a domain admin or a regular user
1003
- * @default false
1004
- */
1005
- admin?: boolean;
1006
- /**
1007
- * Whether or not to filter mail for this recipient. There are three valid values.
1008
- * - `false` - Filtering policy will be applied to messages intended for this recipient. If this would exceed the protected-addresses limit, return an error.
1009
- * - `true` - Filtering policy will not be applied to messages intended for this recipient.
1010
- * - `compute` - Filtering policy will be applied to messages intended for this recipient. If this would exceed the protected-addresses limit, filtering policy will not be applied, and no error will be returned.
1011
- * @default 'compute'
1012
- */
1013
- filter?: boolean | "compute";
1014
- /**
1015
- * safelist and blocklist entries to be added
1016
- */
1017
- listEntries?: {
1018
- blocklist?: string[];
1019
- safelist?: string[];
1020
- };
1021
- }
1022
-
1023
- interface UsersCreateResponse {
1024
- user: {
1025
- email: string;
1026
- roles: string[];
1027
- filter?: boolean;
1028
- listEntries: {
1029
- item: string;
1030
- type: "domain" | "email_address" | "ip_address";
1031
- action: "safelist" | "blocklist";
1032
- }[];
1033
- } | null;
1034
- error: string | null;
1434
+ declare class Lists {
1435
+ protected mailchannels: MailChannelsClient;
1436
+ constructor(mailchannels: MailChannelsClient);
1437
+ /**
1438
+ * Add item to account-level list
1439
+ * @param options - The options for the list entry to add.
1440
+ * @example
1441
+ * ```ts
1442
+ * const mailchannels = new MailChannels('your-api-key')
1443
+ * const { entry } = await mailchannels.lists.addListEntry({
1444
+ * listName: 'safelist',
1445
+ * item: 'name@domain.com'
1446
+ * })
1447
+ * ```
1448
+ */
1449
+ addListEntry(options: ListEntryOptions): Promise<ListEntryResponse>;
1450
+ /**
1451
+ * Get account-level list entries.
1452
+ * @param listName - The name of the list to fetch. This can be a `blocklist`, `safelist`, `blacklist`, or `whitelist`.
1453
+ * @example
1454
+ * ```ts
1455
+ * const mailchannels = new MailChannels('your-api-key')
1456
+ * const { entries } = await mailchannels.lists.listEntries('safelist')
1457
+ * ```
1458
+ */
1459
+ listEntries(listName: ListNames): Promise<ListEntriesResponse>;
1460
+ /**
1461
+ * Delete item from account-level list.
1462
+ * @param options - The options for the list entry to delete.
1463
+ * @example
1464
+ * ```ts
1465
+ * const mailchannels = new MailChannels('your-api-key')
1466
+ * const { success } = await mailchannels.lists.deleteListEntry({
1467
+ * listName: 'safelist',
1468
+ * item: 'name@domain.com'
1469
+ * })
1470
+ * ```
1471
+ */
1472
+ deleteListEntry(options: ListEntryOptions): Promise<SuccessResponse>;
1473
+ }
1474
+
1475
+ interface UsersCreateOptions {
1476
+ /**
1477
+ * Flag to indicate if the user is a domain admin or a regular user
1478
+ * @default false
1479
+ */
1480
+ admin?: boolean;
1481
+ /**
1482
+ * Whether or not to filter mail for this recipient. There are three valid values.
1483
+ * - `false` - Filtering policy will be applied to messages intended for this recipient. If this would exceed the protected-addresses limit, return an error.
1484
+ * - `true` - Filtering policy will not be applied to messages intended for this recipient.
1485
+ * - `compute` - Filtering policy will be applied to messages intended for this recipient. If this would exceed the protected-addresses limit, filtering policy will not be applied, and no error will be returned.
1486
+ * @default 'compute'
1487
+ */
1488
+ filter?: boolean | "compute";
1489
+ /**
1490
+ * safelist and blocklist entries to be added
1491
+ */
1492
+ listEntries?: {
1493
+ blocklist?: string[];
1494
+ safelist?: string[];
1495
+ };
1496
+ }
1497
+
1498
+ interface UsersCreateResponse {
1499
+ user: {
1500
+ email: string;
1501
+ roles: string[];
1502
+ filter?: boolean;
1503
+ listEntries: {
1504
+ item: string;
1505
+ type: "domain" | "email_address" | "ip_address";
1506
+ action: "safelist" | "blocklist";
1507
+ }[];
1508
+ } | null;
1509
+ error: string | null;
1035
1510
  }
1036
1511
 
1037
1512
  declare class Users {
@@ -1091,46 +1566,82 @@ declare class Users {
1091
1566
  deleteListEntry(email: string, options: ListEntryOptions): Promise<SuccessResponse>;
1092
1567
  }
1093
1568
 
1094
- declare class Lists {
1569
+ interface ServiceSubscriptionsResponse {
1570
+ subscriptions: {
1571
+ active: boolean;
1572
+ activeAccountsCount: number;
1573
+ handle: string;
1574
+ limits: {
1575
+ featureHandle: string;
1576
+ value: string;
1577
+ }[];
1578
+ plan: {
1579
+ handle: string;
1580
+ name: string;
1581
+ };
1582
+ }[];
1583
+ error: string | null;
1584
+ }
1585
+
1586
+ interface ServiceReportOptions {
1587
+ /**
1588
+ * The report type. It can be either `false_negative` or `false_positive`.
1589
+ */
1590
+ type: "false_negative" | "false_positive";
1591
+ /**
1592
+ * The full, unaltered message content in accordance with the RFC 2822 specifications without dot stuffing.
1593
+ */
1594
+ messageContent: string;
1595
+ /**
1596
+ * The SMTP envelope information
1597
+ */
1598
+ smtpEnvelopeInformation?: {
1599
+ ehlo: string;
1600
+ mailFrom: string;
1601
+ rcptTo: string;
1602
+ };
1603
+ /**
1604
+ * The sending host information.
1605
+ */
1606
+ sendingHostInformation?: {
1607
+ name: string;
1608
+ };
1609
+ }
1610
+
1611
+ declare class Service {
1095
1612
  protected mailchannels: MailChannelsClient;
1096
1613
  constructor(mailchannels: MailChannelsClient);
1097
1614
  /**
1098
- * Add item to account-level list
1099
- * @param options - The options for the list entry to add.
1615
+ * Retrieve the condition of the service
1100
1616
  * @example
1101
1617
  * ```ts
1102
1618
  * const mailchannels = new MailChannels('your-api-key')
1103
- * const { entry } = await mailchannels.lists.addListEntry({
1104
- * listName: 'safelist',
1105
- * item: 'name@domain.com'
1106
- * })
1619
+ * const { success } = await mailchannels.service.status()
1107
1620
  * ```
1108
1621
  */
1109
- addListEntry(options: ListEntryOptions): Promise<ListEntryResponse>;
1622
+ status(): Promise<SuccessResponse>;
1110
1623
  /**
1111
- * Get account-level list entries.
1112
- * @param listName - The name of the list to fetch. This can be a `blocklist`, `safelist`, `blacklist`, or `whitelist`.
1624
+ * Get a list of your subscriptions to MailChannels Inbound
1113
1625
  * @example
1114
1626
  * ```ts
1115
1627
  * const mailchannels = new MailChannels('your-api-key')
1116
- * const { entries } = await mailchannels.lists.listEntries('safelist')
1628
+ * const { subscriptions } = await mailchannels.service.subscriptions()
1117
1629
  * ```
1118
1630
  */
1119
- listEntries(listName: ListNames): Promise<ListEntriesResponse>;
1631
+ subscriptions(): Promise<ServiceSubscriptionsResponse>;
1120
1632
  /**
1121
- * Delete item from account-level list.
1122
- * @param options - The options for the list entry to delete.
1633
+ * Submit a false negative or false positive report.
1634
+ * @param options - The report options
1123
1635
  * @example
1124
1636
  * ```ts
1125
1637
  * const mailchannels = new MailChannels('your-api-key')
1126
- * const { success } = await mailchannels.lists.deleteListEntry({
1127
- * listName: 'safelist',
1128
- * item: 'name@domain.com'
1638
+ * const { success, error } = await mailchannels.service.report({
1639
+ * // ...
1129
1640
  * })
1130
1641
  * ```
1131
1642
  */
1132
- deleteListEntry(options: ListEntryOptions): Promise<SuccessResponse>;
1643
+ report(options: ServiceReportOptions): Promise<SuccessResponse>;
1133
1644
  }
1134
1645
 
1135
- export { Domains as D, Emails as E, Lists as L, MailChannelsClient as M, SubAccounts as S, Users as U, Webhooks as W, Service as a };
1136
- export type { DomainsProvisionResponse as A, DomainsBulkProvisionResponse as B, DomainsListOptions as C, DomainsListResponse as F, DomainsCreateLoginLinkResponse as G, DomainsListDownstreamAddressesOptions as H, DomainsDownstreamAddress as I, DomainsListDownstreamAddressesResponse as J, ServiceSubscriptionsResponse as K, ServiceReportOptions as N, SuccessResponse as O, ListNames as P, ListEntryOptions as Q, ListEntry as R, ListEntryResponse as T, ListEntriesResponse as V, EmailsSendRecipient as b, EmailsSendAttachment as c, EmailsSendTracking as d, EmailsSendOptionsBase as e, EmailsSendOptions as f, EmailsSendResponse as g, EmailsCheckDomainDkim as h, EmailsCheckDomainOptions as i, EmailsCheckDomainVerdict as j, EmailsCheckDomainResponse as k, SubAccountsAccount as l, SubAccountsCreateResponse as m, SubAccountsListOptions as n, SubAccountsListResponse as o, SubAccountsApiKey as p, SubAccountsCreateApiKeyResponse as q, SubAccountsListApiKeyResponse as r, SubAccountsSmtpPassword as s, SubAccountsCreateSmtpPasswordResponse as t, SubAccountsListSmtpPasswordResponse as u, WebhooksListResponse as v, WebhooksSigningKeyResponse as w, DomainsData as x, DomainsProvisionOptions as y, DomainsBulkProvisionOptions as z };
1646
+ export { Domains as D, Emails as E, Lists as L, MailChannelsClient as M, SubAccounts as S, Users as U, Webhooks as W, Metrics as a, Suppressions as b, Service as c };
1647
+ export type { SuppressionsListResponse as $, SubAccountsLimit as A, SubAccountsLimitResponse as B, SubAccountsUsage as C, SubAccountsUsageResponse as F, MetricsBucket as G, MetricsOptions as H, MetricsEngagement as I, MetricsEngagementResponse as J, MetricsPerformance as K, MetricsPerformanceResponse as N, MetricsRecipientBehaviour as O, MetricsRecipientBehaviourResponse as P, MetricsVolume as Q, MetricsVolumeResponse as R, MetricsUsageResponse as T, SuppressionsTypes as V, SuppressionsCreateOptions as X, SuppressionsSource as Y, SuppressionsListOptions as Z, SuppressionsListEntry as _, DomainsData as a0, DomainsProvisionOptions as a1, DomainsBulkProvisionOptions as a2, DomainsProvisionResponse as a3, DomainsBulkProvisionResponse as a4, DomainsListOptions as a5, DomainsListResponse as a6, DomainsCreateLoginLinkResponse as a7, DomainsListDownstreamAddressesOptions as a8, DomainsDownstreamAddress as a9, DomainsListDownstreamAddressesResponse as aa, DomainsBulkCreateLoginLinkResult as ab, DomainsBulkCreateLoginLink as ac, DomainsBulkCreateLoginLinksResponse as ad, ListNames as ae, ListEntryOptions as af, ListEntry as ag, ListEntryResponse as ah, ListEntriesResponse as ai, UsersCreateOptions as aj, UsersCreateResponse as ak, ServiceSubscriptionsResponse as al, ServiceReportOptions as am, SuccessResponse as an, EmailsSendRecipient as d, EmailsSendAttachment as e, EmailsSendTracking as f, EmailsSendOptionsBase as g, EmailsSendOptions as h, EmailsSendResponse as i, EmailsCheckDomainDkim as j, EmailsCheckDomainOptions as k, EmailsCheckDomainVerdict as l, EmailsCheckDomainResponse as m, WebhooksListResponse as n, WebhooksSigningKeyResponse as o, WebhooksValidateResponse as p, SubAccountsAccount as q, SubAccountsCreateResponse as r, SubAccountsListOptions as s, SubAccountsListResponse as t, SubAccountsApiKey as u, SubAccountsCreateApiKeyResponse as v, SubAccountsListApiKeyResponse as w, SubAccountsSmtpPassword as x, SubAccountsCreateSmtpPasswordResponse as y, SubAccountsListSmtpPasswordResponse as z };