mailchannels-sdk 0.3.6

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.
@@ -0,0 +1,1136 @@
1
+ import { FetchOptions } from 'ofetch';
2
+
3
+ declare class MailChannelsClient {
4
+ #private;
5
+ private static BASE_URL;
6
+ constructor(key: string);
7
+ protected _fetch<T>(path: string, options?: FetchOptions<"json">): Promise<T>;
8
+ post<T>(path: string, options?: Omit<FetchOptions<"json">, "method">): Promise<T>;
9
+ get<T>(path: string, options?: Omit<FetchOptions<"json">, "method">): Promise<T>;
10
+ delete<T>(path: string, options?: Omit<FetchOptions<"json">, "method">): Promise<T>;
11
+ put<T>(path: string, options?: Omit<FetchOptions<"json">, "method">): Promise<T>;
12
+ }
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;
276
+ }
277
+
278
+ declare class Emails {
279
+ protected mailchannels: MailChannelsClient;
280
+ constructor(mailchannels: MailChannelsClient);
281
+ /**
282
+ * Send an email using MailChannels Email API.
283
+ * @param options - The email options to send.
284
+ * @param dryRun - When set to `true`, the message will not be sent. Instead, the fully rendered message will be returned in the `data` property of the response. The default value is `false`.
285
+ * @example
286
+ * ```ts
287
+ * const mailchannels = new MailChannels('your-api-key')
288
+ * const { success } = await mailchannels.emails.send({
289
+ * to: 'to@example.com',
290
+ * from: 'from@example.com',
291
+ * subject: 'Test',
292
+ * html: 'Test'
293
+ * })
294
+ * ```
295
+ */
296
+ send(options: EmailsSendOptions, dryRun?: boolean): Promise<EmailsSendResponse>;
297
+ /**
298
+ * Validates a domain's email authentication setup by retrieving its DKIM, SPF, and Domain Lockdown status. This endpoint checks whether the domain is properly configured for secure email delivery.
299
+ * @param options - The domain options to check.
300
+ * @example
301
+ * ```ts
302
+ * const mailchannels = new MailChannels('your-api-key')
303
+ * const { results } = await mailchannels.emails.checkDomain({
304
+ * dkim: [{
305
+ * domain: 'example.com',
306
+ * privateKey: 'your-private-key',
307
+ * selector: 'mailchannels'
308
+ * }],
309
+ * domain: 'example.com',
310
+ * senderId: 'sender-id'
311
+ * })
312
+ * ```
313
+ */
314
+ checkDomain(options: EmailsCheckDomainOptions): Promise<EmailsCheckDomainResponse>;
315
+ }
316
+
317
+ interface SuccessResponse {
318
+ /**
319
+ * Whether the operation was successful.
320
+ */
321
+ success: boolean;
322
+ error: string | null;
323
+ }
324
+
325
+ interface WebhooksListResponse {
326
+ webhooks: string[];
327
+ error: string | null;
328
+ }
329
+
330
+ interface WebhooksSigningKeyResponse {
331
+ key: string | null;
332
+ error: string | null;
333
+ }
334
+
335
+ declare class Webhooks {
336
+ protected mailchannels: MailChannelsClient;
337
+ constructor(mailchannels: MailChannelsClient);
338
+ /**
339
+ * Enrolls the customer to receive event notifications via webhooks.
340
+ * @param endpoint - The URL to receive event notifications.
341
+ * @example
342
+ * ```ts
343
+ * const mailchannels = new MailChannels('your-api-key')
344
+ * const { success } = mailchannels.webhooks.enroll('https://example.com/api/webhooks/mailchannels')
345
+ * ```
346
+ */
347
+ enroll(endpoint: string): Promise<SuccessResponse>;
348
+ /**
349
+ * Retrieves all registered webhook endpoints associated with the customer.
350
+ * @example
351
+ * ```ts
352
+ * const mailchannels = new MailChannels('your-api-key')
353
+ * const { webhooks } = await mailchannels.webhooks.list()
354
+ * ```
355
+ */
356
+ list(): Promise<WebhooksListResponse>;
357
+ /**
358
+ * Deletes all registered webhook endpoints for the customer.
359
+ * @example
360
+ * ```ts
361
+ * const mailchannels = new MailChannels('your-api-key')
362
+ * const { success } = await mailchannels.webhooks.delete()
363
+ * ```
364
+ */
365
+ delete(): Promise<SuccessResponse>;
366
+ /**
367
+ * Retrieves the public key used to verify signatures on incoming webhook payloads.
368
+ * @param id - The ID of the key.
369
+ * @example
370
+ * ```ts
371
+ * const mailchannels = new MailChannels('your-api-key')
372
+ * const { key } = await mailchannels.webhooks.getSigningKey('key-id')
373
+ * ```
374
+ */
375
+ getSigningKey(id: string): Promise<WebhooksSigningKeyResponse>;
376
+ }
377
+
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;
456
+ }
457
+
458
+ declare class SubAccounts {
459
+ protected mailchannels: MailChannelsClient;
460
+ private static readonly HANDLE_PATTERN;
461
+ constructor(mailchannels: MailChannelsClient);
462
+ /**
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}`.
465
+ * @example
466
+ * ```ts
467
+ * const mailchannels = new MailChannels('your-api-key')
468
+ * const { account } = await mailchannels.subAccounts.create('validhandle123')
469
+ * ```
470
+ */
471
+ create(handle?: string): Promise<SubAccountsCreateResponse>;
472
+ /**
473
+ * 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
+ * @param options - The options to filter the list of sub-accounts.
475
+ * @example
476
+ * ```ts
477
+ * const mailchannels = new MailChannels('your-api-key')
478
+ * const { accounts } = await mailchannels.subAccounts.list()
479
+ * ```
480
+ */
481
+ list(options?: SubAccountsListOptions): Promise<SubAccountsListResponse>;
482
+ /**
483
+ * Deletes the sub-account identified by its handle.
484
+ * @param handle - Handle of sub-account to be deleted.
485
+ * ```ts
486
+ * const mailchannels = new MailChannels('your-api-key')
487
+ * const { success } = await mailchannels.subAccounts.delete('validhandle123')
488
+ * ```
489
+ */
490
+ delete(handle: string): Promise<SuccessResponse>;
491
+ /**
492
+ * Suspends the sub-account identified by its handle. This action disables the account, preventing it from sending any emails until it is reactivated.
493
+ * @param handle - Handle of sub-account to be suspended.
494
+ * @example
495
+ * ```ts
496
+ * const mailchannels = new MailChannels('your-api-key')
497
+ * const { success } = await mailchannels.subAccounts.suspend('validhandle123')
498
+ * ```
499
+ */
500
+ suspend(handle: string): Promise<SuccessResponse>;
501
+ /**
502
+ * Activates a suspended sub-account identified by its handle, restoring its ability to send emails.
503
+ * @param handle - Handle of sub-account to be activated.
504
+ * @example
505
+ * ```ts
506
+ * const mailchannels = new MailChannels('your-api-key')
507
+ * const { success } = await mailchannels.subAccounts.activate('validhandle123')
508
+ * ```
509
+ */
510
+ activate(handle: string): Promise<SuccessResponse>;
511
+ /**
512
+ * Creates a new API key for the specified sub-account.
513
+ * @param handle - Handle of the sub-account to create API key for.
514
+ * @example
515
+ * ```ts
516
+ * const mailchannels = new MailChannels('your-api-key')
517
+ * const { key } = await mailchannels.subAccounts.createApiKey('validhandle123')
518
+ * ```
519
+ */
520
+ createApiKey(handle: string): Promise<SubAccountsCreateApiKeyResponse>;
521
+ /**
522
+ * Retrieves details of all API keys associated with the specified sub-account. For security reasons, the full API key is not returned; only the key ID and a partially redacted version are provided.
523
+ * @param handle - Handle of the sub-account to retrieve the API key for.
524
+ * @example
525
+ * ```ts
526
+ * const mailchannels = new MailChannels('your-api-key')
527
+ * const { keys } = await mailchannels.subAccounts.listApiKeys('validhandle123')
528
+ * ```
529
+ */
530
+ listApiKeys(handle: string): Promise<SubAccountsListApiKeyResponse>;
531
+ /**
532
+ * Deletes the API key identified by its ID for the specified sub-account.
533
+ * @param handle - Handle of the sub-account for which the API key should be deleted.
534
+ * @param id - The ID of the API key to delete.
535
+ * @example
536
+ * ```ts
537
+ * const mailchannels = new MailChannels('your-api-key')
538
+ * const { success } = await mailchannels.subAccounts.deleteApiKey('validhandle123', 1)
539
+ * ```
540
+ */
541
+ deleteApiKey(handle: string, id: number): Promise<SuccessResponse>;
542
+ /**
543
+ * Creates a new SMTP password for the specified sub-account.
544
+ * @param handle - Handle of the sub-account to create SMTP password for.
545
+ * @example
546
+ * ```ts
547
+ * const mailchannels = new MailChannels('your-api-key')
548
+ * const { password } = await mailchannels.subAccounts.createSmtpPassword('validhandle123')
549
+ * ```
550
+ */
551
+ createSmtpPassword(handle: string): Promise<SubAccountsCreateSmtpPasswordResponse>;
552
+ /**
553
+ * Retrieves details of all SMTP passwords associated with the specified sub-account. For security, the full SMTP password is not returned; only the password ID and a partially redacted version are provided.
554
+ * @param handle - Handle of the sub-account to retrieve the SMTP password for.
555
+ * @example
556
+ * ```ts
557
+ * const mailchannels = new MailChannels('your-api-key')
558
+ * const { passwords } = await mailchannels.subAccounts.listSmtpPasswords('validhandle123')
559
+ * ```
560
+ */
561
+ listSmtpPasswords(handle: string): Promise<SubAccountsListSmtpPasswordResponse>;
562
+ /**
563
+ * Deletes the SMTP password identified by its ID for the specified sub-account.
564
+ * @param handle - Handle of the sub-account for which the SMTP password should be deleted.
565
+ * @param id - The ID of the SMTP password to delete.
566
+ * @example
567
+ * ```ts
568
+ * const mailchannels = new MailChannels('your-api-key')
569
+ * const { success } = await mailchannels.subAccounts.deleteSmtpPassword('validhandle123', 1)
570
+ * ```
571
+ */
572
+ deleteSmtpPassword(handle: string, id: number): Promise<SuccessResponse>;
573
+ }
574
+
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
+ };
615
+ }
616
+
617
+ declare class Service {
618
+ protected mailchannels: MailChannelsClient;
619
+ constructor(mailchannels: MailChannelsClient);
620
+ /**
621
+ * Retrieve the condition of the service
622
+ * @example
623
+ * ```ts
624
+ * const mailchannels = new MailChannels('your-api-key')
625
+ * const { success } = await mailchannels.service.status()
626
+ * ```
627
+ */
628
+ status(): Promise<SuccessResponse>;
629
+ /**
630
+ * Get a list of your subscriptions to MailChannels Inbound
631
+ * @example
632
+ * ```ts
633
+ * const mailchannels = new MailChannels('your-api-key')
634
+ * const { subscriptions } = await mailchannels.service.subscriptions()
635
+ * ```
636
+ */
637
+ subscriptions(): Promise<ServiceSubscriptionsResponse>;
638
+ /**
639
+ * Submit a false negative or false positive report.
640
+ * @param options - The report options
641
+ */
642
+ report(options: ServiceReportOptions): Promise<SuccessResponse>;
643
+ }
644
+
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;
850
+ }
851
+
852
+ declare class Domains {
853
+ protected mailchannels: MailChannelsClient;
854
+ constructor(mailchannels: MailChannelsClient);
855
+ /**
856
+ * Provision a single domain to use MailChannels Inbound.
857
+ * @param options - The domain data to provision.
858
+ * @example
859
+ * ```ts
860
+ * const mailchannels = new MailChannels('your-api-key')
861
+ * const { data } = await mailchannels.domains.provision({
862
+ * domain: 'example.com',
863
+ * subscriptionHandle: 'your-subscription-handle'
864
+ * })
865
+ * ```
866
+ */
867
+ provision(options: DomainsProvisionOptions & DomainsData): Promise<DomainsProvisionResponse>;
868
+ /**
869
+ * Provision up to 1000 domains to use MailChannels Inbound.
870
+ * @param options - The options to provision the domains.
871
+ * @param domains - The list of domains to provision.
872
+ * @example
873
+ * ```ts
874
+ * const mailchannels = new MailChannels('your-api-key')
875
+ * const { results } = await mailchannels.domains.bulkProvision({
876
+ * subscriptionHandle: 'your-subscription-handle'
877
+ * }, [
878
+ * {
879
+ * domain: 'example.com',
880
+ * admins: ['support@example.com']
881
+ * },
882
+ * {
883
+ * domain: 'example2.com'
884
+ * }
885
+ * ])
886
+ * ```
887
+ */
888
+ bulkProvision(options: DomainsBulkProvisionOptions, domains: Omit<DomainsData, "subscriptionHandle">[]): Promise<DomainsBulkProvisionResponse>;
889
+ /**
890
+ * Fetch a list of all domains associated with this API key.
891
+ * @param options - The options to filter the list of domains.
892
+ * @example
893
+ * ```ts
894
+ * const mailchannels = new MailChannels('your-api-key')
895
+ * const { domains } = await mailchannels.domains.list()
896
+ * ```
897
+ */
898
+ list(options?: DomainsListOptions): Promise<DomainsListResponse>;
899
+ /**
900
+ * De-provision a domain to cease protecting it with MailChannels Inbound.
901
+ * @param domain - The domain name to be removed.
902
+ * @example
903
+ * ```ts
904
+ * const mailchannels = new MailChannels('your-api-key')
905
+ * const { success } = await mailchannels.domains.delete('example.com')
906
+ * ```
907
+ */
908
+ delete(domain: string): Promise<SuccessResponse>;
909
+ /**
910
+ * Add an entry to a domain blocklist or safelist.
911
+ * @param domain - The domain name.
912
+ * @param options - The options to add a list entry.
913
+ * @example
914
+ * ```ts
915
+ * const mailchannels = new MailChannels('your-api-key')
916
+ * const { entry } = await mailchannels.domains.addListEntry('example.com', {
917
+ * listName: 'safelist',
918
+ * item: 'name@domain.com'
919
+ * })
920
+ * ```
921
+ */
922
+ addListEntry(domain: string, options: ListEntryOptions): Promise<ListEntryResponse>;
923
+ /**
924
+ * Get domain list entries.
925
+ * @param domain - The domain name.
926
+ * @param listName - The name of the list to fetch. This can be a `blocklist`, `safelist`, `blacklist`, or `whitelist`.
927
+ * @example
928
+ * ```ts
929
+ * const mailchannels = new MailChannels('your-api-key')
930
+ * const { entries } = await mailchannels.domains.listEntries('example.com', 'safelist')
931
+ * ```
932
+ */
933
+ listEntries(domain: string, listName: ListNames): Promise<ListEntriesResponse>;
934
+ /**
935
+ * Delete item from domain list.
936
+ * @param email - The domain name whose list will be modified.
937
+ * @param options - The options for the list entry to delete.
938
+ * @example
939
+ * ```ts
940
+ * const mailchannels = new MailChannels('your-api-key')
941
+ * const { success } = await mailchannels.domains.deleteListEntry('example.com', {
942
+ * listName: 'safelist',
943
+ * item: 'name@domain.com'
944
+ * })
945
+ * ```
946
+ */
947
+ deleteListEntry(domain: string, options: ListEntryOptions): Promise<SuccessResponse>;
948
+ /**
949
+ * Generate a link that allows a user to log in as a domain administrator.
950
+ * @param domain - The domain name.
951
+ * @example
952
+ * ```ts
953
+ * const mailchannels = new MailChannels('your-api-key')
954
+ * const { link } = await mailchannels.domains.createLoginLink('example.com')
955
+ * ```
956
+ */
957
+ createLoginLink(domain: string): Promise<DomainsCreateLoginLinkResponse>;
958
+ /**
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.
960
+ * @param domain - The domain name.
961
+ * @param records - The list of records to set for the domain. A maximum of 10 records can be set.
962
+ * @example
963
+ * ```ts
964
+ * const mailchannels = new MailChannels('your-api-key')
965
+ * const { success } = await mailchannels.domains.setDownstreamAddress('example.com', [
966
+ * {
967
+ * port: 25,
968
+ * priority: 10,
969
+ * target: 'example.com.',
970
+ * weight: 10
971
+ * }
972
+ * ])
973
+ * ```
974
+ */
975
+ setDownstreamAddress(domain: string, records?: DomainsDownstreamAddress[]): Promise<SuccessResponse>;
976
+ /**
977
+ * Retrieve stored downstream addresses for the domain.
978
+ * @param domain - The domain name.
979
+ * @param options - The options to filter the list of downstream addresses.
980
+ * @example
981
+ * ```ts
982
+ * const mailchannels = new MailChannels('your-api-key')
983
+ * const { records } = await mailchannels.domains.listDownstreamAddresses('example.com')
984
+ * ```
985
+ */
986
+ listDownstreamAddresses(domain: string, options?: DomainsListDownstreamAddressesOptions): Promise<DomainsListDownstreamAddressesResponse>;
987
+ /**
988
+ * Update the API key that is associated with a domain.
989
+ * @param domain - The domain name.
990
+ * @param key - The new API key to associate with this domain.
991
+ * @example
992
+ * ```ts
993
+ * const mailchannels = new MailChannels('your-api-key')
994
+ * const { success } = await mailchannels.domains.updateApiKey('example.com', 'your-api-key')
995
+ * ```
996
+ */
997
+ updateApiKey(domain: string, key: string): Promise<SuccessResponse>;
998
+ }
999
+
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;
1035
+ }
1036
+
1037
+ declare class Users {
1038
+ protected mailchannels: MailChannelsClient;
1039
+ constructor(mailchannels: MailChannelsClient);
1040
+ /**
1041
+ * Create a recipient user.
1042
+ * @param email - The email address of the user to create.
1043
+ * @param options - The options for the user to create.
1044
+ * @example
1045
+ * ```ts
1046
+ * const mailchannels = new MailChannels('your-api-key')
1047
+ * const { user } = await mailchannels.users.create("name@example.com", {
1048
+ * admin: true
1049
+ * })
1050
+ * ```
1051
+ */
1052
+ create(email: string, options?: UsersCreateOptions): Promise<UsersCreateResponse>;
1053
+ /**
1054
+ * Add item to recipient user list
1055
+ * @param email - The email address of the recipient whose list will be modified.
1056
+ * @param options - The options for the list entry to add.
1057
+ * @example
1058
+ * ```ts
1059
+ * const mailchannels = new MailChannels('your-api-key')
1060
+ * const { entry } = await mailchannels.users.addListEntry('name@example.com', {
1061
+ * listName: 'safelist',
1062
+ * item: 'name@domain.com'
1063
+ * })
1064
+ * ```
1065
+ */
1066
+ addListEntry(email: string, options: ListEntryOptions): Promise<ListEntryResponse>;
1067
+ /**
1068
+ * Get recipient list entries.
1069
+ * @param email - The email address of the recipient whose list will be fetched.
1070
+ * @param listName - The name of the list to fetch. This can be a `blocklist`, `safelist`, `blacklist`, or `whitelist`.
1071
+ * @example
1072
+ * ```ts
1073
+ * const mailchannels = new MailChannels('your-api-key')
1074
+ * const { entries } = await mailchannels.users.listEntries('name@example.com', 'safelist')
1075
+ * ```
1076
+ */
1077
+ listEntries(email: string, listName: ListNames): Promise<ListEntriesResponse>;
1078
+ /**
1079
+ * Delete item from recipient list.
1080
+ * @param email - The email address of the recipient whose list will be modified.
1081
+ * @param options - The options for the list entry to delete.
1082
+ * @example
1083
+ * ```ts
1084
+ * const mailchannels = new MailChannels('your-api-key')
1085
+ * const { success } = await mailchannels.users.deleteListEntry('name@example.com', {
1086
+ * listName: 'safelist',
1087
+ * item: 'name@domain.com'
1088
+ * })
1089
+ * ```
1090
+ */
1091
+ deleteListEntry(email: string, options: ListEntryOptions): Promise<SuccessResponse>;
1092
+ }
1093
+
1094
+ declare class Lists {
1095
+ protected mailchannels: MailChannelsClient;
1096
+ constructor(mailchannels: MailChannelsClient);
1097
+ /**
1098
+ * Add item to account-level list
1099
+ * @param options - The options for the list entry to add.
1100
+ * @example
1101
+ * ```ts
1102
+ * const mailchannels = new MailChannels('your-api-key')
1103
+ * const { entry } = await mailchannels.lists.addListEntry({
1104
+ * listName: 'safelist',
1105
+ * item: 'name@domain.com'
1106
+ * })
1107
+ * ```
1108
+ */
1109
+ addListEntry(options: ListEntryOptions): Promise<ListEntryResponse>;
1110
+ /**
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`.
1113
+ * @example
1114
+ * ```ts
1115
+ * const mailchannels = new MailChannels('your-api-key')
1116
+ * const { entries } = await mailchannels.lists.listEntries('safelist')
1117
+ * ```
1118
+ */
1119
+ listEntries(listName: ListNames): Promise<ListEntriesResponse>;
1120
+ /**
1121
+ * Delete item from account-level list.
1122
+ * @param options - The options for the list entry to delete.
1123
+ * @example
1124
+ * ```ts
1125
+ * const mailchannels = new MailChannels('your-api-key')
1126
+ * const { success } = await mailchannels.lists.deleteListEntry({
1127
+ * listName: 'safelist',
1128
+ * item: 'name@domain.com'
1129
+ * })
1130
+ * ```
1131
+ */
1132
+ deleteListEntry(options: ListEntryOptions): Promise<SuccessResponse>;
1133
+ }
1134
+
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 };