mailchannels-sdk 0.5.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,6 +17,20 @@ interface SuccessResponse {
17
17
  * Whether the operation was successful.
18
18
  */
19
19
  success: boolean;
20
+ /**
21
+ * Error message if the operation failed.
22
+ */
23
+ error: string | null;
24
+ }
25
+
26
+ interface DataResponse<T> {
27
+ /**
28
+ * The response data.
29
+ */
30
+ data: T | null;
31
+ /**
32
+ * Error message if the operation failed.
33
+ */
20
34
  error: string | null;
21
35
  }
22
36
 
@@ -277,6 +291,8 @@ interface EmailsCreateDkimKeyOptions {
277
291
  selector: string;
278
292
  }
279
293
 
294
+ type EmailsDkimKeyStatus = "active" | "retired" | "revoked" | "rotated";
295
+
280
296
  interface EmailsDkimKey {
281
297
  /**
282
298
  * Algorithm used for the key pair.
@@ -285,7 +301,7 @@ interface EmailsDkimKey {
285
301
  /**
286
302
  * Timestamp when the key pair was created.
287
303
  */
288
- createdAt: string;
304
+ createdAt?: string;
289
305
  /**
290
306
  * Suggested DNS records for the DKIM key.
291
307
  */
@@ -298,11 +314,19 @@ interface EmailsDkimKey {
298
314
  * Domain associated with the key pair.
299
315
  */
300
316
  domain: string;
317
+ /**
318
+ * UTC timestamp after which you can no longer use the rotated key for signing.
319
+ */
320
+ gracePeriodExpiresAt?: string;
301
321
  /**
302
322
  * Key length in bits.
303
323
  */
304
324
  length: 1024 | 2048 | 3072 | 4096;
305
325
  publicKey: string;
326
+ /**
327
+ * UTC timestamp when a rotated key pair is retired.
328
+ */
329
+ retiresAt?: string;
306
330
  /**
307
331
  * Selector assigned to the key pair.
308
332
  */
@@ -310,20 +334,14 @@ interface EmailsDkimKey {
310
334
  /**
311
335
  * Status of the key.
312
336
  */
313
- status: "active" | "revoked" | "retired";
337
+ status: EmailsDkimKeyStatus;
314
338
  /**
315
339
  * Timestamp when the key was last modified.
316
340
  */
317
- statusModifiedAt: string;
341
+ statusModifiedAt?: string;
318
342
  }
319
343
 
320
- interface EmailsCreateDkimKeyResponse {
321
- /**
322
- * The created DKIM key information.
323
- */
324
- key: EmailsDkimKey | null;
325
- error: string | null;
326
- }
344
+ type EmailsCreateDkimKeyResponse = DataResponse<EmailsDkimKey>;
327
345
 
328
346
  interface EmailsCheckDomainDkim {
329
347
  /**
@@ -343,12 +361,12 @@ interface EmailsCheckDomainDkim {
343
361
  interface EmailsCheckDomainOptions {
344
362
  /**
345
363
  * 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.
364
+ * 1. If `domain`, `selector`, and `privateKey` are all present, verify using the provided domain, selector, and key.
365
+ * 2. If `domain` and `selector` are present, use the stored private key for the given domain and selector.
366
+ * 3. If only `domain` is present, use all stored keys for the given domain.
367
+ * 4. If none are present, use all stored keys for the `domain` provided in the domain field of the request.
368
+ * 5. If `privateKey` is present, `selector` must be present.
369
+ * 6. If `selector` is present and `domain` is not, the domain will be taken from the domain field of the request.
352
370
  */
353
371
  dkim?: EmailsCheckDomainDkim[] | EmailsCheckDomainDkim;
354
372
  /**
@@ -363,68 +381,59 @@ interface EmailsCheckDomainOptions {
363
381
 
364
382
  type EmailsCheckDomainVerdict = "passed" | "failed" | "soft failed" | "temporary error" | "permanent error" | "neutral" | "none" | "unknown";
365
383
 
366
- interface EmailsCheckDomainResponse {
384
+ type EmailsCheckDomainResponse = DataResponse<{
385
+ dkim: {
386
+ domain: string;
387
+ /**
388
+ * The human readable status of the DKIM key used for verification.
389
+ */
390
+ keyStatus?: EmailsDkimKey["status"] | "provided";
391
+ selector: string;
392
+ /**
393
+ * A human-readable explanation of DKIM check.
394
+ */
395
+ reason?: string;
396
+ verdict: Extract<EmailsCheckDomainVerdict, "passed" | "failed">;
397
+ }[];
398
+ domainLockdown: {
399
+ /**
400
+ * A human-readable explanation of Domain Lockdown check.
401
+ */
402
+ reason?: string;
403
+ verdict: Extract<EmailsCheckDomainVerdict, "passed" | "failed">;
404
+ };
367
405
  /**
368
- * The results of the domain checks.
406
+ * 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
407
  */
370
- results: {
371
- dkim: {
372
- domain: string;
408
+ senderDomain: {
409
+ a: {
373
410
  /**
374
- * The human readable status of the DKIM key used for verification.
375
- */
376
- keyStatus?: EmailsDkimKey["status"] | "provided";
377
- selector: string;
378
- /**
379
- * A human-readable explanation of DKIM check.
411
+ * A human-readable explanation of A record check.
380
412
  */
381
413
  reason?: string;
382
414
  verdict: Extract<EmailsCheckDomainVerdict, "passed" | "failed">;
383
- }[];
384
- domainLockdown: {
415
+ };
416
+ mx: {
385
417
  /**
386
- * A human-readable explanation of Domain Lockdown check.
418
+ * A human-readable explanation of MX record check.
387
419
  */
388
420
  reason?: string;
389
421
  verdict: Extract<EmailsCheckDomainVerdict, "passed" | "failed">;
390
422
  };
391
423
  /**
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
- }
424
+ * Overall verdict. Passed if either A or MX record check passed.
425
+ */
426
+ verdict: Extract<EmailsCheckDomainVerdict, "passed" | "failed">;
427
+ };
428
+ spf: {
429
+ /**
430
+ * A human-readable explanation of SPF check.
431
+ */
432
+ reason?: string;
433
+ verdict: EmailsCheckDomainVerdict;
434
+ };
435
+ references?: string[];
436
+ }>;
428
437
 
429
438
  interface EmailsGetDkimKeysOptions {
430
439
  /**
@@ -454,13 +463,7 @@ interface EmailsGetDkimKeysOptions {
454
463
 
455
464
  type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
456
465
 
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
- }
466
+ type EmailsGetDkimKeysResponse = DataResponse<Optional<EmailsDkimKey, "dnsRecords">[]>;
464
467
 
465
468
  interface EmailsUpdateDkimKeyOptions {
466
469
  /**
@@ -471,10 +474,25 @@ interface EmailsUpdateDkimKeyOptions {
471
474
  * New status of the DKIM key pair.
472
475
  * - `revoked`: Indicates that the key is compromised and should not be used.
473
476
  * - `retired`: Indicates that the key has been rotated and is no longer in use.
477
+ * - `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
478
  */
475
479
  status: Exclude<EmailsDkimKey["status"], "active">;
476
480
  }
477
481
 
482
+ interface EmailsRotateDkimKeyOptions {
483
+ newKey: {
484
+ /**
485
+ * Selector for the new key pair. Must be a maximum of 63 characters.
486
+ */
487
+ selector: string;
488
+ };
489
+ }
490
+
491
+ type EmailsRotateDkimKeyResponse = DataResponse<{
492
+ new: EmailsDkimKey;
493
+ rotated: EmailsDkimKey;
494
+ }>;
495
+
478
496
  declare class Emails {
479
497
  protected mailchannels: MailChannelsClient;
480
498
  constructor(mailchannels: MailChannelsClient);
@@ -519,20 +537,20 @@ declare class Emails {
519
537
  * @example
520
538
  * ```ts
521
539
  * const mailchannels = new MailChannels('your-api-key')
522
- * const { key, error } = await mailchannels.emails.createDkimKey('example.com', {
540
+ * const { data, error } = await mailchannels.emails.createDkimKey('example.com', {
523
541
  * selector: 'mailchannels'
524
542
  * })
525
543
  * ```
526
544
  */
527
545
  createDkimKey(domain: string, options: EmailsCreateDkimKeyOptions): Promise<EmailsCreateDkimKeyResponse>;
528
546
  /**
529
- * Search for DKIM keys by customer handle and domain, with optional filters. If selector is provided, at most one key will be returned.
547
+ * Search for DKIM keys by domain, with optional filters. If selector is provided, at most one key will be returned.
530
548
  * @param domain - The domain to search DKIM keys for.
531
549
  * @param options - The options to filter DKIM keys by.
532
550
  * @example
533
551
  * ```ts
534
552
  * const mailchannels = new MailChannels('your-api-key')
535
- * const { keys } = await mailchannels.getDkimKeys('example.com', {
553
+ * const { data, error } = await mailchannels.getDkimKeys('example.com', {
536
554
  * includeDnsRecord: true
537
555
  * })
538
556
  * ```
@@ -545,25 +563,38 @@ declare class Emails {
545
563
  * @example
546
564
  * ```ts
547
565
  * const mailchannels = new MailChannels('your-api-key')
548
- * const { success } = await mailchannels.emails.updateDkimKey('example.com', {
566
+ * const { success, error } = await mailchannels.emails.updateDkimKey('example.com', {
549
567
  * selector: 'mailchannels',
550
568
  * status: 'retired'
551
569
  * })
552
570
  */
553
571
  updateDkimKey(domain: string, options: EmailsUpdateDkimKeyOptions): Promise<SuccessResponse>;
572
+ /**
573
+ * 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.
574
+ * @param domain - The domain the DKIM key belongs to.
575
+ * @param selector - The selector of the DKIM key to rotate.
576
+ * @param options - The options to rotate the DKIM key.
577
+ * @param options.newKey.selector - The selector for the new key pair. Must be a maximum of 63 characters.
578
+ * @example
579
+ * ```ts
580
+ * const mailchannels = new MailChannels('your-api-key')
581
+ * const { data, error } = await mailchannels.emails.rotateDkimKey('example.com', 'mailchannels', {
582
+ * newKey: {
583
+ * selector: 'new-selector'
584
+ * }
585
+ * })
586
+ * ```
587
+ */
588
+ rotateDkimKey(domain: string, selector: string, options: EmailsRotateDkimKeyOptions): Promise<EmailsRotateDkimKeyResponse>;
554
589
  }
555
590
 
556
- interface WebhooksListResponse {
557
- webhooks: string[];
558
- error: string | null;
559
- }
591
+ type WebhooksListResponse = DataResponse<string[]>;
560
592
 
561
- interface WebhooksSigningKeyResponse {
562
- key: string | null;
563
- error: string | null;
564
- }
593
+ type WebhooksSigningKeyResponse = DataResponse<{
594
+ key: string;
595
+ }>;
565
596
 
566
- interface WebhooksValidateResponse {
597
+ type WebhooksValidateResponse = DataResponse<{
567
598
  /**
568
599
  * Indicates whether all webhook validations passed.
569
600
  */
@@ -594,8 +625,7 @@ interface WebhooksValidateResponse {
594
625
  status: number;
595
626
  } | null;
596
627
  }[];
597
- error: string | null;
598
- }
628
+ }>;
599
629
 
600
630
  declare class Webhooks {
601
631
  protected mailchannels: MailChannelsClient;
@@ -606,7 +636,7 @@ declare class Webhooks {
606
636
  * @example
607
637
  * ```ts
608
638
  * const mailchannels = new MailChannels('your-api-key')
609
- * const { success } = mailchannels.webhooks.enroll('https://example.com/api/webhooks/mailchannels')
639
+ * const { success, error } = mailchannels.webhooks.enroll('https://example.com/api/webhooks/mailchannels')
610
640
  * ```
611
641
  */
612
642
  enroll(endpoint: string): Promise<SuccessResponse>;
@@ -615,7 +645,7 @@ declare class Webhooks {
615
645
  * @example
616
646
  * ```ts
617
647
  * const mailchannels = new MailChannels('your-api-key')
618
- * const { webhooks } = await mailchannels.webhooks.list()
648
+ * const { data, error } = await mailchannels.webhooks.list()
619
649
  * ```
620
650
  */
621
651
  list(): Promise<WebhooksListResponse>;
@@ -624,7 +654,7 @@ declare class Webhooks {
624
654
  * @example
625
655
  * ```ts
626
656
  * const mailchannels = new MailChannels('your-api-key')
627
- * const { success } = await mailchannels.webhooks.delete()
657
+ * const { success, error } = await mailchannels.webhooks.delete()
628
658
  * ```
629
659
  */
630
660
  delete(): Promise<SuccessResponse>;
@@ -634,7 +664,7 @@ declare class Webhooks {
634
664
  * @example
635
665
  * ```ts
636
666
  * const mailchannels = new MailChannels('your-api-key')
637
- * const { key } = await mailchannels.webhooks.getSigningKey('key-id')
667
+ * const { data, error } = await mailchannels.webhooks.getSigningKey('key-id')
638
668
  * ```
639
669
  */
640
670
  getSigningKey(id: string): Promise<WebhooksSigningKeyResponse>;
@@ -644,7 +674,7 @@ declare class Webhooks {
644
674
  * @example
645
675
  * ```ts
646
676
  * const mailchannels = new MailChannels('your-api-key')
647
- * const { allPassed, results } = await mailchannels.webhooks.validate('optional-request-id')
677
+ * const { data, error } = await mailchannels.webhooks.validate('optional-request-id')
648
678
  * ```
649
679
  */
650
680
  validate(requestId?: string): Promise<WebhooksValidateResponse>;
@@ -665,10 +695,7 @@ interface SubAccountsAccount {
665
695
  handle: string;
666
696
  }
667
697
 
668
- interface SubAccountsCreateResponse {
669
- account: SubAccountsAccount | null;
670
- error: string | null;
671
- }
698
+ type SubAccountsCreateResponse = DataResponse<SubAccountsAccount>;
672
699
 
673
700
  interface SubAccountsListOptions {
674
701
  /**
@@ -683,10 +710,7 @@ interface SubAccountsListOptions {
683
710
  offset?: number;
684
711
  }
685
712
 
686
- interface SubAccountsListResponse {
687
- accounts: SubAccountsAccount[];
688
- error: string | null;
689
- }
713
+ type SubAccountsListResponse = DataResponse<SubAccountsAccount[]>;
690
714
 
691
715
  interface SubAccountsApiKey {
692
716
  /**
@@ -699,10 +723,7 @@ interface SubAccountsApiKey {
699
723
  value: string;
700
724
  }
701
725
 
702
- interface SubAccountsCreateApiKeyResponse {
703
- key: SubAccountsApiKey | null;
704
- error: string | null;
705
- }
726
+ type SubAccountsCreateApiKeyResponse = DataResponse<SubAccountsApiKey>;
706
727
 
707
728
  interface SubAccountsListApiKeyOptions {
708
729
  /**
@@ -717,10 +738,7 @@ interface SubAccountsListApiKeyOptions {
717
738
  offset?: number;
718
739
  }
719
740
 
720
- interface SubAccountsListApiKeyResponse {
721
- keys: SubAccountsApiKey[];
722
- error: string | null;
723
- }
741
+ type SubAccountsListApiKeyResponse = DataResponse<SubAccountsApiKey[]>;
724
742
 
725
743
  interface SubAccountsSmtpPassword {
726
744
  /**
@@ -737,24 +755,15 @@ interface SubAccountsSmtpPassword {
737
755
  value: string;
738
756
  }
739
757
 
740
- interface SubAccountsCreateSmtpPasswordResponse {
741
- password: SubAccountsSmtpPassword | null;
742
- error: string | null;
743
- }
758
+ type SubAccountsCreateSmtpPasswordResponse = DataResponse<SubAccountsSmtpPassword>;
744
759
 
745
- interface SubAccountsListSmtpPasswordResponse {
746
- passwords: SubAccountsSmtpPassword[];
747
- error: string | null;
748
- }
760
+ type SubAccountsListSmtpPasswordResponse = DataResponse<SubAccountsSmtpPassword[]>;
749
761
 
750
762
  interface SubAccountsLimit {
751
763
  sends: number;
752
764
  }
753
765
 
754
- interface SubAccountsLimitResponse {
755
- limit: SubAccountsLimit | null;
756
- error: string | null;
757
- }
766
+ type SubAccountsLimitResponse = DataResponse<SubAccountsLimit>;
758
767
 
759
768
  interface SubAccountsUsage {
760
769
  /**
@@ -773,10 +782,7 @@ interface SubAccountsUsage {
773
782
  total: number;
774
783
  }
775
784
 
776
- interface SubAccountsUsageResponse {
777
- usage: SubAccountsUsage | null;
778
- error: string | null;
779
- }
785
+ type SubAccountsUsageResponse = DataResponse<SubAccountsUsage>;
780
786
 
781
787
  declare class SubAccounts {
782
788
  protected mailchannels: MailChannelsClient;
@@ -790,7 +796,7 @@ declare class SubAccounts {
790
796
  * @example
791
797
  * ```ts
792
798
  * const mailchannels = new MailChannels('your-api-key')
793
- * const { account } = await mailchannels.subAccounts.create('My Company', 'validhandle123')
799
+ * const { data, error } = await mailchannels.subAccounts.create('My Company', 'validhandle123')
794
800
  * ```
795
801
  */
796
802
  create(companyName: string, handle?: string): Promise<SubAccountsCreateResponse>;
@@ -800,7 +806,7 @@ declare class SubAccounts {
800
806
  * @example
801
807
  * ```ts
802
808
  * const mailchannels = new MailChannels('your-api-key')
803
- * const { accounts } = await mailchannels.subAccounts.list()
809
+ * const { data, error } = await mailchannels.subAccounts.list()
804
810
  * ```
805
811
  */
806
812
  list(options?: SubAccountsListOptions): Promise<SubAccountsListResponse>;
@@ -809,7 +815,7 @@ declare class SubAccounts {
809
815
  * @param handle - Handle of sub-account to be deleted.
810
816
  * ```ts
811
817
  * const mailchannels = new MailChannels('your-api-key')
812
- * const { success } = await mailchannels.subAccounts.delete('validhandle123')
818
+ * const { success, error } = await mailchannels.subAccounts.delete('validhandle123')
813
819
  * ```
814
820
  */
815
821
  delete(handle: string): Promise<SuccessResponse>;
@@ -819,7 +825,7 @@ declare class SubAccounts {
819
825
  * @example
820
826
  * ```ts
821
827
  * const mailchannels = new MailChannels('your-api-key')
822
- * const { success } = await mailchannels.subAccounts.suspend('validhandle123')
828
+ * const { success, error } = await mailchannels.subAccounts.suspend('validhandle123')
823
829
  * ```
824
830
  */
825
831
  suspend(handle: string): Promise<SuccessResponse>;
@@ -829,7 +835,7 @@ declare class SubAccounts {
829
835
  * @example
830
836
  * ```ts
831
837
  * const mailchannels = new MailChannels('your-api-key')
832
- * const { success } = await mailchannels.subAccounts.activate('validhandle123')
838
+ * const { success, error } = await mailchannels.subAccounts.activate('validhandle123')
833
839
  * ```
834
840
  */
835
841
  activate(handle: string): Promise<SuccessResponse>;
@@ -839,7 +845,7 @@ declare class SubAccounts {
839
845
  * @example
840
846
  * ```ts
841
847
  * const mailchannels = new MailChannels('your-api-key')
842
- * const { key } = await mailchannels.subAccounts.createApiKey('validhandle123')
848
+ * const { data, error } = await mailchannels.subAccounts.createApiKey('validhandle123')
843
849
  * ```
844
850
  */
845
851
  createApiKey(handle: string): Promise<SubAccountsCreateApiKeyResponse>;
@@ -850,7 +856,7 @@ declare class SubAccounts {
850
856
  * @example
851
857
  * ```ts
852
858
  * const mailchannels = new MailChannels('your-api-key')
853
- * const { keys } = await mailchannels.subAccounts.listApiKeys('validhandle123')
859
+ * const { data, error } = await mailchannels.subAccounts.listApiKeys('validhandle123')
854
860
  * ```
855
861
  */
856
862
  listApiKeys(handle: string, options?: SubAccountsListApiKeyOptions): Promise<SubAccountsListApiKeyResponse>;
@@ -861,7 +867,7 @@ declare class SubAccounts {
861
867
  * @example
862
868
  * ```ts
863
869
  * const mailchannels = new MailChannels('your-api-key')
864
- * const { success } = await mailchannels.subAccounts.deleteApiKey('validhandle123', 1)
870
+ * const { success, error } = await mailchannels.subAccounts.deleteApiKey('validhandle123', 1)
865
871
  * ```
866
872
  */
867
873
  deleteApiKey(handle: string, id: number): Promise<SuccessResponse>;
@@ -871,7 +877,7 @@ declare class SubAccounts {
871
877
  * @example
872
878
  * ```ts
873
879
  * const mailchannels = new MailChannels('your-api-key')
874
- * const { password } = await mailchannels.subAccounts.createSmtpPassword('validhandle123')
880
+ * const { data, error } = await mailchannels.subAccounts.createSmtpPassword('validhandle123')
875
881
  * ```
876
882
  */
877
883
  createSmtpPassword(handle: string): Promise<SubAccountsCreateSmtpPasswordResponse>;
@@ -881,7 +887,7 @@ declare class SubAccounts {
881
887
  * @example
882
888
  * ```ts
883
889
  * const mailchannels = new MailChannels('your-api-key')
884
- * const { passwords } = await mailchannels.subAccounts.listSmtpPasswords('validhandle123')
890
+ * const { data, error } = await mailchannels.subAccounts.listSmtpPasswords('validhandle123')
885
891
  * ```
886
892
  */
887
893
  listSmtpPasswords(handle: string): Promise<SubAccountsListSmtpPasswordResponse>;
@@ -892,7 +898,7 @@ declare class SubAccounts {
892
898
  * @example
893
899
  * ```ts
894
900
  * const mailchannels = new MailChannels('your-api-key')
895
- * const { success } = await mailchannels.subAccounts.deleteSmtpPassword('validhandle123', 1)
901
+ * const { success, error } = await mailchannels.subAccounts.deleteSmtpPassword('validhandle123', 1)
896
902
  * ```
897
903
  */
898
904
  deleteSmtpPassword(handle: string, id: number): Promise<SuccessResponse>;
@@ -902,7 +908,7 @@ declare class SubAccounts {
902
908
  * @example
903
909
  * ```ts
904
910
  * const mailchannels = new MailChannels('your-api-key')
905
- * const { limit } = await mailchannels.subAccounts.getLimit('validhandle123')
911
+ * const { data, error } = await mailchannels.subAccounts.getLimit('validhandle123')
906
912
  * ```
907
913
  */
908
914
  getLimit(handle: string): Promise<SubAccountsLimitResponse>;
@@ -913,7 +919,7 @@ declare class SubAccounts {
913
919
  * @example
914
920
  * ```ts
915
921
  * const mailchannels = new MailChannels('your-api-key')
916
- * const { success } = await mailchannels.subAccounts.setLimit('validhandle123', { sends: 1000 })
922
+ * const { success, error } = await mailchannels.subAccounts.setLimit('validhandle123', { sends: 1000 })
917
923
  * ```
918
924
  */
919
925
  setLimit(handle: string, limit: SubAccountsLimit): Promise<SuccessResponse>;
@@ -923,7 +929,7 @@ declare class SubAccounts {
923
929
  * @example
924
930
  * ```ts
925
931
  * const mailchannels = new MailChannels('your-api-key')
926
- * const { success } = await mailchannels.subAccounts.deleteLimit('validhandle123')
932
+ * const { success, error } = await mailchannels.subAccounts.deleteLimit('validhandle123')
927
933
  * ```
928
934
  */
929
935
  deleteLimit(handle: string): Promise<SuccessResponse>;
@@ -933,13 +939,16 @@ declare class SubAccounts {
933
939
  * @example
934
940
  * ```ts
935
941
  * const mailchannels = new MailChannels('your-api-key')
936
- * const { usage } = await mailchannels.subAccounts.getUsage('validhandle123')
942
+ * const { data, error } = await mailchannels.subAccounts.getUsage('validhandle123')
937
943
  * ```
938
944
  */
939
945
  getUsage(handle: string): Promise<SubAccountsUsageResponse>;
940
946
  }
941
947
 
942
948
  interface MetricsEngagement {
949
+ /**
950
+ * A series of metrics aggregations bucketed by time interval (e.g. hour, day).
951
+ */
943
952
  buckets: {
944
953
  click: MetricsBucket[];
945
954
  clickTrackingDelivered: MetricsBucket[];
@@ -954,16 +963,16 @@ interface MetricsEngagement {
954
963
  startTime: string;
955
964
  }
956
965
 
957
- interface MetricsEngagementResponse {
958
- engagement: MetricsEngagement | null;
959
- error: string | null;
960
- }
966
+ type MetricsEngagementResponse = DataResponse<MetricsEngagement>;
961
967
 
962
968
  interface MetricsPerformance {
963
969
  /**
964
970
  * Count of messages bounced during the specified time range.
965
971
  */
966
972
  bounced: number;
973
+ /**
974
+ * A series of metrics aggregations bucketed by time interval (e.g. hour, day).
975
+ */
967
976
  buckets: {
968
977
  bounced: MetricsBucket[];
969
978
  delivered: MetricsBucket[];
@@ -987,12 +996,12 @@ interface MetricsPerformance {
987
996
  startTime: string;
988
997
  }
989
998
 
990
- interface MetricsPerformanceResponse {
991
- performance: MetricsPerformance | null;
992
- error: string | null;
993
- }
999
+ type MetricsPerformanceResponse = DataResponse<MetricsPerformance>;
994
1000
 
995
1001
  interface MetricsRecipientBehaviour {
1002
+ /**
1003
+ * A series of metrics aggregations bucketed by time interval (e.g. hour, day).
1004
+ */
996
1005
  buckets: {
997
1006
  unsubscribeDelivered: MetricsBucket[];
998
1007
  unsubscribed: MetricsBucket[];
@@ -1015,12 +1024,12 @@ interface MetricsRecipientBehaviour {
1015
1024
  unsubscribed: number;
1016
1025
  }
1017
1026
 
1018
- interface MetricsRecipientBehaviourResponse {
1019
- behaviour: MetricsRecipientBehaviour | null;
1020
- error: string | null;
1021
- }
1027
+ type MetricsRecipientBehaviourResponse = DataResponse<MetricsRecipientBehaviour>;
1022
1028
 
1023
1029
  interface MetricsVolume {
1030
+ /**
1031
+ * A series of metrics aggregations bucketed by time interval (e.g. hour, day).
1032
+ */
1024
1033
  buckets: {
1025
1034
  delivered: MetricsBucket[];
1026
1035
  dropped: MetricsBucket[];
@@ -1048,31 +1057,78 @@ interface MetricsVolume {
1048
1057
  startTime: string;
1049
1058
  }
1050
1059
 
1051
- interface MetricsVolumeResponse {
1052
- volume: MetricsVolume | null;
1053
- error: string | null;
1060
+ type MetricsVolumeResponse = DataResponse<MetricsVolume>;
1061
+
1062
+ type MetricsUsageResponse = DataResponse<{
1063
+ /**
1064
+ * The end date of the current billing period (ISO 8601 format).
1065
+ * @example "2025-04-11"
1066
+ */
1067
+ endDate: string;
1068
+ /**
1069
+ * The start date of the current billing period (ISO 8601 format).
1070
+ * @example "2025-03-12"
1071
+ */
1072
+ startDate: string;
1073
+ /**
1074
+ * The total usage for the current billing period.
1075
+ */
1076
+ total: number;
1077
+ }>;
1078
+
1079
+ type MetricsSendersType = "sub-accounts" | "campaigns";
1080
+
1081
+ interface MetricsSendersOptions {
1082
+ /**
1083
+ * 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.
1084
+ * @example "2025-11-02T03:13:35.761763554Z"
1085
+ */
1086
+ startTime?: string;
1087
+ /**
1088
+ * 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.
1089
+ * @example "2025-12-02T03:13:35.761763554Z"
1090
+ */
1091
+ endTime?: string;
1092
+ /**
1093
+ * The maximum number of senders to return. Possible values are 1 to 1000.
1094
+ * @default 10
1095
+ */
1096
+ limit?: number;
1097
+ /**
1098
+ * The number of senders to skip before returning results.
1099
+ * @default 0
1100
+ */
1101
+ offset?: number;
1102
+ /**
1103
+ * The order in which to sort the results, based on total messages (processed + dropped).
1104
+ * @default "desc"
1105
+ */
1106
+ sortOrder?: "asc" | "desc";
1054
1107
  }
1055
1108
 
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;
1109
+ interface MetricsSenders {
1110
+ endTime: string;
1111
+ limit: number;
1112
+ offset: number;
1113
+ senders: {
1114
+ bounced: number;
1115
+ delivered: number;
1116
+ dropped: number;
1068
1117
  /**
1069
- * The total usage for the current billing period.
1118
+ * Maximum character length: 255
1070
1119
  */
1071
- total: number;
1072
- } | null;
1073
- error: string | null;
1120
+ name: string;
1121
+ processed: number;
1122
+ }[];
1123
+ startTime: string;
1124
+ /**
1125
+ * The total number of senders in this category that sent messages in the given time range.
1126
+ */
1127
+ total: number;
1074
1128
  }
1075
1129
 
1130
+ type MetricsSendersResponse = DataResponse<MetricsSenders>;
1131
+
1076
1132
  interface MetricsBucket {
1077
1133
  /**
1078
1134
  * The number of events or occurrences aggregated within this time period.
@@ -1115,7 +1171,7 @@ declare class Metrics {
1115
1171
  * @example
1116
1172
  * ```ts
1117
1173
  * const mailchannels = new MailChannels('your-api-key')
1118
- * const { engagement } = await mailchannels.metrics.engagement()
1174
+ * const { data, error } = await mailchannels.metrics.engagement()
1119
1175
  * ```
1120
1176
  */
1121
1177
  engagement(options?: MetricsOptions): Promise<MetricsEngagementResponse>;
@@ -1125,7 +1181,7 @@ declare class Metrics {
1125
1181
  * @example
1126
1182
  * ```ts
1127
1183
  * const mailchannels = new MailChannels('your-api-key')
1128
- * const { performance } = await mailchannels.metrics.performance()
1184
+ * const { data, error } = await mailchannels.metrics.performance()
1129
1185
  * ```
1130
1186
  */
1131
1187
  performance(options?: MetricsOptions): Promise<MetricsPerformanceResponse>;
@@ -1135,7 +1191,7 @@ declare class Metrics {
1135
1191
  * @example
1136
1192
  * ```ts
1137
1193
  * const mailchannels = new MailChannels('your-api-key')
1138
- * const { behaviour } = await mailchannels.metrics.recipientBehaviour()
1194
+ * const { data, error } = await mailchannels.metrics.recipientBehaviour()
1139
1195
  * ```
1140
1196
  */
1141
1197
  recipientBehaviour(options?: MetricsOptions): Promise<MetricsRecipientBehaviourResponse>;
@@ -1145,7 +1201,7 @@ declare class Metrics {
1145
1201
  * @example
1146
1202
  * ```ts
1147
1203
  * const mailchannels = new MailChannels('your-api-key')
1148
- * const { volume } = await mailchannels.metrics.volume()
1204
+ * const { data, error } = await mailchannels.metrics.volume()
1149
1205
  * ```
1150
1206
  */
1151
1207
  volume(options?: MetricsOptions): Promise<MetricsVolumeResponse>;
@@ -1154,10 +1210,21 @@ declare class Metrics {
1154
1210
  * @example
1155
1211
  * ```ts
1156
1212
  * const mailchannels = new MailChannels('your-api-key')
1157
- * const { usage } = await mailchannels.metrics.usage()
1213
+ * const { data, error } = await mailchannels.metrics.usage()
1158
1214
  * ```
1159
1215
  */
1160
1216
  usage(): Promise<MetricsUsageResponse>;
1217
+ /**
1218
+ * 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.
1219
+ * @param type - The type of senders to retrieve metrics for. Can be either `sub-accounts` or `campaigns`.
1220
+ * @param options - Optional filter options for time range, limit, offset, and sort order.
1221
+ * @example
1222
+ * ```ts
1223
+ * const mailchannels = new MailChannels('your-api-key')
1224
+ * const { data, error } = await mailchannels.metrics.senders('campaigns')
1225
+ * ```
1226
+ */
1227
+ senders(type: MetricsSendersType, options?: MetricsSendersOptions): Promise<MetricsSendersResponse>;
1161
1228
  }
1162
1229
 
1163
1230
  type SuppressionsTypes = "transactional" | "non-transactional";
@@ -1231,10 +1298,7 @@ interface SuppressionsListEntry {
1231
1298
  types: SuppressionsTypes[];
1232
1299
  }
1233
1300
 
1234
- interface SuppressionsListResponse {
1235
- list: SuppressionsListEntry[];
1236
- error: string | null;
1237
- }
1301
+ type SuppressionsListResponse = DataResponse<SuppressionsListEntry[]>;
1238
1302
 
1239
1303
  declare class Suppressions {
1240
1304
  protected mailchannels: MailChannelsClient;
@@ -1245,7 +1309,7 @@ declare class Suppressions {
1245
1309
  * @example
1246
1310
  * ```ts
1247
1311
  * const mailchannels = new MailChannels('your-api-key')
1248
- * const { success } = await mailchannels.suppressions.create({
1312
+ * const { success, error } = await mailchannels.suppressions.create({
1249
1313
  * // ...
1250
1314
  * });
1251
1315
  */
@@ -1257,7 +1321,7 @@ declare class Suppressions {
1257
1321
  * @example
1258
1322
  * ```ts
1259
1323
  * const mailchannels = new MailChannels('your-api-key')
1260
- * const { success } = await mailchannels.suppressions.delete('name@example.com', 'api');
1324
+ * const { success, error } = await mailchannels.suppressions.delete('name@example.com', 'api');
1261
1325
  * ```
1262
1326
  */
1263
1327
  delete(recipient: string, source?: SuppressionsSource): Promise<SuccessResponse>;
@@ -1266,7 +1330,7 @@ declare class Suppressions {
1266
1330
  * @example
1267
1331
  * ```ts
1268
1332
  * const mailchannels = new MailChannels('your-api-key')
1269
- * const { list }= await mailchannels.suppressions.list();
1333
+ * const { data, error } = await mailchannels.suppressions.list();
1270
1334
  * ```
1271
1335
  * @param options - Options to filter and customize the suppression entries retrieval.
1272
1336
  */
@@ -1292,15 +1356,9 @@ interface ListEntry {
1292
1356
  type: "domain" | "email_address" | "ip_address";
1293
1357
  }
1294
1358
 
1295
- interface ListEntryResponse {
1296
- entry: ListEntry | null;
1297
- error: string | null;
1298
- }
1359
+ type ListEntryResponse = DataResponse<ListEntry>;
1299
1360
 
1300
- interface ListEntriesResponse {
1301
- entries: ListEntry[];
1302
- error: string | null;
1303
- }
1361
+ type ListEntriesResponse = DataResponse<ListEntry[]>;
1304
1362
 
1305
1363
  interface DomainsData {
1306
1364
  /**
@@ -1376,44 +1434,32 @@ interface DomainsProvisionOptions {
1376
1434
 
1377
1435
  type DomainsBulkProvisionOptions = DomainsProvisionOptions & Pick<DomainsData, "subscriptionHandle">;
1378
1436
 
1379
- interface DomainsProvisionResponse {
1380
- /**
1381
- * The provisioned domain data.
1382
- */
1383
- data: DomainsData | null;
1384
- error: string | null;
1385
- }
1437
+ type DomainsProvisionResponse = DataResponse<DomainsData>;
1386
1438
 
1387
- interface DomainsBulkProvisionResponse {
1439
+ type DomainsBulkProvisionResponse = DataResponse<{
1388
1440
  /**
1389
- * If the request was processed successfully, this does not necessarily mean all the domains in the request were successfully provisioned.
1441
+ * Domains that were successfully provisioned or updated.
1390
1442
  */
1391
- results: {
1443
+ successes: {
1392
1444
  /**
1393
- * Domains that were successfully provisioned or updated.
1445
+ * The provisioned domain data.
1394
1446
  */
1395
- successes: {
1396
- /**
1397
- * The provisioned domain data.
1398
- */
1399
- domain: DomainsData;
1400
- code: number;
1401
- comment?: string;
1402
- }[];
1447
+ domain: DomainsData;
1448
+ code: number;
1449
+ comment?: string;
1450
+ }[];
1451
+ /**
1452
+ * Domains that were not successfully provisioned.
1453
+ */
1454
+ errors: {
1403
1455
  /**
1404
- * Domains that were not successfully provisioned.
1456
+ * The failed to provision domain data.
1405
1457
  */
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
- }
1458
+ domain: DomainsData;
1459
+ code: number;
1460
+ comment?: string;
1461
+ }[];
1462
+ }>;
1417
1463
 
1418
1464
  interface DomainsListOptions {
1419
1465
  /**
@@ -1432,7 +1478,7 @@ interface DomainsListOptions {
1432
1478
  offset?: number;
1433
1479
  }
1434
1480
 
1435
- interface DomainsListResponse {
1481
+ type DomainsListResponse = DataResponse<{
1436
1482
  /**
1437
1483
  * A list of domains.
1438
1484
  */
@@ -1441,17 +1487,17 @@ interface DomainsListResponse {
1441
1487
  * 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
1488
  */
1443
1489
  total: number;
1444
- error: string | null;
1445
- }
1490
+ }>;
1446
1491
 
1447
- interface DomainsCreateLoginLinkResponse {
1492
+ interface DomainsCreateLoginLink {
1448
1493
  /**
1449
1494
  * If a user browses to this URL, they will be automatically logged in as a domain admin.
1450
1495
  */
1451
- link: string | null;
1452
- error: string | null;
1496
+ link: string;
1453
1497
  }
1454
1498
 
1499
+ type DomainsCreateLoginLinkResponse = DataResponse<DomainsCreateLoginLink>;
1500
+
1455
1501
  interface DomainsListDownstreamAddressesOptions {
1456
1502
  /**
1457
1503
  * The number of records to return.
@@ -1484,10 +1530,7 @@ interface DomainsDownstreamAddress {
1484
1530
  weight: number;
1485
1531
  }
1486
1532
 
1487
- interface DomainsListDownstreamAddressesResponse {
1488
- records: DomainsDownstreamAddress[];
1489
- error: string | null;
1490
- }
1533
+ type DomainsListDownstreamAddressesResponse = DataResponse<DomainsDownstreamAddress[]>;
1491
1534
 
1492
1535
  interface DomainsBulkCreateLoginLinkResult {
1493
1536
  /**
@@ -1510,10 +1553,7 @@ interface DomainsBulkCreateLoginLinks {
1510
1553
  errors: Omit<DomainsBulkCreateLoginLinkResult, "loginLink">[];
1511
1554
  }
1512
1555
 
1513
- interface DomainsBulkCreateLoginLinksResponse {
1514
- results: DomainsBulkCreateLoginLinks | null;
1515
- error: string | null;
1516
- }
1556
+ type DomainsBulkCreateLoginLinksResponse = DataResponse<DomainsBulkCreateLoginLinks>;
1517
1557
 
1518
1558
  declare class Domains {
1519
1559
  protected mailchannels: MailChannelsClient;
@@ -1524,7 +1564,7 @@ declare class Domains {
1524
1564
  * @example
1525
1565
  * ```ts
1526
1566
  * const mailchannels = new MailChannels('your-api-key')
1527
- * const { data } = await mailchannels.domains.provision({
1567
+ * const { data, error } = await mailchannels.domains.provision({
1528
1568
  * domain: 'example.com',
1529
1569
  * subscriptionHandle: 'your-subscription-handle'
1530
1570
  * })
@@ -1538,7 +1578,7 @@ declare class Domains {
1538
1578
  * @example
1539
1579
  * ```ts
1540
1580
  * const mailchannels = new MailChannels('your-api-key')
1541
- * const { results } = await mailchannels.domains.bulkProvision({
1581
+ * const { data, error } = await mailchannels.domains.bulkProvision({
1542
1582
  * subscriptionHandle: 'your-subscription-handle'
1543
1583
  * }, [
1544
1584
  * {
@@ -1558,7 +1598,7 @@ declare class Domains {
1558
1598
  * @example
1559
1599
  * ```ts
1560
1600
  * const mailchannels = new MailChannels('your-api-key')
1561
- * const { domains } = await mailchannels.domains.list()
1601
+ * const { data, error } = await mailchannels.domains.list()
1562
1602
  * ```
1563
1603
  */
1564
1604
  list(options?: DomainsListOptions): Promise<DomainsListResponse>;
@@ -1568,7 +1608,7 @@ declare class Domains {
1568
1608
  * @example
1569
1609
  * ```ts
1570
1610
  * const mailchannels = new MailChannels('your-api-key')
1571
- * const { success } = await mailchannels.domains.delete('example.com')
1611
+ * const { success, error } = await mailchannels.domains.delete('example.com')
1572
1612
  * ```
1573
1613
  */
1574
1614
  delete(domain: string): Promise<SuccessResponse>;
@@ -1579,7 +1619,7 @@ declare class Domains {
1579
1619
  * @example
1580
1620
  * ```ts
1581
1621
  * const mailchannels = new MailChannels('your-api-key')
1582
- * const { entry } = await mailchannels.domains.addListEntry('example.com', {
1622
+ * const { data, error } = await mailchannels.domains.addListEntry('example.com', {
1583
1623
  * listName: 'safelist',
1584
1624
  * item: 'name@domain.com'
1585
1625
  * })
@@ -1593,7 +1633,7 @@ declare class Domains {
1593
1633
  * @example
1594
1634
  * ```ts
1595
1635
  * const mailchannels = new MailChannels('your-api-key')
1596
- * const { entries } = await mailchannels.domains.listEntries('example.com', 'safelist')
1636
+ * const { data, error } = await mailchannels.domains.listEntries('example.com', 'safelist')
1597
1637
  * ```
1598
1638
  */
1599
1639
  listEntries(domain: string, listName: ListNames): Promise<ListEntriesResponse>;
@@ -1604,7 +1644,7 @@ declare class Domains {
1604
1644
  * @example
1605
1645
  * ```ts
1606
1646
  * const mailchannels = new MailChannels('your-api-key')
1607
- * const { success } = await mailchannels.domains.deleteListEntry('example.com', {
1647
+ * const { success, error } = await mailchannels.domains.deleteListEntry('example.com', {
1608
1648
  * listName: 'safelist',
1609
1649
  * item: 'name@domain.com'
1610
1650
  * })
@@ -1617,7 +1657,7 @@ declare class Domains {
1617
1657
  * @example
1618
1658
  * ```ts
1619
1659
  * const mailchannels = new MailChannels('your-api-key')
1620
- * const { link } = await mailchannels.domains.createLoginLink('example.com')
1660
+ * const { data, error } = await mailchannels.domains.createLoginLink('example.com')
1621
1661
  * ```
1622
1662
  */
1623
1663
  createLoginLink(domain: string): Promise<DomainsCreateLoginLinkResponse>;
@@ -1628,7 +1668,7 @@ declare class Domains {
1628
1668
  * @example
1629
1669
  * ```ts
1630
1670
  * const mailchannels = new MailChannels('your-api-key')
1631
- * const { success } = await mailchannels.domains.setDownstreamAddress('example.com', [
1671
+ * const { success, error } = await mailchannels.domains.setDownstreamAddress('example.com', [
1632
1672
  * {
1633
1673
  * port: 25,
1634
1674
  * priority: 10,
@@ -1646,7 +1686,7 @@ declare class Domains {
1646
1686
  * @example
1647
1687
  * ```ts
1648
1688
  * const mailchannels = new MailChannels('your-api-key')
1649
- * const { records } = await mailchannels.domains.listDownstreamAddresses('example.com')
1689
+ * const { data, error } = await mailchannels.domains.listDownstreamAddresses('example.com')
1650
1690
  * ```
1651
1691
  */
1652
1692
  listDownstreamAddresses(domain: string, options?: DomainsListDownstreamAddressesOptions): Promise<DomainsListDownstreamAddressesResponse>;
@@ -1657,7 +1697,7 @@ declare class Domains {
1657
1697
  * @example
1658
1698
  * ```ts
1659
1699
  * const mailchannels = new MailChannels('your-api-key')
1660
- * const { success } = await mailchannels.domains.updateApiKey('example.com', 'your-api-key')
1700
+ * const { success, error } = await mailchannels.domains.updateApiKey('example.com', 'your-api-key')
1661
1701
  * ```
1662
1702
  */
1663
1703
  updateApiKey(domain: string, key: string): Promise<SuccessResponse>;
@@ -1667,7 +1707,7 @@ declare class Domains {
1667
1707
  * @example
1668
1708
  * ```ts
1669
1709
  * const mailchannels = new MailChannels('your-api-key')
1670
- * const { results } = await mailchannels.domains.bulkCreateLoginLinks(['example.com', 'example2.com'])
1710
+ * const { data, error } = await mailchannels.domains.bulkCreateLoginLinks(['example.com', 'example2.com'])
1671
1711
  * ```
1672
1712
  */
1673
1713
  bulkCreateLoginLinks(domains: string[]): Promise<DomainsBulkCreateLoginLinksResponse>;
@@ -1682,7 +1722,7 @@ declare class Lists {
1682
1722
  * @example
1683
1723
  * ```ts
1684
1724
  * const mailchannels = new MailChannels('your-api-key')
1685
- * const { entry } = await mailchannels.lists.addListEntry({
1725
+ * const { data, error } = await mailchannels.lists.addListEntry({
1686
1726
  * listName: 'safelist',
1687
1727
  * item: 'name@domain.com'
1688
1728
  * })
@@ -1695,7 +1735,7 @@ declare class Lists {
1695
1735
  * @example
1696
1736
  * ```ts
1697
1737
  * const mailchannels = new MailChannels('your-api-key')
1698
- * const { entries } = await mailchannels.lists.listEntries('safelist')
1738
+ * const { data, error } = await mailchannels.lists.listEntries('safelist')
1699
1739
  * ```
1700
1740
  */
1701
1741
  listEntries(listName: ListNames): Promise<ListEntriesResponse>;
@@ -1705,7 +1745,7 @@ declare class Lists {
1705
1745
  * @example
1706
1746
  * ```ts
1707
1747
  * const mailchannels = new MailChannels('your-api-key')
1708
- * const { success } = await mailchannels.lists.deleteListEntry({
1748
+ * const { success, error } = await mailchannels.lists.deleteListEntry({
1709
1749
  * listName: 'safelist',
1710
1750
  * item: 'name@domain.com'
1711
1751
  * })
@@ -1737,19 +1777,16 @@ interface UsersCreateOptions {
1737
1777
  };
1738
1778
  }
1739
1779
 
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
- }
1780
+ type UsersCreateResponse = DataResponse<{
1781
+ email: string;
1782
+ roles: string[];
1783
+ filter?: boolean;
1784
+ listEntries: {
1785
+ item: string;
1786
+ type: "domain" | "email_address" | "ip_address";
1787
+ action: "safelist" | "blocklist";
1788
+ }[];
1789
+ }>;
1753
1790
 
1754
1791
  declare class Users {
1755
1792
  protected mailchannels: MailChannelsClient;
@@ -1761,7 +1798,7 @@ declare class Users {
1761
1798
  * @example
1762
1799
  * ```ts
1763
1800
  * const mailchannels = new MailChannels('your-api-key')
1764
- * const { user } = await mailchannels.users.create("name@example.com", {
1801
+ * const { data, error } = await mailchannels.users.create("name@example.com", {
1765
1802
  * admin: true
1766
1803
  * })
1767
1804
  * ```
@@ -1774,7 +1811,7 @@ declare class Users {
1774
1811
  * @example
1775
1812
  * ```ts
1776
1813
  * const mailchannels = new MailChannels('your-api-key')
1777
- * const { entry } = await mailchannels.users.addListEntry('name@example.com', {
1814
+ * const { data, error } = await mailchannels.users.addListEntry('name@example.com', {
1778
1815
  * listName: 'safelist',
1779
1816
  * item: 'name@domain.com'
1780
1817
  * })
@@ -1788,7 +1825,7 @@ declare class Users {
1788
1825
  * @example
1789
1826
  * ```ts
1790
1827
  * const mailchannels = new MailChannels('your-api-key')
1791
- * const { entries } = await mailchannels.users.listEntries('name@example.com', 'safelist')
1828
+ * const { data, error } = await mailchannels.users.listEntries('name@example.com', 'safelist')
1792
1829
  * ```
1793
1830
  */
1794
1831
  listEntries(email: string, listName: ListNames): Promise<ListEntriesResponse>;
@@ -1799,7 +1836,7 @@ declare class Users {
1799
1836
  * @example
1800
1837
  * ```ts
1801
1838
  * const mailchannels = new MailChannels('your-api-key')
1802
- * const { success } = await mailchannels.users.deleteListEntry('name@example.com', {
1839
+ * const { success, error } = await mailchannels.users.deleteListEntry('name@example.com', {
1803
1840
  * listName: 'safelist',
1804
1841
  * item: 'name@domain.com'
1805
1842
  * })
@@ -1808,22 +1845,19 @@ declare class Users {
1808
1845
  deleteListEntry(email: string, options: ListEntryOptions): Promise<SuccessResponse>;
1809
1846
  }
1810
1847
 
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
- };
1848
+ type ServiceSubscriptionsResponse = DataResponse<{
1849
+ active: boolean;
1850
+ activeAccountsCount: number;
1851
+ handle: string;
1852
+ limits: {
1853
+ featureHandle: string;
1854
+ value: string;
1824
1855
  }[];
1825
- error: string | null;
1826
- }
1856
+ plan: {
1857
+ handle: string;
1858
+ name: string;
1859
+ };
1860
+ }[]>;
1827
1861
 
1828
1862
  interface ServiceReportOptions {
1829
1863
  /**
@@ -1858,7 +1892,7 @@ declare class Service {
1858
1892
  * @example
1859
1893
  * ```ts
1860
1894
  * const mailchannels = new MailChannels('your-api-key')
1861
- * const { success } = await mailchannels.service.status()
1895
+ * const { success, error } = await mailchannels.service.status()
1862
1896
  * ```
1863
1897
  */
1864
1898
  status(): Promise<SuccessResponse>;
@@ -1867,7 +1901,7 @@ declare class Service {
1867
1901
  * @example
1868
1902
  * ```ts
1869
1903
  * const mailchannels = new MailChannels('your-api-key')
1870
- * const { subscriptions } = await mailchannels.service.subscriptions()
1904
+ * const { data, error } = await mailchannels.service.subscriptions()
1871
1905
  * ```
1872
1906
  */
1873
1907
  subscriptions(): Promise<ServiceSubscriptionsResponse>;
@@ -1899,4 +1933,4 @@ declare class MailChannels extends MailChannelsClient {
1899
1933
  }
1900
1934
 
1901
1935
  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 };
1936
+ 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 };