resend 6.4.0-canary.0 → 6.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -10,7 +10,6 @@ interface DomainApiOptions {
10
10
  name: string;
11
11
  region?: string;
12
12
  custom_return_path?: string;
13
- capability?: 'send' | 'receive' | 'send-and-receive';
14
13
  }
15
14
 
16
15
  declare const RESEND_ERROR_CODES_BY_KEY: {
@@ -33,6 +32,15 @@ declare const RESEND_ERROR_CODES_BY_KEY: {
33
32
  readonly internal_server_error: 500;
34
33
  };
35
34
  type RESEND_ERROR_CODE_KEY = keyof typeof RESEND_ERROR_CODES_BY_KEY;
35
+ type Response<T> = ({
36
+ data: T;
37
+ error: null;
38
+ } | {
39
+ error: ErrorResponse;
40
+ data: null;
41
+ }) & {
42
+ headers: Record<string, string> | null;
43
+ };
36
44
  type ErrorResponse = {
37
45
  message: string;
38
46
  statusCode: number | null;
@@ -67,7 +75,7 @@ interface EmailApiOptions {
67
75
  attachments?: EmailApiAttachment[];
68
76
  template?: {
69
77
  id: string;
70
- variables?: Record<string, string | number | boolean>;
78
+ variables?: Record<string, string | number>;
71
79
  };
72
80
  }
73
81
 
@@ -145,13 +153,7 @@ interface CreateApiKeyResponseSuccess {
145
153
  token: string;
146
154
  id: string;
147
155
  }
148
- type CreateApiKeyResponse = {
149
- data: CreateApiKeyResponseSuccess;
150
- error: null;
151
- } | {
152
- data: null;
153
- error: ErrorResponse;
154
- };
156
+ type CreateApiKeyResponse = Response<CreateApiKeyResponseSuccess>;
155
157
 
156
158
  type ListApiKeysOptions = PaginationOptions;
157
159
  type ListApiKeysResponseSuccess = {
@@ -159,22 +161,10 @@ type ListApiKeysResponseSuccess = {
159
161
  has_more: boolean;
160
162
  data: Pick<ApiKey, 'name' | 'id' | 'created_at'>[];
161
163
  };
162
- type ListApiKeysResponse = {
163
- data: ListApiKeysResponseSuccess;
164
- error: null;
165
- } | {
166
- data: null;
167
- error: ErrorResponse;
168
- };
164
+ type ListApiKeysResponse = Response<ListApiKeysResponseSuccess>;
169
165
 
170
166
  type RemoveApiKeyResponseSuccess = {};
171
- type RemoveApiKeyResponse = {
172
- data: RemoveApiKeyResponseSuccess;
173
- error: null;
174
- } | {
175
- data: null;
176
- error: ErrorResponse;
177
- };
167
+ type RemoveApiKeyResponse = Response<RemoveApiKeyResponseSuccess>;
178
168
 
179
169
  interface EmailRenderOptions$1 {
180
170
  /**
@@ -199,7 +189,7 @@ interface EmailRenderOptions$1 {
199
189
  interface EmailTemplateOptions {
200
190
  template: {
201
191
  id: string;
202
- variables?: Record<string, string | number | boolean>;
192
+ variables?: Record<string, string | number>;
203
193
  };
204
194
  }
205
195
  interface CreateEmailBaseOptionsWithTemplate extends Omit<CreateEmailBaseOptions, 'from' | 'subject'> {
@@ -288,13 +278,7 @@ interface CreateEmailResponseSuccess {
288
278
  /** The ID of the newly created email. */
289
279
  id: string;
290
280
  }
291
- type CreateEmailResponse = {
292
- data: CreateEmailResponseSuccess;
293
- error: null;
294
- } | {
295
- data: null;
296
- error: ErrorResponse;
297
- };
281
+ type CreateEmailResponse = Response<CreateEmailResponseSuccess>;
298
282
  interface Attachment$1 {
299
283
  /** Content of an attached file. */
300
284
  content?: string | Buffer;
@@ -348,13 +332,7 @@ type CreateBatchSuccessResponse<Options extends CreateBatchRequestOptions = Crea
348
332
  message: string;
349
333
  }[];
350
334
  } : Record<string, never>);
351
- type CreateBatchResponse<Options extends CreateBatchRequestOptions> = {
352
- data: CreateBatchSuccessResponse<Options>;
353
- error: null;
354
- } | {
355
- data: null;
356
- error: ErrorResponse;
357
- };
335
+ type CreateBatchResponse<Options extends CreateBatchRequestOptions> = Response<CreateBatchSuccessResponse<Options>>;
358
336
 
359
337
  interface Broadcast {
360
338
  id: string;
@@ -451,24 +429,12 @@ interface CreateBroadcastResponseSuccess {
451
429
  /** The ID of the newly sent broadcasts. */
452
430
  id: string;
453
431
  }
454
- type CreateBroadcastResponse = {
455
- data: CreateBroadcastResponseSuccess;
456
- error: null;
457
- } | {
458
- data: null;
459
- error: ErrorResponse;
460
- };
432
+ type CreateBroadcastResponse = Response<CreateBroadcastResponseSuccess>;
461
433
 
462
434
  interface GetBroadcastResponseSuccess extends Broadcast {
463
435
  object: 'broadcast';
464
436
  }
465
- type GetBroadcastResponse = {
466
- data: GetBroadcastResponseSuccess;
467
- error: null;
468
- } | {
469
- data: null;
470
- error: ErrorResponse;
471
- };
437
+ type GetBroadcastResponse = Response<GetBroadcastResponseSuccess>;
472
438
 
473
439
  type ListBroadcastsOptions = PaginationOptions;
474
440
  type ListBroadcastsResponseSuccess = {
@@ -476,25 +442,13 @@ type ListBroadcastsResponseSuccess = {
476
442
  has_more: boolean;
477
443
  data: Pick<Broadcast, 'id' | 'name' | 'audience_id' | 'segment_id' | 'status' | 'created_at' | 'scheduled_at' | 'sent_at'>[];
478
444
  };
479
- type ListBroadcastsResponse = {
480
- data: ListBroadcastsResponseSuccess;
481
- error: null;
482
- } | {
483
- data: null;
484
- error: ErrorResponse;
485
- };
445
+ type ListBroadcastsResponse = Response<ListBroadcastsResponseSuccess>;
486
446
 
487
447
  interface RemoveBroadcastResponseSuccess extends Pick<Broadcast, 'id'> {
488
448
  object: 'broadcast';
489
449
  deleted: boolean;
490
450
  }
491
- type RemoveBroadcastResponse = {
492
- data: RemoveBroadcastResponseSuccess;
493
- error: null;
494
- } | {
495
- data: null;
496
- error: ErrorResponse;
497
- };
451
+ type RemoveBroadcastResponse = Response<RemoveBroadcastResponseSuccess>;
498
452
 
499
453
  interface SendBroadcastBaseOptions {
500
454
  /**
@@ -513,13 +467,7 @@ interface SendBroadcastResponseSuccess {
513
467
  /** The ID of the sent broadcast. */
514
468
  id: string;
515
469
  }
516
- type SendBroadcastResponse = {
517
- data: SendBroadcastResponseSuccess;
518
- error: null;
519
- } | {
520
- data: null;
521
- error: ErrorResponse;
522
- };
470
+ type SendBroadcastResponse = Response<SendBroadcastResponseSuccess>;
523
471
 
524
472
  interface UpdateBroadcastResponseSuccess {
525
473
  id: string;
@@ -540,13 +488,7 @@ type UpdateBroadcastOptions = {
540
488
  previewText?: string;
541
489
  topicId?: string | null;
542
490
  };
543
- type UpdateBroadcastResponse = {
544
- data: UpdateBroadcastResponseSuccess;
545
- error: null;
546
- } | {
547
- data: null;
548
- error: ErrorResponse;
549
- };
491
+ type UpdateBroadcastResponse = Response<UpdateBroadcastResponseSuccess>;
550
492
 
551
493
  interface Contact {
552
494
  created_at: string;
@@ -584,39 +526,42 @@ type SelectingField = {
584
526
  email: string;
585
527
  };
586
528
 
529
+ interface CreateContactPropertiesOptions {
530
+ [key: string]: string | number | null;
531
+ }
587
532
  interface CreateContactOptions {
588
533
  audienceId?: string;
589
534
  email: string;
590
535
  unsubscribed?: boolean;
591
536
  firstName?: string;
592
537
  lastName?: string;
538
+ properties?: CreateContactPropertiesOptions;
593
539
  }
594
540
  interface CreateContactRequestOptions extends PostOptions {
595
541
  }
596
542
  interface CreateContactResponseSuccess extends Pick<Contact, 'id'> {
597
543
  object: 'contact';
598
544
  }
599
- type CreateContactResponse = {
600
- data: CreateContactResponseSuccess;
601
- error: null;
602
- } | {
603
- data: null;
604
- error: ErrorResponse;
605
- };
545
+ type CreateContactResponse = Response<CreateContactResponseSuccess>;
606
546
 
607
547
  type GetContactOptions = string | ({
608
548
  audienceId?: string;
609
549
  } & SelectingField);
550
+ type ContactPropertyValue = {
551
+ type: 'string';
552
+ value: string;
553
+ } | {
554
+ type: 'number';
555
+ value: number;
556
+ };
557
+ interface ContactProperties$1 {
558
+ [key: string]: ContactPropertyValue;
559
+ }
610
560
  interface GetContactResponseSuccess extends Pick<Contact, 'id' | 'email' | 'created_at' | 'first_name' | 'last_name' | 'unsubscribed'> {
611
561
  object: 'contact';
562
+ properties: ContactProperties$1;
612
563
  }
613
- type GetContactResponse = {
614
- data: GetContactResponseSuccess;
615
- error: null;
616
- } | {
617
- data: null;
618
- error: ErrorResponse;
619
- };
564
+ type GetContactResponse = Response<GetContactResponseSuccess>;
620
565
 
621
566
  type ListAudienceContactsOptions = {
622
567
  audienceId: string;
@@ -629,13 +574,7 @@ interface ListContactsResponseSuccess {
629
574
  data: Contact[];
630
575
  has_more: boolean;
631
576
  }
632
- type ListContactsResponse = {
633
- data: ListContactsResponseSuccess;
634
- error: null;
635
- } | {
636
- data: null;
637
- error: ErrorResponse;
638
- };
577
+ type ListContactsResponse = Response<ListContactsResponseSuccess>;
639
578
 
640
579
  type RemoveContactsResponseSuccess = {
641
580
  object: 'contact';
@@ -645,30 +584,22 @@ type RemoveContactsResponseSuccess = {
645
584
  type RemoveContactOptions = string | (SelectingField & {
646
585
  audienceId?: string;
647
586
  });
648
- type RemoveContactsResponse = {
649
- data: RemoveContactsResponseSuccess;
650
- error: null;
651
- } | {
652
- data: null;
653
- error: ErrorResponse;
654
- };
587
+ type RemoveContactsResponse = Response<RemoveContactsResponseSuccess>;
655
588
 
589
+ interface UpdateContactPropertiesOptions {
590
+ [key: string]: string | number | null;
591
+ }
656
592
  type UpdateContactOptions = {
657
593
  audienceId?: string;
658
594
  unsubscribed?: boolean;
659
595
  firstName?: string;
660
596
  lastName?: string;
597
+ properties?: UpdateContactPropertiesOptions;
661
598
  } & SelectingField;
662
599
  type UpdateContactResponseSuccess = Pick<Contact, 'id'> & {
663
600
  object: 'contact';
664
601
  };
665
- type UpdateContactResponse = {
666
- data: UpdateContactResponseSuccess;
667
- error: null;
668
- } | {
669
- data: null;
670
- error: ErrorResponse;
671
- };
602
+ type UpdateContactResponse = Response<UpdateContactResponseSuccess>;
672
603
 
673
604
  type DomainRegion = 'us-east-1' | 'eu-west-1' | 'sa-east-1' | 'ap-northeast-1';
674
605
  type DomainNameservers = 'Amazon Route 53' | 'Cloudflare' | 'Digital Ocean' | 'GoDaddy' | 'Google Domains' | 'Namecheap' | 'Unidentified' | 'Vercel';
@@ -711,39 +642,25 @@ interface Domain {
711
642
  status: DomainStatus;
712
643
  created_at: string;
713
644
  region: DomainRegion;
714
- capability: 'send' | 'receive' | 'send-and-receive';
715
645
  }
716
646
 
717
647
  interface CreateDomainOptions {
718
648
  name: string;
719
649
  region?: DomainRegion;
720
650
  customReturnPath?: string;
721
- capability?: 'send' | 'receive' | 'send-and-receive';
722
651
  }
723
652
  interface CreateDomainRequestOptions extends PostOptions {
724
653
  }
725
- interface CreateDomainResponseSuccess extends Pick<Domain, 'name' | 'id' | 'status' | 'created_at' | 'region' | 'capability'> {
654
+ interface CreateDomainResponseSuccess extends Pick<Domain, 'name' | 'id' | 'status' | 'created_at' | 'region'> {
726
655
  records: DomainRecords[];
727
656
  }
728
- type CreateDomainResponse = {
729
- data: CreateDomainResponseSuccess;
730
- error: null;
731
- } | {
732
- data: null;
733
- error: ErrorResponse;
734
- };
657
+ type CreateDomainResponse = Response<CreateDomainResponseSuccess>;
735
658
 
736
- interface GetDomainResponseSuccess extends Pick<Domain, 'id' | 'name' | 'created_at' | 'region' | 'status' | 'capability'> {
659
+ interface GetDomainResponseSuccess extends Pick<Domain, 'id' | 'name' | 'created_at' | 'region' | 'status'> {
737
660
  object: 'domain';
738
661
  records: DomainRecords[];
739
662
  }
740
- type GetDomainResponse = {
741
- data: GetDomainResponseSuccess;
742
- error: null;
743
- } | {
744
- data: null;
745
- error: ErrorResponse;
746
- };
663
+ type GetDomainResponse = Response<GetDomainResponseSuccess>;
747
664
 
748
665
  type ListDomainsOptions = PaginationOptions;
749
666
  type ListDomainsResponseSuccess = {
@@ -751,25 +668,13 @@ type ListDomainsResponseSuccess = {
751
668
  object: 'list';
752
669
  has_more: boolean;
753
670
  };
754
- type ListDomainsResponse = {
755
- data: ListDomainsResponseSuccess;
756
- error: null;
757
- } | {
758
- data: null;
759
- error: ErrorResponse;
760
- };
671
+ type ListDomainsResponse = Response<ListDomainsResponseSuccess>;
761
672
 
762
673
  type RemoveDomainsResponseSuccess = Pick<Domain, 'id'> & {
763
674
  object: 'domain';
764
675
  deleted: boolean;
765
676
  };
766
- type RemoveDomainsResponse = {
767
- data: RemoveDomainsResponseSuccess;
768
- error: null;
769
- } | {
770
- data: null;
771
- error: ErrorResponse;
772
- };
677
+ type RemoveDomainsResponse = Response<RemoveDomainsResponseSuccess>;
773
678
 
774
679
  interface UpdateDomainsOptions {
775
680
  id: string;
@@ -780,24 +685,12 @@ interface UpdateDomainsOptions {
780
685
  type UpdateDomainsResponseSuccess = Pick<Domain, 'id'> & {
781
686
  object: 'domain';
782
687
  };
783
- type UpdateDomainsResponse = {
784
- data: UpdateDomainsResponseSuccess;
785
- error: null;
786
- } | {
787
- data: null;
788
- error: ErrorResponse;
789
- };
688
+ type UpdateDomainsResponse = Response<UpdateDomainsResponseSuccess>;
790
689
 
791
690
  type VerifyDomainsResponseSuccess = Pick<Domain, 'id'> & {
792
691
  object: 'domain';
793
692
  };
794
- type VerifyDomainsResponse = {
795
- data: VerifyDomainsResponseSuccess;
796
- error: null;
797
- } | {
798
- data: null;
799
- error: ErrorResponse;
800
- };
693
+ type VerifyDomainsResponse = Response<VerifyDomainsResponseSuccess>;
801
694
 
802
695
  interface Attachment {
803
696
  id: string;
@@ -817,13 +710,7 @@ interface GetAttachmentOptions {
817
710
  type GetAttachmentResponseSuccess = {
818
711
  object: 'attachment';
819
712
  } & Attachment;
820
- type GetAttachmentResponse = {
821
- data: GetAttachmentResponseSuccess;
822
- error: null;
823
- } | {
824
- data: null;
825
- error: ErrorResponse;
826
- };
713
+ type GetAttachmentResponse = Response<GetAttachmentResponseSuccess>;
827
714
 
828
715
  type ListAttachmentsOptions = PaginationOptions & {
829
716
  emailId: string;
@@ -838,25 +725,13 @@ interface ListAttachmentsResponseSuccess {
838
725
  has_more: boolean;
839
726
  data: Attachment[];
840
727
  }
841
- type ListAttachmentsResponse = {
842
- data: ListAttachmentsResponseSuccess;
843
- error: null;
844
- } | {
845
- data: null;
846
- error: ErrorResponse;
847
- };
728
+ type ListAttachmentsResponse = Response<ListAttachmentsResponseSuccess>;
848
729
 
849
730
  interface CancelEmailResponseSuccess {
850
731
  object: 'email';
851
732
  id: string;
852
733
  }
853
- type CancelEmailResponse = {
854
- data: CancelEmailResponseSuccess;
855
- error: null;
856
- } | {
857
- data: null;
858
- error: ErrorResponse;
859
- };
734
+ type CancelEmailResponse = Response<CancelEmailResponseSuccess>;
860
735
 
861
736
  interface GetEmailResponseSuccess {
862
737
  bcc: string[] | null;
@@ -878,13 +753,7 @@ interface GetEmailResponseSuccess {
878
753
  scheduled_at: string | null;
879
754
  object: 'email';
880
755
  }
881
- type GetEmailResponse = {
882
- data: GetEmailResponseSuccess;
883
- error: null;
884
- } | {
885
- data: null;
886
- error: ErrorResponse;
887
- };
756
+ type GetEmailResponse = Response<GetEmailResponseSuccess>;
888
757
 
889
758
  interface UpdateEmailOptions {
890
759
  id: string;
@@ -894,13 +763,7 @@ interface UpdateEmailResponseSuccess {
894
763
  id: string;
895
764
  object: 'email';
896
765
  }
897
- type UpdateEmailResponse = {
898
- data: UpdateEmailResponseSuccess;
899
- error: null;
900
- } | {
901
- data: null;
902
- error: ErrorResponse;
903
- };
766
+ type UpdateEmailResponse = Response<UpdateEmailResponseSuccess>;
904
767
 
905
768
  interface GetReceivingEmailResponseSuccess {
906
769
  object: 'email';
@@ -925,13 +788,7 @@ interface GetReceivingEmailResponseSuccess {
925
788
  content_disposition: string;
926
789
  }>;
927
790
  }
928
- type GetReceivingEmailResponse = {
929
- data: GetReceivingEmailResponseSuccess;
930
- error: null;
931
- } | {
932
- data: null;
933
- error: ErrorResponse;
934
- };
791
+ type GetReceivingEmailResponse = Response<GetReceivingEmailResponseSuccess>;
935
792
 
936
793
  type ListReceivingEmailsOptions = PaginationOptions;
937
794
  type ListReceivingEmail = Omit<GetReceivingEmailResponseSuccess, 'html' | 'text' | 'headers' | 'object'>;
@@ -1001,49 +858,28 @@ type CreateContactPropertyOptions = {
1001
858
  key: string;
1002
859
  } & (StringBaseContactPropertyOptions | NumberBaseContactPropertyOptions);
1003
860
  type CreateContactPropertyResponseSuccess = Pick<ContactProperty, 'id' | 'object'>;
1004
- interface CreateContactPropertyResponse {
1005
- data: CreateContactPropertyResponseSuccess | null;
1006
- error: ErrorResponse | null;
1007
- }
861
+ type CreateContactPropertyResponse = Response<CreateContactPropertyResponseSuccess>;
1008
862
 
1009
863
  type RemoveContactPropertyResponseSuccess = Pick<ContactProperty, 'id' | 'object'> & {
1010
864
  deleted: boolean;
1011
865
  };
1012
- interface RemoveContactPropertyResponse {
1013
- data: RemoveContactPropertyResponseSuccess | null;
1014
- error: ErrorResponse | null;
1015
- }
866
+ type RemoveContactPropertyResponse = Response<RemoveContactPropertyResponseSuccess>;
1016
867
 
1017
- type GetContactPropertyResponse = {
1018
- data: ContactProperty;
1019
- error: null;
1020
- } | {
1021
- data: null;
1022
- error: ErrorResponse;
1023
- };
868
+ type GetContactPropertyResponse = Response<ContactProperty>;
1024
869
 
1025
870
  type ListContactPropertiesOptions = PaginationOptions;
1026
- type ListContactPropertiesResponse = {
1027
- data: {
1028
- object: 'list';
1029
- has_more: boolean;
1030
- data: ContactProperty[];
1031
- };
1032
- error: null;
1033
- } | {
1034
- data: null;
1035
- error: ErrorResponse;
1036
- };
871
+ type ListContactPropertiesResponse = Response<{
872
+ object: 'list';
873
+ has_more: boolean;
874
+ data: ContactProperty[];
875
+ }>;
1037
876
 
1038
877
  type UpdateContactPropertyOptions = {
1039
878
  id: string;
1040
879
  fallbackValue?: string | number | null;
1041
880
  };
1042
881
  type UpdateContactPropertyResponseSuccess = Pick<ContactProperty, 'id' | 'object'>;
1043
- interface UpdateContactPropertyResponse {
1044
- data: UpdateContactPropertyResponseSuccess | null;
1045
- error: ErrorResponse | null;
1046
- }
882
+ type UpdateContactPropertyResponse = Response<UpdateContactPropertyResponseSuccess>;
1047
883
 
1048
884
  declare class ContactProperties {
1049
885
  private readonly resend;
@@ -1069,13 +905,7 @@ type AddContactSegmentOptions = ContactSegmentsBaseOptions & {
1069
905
  interface AddContactSegmentResponseSuccess {
1070
906
  id: string;
1071
907
  }
1072
- type AddContactSegmentResponse = {
1073
- data: AddContactSegmentResponseSuccess;
1074
- error: null;
1075
- } | {
1076
- data: null;
1077
- error: ErrorResponse;
1078
- };
908
+ type AddContactSegmentResponse = Response<AddContactSegmentResponseSuccess>;
1079
909
 
1080
910
  interface Segment {
1081
911
  created_at: string;
@@ -1085,13 +915,7 @@ interface Segment {
1085
915
 
1086
916
  type ListContactSegmentsOptions = PaginationOptions & ContactSegmentsBaseOptions;
1087
917
  type ListContactSegmentsResponseSuccess = PaginatedData<Segment[]>;
1088
- type ListContactSegmentsResponse = {
1089
- data: ListContactSegmentsResponseSuccess;
1090
- error: null;
1091
- } | {
1092
- data: null;
1093
- error: ErrorResponse;
1094
- };
918
+ type ListContactSegmentsResponse = Response<ListContactSegmentsResponseSuccess>;
1095
919
 
1096
920
  type RemoveContactSegmentOptions = ContactSegmentsBaseOptions & {
1097
921
  segmentId: string;
@@ -1100,13 +924,7 @@ interface RemoveContactSegmentResponseSuccess {
1100
924
  id: string;
1101
925
  deleted: boolean;
1102
926
  }
1103
- type RemoveContactSegmentResponse = {
1104
- data: RemoveContactSegmentResponseSuccess;
1105
- error: null;
1106
- } | {
1107
- data: null;
1108
- error: ErrorResponse;
1109
- };
927
+ type RemoveContactSegmentResponse = Response<RemoveContactSegmentResponseSuccess>;
1110
928
 
1111
929
  declare class ContactSegments {
1112
930
  private readonly resend;
@@ -1128,13 +946,7 @@ interface ContactTopic {
1128
946
  subscription: 'opt_in' | 'opt_out';
1129
947
  }
1130
948
  type ListContactTopicsResponseSuccess = PaginatedData<ContactTopic[]>;
1131
- type ListContactTopicsResponse = {
1132
- data: ListContactTopicsResponseSuccess;
1133
- error: null;
1134
- } | {
1135
- data: null;
1136
- error: ErrorResponse;
1137
- };
949
+ type ListContactTopicsResponse = Response<ListContactTopicsResponseSuccess>;
1138
950
 
1139
951
  interface UpdateContactTopicsBaseOptions {
1140
952
  id?: string;
@@ -1149,10 +961,7 @@ interface UpdateContactTopicsOptions extends UpdateContactTopicsBaseOptions {
1149
961
  interface UpdateContactTopicsResponseSuccess {
1150
962
  id: string;
1151
963
  }
1152
- interface UpdateContactTopicsResponse {
1153
- data: UpdateContactTopicsResponseSuccess | null;
1154
- error: ErrorResponse | null;
1155
- }
964
+ type UpdateContactTopicsResponse = Response<UpdateContactTopicsResponseSuccess>;
1156
965
 
1157
966
  declare class ContactTopics {
1158
967
  private readonly resend;
@@ -1198,13 +1007,7 @@ type ListEmailsResponseSuccess = {
1198
1007
  has_more: boolean;
1199
1008
  data: ListEmail[];
1200
1009
  };
1201
- type ListEmailsResponse = {
1202
- data: ListEmailsResponseSuccess;
1203
- error: null;
1204
- } | {
1205
- data: null;
1206
- error: ErrorResponse;
1207
- };
1010
+ type ListEmailsResponse = Response<ListEmailsResponseSuccess>;
1208
1011
 
1209
1012
  declare class Attachments {
1210
1013
  private readonly resend;
@@ -1242,24 +1045,12 @@ interface CreateSegmentRequestOptions extends PostOptions {
1242
1045
  interface CreateSegmentResponseSuccess extends Pick<Segment, 'name' | 'id'> {
1243
1046
  object: 'segment';
1244
1047
  }
1245
- type CreateSegmentResponse = {
1246
- data: CreateSegmentResponseSuccess;
1247
- error: null;
1248
- } | {
1249
- data: null;
1250
- error: ErrorResponse;
1251
- };
1048
+ type CreateSegmentResponse = Response<CreateSegmentResponseSuccess>;
1252
1049
 
1253
1050
  interface GetSegmentResponseSuccess extends Pick<Segment, 'id' | 'name' | 'created_at'> {
1254
1051
  object: 'segment';
1255
1052
  }
1256
- type GetSegmentResponse = {
1257
- data: GetSegmentResponseSuccess;
1258
- error: null;
1259
- } | {
1260
- data: null;
1261
- error: ErrorResponse;
1262
- };
1053
+ type GetSegmentResponse = Response<GetSegmentResponseSuccess>;
1263
1054
 
1264
1055
  type ListSegmentsOptions = PaginationOptions;
1265
1056
  type ListSegmentsResponseSuccess = {
@@ -1267,25 +1058,13 @@ type ListSegmentsResponseSuccess = {
1267
1058
  data: Segment[];
1268
1059
  has_more: boolean;
1269
1060
  };
1270
- type ListSegmentsResponse = {
1271
- data: ListSegmentsResponseSuccess;
1272
- error: null;
1273
- } | {
1274
- data: null;
1275
- error: ErrorResponse;
1276
- };
1061
+ type ListSegmentsResponse = Response<ListSegmentsResponseSuccess>;
1277
1062
 
1278
1063
  interface RemoveSegmentResponseSuccess extends Pick<Segment, 'id'> {
1279
1064
  object: 'segment';
1280
1065
  deleted: boolean;
1281
1066
  }
1282
- type RemoveSegmentResponse = {
1283
- data: RemoveSegmentResponseSuccess;
1284
- error: null;
1285
- } | {
1286
- data: null;
1287
- error: ErrorResponse;
1288
- };
1067
+ type RemoveSegmentResponse = Response<RemoveSegmentResponseSuccess>;
1289
1068
 
1290
1069
  declare class Segments {
1291
1070
  private readonly resend;
@@ -1340,35 +1119,17 @@ type CreateTemplateOptions = Pick<Template, 'name'> & TemplateOptionalFieldsForC
1340
1119
  interface CreateTemplateResponseSuccess extends Pick<Template, 'id'> {
1341
1120
  object: 'template';
1342
1121
  }
1343
- type CreateTemplateResponse = {
1344
- data: CreateTemplateResponseSuccess;
1345
- error: null;
1346
- } | {
1347
- data: null;
1348
- error: ErrorResponse;
1349
- };
1122
+ type CreateTemplateResponse = Response<CreateTemplateResponseSuccess>;
1350
1123
 
1351
1124
  interface DuplicateTemplateResponseSuccess extends Pick<Template, 'id'> {
1352
1125
  object: 'template';
1353
1126
  }
1354
- type DuplicateTemplateResponse = {
1355
- data: DuplicateTemplateResponseSuccess;
1356
- error: null;
1357
- } | {
1358
- data: null;
1359
- error: ErrorResponse;
1360
- };
1127
+ type DuplicateTemplateResponse = Response<DuplicateTemplateResponseSuccess>;
1361
1128
 
1362
1129
  interface PublishTemplateResponseSuccess extends Pick<Template, 'id'> {
1363
1130
  object: 'template';
1364
1131
  }
1365
- type PublishTemplateResponse = {
1366
- data: PublishTemplateResponseSuccess;
1367
- error: null;
1368
- } | {
1369
- data: null;
1370
- error: ErrorResponse;
1371
- };
1132
+ type PublishTemplateResponse = Response<PublishTemplateResponseSuccess>;
1372
1133
 
1373
1134
  declare class ChainableTemplateResult<T extends CreateTemplateResponse | DuplicateTemplateResponse> implements PromiseLike<T> {
1374
1135
  private readonly promise;
@@ -1381,13 +1142,7 @@ declare class ChainableTemplateResult<T extends CreateTemplateResponse | Duplica
1381
1142
  interface GetTemplateResponseSuccess extends Template {
1382
1143
  object: 'template';
1383
1144
  }
1384
- type GetTemplateResponse = {
1385
- data: GetTemplateResponseSuccess;
1386
- error: null;
1387
- } | {
1388
- data: null;
1389
- error: ErrorResponse;
1390
- };
1145
+ type GetTemplateResponse = Response<GetTemplateResponseSuccess>;
1391
1146
 
1392
1147
  interface TemplateListItem extends Pick<Template, 'id' | 'name' | 'created_at' | 'updated_at' | 'status' | 'published_at' | 'alias'> {
1393
1148
  }
@@ -1396,26 +1151,14 @@ interface ListTemplatesResponseSuccess {
1396
1151
  data: TemplateListItem[];
1397
1152
  has_more: boolean;
1398
1153
  }
1399
- type ListTemplatesResponse = {
1400
- data: ListTemplatesResponseSuccess;
1401
- error: null;
1402
- } | {
1403
- data: null;
1404
- error: ErrorResponse;
1405
- };
1154
+ type ListTemplatesResponse = Response<ListTemplatesResponseSuccess>;
1406
1155
 
1407
1156
  interface RemoveTemplateResponseSuccess {
1408
1157
  object: 'template';
1409
1158
  id: string;
1410
1159
  deleted: boolean;
1411
1160
  }
1412
- type RemoveTemplateResponse = {
1413
- data: RemoveTemplateResponseSuccess;
1414
- error: null;
1415
- } | {
1416
- data: null;
1417
- error: ErrorResponse;
1418
- };
1161
+ type RemoveTemplateResponse = Response<RemoveTemplateResponseSuccess>;
1419
1162
 
1420
1163
  type TemplateVariableUpdateOptions = Pick<TemplateVariable, 'key' | 'type'> & ({
1421
1164
  type: 'string';
@@ -1431,13 +1174,7 @@ interface UpdateTemplateOptions extends Partial<Pick<Template, 'name' | 'subject
1431
1174
  interface UpdateTemplateResponseSuccess extends Pick<Template, 'id'> {
1432
1175
  object: 'template';
1433
1176
  }
1434
- type UpdateTemplateResponse = {
1435
- data: UpdateTemplateResponseSuccess;
1436
- error: null;
1437
- } | {
1438
- data: null;
1439
- error: ErrorResponse;
1440
- };
1177
+ type UpdateTemplateResponse = Response<UpdateTemplateResponseSuccess>;
1441
1178
 
1442
1179
  declare class Templates {
1443
1180
  private readonly resend;
@@ -1467,33 +1204,21 @@ interface CreateTopicOptions {
1467
1204
  defaultSubscription: 'opt_in' | 'opt_out';
1468
1205
  }
1469
1206
  type CreateTopicResponseSuccess = Pick<Topic, 'id'>;
1470
- interface CreateTopicResponse {
1471
- data: CreateTopicResponseSuccess | null;
1472
- error: ErrorResponse | null;
1473
- }
1207
+ type CreateTopicResponse = Response<CreateTopicResponseSuccess>;
1474
1208
 
1475
1209
  type GetTopicResponseSuccess = Topic;
1476
- interface GetTopicResponse {
1477
- data: GetTopicResponseSuccess | null;
1478
- error: ErrorResponse | null;
1479
- }
1210
+ type GetTopicResponse = Response<GetTopicResponseSuccess>;
1480
1211
 
1481
1212
  interface ListTopicsResponseSuccess {
1482
1213
  data: Topic[];
1483
1214
  }
1484
- interface ListTopicsResponse {
1485
- data: ListTopicsResponseSuccess | null;
1486
- error: ErrorResponse | null;
1487
- }
1215
+ type ListTopicsResponse = Response<ListTopicsResponseSuccess>;
1488
1216
 
1489
1217
  type RemoveTopicResponseSuccess = Pick<Topic, 'id'> & {
1490
1218
  object: 'topic';
1491
1219
  deleted: boolean;
1492
1220
  };
1493
- interface RemoveTopicResponse {
1494
- data: RemoveTopicResponseSuccess | null;
1495
- error: ErrorResponse | null;
1496
- }
1221
+ type RemoveTopicResponse = Response<RemoveTopicResponseSuccess>;
1497
1222
 
1498
1223
  interface UpdateTopicOptions {
1499
1224
  id: string;
@@ -1501,10 +1226,7 @@ interface UpdateTopicOptions {
1501
1226
  description?: string;
1502
1227
  }
1503
1228
  type UpdateTopicResponseSuccess = Pick<Topic, 'id'>;
1504
- interface UpdateTopicResponse {
1505
- data: UpdateTopicResponseSuccess | null;
1506
- error: ErrorResponse | null;
1507
- }
1229
+ type UpdateTopicResponse = Response<UpdateTopicResponseSuccess>;
1508
1230
 
1509
1231
  declare class Topics {
1510
1232
  private readonly resend;
@@ -1529,13 +1251,7 @@ interface CreateWebhookResponseSuccess {
1529
1251
  id: string;
1530
1252
  signing_secret: string;
1531
1253
  }
1532
- type CreateWebhookResponse = {
1533
- data: CreateWebhookResponseSuccess;
1534
- error: null;
1535
- } | {
1536
- data: null;
1537
- error: ErrorResponse;
1538
- };
1254
+ type CreateWebhookResponse = Response<CreateWebhookResponseSuccess>;
1539
1255
 
1540
1256
  interface GetWebhookResponseSuccess {
1541
1257
  object: 'webhook';
@@ -1546,13 +1262,7 @@ interface GetWebhookResponseSuccess {
1546
1262
  events: WebhookEvent[] | null;
1547
1263
  signing_secret: string;
1548
1264
  }
1549
- type GetWebhookResponse = {
1550
- data: GetWebhookResponseSuccess;
1551
- error: null;
1552
- } | {
1553
- data: null;
1554
- error: ErrorResponse;
1555
- };
1265
+ type GetWebhookResponse = Response<GetWebhookResponseSuccess>;
1556
1266
 
1557
1267
  type ListWebhooksOptions = PaginationOptions;
1558
1268
  interface Webhook {
@@ -1567,25 +1277,13 @@ type ListWebhooksResponseSuccess = {
1567
1277
  has_more: boolean;
1568
1278
  data: Webhook[];
1569
1279
  };
1570
- type ListWebhooksResponse = {
1571
- data: ListWebhooksResponseSuccess;
1572
- error: null;
1573
- } | {
1574
- data: null;
1575
- error: ErrorResponse;
1576
- };
1280
+ type ListWebhooksResponse = Response<ListWebhooksResponseSuccess>;
1577
1281
 
1578
1282
  type RemoveWebhookResponseSuccess = Pick<Webhook, 'id'> & {
1579
1283
  object: 'webhook';
1580
1284
  deleted: boolean;
1581
1285
  };
1582
- type RemoveWebhookResponse = {
1583
- data: RemoveWebhookResponseSuccess;
1584
- error: null;
1585
- } | {
1586
- data: null;
1587
- error: ErrorResponse;
1588
- };
1286
+ type RemoveWebhookResponse = Response<RemoveWebhookResponseSuccess>;
1589
1287
 
1590
1288
  interface UpdateWebhookOptions {
1591
1289
  endpoint?: string;
@@ -1596,13 +1294,7 @@ interface UpdateWebhookResponseSuccess {
1596
1294
  object: 'webhook';
1597
1295
  id: string;
1598
1296
  }
1599
- type UpdateWebhookResponse = {
1600
- data: UpdateWebhookResponseSuccess;
1601
- error: null;
1602
- } | {
1603
- data: null;
1604
- error: ErrorResponse;
1605
- };
1297
+ type UpdateWebhookResponse = Response<UpdateWebhookResponseSuccess>;
1606
1298
 
1607
1299
  interface Headers {
1608
1300
  id: string;
@@ -1644,48 +1336,12 @@ declare class Resend {
1644
1336
  readonly templates: Templates;
1645
1337
  readonly topics: Topics;
1646
1338
  constructor(key?: string | undefined);
1647
- fetchRequest<T>(path: string, options?: {}): Promise<{
1648
- data: T;
1649
- error: null;
1650
- } | {
1651
- data: null;
1652
- error: ErrorResponse;
1653
- }>;
1654
- post<T>(path: string, entity?: unknown, options?: PostOptions & IdempotentRequest): Promise<{
1655
- data: null;
1656
- error: ErrorResponse;
1657
- } | {
1658
- data: T;
1659
- error: null;
1660
- }>;
1661
- get<T>(path: string, options?: GetOptions): Promise<{
1662
- data: null;
1663
- error: ErrorResponse;
1664
- } | {
1665
- data: T;
1666
- error: null;
1667
- }>;
1668
- put<T>(path: string, entity: unknown, options?: PutOptions): Promise<{
1669
- data: null;
1670
- error: ErrorResponse;
1671
- } | {
1672
- data: T;
1673
- error: null;
1674
- }>;
1675
- patch<T>(path: string, entity: unknown, options?: PatchOptions): Promise<{
1676
- data: null;
1677
- error: ErrorResponse;
1678
- } | {
1679
- data: T;
1680
- error: null;
1681
- }>;
1682
- delete<T>(path: string, query?: unknown): Promise<{
1683
- data: null;
1684
- error: ErrorResponse;
1685
- } | {
1686
- data: T;
1687
- error: null;
1688
- }>;
1339
+ fetchRequest<T>(path: string, options?: {}): Promise<Response<T>>;
1340
+ post<T>(path: string, entity?: unknown, options?: PostOptions & IdempotentRequest): Promise<Response<T>>;
1341
+ get<T>(path: string, options?: GetOptions): Promise<Response<T>>;
1342
+ put<T>(path: string, entity: unknown, options?: PutOptions): Promise<Response<T>>;
1343
+ patch<T>(path: string, entity: unknown, options?: PatchOptions): Promise<Response<T>>;
1344
+ delete<T>(path: string, query?: unknown): Promise<Response<T>>;
1689
1345
  }
1690
1346
 
1691
1347
  export { type ApiKey, type Attachment$1 as Attachment, type Broadcast, type CancelEmailResponse, type CancelEmailResponseSuccess, type Contact, type CreateApiKeyOptions, type CreateApiKeyRequestOptions, type CreateApiKeyResponse, type CreateApiKeyResponseSuccess, type CreateBatchOptions, type CreateBatchRequestOptions, type CreateBatchResponse, type CreateBatchSuccessResponse, type CreateBroadcastOptions, type CreateBroadcastRequestOptions, type CreateBroadcastResponse, type CreateBroadcastResponseSuccess, type CreateContactOptions, type CreateContactRequestOptions, type CreateContactResponse, type CreateContactResponseSuccess, type CreateDomainOptions, type CreateDomainRequestOptions, type CreateDomainResponse, type CreateDomainResponseSuccess, type CreateEmailOptions, type CreateEmailRequestOptions, type CreateEmailResponse, type CreateEmailResponseSuccess, type CreateSegmentOptions, type CreateSegmentRequestOptions, type CreateSegmentResponse, type CreateSegmentResponseSuccess, type CreateWebhookOptions, type CreateWebhookRequestOptions, type CreateWebhookResponse, type CreateWebhookResponseSuccess, type Domain, type DomainApiOptions, type DomainDkimRecord, type DomainNameservers, type DomainRecords, type DomainRegion, type DomainSpfRecord, type DomainStatus, type EmailApiAttachment, type EmailApiOptions, type ErrorResponse, type GetAttachmentOptions, type GetAttachmentResponse, type GetAttachmentResponseSuccess, type GetBroadcastResponse, type GetBroadcastResponseSuccess, type GetContactOptions, type GetContactResponse, type GetContactResponseSuccess, type GetDomainResponse, type GetDomainResponseSuccess, type GetEmailResponse, type GetEmailResponseSuccess, type GetOptions, type GetReceivingEmailResponse, type GetReceivingEmailResponseSuccess, type GetSegmentResponse, type GetSegmentResponseSuccess, type GetWebhookResponse, type GetWebhookResponseSuccess, type IdempotentRequest, type ListApiKeysOptions, type ListApiKeysResponse, type ListApiKeysResponseSuccess, type ListAttachmentsApiResponse, type ListAttachmentsOptions, type ListAttachmentsResponse, type ListAttachmentsResponseSuccess, type ListAudienceContactsOptions, type ListBroadcastsOptions, type ListBroadcastsResponse, type ListBroadcastsResponseSuccess, type ListContactsOptions, type ListContactsResponse, type ListContactsResponseSuccess, type ListDomainsOptions, type ListDomainsResponse, type ListDomainsResponseSuccess, type ListReceivingEmail, type ListReceivingEmailsOptions, type ListReceivingEmailsResponse, type ListReceivingEmailsResponseSuccess, type ListSegmentsOptions, type ListSegmentsResponse, type ListSegmentsResponseSuccess, type ListWebhooksOptions, type ListWebhooksResponse, type ListWebhooksResponseSuccess, type PaginatedData, type PaginationOptions, type PatchOptions, type PostOptions, type PutOptions, type ReceivingRecord, type RemoveApiKeyResponse, type RemoveApiKeyResponseSuccess, type RemoveBroadcastResponse, type RemoveBroadcastResponseSuccess, type RemoveContactOptions, type RemoveContactsResponse, type RemoveContactsResponseSuccess, type RemoveDomainsResponse, type RemoveDomainsResponseSuccess, type RemoveSegmentResponse, type RemoveSegmentResponseSuccess, type RemoveWebhookResponse, type RemoveWebhookResponseSuccess, type RequireAtLeastOne, Resend, type Segment, type SelectingField, type SendBroadcastOptions, type SendBroadcastRequestOptions, type SendBroadcastResponse, type SendBroadcastResponseSuccess, type Tag, type UpdateBroadcastOptions, type UpdateBroadcastResponse, type UpdateBroadcastResponseSuccess, type UpdateContactOptions, type UpdateContactResponse, type UpdateContactResponseSuccess, type UpdateDomainsOptions, type UpdateDomainsResponse, type UpdateDomainsResponseSuccess, type UpdateEmailOptions, type UpdateEmailResponse, type UpdateEmailResponseSuccess, type UpdateWebhookOptions, type UpdateWebhookResponse, type UpdateWebhookResponseSuccess, type VerifyDomainsResponse, type VerifyDomainsResponseSuccess, type Webhook, type WebhookEvent };