mailchannels-sdk 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,6 +20,11 @@ interface SuccessResponse {
20
20
  error: string | null;
21
21
  }
22
22
 
23
+ interface DataResponse<T> {
24
+ data: T | null;
25
+ error: string | null;
26
+ }
27
+
23
28
  interface EmailsSendRecipient {
24
29
  /**
25
30
  * The email address of the recipient.
@@ -277,6 +282,8 @@ interface EmailsCreateDkimKeyOptions {
277
282
  selector: string;
278
283
  }
279
284
 
285
+ type EmailsDkimKeyStatus = "active" | "retired" | "revoked" | "rotated";
286
+
280
287
  interface EmailsDkimKey {
281
288
  /**
282
289
  * Algorithm used for the key pair.
@@ -285,7 +292,7 @@ interface EmailsDkimKey {
285
292
  /**
286
293
  * Timestamp when the key pair was created.
287
294
  */
288
- createdAt: string;
295
+ createdAt?: string;
289
296
  /**
290
297
  * Suggested DNS records for the DKIM key.
291
298
  */
@@ -298,11 +305,19 @@ interface EmailsDkimKey {
298
305
  * Domain associated with the key pair.
299
306
  */
300
307
  domain: string;
308
+ /**
309
+ * UTC timestamp after which you can no longer use the rotated key for signing.
310
+ */
311
+ gracePeriodExpiresAt?: string;
301
312
  /**
302
313
  * Key length in bits.
303
314
  */
304
315
  length: 1024 | 2048 | 3072 | 4096;
305
316
  publicKey: string;
317
+ /**
318
+ * UTC timestamp when a rotated key pair is retired.
319
+ */
320
+ retiresAt?: string;
306
321
  /**
307
322
  * Selector assigned to the key pair.
308
323
  */
@@ -310,20 +325,14 @@ interface EmailsDkimKey {
310
325
  /**
311
326
  * Status of the key.
312
327
  */
313
- status: "active" | "revoked" | "retired";
328
+ status: EmailsDkimKeyStatus;
314
329
  /**
315
330
  * Timestamp when the key was last modified.
316
331
  */
317
- statusModifiedAt: string;
332
+ statusModifiedAt?: string;
318
333
  }
319
334
 
320
- interface EmailsCreateDkimKeyResponse {
321
- /**
322
- * The created DKIM key information.
323
- */
324
- key: EmailsDkimKey | null;
325
- error: string | null;
326
- }
335
+ type EmailsCreateDkimKeyResponse = DataResponse<EmailsDkimKey>;
327
336
 
328
337
  interface EmailsCheckDomainDkim {
329
338
  /**
@@ -343,12 +352,12 @@ interface EmailsCheckDomainDkim {
343
352
  interface EmailsCheckDomainOptions {
344
353
  /**
345
354
  * Each item may include DKIM `domain`, `selector` and `privateKey`. Up to 10 items are allowed. The absence or presence of these fields affects how DKIM settings are validated:
346
- * - If `domain`, `selector`, and `privateKey` are all present, verify using the provided domain, selector, and key.
347
- * - If `domain` and `selector` are present, use the stored private key for the given domain and selector.
348
- * - If only `domain` is present, use all stored keys for the given domain.
349
- * - If none are present, use all stored keys for the `domain` provided in the domain field of the request.
350
- * - If `privateKey` is present, `selector` must be present.
351
- * - If `selector` is present and `domain` is not, the domain will be taken from the domain field of the request.
355
+ * 1. If `domain`, `selector`, and `privateKey` are all present, verify using the provided domain, selector, and key.
356
+ * 2. If `domain` and `selector` are present, use the stored private key for the given domain and selector.
357
+ * 3. If only `domain` is present, use all stored keys for the given domain.
358
+ * 4. If none are present, use all stored keys for the `domain` provided in the domain field of the request.
359
+ * 5. If `privateKey` is present, `selector` must be present.
360
+ * 6. If `selector` is present and `domain` is not, the domain will be taken from the domain field of the request.
352
361
  */
353
362
  dkim?: EmailsCheckDomainDkim[] | EmailsCheckDomainDkim;
354
363
  /**
@@ -363,68 +372,59 @@ interface EmailsCheckDomainOptions {
363
372
 
364
373
  type EmailsCheckDomainVerdict = "passed" | "failed" | "soft failed" | "temporary error" | "permanent error" | "neutral" | "none" | "unknown";
365
374
 
366
- interface EmailsCheckDomainResponse {
375
+ type EmailsCheckDomainResponse = DataResponse<{
376
+ dkim: {
377
+ domain: string;
378
+ /**
379
+ * The human readable status of the DKIM key used for verification.
380
+ */
381
+ keyStatus?: EmailsDkimKey["status"] | "provided";
382
+ selector: string;
383
+ /**
384
+ * A human-readable explanation of DKIM check.
385
+ */
386
+ reason?: string;
387
+ verdict: Extract<EmailsCheckDomainVerdict, "passed" | "failed">;
388
+ }[];
389
+ domainLockdown: {
390
+ /**
391
+ * A human-readable explanation of Domain Lockdown check.
392
+ */
393
+ reason?: string;
394
+ verdict: Extract<EmailsCheckDomainVerdict, "passed" | "failed">;
395
+ };
367
396
  /**
368
- * The results of the domain checks.
397
+ * These results are here to help avoid [SDNF](https://support.mailchannels.com/hc/en-us/articles/203155500-550-5-2-1-SDNF-Sender-Domain-Not-Found) (Sender Domain Not Found) blocks. For messages not to get blocked by SDNF, we require either an MX or A record to exist for the sender domain.
369
398
  */
370
- results: {
371
- dkim: {
372
- domain: string;
373
- /**
374
- * The human readable status of the DKIM key used for verification.
375
- */
376
- keyStatus?: EmailsDkimKey["status"] | "provided";
377
- selector: string;
399
+ senderDomain: {
400
+ a: {
378
401
  /**
379
- * A human-readable explanation of DKIM check.
402
+ * A human-readable explanation of A record check.
380
403
  */
381
404
  reason?: string;
382
405
  verdict: Extract<EmailsCheckDomainVerdict, "passed" | "failed">;
383
- }[];
384
- domainLockdown: {
406
+ };
407
+ mx: {
385
408
  /**
386
- * A human-readable explanation of Domain Lockdown check.
409
+ * A human-readable explanation of MX record check.
387
410
  */
388
411
  reason?: string;
389
412
  verdict: Extract<EmailsCheckDomainVerdict, "passed" | "failed">;
390
413
  };
391
414
  /**
392
- * These results are here to help avoid [SDNF](https://support.mailchannels.com/hc/en-us/articles/203155500-550-5-2-1-SDNF-Sender-Domain-Not-Found) (Sender Domain Not Found) blocks. For messages not to get blocked by SDNF, we require either an MX or A record to exist for the sender domain.
393
- */
394
- senderDomain: {
395
- a: {
396
- /**
397
- * A human-readable explanation of A record check.
398
- */
399
- reason?: string;
400
- verdict: Extract<EmailsCheckDomainVerdict, "passed" | "failed">;
401
- };
402
- mx: {
403
- /**
404
- * A human-readable explanation of MX record check.
405
- */
406
- reason?: string;
407
- verdict: Extract<EmailsCheckDomainVerdict, "passed" | "failed">;
408
- };
409
- /**
410
- * Overall verdict. Passed if either A or MX record check passed.
411
- */
412
- verdict: Extract<EmailsCheckDomainVerdict, "passed" | "failed">;
413
- };
414
- spf: {
415
- /**
416
- * A human-readable explanation of SPF check.
417
- */
418
- reason?: string;
419
- verdict: EmailsCheckDomainVerdict;
420
- };
421
- references?: string[];
422
- } | null;
423
- /**
424
- * Link to SPF, Domain Lockdown or DKIM references, displayed if any verdict is not passed.
425
- */
426
- error: string | null;
427
- }
415
+ * Overall verdict. Passed if either A or MX record check passed.
416
+ */
417
+ verdict: Extract<EmailsCheckDomainVerdict, "passed" | "failed">;
418
+ };
419
+ spf: {
420
+ /**
421
+ * A human-readable explanation of SPF check.
422
+ */
423
+ reason?: string;
424
+ verdict: EmailsCheckDomainVerdict;
425
+ };
426
+ references?: string[];
427
+ }>;
428
428
 
429
429
  interface EmailsGetDkimKeysOptions {
430
430
  /**
@@ -454,13 +454,7 @@ interface EmailsGetDkimKeysOptions {
454
454
 
455
455
  type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
456
456
 
457
- interface EmailsGetDkimKeysResponse {
458
- /**
459
- * List of keys matching the filter. Empty if no keys match the filter.
460
- */
461
- keys: Optional<EmailsDkimKey, "dnsRecords">[];
462
- error: string | null;
463
- }
457
+ type EmailsGetDkimKeysResponse = DataResponse<Optional<EmailsDkimKey, "dnsRecords">[]>;
464
458
 
465
459
  interface EmailsUpdateDkimKeyOptions {
466
460
  /**
@@ -471,10 +465,25 @@ interface EmailsUpdateDkimKeyOptions {
471
465
  * New status of the DKIM key pair.
472
466
  * - `revoked`: Indicates that the key is compromised and should not be used.
473
467
  * - `retired`: Indicates that the key has been rotated and is no longer in use.
468
+ * - `rotated`: Indicates that the key is going through the rotation process. Only active key pairs can be updated to this status, and no new key pair is created. The rotated key can be used to sign emails for 3 days after the status update, and will automatically change to `retired` 2 weeks after update. For a smooth key transition, it is recommended to create and publish a new key pair before signing is disabled for the rotated key.
474
469
  */
475
470
  status: Exclude<EmailsDkimKey["status"], "active">;
476
471
  }
477
472
 
473
+ interface EmailsRotateDkimKeyOptions {
474
+ newKey: {
475
+ /**
476
+ * Selector for the new key pair. Must be a maximum of 63 characters.
477
+ */
478
+ selector: string;
479
+ };
480
+ }
481
+
482
+ type EmailsRotateDkimKeyResponse = DataResponse<{
483
+ new: EmailsDkimKey;
484
+ rotated: EmailsDkimKey;
485
+ }>;
486
+
478
487
  declare class Emails {
479
488
  protected mailchannels: MailChannelsClient;
480
489
  constructor(mailchannels: MailChannelsClient);
@@ -519,20 +528,20 @@ declare class Emails {
519
528
  * @example
520
529
  * ```ts
521
530
  * const mailchannels = new MailChannels('your-api-key')
522
- * const { key, error } = await mailchannels.emails.createDkimKey('example.com', {
531
+ * const { data, error } = await mailchannels.emails.createDkimKey('example.com', {
523
532
  * selector: 'mailchannels'
524
533
  * })
525
534
  * ```
526
535
  */
527
536
  createDkimKey(domain: string, options: EmailsCreateDkimKeyOptions): Promise<EmailsCreateDkimKeyResponse>;
528
537
  /**
529
- * Search for DKIM keys by customer handle and domain, with optional filters. If selector is provided, at most one key will be returned.
538
+ * Search for DKIM keys by domain, with optional filters. If selector is provided, at most one key will be returned.
530
539
  * @param domain - The domain to search DKIM keys for.
531
540
  * @param options - The options to filter DKIM keys by.
532
541
  * @example
533
542
  * ```ts
534
543
  * const mailchannels = new MailChannels('your-api-key')
535
- * const { keys } = await mailchannels.getDkimKeys('example.com', {
544
+ * const { data, error } = await mailchannels.getDkimKeys('example.com', {
536
545
  * includeDnsRecord: true
537
546
  * })
538
547
  * ```
@@ -545,25 +554,38 @@ declare class Emails {
545
554
  * @example
546
555
  * ```ts
547
556
  * const mailchannels = new MailChannels('your-api-key')
548
- * const { success } = await mailchannels.emails.updateDkimKey('example.com', {
557
+ * const { success, error } = await mailchannels.emails.updateDkimKey('example.com', {
549
558
  * selector: 'mailchannels',
550
559
  * status: 'retired'
551
560
  * })
552
561
  */
553
562
  updateDkimKey(domain: string, options: EmailsUpdateDkimKeyOptions): Promise<SuccessResponse>;
563
+ /**
564
+ * Rotate an active DKIM key pair. Mark the original key as `rotated`, and create a new key pair with the required new key selector, reusing the same algorithm and key length. The rotated key remains valid for signing for a 3-day grace period, and is automatically changed to `retired` 2 weeks after rotation. Publish the new key to its DNS TXT record before rotated key expires for signing as emails sent with an unpublished key will fail DKIM validation by receiving providers. After the grace period, only the new key is valid for signing if published.
565
+ * @param domain - The domain the DKIM key belongs to.
566
+ * @param selector - The selector of the DKIM key to rotate.
567
+ * @param options - The options to rotate the DKIM key.
568
+ * @param options.newKey.selector - The selector for the new key pair. Must be a maximum of 63 characters.
569
+ * @example
570
+ * ```ts
571
+ * const mailchannels = new MailChannels('your-api-key')
572
+ * const { data, error } = await mailchannels.emails.rotateDkimKey('example.com', 'mailchannels', {
573
+ * newKey: {
574
+ * selector: 'new-selector'
575
+ * }
576
+ * })
577
+ * ```
578
+ */
579
+ rotateDkimKey(domain: string, selector: string, options: EmailsRotateDkimKeyOptions): Promise<EmailsRotateDkimKeyResponse>;
554
580
  }
555
581
 
556
- interface WebhooksListResponse {
557
- webhooks: string[];
558
- error: string | null;
559
- }
582
+ type WebhooksListResponse = DataResponse<string[]>;
560
583
 
561
- interface WebhooksSigningKeyResponse {
562
- key: string | null;
563
- error: string | null;
564
- }
584
+ type WebhooksSigningKeyResponse = DataResponse<{
585
+ key: string;
586
+ }>;
565
587
 
566
- interface WebhooksValidateResponse {
588
+ type WebhooksValidateResponse = DataResponse<{
567
589
  /**
568
590
  * Indicates whether all webhook validations passed.
569
591
  */
@@ -594,8 +616,7 @@ interface WebhooksValidateResponse {
594
616
  status: number;
595
617
  } | null;
596
618
  }[];
597
- error: string | null;
598
- }
619
+ }>;
599
620
 
600
621
  declare class Webhooks {
601
622
  protected mailchannels: MailChannelsClient;
@@ -606,7 +627,7 @@ declare class Webhooks {
606
627
  * @example
607
628
  * ```ts
608
629
  * const mailchannels = new MailChannels('your-api-key')
609
- * const { success } = mailchannels.webhooks.enroll('https://example.com/api/webhooks/mailchannels')
630
+ * const { success, error } = mailchannels.webhooks.enroll('https://example.com/api/webhooks/mailchannels')
610
631
  * ```
611
632
  */
612
633
  enroll(endpoint: string): Promise<SuccessResponse>;
@@ -615,7 +636,7 @@ declare class Webhooks {
615
636
  * @example
616
637
  * ```ts
617
638
  * const mailchannels = new MailChannels('your-api-key')
618
- * const { webhooks } = await mailchannels.webhooks.list()
639
+ * const { data, error } = await mailchannels.webhooks.list()
619
640
  * ```
620
641
  */
621
642
  list(): Promise<WebhooksListResponse>;
@@ -624,7 +645,7 @@ declare class Webhooks {
624
645
  * @example
625
646
  * ```ts
626
647
  * const mailchannels = new MailChannels('your-api-key')
627
- * const { success } = await mailchannels.webhooks.delete()
648
+ * const { success, error } = await mailchannels.webhooks.delete()
628
649
  * ```
629
650
  */
630
651
  delete(): Promise<SuccessResponse>;
@@ -634,7 +655,7 @@ declare class Webhooks {
634
655
  * @example
635
656
  * ```ts
636
657
  * const mailchannels = new MailChannels('your-api-key')
637
- * const { key } = await mailchannels.webhooks.getSigningKey('key-id')
658
+ * const { data, error } = await mailchannels.webhooks.getSigningKey('key-id')
638
659
  * ```
639
660
  */
640
661
  getSigningKey(id: string): Promise<WebhooksSigningKeyResponse>;
@@ -644,7 +665,7 @@ declare class Webhooks {
644
665
  * @example
645
666
  * ```ts
646
667
  * const mailchannels = new MailChannels('your-api-key')
647
- * const { allPassed, results } = await mailchannels.webhooks.validate('optional-request-id')
668
+ * const { data, error } = await mailchannels.webhooks.validate('optional-request-id')
648
669
  * ```
649
670
  */
650
671
  validate(requestId?: string): Promise<WebhooksValidateResponse>;
@@ -665,10 +686,7 @@ interface SubAccountsAccount {
665
686
  handle: string;
666
687
  }
667
688
 
668
- interface SubAccountsCreateResponse {
669
- account: SubAccountsAccount | null;
670
- error: string | null;
671
- }
689
+ type SubAccountsCreateResponse = DataResponse<SubAccountsAccount>;
672
690
 
673
691
  interface SubAccountsListOptions {
674
692
  /**
@@ -683,10 +701,7 @@ interface SubAccountsListOptions {
683
701
  offset?: number;
684
702
  }
685
703
 
686
- interface SubAccountsListResponse {
687
- accounts: SubAccountsAccount[];
688
- error: string | null;
689
- }
704
+ type SubAccountsListResponse = DataResponse<SubAccountsAccount[]>;
690
705
 
691
706
  interface SubAccountsApiKey {
692
707
  /**
@@ -699,10 +714,7 @@ interface SubAccountsApiKey {
699
714
  value: string;
700
715
  }
701
716
 
702
- interface SubAccountsCreateApiKeyResponse {
703
- key: SubAccountsApiKey | null;
704
- error: string | null;
705
- }
717
+ type SubAccountsCreateApiKeyResponse = DataResponse<SubAccountsApiKey>;
706
718
 
707
719
  interface SubAccountsListApiKeyOptions {
708
720
  /**
@@ -717,10 +729,7 @@ interface SubAccountsListApiKeyOptions {
717
729
  offset?: number;
718
730
  }
719
731
 
720
- interface SubAccountsListApiKeyResponse {
721
- keys: SubAccountsApiKey[];
722
- error: string | null;
723
- }
732
+ type SubAccountsListApiKeyResponse = DataResponse<SubAccountsApiKey[]>;
724
733
 
725
734
  interface SubAccountsSmtpPassword {
726
735
  /**
@@ -737,24 +746,15 @@ interface SubAccountsSmtpPassword {
737
746
  value: string;
738
747
  }
739
748
 
740
- interface SubAccountsCreateSmtpPasswordResponse {
741
- password: SubAccountsSmtpPassword | null;
742
- error: string | null;
743
- }
749
+ type SubAccountsCreateSmtpPasswordResponse = DataResponse<SubAccountsSmtpPassword>;
744
750
 
745
- interface SubAccountsListSmtpPasswordResponse {
746
- passwords: SubAccountsSmtpPassword[];
747
- error: string | null;
748
- }
751
+ type SubAccountsListSmtpPasswordResponse = DataResponse<SubAccountsSmtpPassword[]>;
749
752
 
750
753
  interface SubAccountsLimit {
751
754
  sends: number;
752
755
  }
753
756
 
754
- interface SubAccountsLimitResponse {
755
- limit: SubAccountsLimit | null;
756
- error: string | null;
757
- }
757
+ type SubAccountsLimitResponse = DataResponse<SubAccountsLimit>;
758
758
 
759
759
  interface SubAccountsUsage {
760
760
  /**
@@ -773,10 +773,7 @@ interface SubAccountsUsage {
773
773
  total: number;
774
774
  }
775
775
 
776
- interface SubAccountsUsageResponse {
777
- usage: SubAccountsUsage | null;
778
- error: string | null;
779
- }
776
+ type SubAccountsUsageResponse = DataResponse<SubAccountsUsage>;
780
777
 
781
778
  declare class SubAccounts {
782
779
  protected mailchannels: MailChannelsClient;
@@ -790,7 +787,7 @@ declare class SubAccounts {
790
787
  * @example
791
788
  * ```ts
792
789
  * const mailchannels = new MailChannels('your-api-key')
793
- * const { account } = await mailchannels.subAccounts.create('My Company', 'validhandle123')
790
+ * const { data, error } = await mailchannels.subAccounts.create('My Company', 'validhandle123')
794
791
  * ```
795
792
  */
796
793
  create(companyName: string, handle?: string): Promise<SubAccountsCreateResponse>;
@@ -800,7 +797,7 @@ declare class SubAccounts {
800
797
  * @example
801
798
  * ```ts
802
799
  * const mailchannels = new MailChannels('your-api-key')
803
- * const { accounts } = await mailchannels.subAccounts.list()
800
+ * const { data, error } = await mailchannels.subAccounts.list()
804
801
  * ```
805
802
  */
806
803
  list(options?: SubAccountsListOptions): Promise<SubAccountsListResponse>;
@@ -809,7 +806,7 @@ declare class SubAccounts {
809
806
  * @param handle - Handle of sub-account to be deleted.
810
807
  * ```ts
811
808
  * const mailchannels = new MailChannels('your-api-key')
812
- * const { success } = await mailchannels.subAccounts.delete('validhandle123')
809
+ * const { success, error } = await mailchannels.subAccounts.delete('validhandle123')
813
810
  * ```
814
811
  */
815
812
  delete(handle: string): Promise<SuccessResponse>;
@@ -819,7 +816,7 @@ declare class SubAccounts {
819
816
  * @example
820
817
  * ```ts
821
818
  * const mailchannels = new MailChannels('your-api-key')
822
- * const { success } = await mailchannels.subAccounts.suspend('validhandle123')
819
+ * const { success, error } = await mailchannels.subAccounts.suspend('validhandle123')
823
820
  * ```
824
821
  */
825
822
  suspend(handle: string): Promise<SuccessResponse>;
@@ -829,7 +826,7 @@ declare class SubAccounts {
829
826
  * @example
830
827
  * ```ts
831
828
  * const mailchannels = new MailChannels('your-api-key')
832
- * const { success } = await mailchannels.subAccounts.activate('validhandle123')
829
+ * const { success, error } = await mailchannels.subAccounts.activate('validhandle123')
833
830
  * ```
834
831
  */
835
832
  activate(handle: string): Promise<SuccessResponse>;
@@ -839,7 +836,7 @@ declare class SubAccounts {
839
836
  * @example
840
837
  * ```ts
841
838
  * const mailchannels = new MailChannels('your-api-key')
842
- * const { key } = await mailchannels.subAccounts.createApiKey('validhandle123')
839
+ * const { data, error } = await mailchannels.subAccounts.createApiKey('validhandle123')
843
840
  * ```
844
841
  */
845
842
  createApiKey(handle: string): Promise<SubAccountsCreateApiKeyResponse>;
@@ -850,7 +847,7 @@ declare class SubAccounts {
850
847
  * @example
851
848
  * ```ts
852
849
  * const mailchannels = new MailChannels('your-api-key')
853
- * const { keys } = await mailchannels.subAccounts.listApiKeys('validhandle123')
850
+ * const { data, error } = await mailchannels.subAccounts.listApiKeys('validhandle123')
854
851
  * ```
855
852
  */
856
853
  listApiKeys(handle: string, options?: SubAccountsListApiKeyOptions): Promise<SubAccountsListApiKeyResponse>;
@@ -861,7 +858,7 @@ declare class SubAccounts {
861
858
  * @example
862
859
  * ```ts
863
860
  * const mailchannels = new MailChannels('your-api-key')
864
- * const { success } = await mailchannels.subAccounts.deleteApiKey('validhandle123', 1)
861
+ * const { success, error } = await mailchannels.subAccounts.deleteApiKey('validhandle123', 1)
865
862
  * ```
866
863
  */
867
864
  deleteApiKey(handle: string, id: number): Promise<SuccessResponse>;
@@ -871,7 +868,7 @@ declare class SubAccounts {
871
868
  * @example
872
869
  * ```ts
873
870
  * const mailchannels = new MailChannels('your-api-key')
874
- * const { password } = await mailchannels.subAccounts.createSmtpPassword('validhandle123')
871
+ * const { data, error } = await mailchannels.subAccounts.createSmtpPassword('validhandle123')
875
872
  * ```
876
873
  */
877
874
  createSmtpPassword(handle: string): Promise<SubAccountsCreateSmtpPasswordResponse>;
@@ -881,7 +878,7 @@ declare class SubAccounts {
881
878
  * @example
882
879
  * ```ts
883
880
  * const mailchannels = new MailChannels('your-api-key')
884
- * const { passwords } = await mailchannels.subAccounts.listSmtpPasswords('validhandle123')
881
+ * const { data, error } = await mailchannels.subAccounts.listSmtpPasswords('validhandle123')
885
882
  * ```
886
883
  */
887
884
  listSmtpPasswords(handle: string): Promise<SubAccountsListSmtpPasswordResponse>;
@@ -892,7 +889,7 @@ declare class SubAccounts {
892
889
  * @example
893
890
  * ```ts
894
891
  * const mailchannels = new MailChannels('your-api-key')
895
- * const { success } = await mailchannels.subAccounts.deleteSmtpPassword('validhandle123', 1)
892
+ * const { success, error } = await mailchannels.subAccounts.deleteSmtpPassword('validhandle123', 1)
896
893
  * ```
897
894
  */
898
895
  deleteSmtpPassword(handle: string, id: number): Promise<SuccessResponse>;
@@ -902,7 +899,7 @@ declare class SubAccounts {
902
899
  * @example
903
900
  * ```ts
904
901
  * const mailchannels = new MailChannels('your-api-key')
905
- * const { limit } = await mailchannels.subAccounts.getLimit('validhandle123')
902
+ * const { data, error } = await mailchannels.subAccounts.getLimit('validhandle123')
906
903
  * ```
907
904
  */
908
905
  getLimit(handle: string): Promise<SubAccountsLimitResponse>;
@@ -913,7 +910,7 @@ declare class SubAccounts {
913
910
  * @example
914
911
  * ```ts
915
912
  * const mailchannels = new MailChannels('your-api-key')
916
- * const { success } = await mailchannels.subAccounts.setLimit('validhandle123', { sends: 1000 })
913
+ * const { success, error } = await mailchannels.subAccounts.setLimit('validhandle123', { sends: 1000 })
917
914
  * ```
918
915
  */
919
916
  setLimit(handle: string, limit: SubAccountsLimit): Promise<SuccessResponse>;
@@ -923,7 +920,7 @@ declare class SubAccounts {
923
920
  * @example
924
921
  * ```ts
925
922
  * const mailchannels = new MailChannels('your-api-key')
926
- * const { success } = await mailchannels.subAccounts.deleteLimit('validhandle123')
923
+ * const { success, error } = await mailchannels.subAccounts.deleteLimit('validhandle123')
927
924
  * ```
928
925
  */
929
926
  deleteLimit(handle: string): Promise<SuccessResponse>;
@@ -933,13 +930,16 @@ declare class SubAccounts {
933
930
  * @example
934
931
  * ```ts
935
932
  * const mailchannels = new MailChannels('your-api-key')
936
- * const { usage } = await mailchannels.subAccounts.getUsage('validhandle123')
933
+ * const { data, error } = await mailchannels.subAccounts.getUsage('validhandle123')
937
934
  * ```
938
935
  */
939
936
  getUsage(handle: string): Promise<SubAccountsUsageResponse>;
940
937
  }
941
938
 
942
939
  interface MetricsEngagement {
940
+ /**
941
+ * A series of metrics aggregations bucketed by time interval (e.g. hour, day).
942
+ */
943
943
  buckets: {
944
944
  click: MetricsBucket[];
945
945
  clickTrackingDelivered: MetricsBucket[];
@@ -954,16 +954,16 @@ interface MetricsEngagement {
954
954
  startTime: string;
955
955
  }
956
956
 
957
- interface MetricsEngagementResponse {
958
- engagement: MetricsEngagement | null;
959
- error: string | null;
960
- }
957
+ type MetricsEngagementResponse = DataResponse<MetricsEngagement>;
961
958
 
962
959
  interface MetricsPerformance {
963
960
  /**
964
961
  * Count of messages bounced during the specified time range.
965
962
  */
966
963
  bounced: number;
964
+ /**
965
+ * A series of metrics aggregations bucketed by time interval (e.g. hour, day).
966
+ */
967
967
  buckets: {
968
968
  bounced: MetricsBucket[];
969
969
  delivered: MetricsBucket[];
@@ -987,12 +987,12 @@ interface MetricsPerformance {
987
987
  startTime: string;
988
988
  }
989
989
 
990
- interface MetricsPerformanceResponse {
991
- performance: MetricsPerformance | null;
992
- error: string | null;
993
- }
990
+ type MetricsPerformanceResponse = DataResponse<MetricsPerformance>;
994
991
 
995
992
  interface MetricsRecipientBehaviour {
993
+ /**
994
+ * A series of metrics aggregations bucketed by time interval (e.g. hour, day).
995
+ */
996
996
  buckets: {
997
997
  unsubscribeDelivered: MetricsBucket[];
998
998
  unsubscribed: MetricsBucket[];
@@ -1015,12 +1015,12 @@ interface MetricsRecipientBehaviour {
1015
1015
  unsubscribed: number;
1016
1016
  }
1017
1017
 
1018
- interface MetricsRecipientBehaviourResponse {
1019
- behaviour: MetricsRecipientBehaviour | null;
1020
- error: string | null;
1021
- }
1018
+ type MetricsRecipientBehaviourResponse = DataResponse<MetricsRecipientBehaviour>;
1022
1019
 
1023
1020
  interface MetricsVolume {
1021
+ /**
1022
+ * A series of metrics aggregations bucketed by time interval (e.g. hour, day).
1023
+ */
1024
1024
  buckets: {
1025
1025
  delivered: MetricsBucket[];
1026
1026
  dropped: MetricsBucket[];
@@ -1048,31 +1048,78 @@ interface MetricsVolume {
1048
1048
  startTime: string;
1049
1049
  }
1050
1050
 
1051
- interface MetricsVolumeResponse {
1052
- volume: MetricsVolume | null;
1053
- error: string | null;
1051
+ type MetricsVolumeResponse = DataResponse<MetricsVolume>;
1052
+
1053
+ type MetricsUsageResponse = DataResponse<{
1054
+ /**
1055
+ * The end date of the current billing period (ISO 8601 format).
1056
+ * @example "2025-04-11"
1057
+ */
1058
+ endDate: string;
1059
+ /**
1060
+ * The start date of the current billing period (ISO 8601 format).
1061
+ * @example "2025-03-12"
1062
+ */
1063
+ startDate: string;
1064
+ /**
1065
+ * The total usage for the current billing period.
1066
+ */
1067
+ total: number;
1068
+ }>;
1069
+
1070
+ type MetricsSendersType = "sub-accounts" | "campaigns";
1071
+
1072
+ interface MetricsSendersOptions {
1073
+ /**
1074
+ * The beginning of the time range for retrieving top senders metrics (inclusive). Formats: `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SSZ`. Defaults to one month ago if not provided.
1075
+ * @example "2025-11-02T03:13:35.761763554Z"
1076
+ */
1077
+ startTime?: string;
1078
+ /**
1079
+ * The end of the time range for retrieving top senders metrics (exclusive). Formats: `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SSZ`. Defaults to the current time if not provided.
1080
+ * @example "2025-12-02T03:13:35.761763554Z"
1081
+ */
1082
+ endTime?: string;
1083
+ /**
1084
+ * The maximum number of senders to return. Possible values are 1 to 1000.
1085
+ * @default 10
1086
+ */
1087
+ limit?: number;
1088
+ /**
1089
+ * The number of senders to skip before returning results.
1090
+ * @default 0
1091
+ */
1092
+ offset?: number;
1093
+ /**
1094
+ * The order in which to sort the results, based on total messages (processed + dropped).
1095
+ * @default "desc"
1096
+ */
1097
+ sortOrder?: "asc" | "desc";
1054
1098
  }
1055
1099
 
1056
- interface MetricsUsageResponse {
1057
- usage: {
1058
- /**
1059
- * The end date of the current billing period (ISO 8601 format).
1060
- * @example "2025-04-11"
1061
- */
1062
- endDate: string;
1063
- /**
1064
- * The start date of the current billing period (ISO 8601 format).
1065
- * @example "2025-03-12"
1066
- */
1067
- startDate: string;
1100
+ interface MetricsSenders {
1101
+ endTime: string;
1102
+ limit: number;
1103
+ offset: number;
1104
+ senders: {
1105
+ bounced: number;
1106
+ delivered: number;
1107
+ dropped: number;
1068
1108
  /**
1069
- * The total usage for the current billing period.
1109
+ * Maximum character length: 255
1070
1110
  */
1071
- total: number;
1072
- } | null;
1073
- error: string | null;
1111
+ name: string;
1112
+ processed: number;
1113
+ }[];
1114
+ startTime: string;
1115
+ /**
1116
+ * The total number of senders in this category that sent messages in the given time range.
1117
+ */
1118
+ total: number;
1074
1119
  }
1075
1120
 
1121
+ type MetricsSendersResponse = DataResponse<MetricsSenders>;
1122
+
1076
1123
  interface MetricsBucket {
1077
1124
  /**
1078
1125
  * The number of events or occurrences aggregated within this time period.
@@ -1115,7 +1162,7 @@ declare class Metrics {
1115
1162
  * @example
1116
1163
  * ```ts
1117
1164
  * const mailchannels = new MailChannels('your-api-key')
1118
- * const { engagement } = await mailchannels.metrics.engagement()
1165
+ * const { data, error } = await mailchannels.metrics.engagement()
1119
1166
  * ```
1120
1167
  */
1121
1168
  engagement(options?: MetricsOptions): Promise<MetricsEngagementResponse>;
@@ -1125,7 +1172,7 @@ declare class Metrics {
1125
1172
  * @example
1126
1173
  * ```ts
1127
1174
  * const mailchannels = new MailChannels('your-api-key')
1128
- * const { performance } = await mailchannels.metrics.performance()
1175
+ * const { data, error } = await mailchannels.metrics.performance()
1129
1176
  * ```
1130
1177
  */
1131
1178
  performance(options?: MetricsOptions): Promise<MetricsPerformanceResponse>;
@@ -1135,7 +1182,7 @@ declare class Metrics {
1135
1182
  * @example
1136
1183
  * ```ts
1137
1184
  * const mailchannels = new MailChannels('your-api-key')
1138
- * const { behaviour } = await mailchannels.metrics.recipientBehaviour()
1185
+ * const { data, error } = await mailchannels.metrics.recipientBehaviour()
1139
1186
  * ```
1140
1187
  */
1141
1188
  recipientBehaviour(options?: MetricsOptions): Promise<MetricsRecipientBehaviourResponse>;
@@ -1145,7 +1192,7 @@ declare class Metrics {
1145
1192
  * @example
1146
1193
  * ```ts
1147
1194
  * const mailchannels = new MailChannels('your-api-key')
1148
- * const { volume } = await mailchannels.metrics.volume()
1195
+ * const { data, error } = await mailchannels.metrics.volume()
1149
1196
  * ```
1150
1197
  */
1151
1198
  volume(options?: MetricsOptions): Promise<MetricsVolumeResponse>;
@@ -1154,10 +1201,21 @@ declare class Metrics {
1154
1201
  * @example
1155
1202
  * ```ts
1156
1203
  * const mailchannels = new MailChannels('your-api-key')
1157
- * const { usage } = await mailchannels.metrics.usage()
1204
+ * const { data, error } = await mailchannels.metrics.usage()
1158
1205
  * ```
1159
1206
  */
1160
1207
  usage(): Promise<MetricsUsageResponse>;
1208
+ /**
1209
+ * Retrieves a list of senders, either sub-accounts or campaigns, with their associated message metrics. Sorted by total # of sent messages (processed + dropped). Supports optional filter for time range, and optional settings for limit, offset, and sort order. Note: senders without any messages in the given time range will not be included in the results. The default time range is from one month ago to now, and the default sort order is descending.
1210
+ * @param type - The type of senders to retrieve metrics for. Can be either `sub-accounts` or `campaigns`.
1211
+ * @param options - Optional filter options for time range, limit, offset, and sort order.
1212
+ * @example
1213
+ * ```ts
1214
+ * const mailchannels = new MailChannels('your-api-key')
1215
+ * const { data, error } = await mailchannels.metrics.senders('campaigns')
1216
+ * ```
1217
+ */
1218
+ senders(type: MetricsSendersType, options?: MetricsSendersOptions): Promise<MetricsSendersResponse>;
1161
1219
  }
1162
1220
 
1163
1221
  type SuppressionsTypes = "transactional" | "non-transactional";
@@ -1231,10 +1289,7 @@ interface SuppressionsListEntry {
1231
1289
  types: SuppressionsTypes[];
1232
1290
  }
1233
1291
 
1234
- interface SuppressionsListResponse {
1235
- list: SuppressionsListEntry[];
1236
- error: string | null;
1237
- }
1292
+ type SuppressionsListResponse = DataResponse<SuppressionsListEntry[]>;
1238
1293
 
1239
1294
  declare class Suppressions {
1240
1295
  protected mailchannels: MailChannelsClient;
@@ -1245,7 +1300,7 @@ declare class Suppressions {
1245
1300
  * @example
1246
1301
  * ```ts
1247
1302
  * const mailchannels = new MailChannels('your-api-key')
1248
- * const { success } = await mailchannels.suppressions.create({
1303
+ * const { success, error } = await mailchannels.suppressions.create({
1249
1304
  * // ...
1250
1305
  * });
1251
1306
  */
@@ -1257,7 +1312,7 @@ declare class Suppressions {
1257
1312
  * @example
1258
1313
  * ```ts
1259
1314
  * const mailchannels = new MailChannels('your-api-key')
1260
- * const { success } = await mailchannels.suppressions.delete('name@example.com', 'api');
1315
+ * const { success, error } = await mailchannels.suppressions.delete('name@example.com', 'api');
1261
1316
  * ```
1262
1317
  */
1263
1318
  delete(recipient: string, source?: SuppressionsSource): Promise<SuccessResponse>;
@@ -1266,7 +1321,7 @@ declare class Suppressions {
1266
1321
  * @example
1267
1322
  * ```ts
1268
1323
  * const mailchannels = new MailChannels('your-api-key')
1269
- * const { list }= await mailchannels.suppressions.list();
1324
+ * const { data, error } = await mailchannels.suppressions.list();
1270
1325
  * ```
1271
1326
  * @param options - Options to filter and customize the suppression entries retrieval.
1272
1327
  */
@@ -1292,15 +1347,9 @@ interface ListEntry {
1292
1347
  type: "domain" | "email_address" | "ip_address";
1293
1348
  }
1294
1349
 
1295
- interface ListEntryResponse {
1296
- entry: ListEntry | null;
1297
- error: string | null;
1298
- }
1350
+ type ListEntryResponse = DataResponse<ListEntry>;
1299
1351
 
1300
- interface ListEntriesResponse {
1301
- entries: ListEntry[];
1302
- error: string | null;
1303
- }
1352
+ type ListEntriesResponse = DataResponse<ListEntry[]>;
1304
1353
 
1305
1354
  interface DomainsData {
1306
1355
  /**
@@ -1376,44 +1425,32 @@ interface DomainsProvisionOptions {
1376
1425
 
1377
1426
  type DomainsBulkProvisionOptions = DomainsProvisionOptions & Pick<DomainsData, "subscriptionHandle">;
1378
1427
 
1379
- interface DomainsProvisionResponse {
1380
- /**
1381
- * The provisioned domain data.
1382
- */
1383
- data: DomainsData | null;
1384
- error: string | null;
1385
- }
1428
+ type DomainsProvisionResponse = DataResponse<DomainsData>;
1386
1429
 
1387
- interface DomainsBulkProvisionResponse {
1430
+ type DomainsBulkProvisionResponse = DataResponse<{
1388
1431
  /**
1389
- * If the request was processed successfully, this does not necessarily mean all the domains in the request were successfully provisioned.
1432
+ * Domains that were successfully provisioned or updated.
1390
1433
  */
1391
- results: {
1434
+ successes: {
1392
1435
  /**
1393
- * Domains that were successfully provisioned or updated.
1436
+ * The provisioned domain data.
1394
1437
  */
1395
- successes: {
1396
- /**
1397
- * The provisioned domain data.
1398
- */
1399
- domain: DomainsData;
1400
- code: number;
1401
- comment?: string;
1402
- }[];
1438
+ domain: DomainsData;
1439
+ code: number;
1440
+ comment?: string;
1441
+ }[];
1442
+ /**
1443
+ * Domains that were not successfully provisioned.
1444
+ */
1445
+ errors: {
1403
1446
  /**
1404
- * Domains that were not successfully provisioned.
1447
+ * The failed to provision domain data.
1405
1448
  */
1406
- errors: {
1407
- /**
1408
- * The failed to provision domain data.
1409
- */
1410
- domain: DomainsData;
1411
- code: number;
1412
- comment?: string;
1413
- }[];
1414
- } | null;
1415
- error: string | null;
1416
- }
1449
+ domain: DomainsData;
1450
+ code: number;
1451
+ comment?: string;
1452
+ }[];
1453
+ }>;
1417
1454
 
1418
1455
  interface DomainsListOptions {
1419
1456
  /**
@@ -1432,7 +1469,7 @@ interface DomainsListOptions {
1432
1469
  offset?: number;
1433
1470
  }
1434
1471
 
1435
- interface DomainsListResponse {
1472
+ type DomainsListResponse = DataResponse<{
1436
1473
  /**
1437
1474
  * A list of domains.
1438
1475
  */
@@ -1441,17 +1478,17 @@ interface DomainsListResponse {
1441
1478
  * 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.
1442
1479
  */
1443
1480
  total: number;
1444
- error: string | null;
1445
- }
1481
+ }>;
1446
1482
 
1447
- interface DomainsCreateLoginLinkResponse {
1483
+ interface DomainsCreateLoginLink {
1448
1484
  /**
1449
1485
  * If a user browses to this URL, they will be automatically logged in as a domain admin.
1450
1486
  */
1451
- link: string | null;
1452
- error: string | null;
1487
+ link: string;
1453
1488
  }
1454
1489
 
1490
+ type DomainsCreateLoginLinkResponse = DataResponse<DomainsCreateLoginLink>;
1491
+
1455
1492
  interface DomainsListDownstreamAddressesOptions {
1456
1493
  /**
1457
1494
  * The number of records to return.
@@ -1484,10 +1521,7 @@ interface DomainsDownstreamAddress {
1484
1521
  weight: number;
1485
1522
  }
1486
1523
 
1487
- interface DomainsListDownstreamAddressesResponse {
1488
- records: DomainsDownstreamAddress[];
1489
- error: string | null;
1490
- }
1524
+ type DomainsListDownstreamAddressesResponse = DataResponse<DomainsDownstreamAddress[]>;
1491
1525
 
1492
1526
  interface DomainsBulkCreateLoginLinkResult {
1493
1527
  /**
@@ -1510,10 +1544,7 @@ interface DomainsBulkCreateLoginLinks {
1510
1544
  errors: Omit<DomainsBulkCreateLoginLinkResult, "loginLink">[];
1511
1545
  }
1512
1546
 
1513
- interface DomainsBulkCreateLoginLinksResponse {
1514
- results: DomainsBulkCreateLoginLinks | null;
1515
- error: string | null;
1516
- }
1547
+ type DomainsBulkCreateLoginLinksResponse = DataResponse<DomainsBulkCreateLoginLinks>;
1517
1548
 
1518
1549
  declare class Domains {
1519
1550
  protected mailchannels: MailChannelsClient;
@@ -1524,7 +1555,7 @@ declare class Domains {
1524
1555
  * @example
1525
1556
  * ```ts
1526
1557
  * const mailchannels = new MailChannels('your-api-key')
1527
- * const { data } = await mailchannels.domains.provision({
1558
+ * const { data, error } = await mailchannels.domains.provision({
1528
1559
  * domain: 'example.com',
1529
1560
  * subscriptionHandle: 'your-subscription-handle'
1530
1561
  * })
@@ -1538,7 +1569,7 @@ declare class Domains {
1538
1569
  * @example
1539
1570
  * ```ts
1540
1571
  * const mailchannels = new MailChannels('your-api-key')
1541
- * const { results } = await mailchannels.domains.bulkProvision({
1572
+ * const { data, error } = await mailchannels.domains.bulkProvision({
1542
1573
  * subscriptionHandle: 'your-subscription-handle'
1543
1574
  * }, [
1544
1575
  * {
@@ -1558,7 +1589,7 @@ declare class Domains {
1558
1589
  * @example
1559
1590
  * ```ts
1560
1591
  * const mailchannels = new MailChannels('your-api-key')
1561
- * const { domains } = await mailchannels.domains.list()
1592
+ * const { data, error } = await mailchannels.domains.list()
1562
1593
  * ```
1563
1594
  */
1564
1595
  list(options?: DomainsListOptions): Promise<DomainsListResponse>;
@@ -1568,7 +1599,7 @@ declare class Domains {
1568
1599
  * @example
1569
1600
  * ```ts
1570
1601
  * const mailchannels = new MailChannels('your-api-key')
1571
- * const { success } = await mailchannels.domains.delete('example.com')
1602
+ * const { success, error } = await mailchannels.domains.delete('example.com')
1572
1603
  * ```
1573
1604
  */
1574
1605
  delete(domain: string): Promise<SuccessResponse>;
@@ -1579,7 +1610,7 @@ declare class Domains {
1579
1610
  * @example
1580
1611
  * ```ts
1581
1612
  * const mailchannels = new MailChannels('your-api-key')
1582
- * const { entry } = await mailchannels.domains.addListEntry('example.com', {
1613
+ * const { data, error } = await mailchannels.domains.addListEntry('example.com', {
1583
1614
  * listName: 'safelist',
1584
1615
  * item: 'name@domain.com'
1585
1616
  * })
@@ -1593,7 +1624,7 @@ declare class Domains {
1593
1624
  * @example
1594
1625
  * ```ts
1595
1626
  * const mailchannels = new MailChannels('your-api-key')
1596
- * const { entries } = await mailchannels.domains.listEntries('example.com', 'safelist')
1627
+ * const { data, error } = await mailchannels.domains.listEntries('example.com', 'safelist')
1597
1628
  * ```
1598
1629
  */
1599
1630
  listEntries(domain: string, listName: ListNames): Promise<ListEntriesResponse>;
@@ -1604,7 +1635,7 @@ declare class Domains {
1604
1635
  * @example
1605
1636
  * ```ts
1606
1637
  * const mailchannels = new MailChannels('your-api-key')
1607
- * const { success } = await mailchannels.domains.deleteListEntry('example.com', {
1638
+ * const { success, error } = await mailchannels.domains.deleteListEntry('example.com', {
1608
1639
  * listName: 'safelist',
1609
1640
  * item: 'name@domain.com'
1610
1641
  * })
@@ -1617,7 +1648,7 @@ declare class Domains {
1617
1648
  * @example
1618
1649
  * ```ts
1619
1650
  * const mailchannels = new MailChannels('your-api-key')
1620
- * const { link } = await mailchannels.domains.createLoginLink('example.com')
1651
+ * const { data, error } = await mailchannels.domains.createLoginLink('example.com')
1621
1652
  * ```
1622
1653
  */
1623
1654
  createLoginLink(domain: string): Promise<DomainsCreateLoginLinkResponse>;
@@ -1628,7 +1659,7 @@ declare class Domains {
1628
1659
  * @example
1629
1660
  * ```ts
1630
1661
  * const mailchannels = new MailChannels('your-api-key')
1631
- * const { success } = await mailchannels.domains.setDownstreamAddress('example.com', [
1662
+ * const { success, error } = await mailchannels.domains.setDownstreamAddress('example.com', [
1632
1663
  * {
1633
1664
  * port: 25,
1634
1665
  * priority: 10,
@@ -1646,7 +1677,7 @@ declare class Domains {
1646
1677
  * @example
1647
1678
  * ```ts
1648
1679
  * const mailchannels = new MailChannels('your-api-key')
1649
- * const { records } = await mailchannels.domains.listDownstreamAddresses('example.com')
1680
+ * const { data, error } = await mailchannels.domains.listDownstreamAddresses('example.com')
1650
1681
  * ```
1651
1682
  */
1652
1683
  listDownstreamAddresses(domain: string, options?: DomainsListDownstreamAddressesOptions): Promise<DomainsListDownstreamAddressesResponse>;
@@ -1657,7 +1688,7 @@ declare class Domains {
1657
1688
  * @example
1658
1689
  * ```ts
1659
1690
  * const mailchannels = new MailChannels('your-api-key')
1660
- * const { success } = await mailchannels.domains.updateApiKey('example.com', 'your-api-key')
1691
+ * const { success, error } = await mailchannels.domains.updateApiKey('example.com', 'your-api-key')
1661
1692
  * ```
1662
1693
  */
1663
1694
  updateApiKey(domain: string, key: string): Promise<SuccessResponse>;
@@ -1667,7 +1698,7 @@ declare class Domains {
1667
1698
  * @example
1668
1699
  * ```ts
1669
1700
  * const mailchannels = new MailChannels('your-api-key')
1670
- * const { results } = await mailchannels.domains.bulkCreateLoginLinks(['example.com', 'example2.com'])
1701
+ * const { data, error } = await mailchannels.domains.bulkCreateLoginLinks(['example.com', 'example2.com'])
1671
1702
  * ```
1672
1703
  */
1673
1704
  bulkCreateLoginLinks(domains: string[]): Promise<DomainsBulkCreateLoginLinksResponse>;
@@ -1682,7 +1713,7 @@ declare class Lists {
1682
1713
  * @example
1683
1714
  * ```ts
1684
1715
  * const mailchannels = new MailChannels('your-api-key')
1685
- * const { entry } = await mailchannels.lists.addListEntry({
1716
+ * const { data, error } = await mailchannels.lists.addListEntry({
1686
1717
  * listName: 'safelist',
1687
1718
  * item: 'name@domain.com'
1688
1719
  * })
@@ -1695,7 +1726,7 @@ declare class Lists {
1695
1726
  * @example
1696
1727
  * ```ts
1697
1728
  * const mailchannels = new MailChannels('your-api-key')
1698
- * const { entries } = await mailchannels.lists.listEntries('safelist')
1729
+ * const { data, error } = await mailchannels.lists.listEntries('safelist')
1699
1730
  * ```
1700
1731
  */
1701
1732
  listEntries(listName: ListNames): Promise<ListEntriesResponse>;
@@ -1705,7 +1736,7 @@ declare class Lists {
1705
1736
  * @example
1706
1737
  * ```ts
1707
1738
  * const mailchannels = new MailChannels('your-api-key')
1708
- * const { success } = await mailchannels.lists.deleteListEntry({
1739
+ * const { success, error } = await mailchannels.lists.deleteListEntry({
1709
1740
  * listName: 'safelist',
1710
1741
  * item: 'name@domain.com'
1711
1742
  * })
@@ -1737,19 +1768,16 @@ interface UsersCreateOptions {
1737
1768
  };
1738
1769
  }
1739
1770
 
1740
- interface UsersCreateResponse {
1741
- user: {
1742
- email: string;
1743
- roles: string[];
1744
- filter?: boolean;
1745
- listEntries: {
1746
- item: string;
1747
- type: "domain" | "email_address" | "ip_address";
1748
- action: "safelist" | "blocklist";
1749
- }[];
1750
- } | null;
1751
- error: string | null;
1752
- }
1771
+ type UsersCreateResponse = DataResponse<{
1772
+ email: string;
1773
+ roles: string[];
1774
+ filter?: boolean;
1775
+ listEntries: {
1776
+ item: string;
1777
+ type: "domain" | "email_address" | "ip_address";
1778
+ action: "safelist" | "blocklist";
1779
+ }[];
1780
+ }>;
1753
1781
 
1754
1782
  declare class Users {
1755
1783
  protected mailchannels: MailChannelsClient;
@@ -1761,7 +1789,7 @@ declare class Users {
1761
1789
  * @example
1762
1790
  * ```ts
1763
1791
  * const mailchannels = new MailChannels('your-api-key')
1764
- * const { user } = await mailchannels.users.create("name@example.com", {
1792
+ * const { data, error } = await mailchannels.users.create("name@example.com", {
1765
1793
  * admin: true
1766
1794
  * })
1767
1795
  * ```
@@ -1774,7 +1802,7 @@ declare class Users {
1774
1802
  * @example
1775
1803
  * ```ts
1776
1804
  * const mailchannels = new MailChannels('your-api-key')
1777
- * const { entry } = await mailchannels.users.addListEntry('name@example.com', {
1805
+ * const { data, error } = await mailchannels.users.addListEntry('name@example.com', {
1778
1806
  * listName: 'safelist',
1779
1807
  * item: 'name@domain.com'
1780
1808
  * })
@@ -1788,7 +1816,7 @@ declare class Users {
1788
1816
  * @example
1789
1817
  * ```ts
1790
1818
  * const mailchannels = new MailChannels('your-api-key')
1791
- * const { entries } = await mailchannels.users.listEntries('name@example.com', 'safelist')
1819
+ * const { data, error } = await mailchannels.users.listEntries('name@example.com', 'safelist')
1792
1820
  * ```
1793
1821
  */
1794
1822
  listEntries(email: string, listName: ListNames): Promise<ListEntriesResponse>;
@@ -1799,7 +1827,7 @@ declare class Users {
1799
1827
  * @example
1800
1828
  * ```ts
1801
1829
  * const mailchannels = new MailChannels('your-api-key')
1802
- * const { success } = await mailchannels.users.deleteListEntry('name@example.com', {
1830
+ * const { success, error } = await mailchannels.users.deleteListEntry('name@example.com', {
1803
1831
  * listName: 'safelist',
1804
1832
  * item: 'name@domain.com'
1805
1833
  * })
@@ -1808,22 +1836,19 @@ declare class Users {
1808
1836
  deleteListEntry(email: string, options: ListEntryOptions): Promise<SuccessResponse>;
1809
1837
  }
1810
1838
 
1811
- interface ServiceSubscriptionsResponse {
1812
- subscriptions: {
1813
- active: boolean;
1814
- activeAccountsCount: number;
1815
- handle: string;
1816
- limits: {
1817
- featureHandle: string;
1818
- value: string;
1819
- }[];
1820
- plan: {
1821
- handle: string;
1822
- name: string;
1823
- };
1839
+ type ServiceSubscriptionsResponse = DataResponse<{
1840
+ active: boolean;
1841
+ activeAccountsCount: number;
1842
+ handle: string;
1843
+ limits: {
1844
+ featureHandle: string;
1845
+ value: string;
1824
1846
  }[];
1825
- error: string | null;
1826
- }
1847
+ plan: {
1848
+ handle: string;
1849
+ name: string;
1850
+ };
1851
+ }[]>;
1827
1852
 
1828
1853
  interface ServiceReportOptions {
1829
1854
  /**
@@ -1858,7 +1883,7 @@ declare class Service {
1858
1883
  * @example
1859
1884
  * ```ts
1860
1885
  * const mailchannels = new MailChannels('your-api-key')
1861
- * const { success } = await mailchannels.service.status()
1886
+ * const { success, error } = await mailchannels.service.status()
1862
1887
  * ```
1863
1888
  */
1864
1889
  status(): Promise<SuccessResponse>;
@@ -1867,7 +1892,7 @@ declare class Service {
1867
1892
  * @example
1868
1893
  * ```ts
1869
1894
  * const mailchannels = new MailChannels('your-api-key')
1870
- * const { subscriptions } = await mailchannels.service.subscriptions()
1895
+ * const { data, error } = await mailchannels.service.subscriptions()
1871
1896
  * ```
1872
1897
  */
1873
1898
  subscriptions(): Promise<ServiceSubscriptionsResponse>;
@@ -1899,4 +1924,4 @@ declare class MailChannels extends MailChannelsClient {
1899
1924
  }
1900
1925
 
1901
1926
  export { Domains, Emails, Lists, MailChannels, MailChannelsClient, Metrics, Service, SubAccounts, Suppressions, Users, Webhooks };
1902
- export type { DomainsBulkCreateLoginLinkResult, DomainsBulkCreateLoginLinks, DomainsBulkCreateLoginLinksResponse, DomainsBulkProvisionOptions, DomainsBulkProvisionResponse, DomainsCreateLoginLinkResponse, DomainsData, DomainsDownstreamAddress, DomainsListDownstreamAddressesOptions, DomainsListDownstreamAddressesResponse, DomainsListOptions, DomainsListResponse, DomainsProvisionOptions, DomainsProvisionResponse, EmailsCheckDomainDkim, EmailsCheckDomainOptions, EmailsCheckDomainResponse, EmailsCheckDomainVerdict, EmailsCreateDkimKeyOptions, EmailsCreateDkimKeyResponse, EmailsDkimKey, EmailsGetDkimKeysOptions, EmailsGetDkimKeysResponse, EmailsSendAttachment, EmailsSendOptions, EmailsSendOptionsBase, EmailsSendRecipient, EmailsSendResponse, EmailsSendTracking, EmailsUpdateDkimKeyOptions, ListEntriesResponse, ListEntry, ListEntryOptions, ListEntryResponse, ListNames, MetricsBucket, MetricsEngagement, MetricsEngagementResponse, MetricsOptions, MetricsPerformance, MetricsPerformanceResponse, MetricsRecipientBehaviour, MetricsRecipientBehaviourResponse, MetricsUsageResponse, MetricsVolume, MetricsVolumeResponse, Optional, ServiceReportOptions, ServiceSubscriptionsResponse, SubAccountsAccount, SubAccountsApiKey, SubAccountsCreateApiKeyResponse, SubAccountsCreateResponse, SubAccountsCreateSmtpPasswordResponse, SubAccountsLimit, SubAccountsLimitResponse, SubAccountsListApiKeyOptions, SubAccountsListApiKeyResponse, SubAccountsListOptions, SubAccountsListResponse, SubAccountsListSmtpPasswordResponse, SubAccountsSmtpPassword, SubAccountsUsage, SubAccountsUsageResponse, SuccessResponse, SuppressionsCreateOptions, SuppressionsListEntry, SuppressionsListOptions, SuppressionsListResponse, SuppressionsSource, SuppressionsTypes, UsersCreateOptions, UsersCreateResponse, WebhooksListResponse, WebhooksSigningKeyResponse, WebhooksValidateResponse };
1927
+ export type { DataResponse, DomainsBulkCreateLoginLinkResult, DomainsBulkCreateLoginLinks, DomainsBulkCreateLoginLinksResponse, DomainsBulkProvisionOptions, DomainsBulkProvisionResponse, DomainsCreateLoginLink, DomainsCreateLoginLinkResponse, DomainsData, DomainsDownstreamAddress, DomainsListDownstreamAddressesOptions, DomainsListDownstreamAddressesResponse, DomainsListOptions, DomainsListResponse, DomainsProvisionOptions, DomainsProvisionResponse, EmailsCheckDomainDkim, EmailsCheckDomainOptions, EmailsCheckDomainResponse, EmailsCheckDomainVerdict, EmailsCreateDkimKeyOptions, EmailsCreateDkimKeyResponse, EmailsDkimKey, EmailsDkimKeyStatus, EmailsGetDkimKeysOptions, EmailsGetDkimKeysResponse, EmailsRotateDkimKeyOptions, EmailsRotateDkimKeyResponse, EmailsSendAttachment, EmailsSendOptions, EmailsSendOptionsBase, EmailsSendRecipient, EmailsSendResponse, EmailsSendTracking, EmailsUpdateDkimKeyOptions, ListEntriesResponse, ListEntry, ListEntryOptions, ListEntryResponse, ListNames, MetricsBucket, MetricsEngagement, MetricsEngagementResponse, MetricsOptions, MetricsPerformance, MetricsPerformanceResponse, MetricsRecipientBehaviour, MetricsRecipientBehaviourResponse, MetricsSenders, MetricsSendersOptions, MetricsSendersResponse, MetricsSendersType, MetricsUsageResponse, MetricsVolume, MetricsVolumeResponse, Optional, ServiceReportOptions, ServiceSubscriptionsResponse, SubAccountsAccount, SubAccountsApiKey, SubAccountsCreateApiKeyResponse, SubAccountsCreateResponse, SubAccountsCreateSmtpPasswordResponse, SubAccountsLimit, SubAccountsLimitResponse, SubAccountsListApiKeyOptions, SubAccountsListApiKeyResponse, SubAccountsListOptions, SubAccountsListResponse, SubAccountsListSmtpPasswordResponse, SubAccountsSmtpPassword, SubAccountsUsage, SubAccountsUsageResponse, SuccessResponse, SuppressionsCreateOptions, SuppressionsListEntry, SuppressionsListOptions, SuppressionsListResponse, SuppressionsSource, SuppressionsTypes, UsersCreateOptions, UsersCreateResponse, WebhooksListResponse, WebhooksSigningKeyResponse, WebhooksValidateResponse };