resend 6.1.0 → 6.1.2

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
@@ -1,10 +1,87 @@
1
1
  import * as React$1 from 'react';
2
2
 
3
+ interface ApiKey {
4
+ created_at: string;
5
+ id: string;
6
+ name: string;
7
+ }
8
+
9
+ interface DomainApiOptions {
10
+ name: string;
11
+ region?: string;
12
+ custom_return_path?: string;
13
+ }
14
+
15
+ declare const RESEND_ERROR_CODES_BY_KEY: {
16
+ readonly missing_required_field: 422;
17
+ readonly invalid_idempotency_key: 400;
18
+ readonly invalid_idempotent_request: 409;
19
+ readonly concurrent_idempotent_requests: 409;
20
+ readonly invalid_access: 422;
21
+ readonly invalid_parameter: 422;
22
+ readonly invalid_region: 422;
23
+ readonly rate_limit_exceeded: 429;
24
+ readonly missing_api_key: 401;
25
+ readonly invalid_api_key: 403;
26
+ readonly invalid_from_address: 403;
27
+ readonly validation_error: 403;
28
+ readonly not_found: 404;
29
+ readonly method_not_allowed: 405;
30
+ readonly application_error: 500;
31
+ readonly internal_server_error: 500;
32
+ };
33
+ type RESEND_ERROR_CODE_KEY = keyof typeof RESEND_ERROR_CODES_BY_KEY;
34
+ interface ErrorResponse {
35
+ message: string;
36
+ name: RESEND_ERROR_CODE_KEY;
37
+ }
38
+ type Tag$1 = {
39
+ name: string;
40
+ value: string;
41
+ };
42
+
43
+ interface EmailApiAttachment {
44
+ content?: string | Buffer;
45
+ filename?: string | false | undefined;
46
+ path?: string;
47
+ content_type?: string;
48
+ content_id?: string;
49
+ }
50
+ interface EmailApiOptions {
51
+ from: string;
52
+ to: string | string[];
53
+ subject: string;
54
+ region?: string;
55
+ headers?: Record<string, string>;
56
+ html?: string;
57
+ text?: string;
58
+ bcc?: string | string[];
59
+ cc?: string | string[];
60
+ reply_to?: string | string[];
61
+ scheduled_at?: string;
62
+ tags?: Tag$1[];
63
+ attachments?: EmailApiAttachment[];
64
+ }
65
+
3
66
  interface GetOptions {
4
67
  query?: Record<string, unknown>;
5
68
  headers?: HeadersInit;
6
69
  }
7
70
 
71
+ interface IdempotentRequest {
72
+ /**
73
+ * Unique key that ensures the same operation is not processed multiple times.
74
+ * Allows for safe retries without duplicating operations.
75
+ * If provided, will be sent as the `Idempotency-Key` header.
76
+ */
77
+ idempotencyKey?: string;
78
+ }
79
+
80
+ interface List<T> {
81
+ readonly object: 'list';
82
+ data: T[];
83
+ }
84
+
8
85
  type PaginationOptions = {
9
86
  /**
10
87
  * Maximum number of items to return (1-100, default: 20)
@@ -24,6 +101,13 @@ type PaginationOptions = {
24
101
  after?: never;
25
102
  });
26
103
 
104
+ interface PatchOptions {
105
+ query?: {
106
+ [key: string]: unknown;
107
+ };
108
+ headers?: HeadersInit;
109
+ }
110
+
27
111
  interface PostOptions {
28
112
  query?: {
29
113
  [key: string]: unknown;
@@ -38,29 +122,9 @@ interface PutOptions {
38
122
  headers?: HeadersInit;
39
123
  }
40
124
 
41
- declare const RESEND_ERROR_CODES_BY_KEY: {
42
- readonly missing_required_field: 422;
43
- readonly invalid_idempotency_key: 400;
44
- readonly invalid_idempotent_request: 409;
45
- readonly concurrent_idempotent_requests: 409;
46
- readonly invalid_access: 422;
47
- readonly invalid_parameter: 422;
48
- readonly invalid_region: 422;
49
- readonly rate_limit_exceeded: 429;
50
- readonly missing_api_key: 401;
51
- readonly invalid_api_key: 403;
52
- readonly invalid_from_address: 403;
53
- readonly validation_error: 403;
54
- readonly not_found: 404;
55
- readonly method_not_allowed: 405;
56
- readonly application_error: 500;
57
- readonly internal_server_error: 500;
58
- };
59
- type RESEND_ERROR_CODE_KEY = keyof typeof RESEND_ERROR_CODES_BY_KEY;
60
- interface ErrorResponse {
61
- message: string;
62
- name: RESEND_ERROR_CODE_KEY;
63
- }
125
+ type RequireAtLeastOne<T> = {
126
+ [K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>;
127
+ }[keyof T];
64
128
 
65
129
  interface CreateApiKeyOptions {
66
130
  name: string;
@@ -81,12 +145,6 @@ type CreateApiKeyResponse = {
81
145
  error: ErrorResponse;
82
146
  };
83
147
 
84
- interface ApiKey {
85
- created_at: string;
86
- id: string;
87
- name: string;
88
- }
89
-
90
148
  type ListApiKeysOptions = PaginationOptions;
91
149
  type ListApiKeysResponseSuccess = {
92
150
  object: 'list';
@@ -169,19 +227,6 @@ type RemoveAudiencesResponse = {
169
227
  error: ErrorResponse;
170
228
  };
171
229
 
172
- interface IdempotentRequest {
173
- /**
174
- * Unique key that ensures the same operation is not processed multiple times.
175
- * Allows for safe retries without duplicating operations.
176
- * If provided, will be sent as the `Idempotency-Key` header.
177
- */
178
- idempotencyKey?: string;
179
- }
180
-
181
- type RequireAtLeastOne<T> = {
182
- [K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>;
183
- }[keyof T];
184
-
185
230
  interface EmailRenderOptions$1 {
186
231
  /**
187
232
  * The React component used to write the message.
@@ -340,6 +385,20 @@ type CreateBatchResponse<Options extends CreateBatchRequestOptions> = {
340
385
  error: ErrorResponse;
341
386
  };
342
387
 
388
+ interface Broadcast {
389
+ id: string;
390
+ name: string;
391
+ audience_id: string | null;
392
+ from: string | null;
393
+ subject: string | null;
394
+ reply_to: string[] | null;
395
+ preview_text: string | null;
396
+ status: 'draft' | 'sent' | 'queued';
397
+ created_at: string;
398
+ scheduled_at: string | null;
399
+ sent_at: string | null;
400
+ }
401
+
343
402
  interface EmailRenderOptions {
344
403
  /**
345
404
  * The React component used to write the message.
@@ -413,6 +472,43 @@ type CreateBroadcastResponse = {
413
472
  error: ErrorResponse;
414
473
  };
415
474
 
475
+ interface GetBroadcastResponseSuccess extends Broadcast {
476
+ object: 'broadcast';
477
+ }
478
+ type GetBroadcastResponse = {
479
+ data: GetBroadcastResponseSuccess;
480
+ error: null;
481
+ } | {
482
+ data: null;
483
+ error: ErrorResponse;
484
+ };
485
+
486
+ type ListBroadcastsOptions = PaginationOptions;
487
+ type ListBroadcastsResponseSuccess = {
488
+ object: 'list';
489
+ has_more: boolean;
490
+ data: Pick<Broadcast, 'id' | 'name' | 'audience_id' | 'status' | 'created_at' | 'scheduled_at' | 'sent_at'>[];
491
+ };
492
+ type ListBroadcastsResponse = {
493
+ data: ListBroadcastsResponseSuccess;
494
+ error: null;
495
+ } | {
496
+ data: null;
497
+ error: ErrorResponse;
498
+ };
499
+
500
+ interface RemoveBroadcastResponseSuccess extends Pick<Broadcast, 'id'> {
501
+ object: 'broadcast';
502
+ deleted: boolean;
503
+ }
504
+ type RemoveBroadcastResponse = {
505
+ data: RemoveBroadcastResponseSuccess;
506
+ error: null;
507
+ } | {
508
+ data: null;
509
+ error: ErrorResponse;
510
+ };
511
+
416
512
  interface SendBroadcastBaseOptions {
417
513
  /**
418
514
  * Schedule email to be sent later.
@@ -438,6 +534,28 @@ type SendBroadcastResponse = {
438
534
  error: ErrorResponse;
439
535
  };
440
536
 
537
+ interface UpdateBroadcastResponseSuccess {
538
+ id: string;
539
+ }
540
+ type UpdateBroadcastOptions = {
541
+ name?: string;
542
+ audienceId?: string;
543
+ from?: string;
544
+ html?: string;
545
+ react?: React.ReactNode;
546
+ text?: string;
547
+ subject?: string;
548
+ replyTo?: string[];
549
+ previewText?: string;
550
+ };
551
+ type UpdateBroadcastResponse = {
552
+ data: UpdateBroadcastResponseSuccess;
553
+ error: null;
554
+ } | {
555
+ data: null;
556
+ error: ErrorResponse;
557
+ };
558
+
441
559
  interface Contact {
442
560
  created_at: string;
443
561
  id: string;
@@ -558,6 +676,7 @@ type UpdateContactResponse = {
558
676
  };
559
677
 
560
678
  type DomainRegion = 'us-east-1' | 'eu-west-1' | 'sa-east-1' | 'ap-northeast-1';
679
+ type DomainNameservers = 'Amazon Route 53' | 'Cloudflare' | 'Digital Ocean' | 'GoDaddy' | 'Google Domains' | 'Namecheap' | 'Unidentified' | 'Vercel';
561
680
  type DomainStatus = 'pending' | 'verified' | 'failed' | 'temporary_failure' | 'not_started';
562
681
  type DomainRecords = DomainSpfRecord | DomainDkimRecord;
563
682
  interface DomainSpfRecord {
@@ -674,6 +793,18 @@ type VerifyDomainsResponse = {
674
793
  error: ErrorResponse;
675
794
  };
676
795
 
796
+ interface CancelEmailResponseSuccess {
797
+ object: 'email';
798
+ id: string;
799
+ }
800
+ type CancelEmailResponse = {
801
+ data: CancelEmailResponseSuccess;
802
+ error: null;
803
+ } | {
804
+ data: null;
805
+ error: ErrorResponse;
806
+ };
807
+
677
808
  interface GetEmailResponseSuccess {
678
809
  bcc: string[] | null;
679
810
  cc: string[] | null;
@@ -701,6 +832,22 @@ type GetEmailResponse = {
701
832
  error: ErrorResponse;
702
833
  };
703
834
 
835
+ interface UpdateEmailOptions {
836
+ id: string;
837
+ scheduledAt: string;
838
+ }
839
+ interface UpdateEmailResponseSuccess {
840
+ id: string;
841
+ object: 'email';
842
+ }
843
+ type UpdateEmailResponse = {
844
+ data: UpdateEmailResponseSuccess;
845
+ error: null;
846
+ } | {
847
+ data: null;
848
+ error: ErrorResponse;
849
+ };
850
+
704
851
  declare class ApiKeys {
705
852
  private readonly resend;
706
853
  constructor(resend: Resend);
@@ -725,79 +872,6 @@ declare class Batch {
725
872
  create<Options extends CreateBatchRequestOptions>(payload: CreateBatchOptions, options?: Options): Promise<CreateBatchResponse<Options>>;
726
873
  }
727
874
 
728
- interface Broadcast {
729
- id: string;
730
- name: string;
731
- audience_id: string | null;
732
- from: string | null;
733
- subject: string | null;
734
- reply_to: string[] | null;
735
- preview_text: string | null;
736
- status: 'draft' | 'sent' | 'queued';
737
- created_at: string;
738
- scheduled_at: string | null;
739
- sent_at: string | null;
740
- }
741
-
742
- interface GetBroadcastResponseSuccess extends Broadcast {
743
- object: 'broadcast';
744
- }
745
- type GetBroadcastResponse = {
746
- data: GetBroadcastResponseSuccess;
747
- error: null;
748
- } | {
749
- data: null;
750
- error: ErrorResponse;
751
- };
752
-
753
- type ListBroadcastsOptions = PaginationOptions;
754
- type ListBroadcastsResponseSuccess = {
755
- object: 'list';
756
- has_more: boolean;
757
- data: Pick<Broadcast, 'id' | 'name' | 'audience_id' | 'status' | 'created_at' | 'scheduled_at' | 'sent_at'>[];
758
- };
759
- type ListBroadcastsResponse = {
760
- data: ListBroadcastsResponseSuccess;
761
- error: null;
762
- } | {
763
- data: null;
764
- error: ErrorResponse;
765
- };
766
-
767
- interface RemoveBroadcastResponseSuccess extends Pick<Broadcast, 'id'> {
768
- object: 'broadcast';
769
- deleted: boolean;
770
- }
771
- type RemoveBroadcastResponse = {
772
- data: RemoveBroadcastResponseSuccess;
773
- error: null;
774
- } | {
775
- data: null;
776
- error: ErrorResponse;
777
- };
778
-
779
- interface UpdateBroadcastResponseSuccess {
780
- id: string;
781
- }
782
- type UpdateBroadcastOptions = {
783
- name?: string;
784
- audienceId?: string;
785
- from?: string;
786
- html?: string;
787
- react?: React.ReactNode;
788
- text?: string;
789
- subject?: string;
790
- replyTo?: string[];
791
- previewText?: string;
792
- };
793
- type UpdateBroadcastResponse = {
794
- data: UpdateBroadcastResponseSuccess;
795
- error: null;
796
- } | {
797
- data: null;
798
- error: ErrorResponse;
799
- };
800
-
801
875
  declare class Broadcasts {
802
876
  private readonly resend;
803
877
  constructor(resend: Resend);
@@ -809,13 +883,6 @@ declare class Broadcasts {
809
883
  update(id: string, payload: UpdateBroadcastOptions): Promise<UpdateBroadcastResponse>;
810
884
  }
811
885
 
812
- interface PatchOptions {
813
- query?: {
814
- [key: string]: unknown;
815
- };
816
- headers?: HeadersInit;
817
- }
818
-
819
886
  declare class Contacts {
820
887
  private readonly resend;
821
888
  constructor(resend: Resend);
@@ -837,18 +904,6 @@ declare class Domains {
837
904
  verify(id: string): Promise<VerifyDomainsResponse>;
838
905
  }
839
906
 
840
- interface CancelEmailResponseSuccess {
841
- object: 'email';
842
- id: string;
843
- }
844
- type CancelEmailResponse = {
845
- data: CancelEmailResponseSuccess;
846
- error: null;
847
- } | {
848
- data: null;
849
- error: ErrorResponse;
850
- };
851
-
852
907
  type ListEmailsOptions = PaginationOptions;
853
908
  type ListEmail = Omit<GetEmailResponseSuccess, 'html' | 'text' | 'tags' | 'object'>;
854
909
  type ListEmailsResponseSuccess = {
@@ -864,22 +919,6 @@ type ListEmailsResponse = {
864
919
  error: ErrorResponse;
865
920
  };
866
921
 
867
- interface UpdateEmailOptions {
868
- id: string;
869
- scheduledAt: string;
870
- }
871
- interface UpdateEmailResponseSuccess {
872
- id: string;
873
- object: 'email';
874
- }
875
- type UpdateEmailResponse = {
876
- data: UpdateEmailResponseSuccess;
877
- error: null;
878
- } | {
879
- data: null;
880
- error: ErrorResponse;
881
- };
882
-
883
922
  declare class Emails {
884
923
  private readonly resend;
885
924
  constructor(resend: Resend);
@@ -946,4 +985,4 @@ declare class Resend {
946
985
  }>;
947
986
  }
948
987
 
949
- export { type Attachment, type CreateApiKeyOptions, type CreateApiKeyRequestOptions, type CreateApiKeyResponse, type CreateApiKeyResponseSuccess, type CreateAudienceOptions, type CreateAudienceRequestOptions, type CreateAudienceResponse, type CreateAudienceResponseSuccess, 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 ErrorResponse, type GetAudienceResponse, type GetAudienceResponseSuccess, type GetContactOptions, type GetContactResponse, type GetContactResponseSuccess, type GetDomainResponse, type GetDomainResponseSuccess, type GetEmailResponse, type GetEmailResponseSuccess, type ListApiKeysOptions, type ListApiKeysResponse, type ListApiKeysResponseSuccess, type ListAudiencesOptions, type ListAudiencesResponse, type ListAudiencesResponseSuccess, type ListContactsOptions, type ListContactsResponse, type ListContactsResponseSuccess, type ListDomainsOptions, type ListDomainsResponse, type ListDomainsResponseSuccess, type PaginationOptions, type RemoveApiKeyResponse, type RemoveApiKeyResponseSuccess, type RemoveAudiencesResponse, type RemoveAudiencesResponseSuccess, type RemoveContactOptions, type RemoveContactsResponse, type RemoveContactsResponseSuccess, type RemoveDomainsResponse, type RemoveDomainsResponseSuccess, Resend, type SendBroadcastOptions, type SendBroadcastRequestOptions, type SendBroadcastResponse, type SendBroadcastResponseSuccess, type Tag, type UpdateContactOptions, type UpdateContactResponse, type UpdateContactResponseSuccess, type UpdateDomainsOptions, type UpdateDomainsResponse, type UpdateDomainsResponseSuccess, type VerifyDomainsResponse, type VerifyDomainsResponseSuccess };
988
+ export { type ApiKey, type Attachment, type Audience, type Broadcast, type CancelEmailResponse, type CancelEmailResponseSuccess, type Contact, type CreateApiKeyOptions, type CreateApiKeyRequestOptions, type CreateApiKeyResponse, type CreateApiKeyResponseSuccess, type CreateAudienceOptions, type CreateAudienceRequestOptions, type CreateAudienceResponse, type CreateAudienceResponseSuccess, 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 Domain, type DomainApiOptions, type DomainDkimRecord, type DomainNameservers, type DomainRecords, type DomainRegion, type DomainSpfRecord, type DomainStatus, type EmailApiAttachment, type EmailApiOptions, type ErrorResponse, type GetAudienceResponse, type GetAudienceResponseSuccess, type GetBroadcastResponse, type GetBroadcastResponseSuccess, type GetContactOptions, type GetContactResponse, type GetContactResponseSuccess, type GetDomainResponse, type GetDomainResponseSuccess, type GetEmailResponse, type GetEmailResponseSuccess, type GetOptions, type IdempotentRequest, type List, type ListApiKeysOptions, type ListApiKeysResponse, type ListApiKeysResponseSuccess, type ListAudiencesOptions, type ListAudiencesResponse, type ListAudiencesResponseSuccess, type ListBroadcastsOptions, type ListBroadcastsResponse, type ListBroadcastsResponseSuccess, type ListContactsOptions, type ListContactsResponse, type ListContactsResponseSuccess, type ListDomainsOptions, type ListDomainsResponse, type ListDomainsResponseSuccess, type PaginationOptions, type PatchOptions, type PostOptions, type PutOptions, type RemoveApiKeyResponse, type RemoveApiKeyResponseSuccess, type RemoveAudiencesResponse, type RemoveAudiencesResponseSuccess, type RemoveBroadcastResponse, type RemoveBroadcastResponseSuccess, type RemoveContactOptions, type RemoveContactsResponse, type RemoveContactsResponseSuccess, type RemoveDomainsResponse, type RemoveDomainsResponseSuccess, type RequireAtLeastOne, Resend, 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 VerifyDomainsResponse, type VerifyDomainsResponseSuccess };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,87 @@
1
1
  import * as React$1 from 'react';
2
2
 
3
+ interface ApiKey {
4
+ created_at: string;
5
+ id: string;
6
+ name: string;
7
+ }
8
+
9
+ interface DomainApiOptions {
10
+ name: string;
11
+ region?: string;
12
+ custom_return_path?: string;
13
+ }
14
+
15
+ declare const RESEND_ERROR_CODES_BY_KEY: {
16
+ readonly missing_required_field: 422;
17
+ readonly invalid_idempotency_key: 400;
18
+ readonly invalid_idempotent_request: 409;
19
+ readonly concurrent_idempotent_requests: 409;
20
+ readonly invalid_access: 422;
21
+ readonly invalid_parameter: 422;
22
+ readonly invalid_region: 422;
23
+ readonly rate_limit_exceeded: 429;
24
+ readonly missing_api_key: 401;
25
+ readonly invalid_api_key: 403;
26
+ readonly invalid_from_address: 403;
27
+ readonly validation_error: 403;
28
+ readonly not_found: 404;
29
+ readonly method_not_allowed: 405;
30
+ readonly application_error: 500;
31
+ readonly internal_server_error: 500;
32
+ };
33
+ type RESEND_ERROR_CODE_KEY = keyof typeof RESEND_ERROR_CODES_BY_KEY;
34
+ interface ErrorResponse {
35
+ message: string;
36
+ name: RESEND_ERROR_CODE_KEY;
37
+ }
38
+ type Tag$1 = {
39
+ name: string;
40
+ value: string;
41
+ };
42
+
43
+ interface EmailApiAttachment {
44
+ content?: string | Buffer;
45
+ filename?: string | false | undefined;
46
+ path?: string;
47
+ content_type?: string;
48
+ content_id?: string;
49
+ }
50
+ interface EmailApiOptions {
51
+ from: string;
52
+ to: string | string[];
53
+ subject: string;
54
+ region?: string;
55
+ headers?: Record<string, string>;
56
+ html?: string;
57
+ text?: string;
58
+ bcc?: string | string[];
59
+ cc?: string | string[];
60
+ reply_to?: string | string[];
61
+ scheduled_at?: string;
62
+ tags?: Tag$1[];
63
+ attachments?: EmailApiAttachment[];
64
+ }
65
+
3
66
  interface GetOptions {
4
67
  query?: Record<string, unknown>;
5
68
  headers?: HeadersInit;
6
69
  }
7
70
 
71
+ interface IdempotentRequest {
72
+ /**
73
+ * Unique key that ensures the same operation is not processed multiple times.
74
+ * Allows for safe retries without duplicating operations.
75
+ * If provided, will be sent as the `Idempotency-Key` header.
76
+ */
77
+ idempotencyKey?: string;
78
+ }
79
+
80
+ interface List<T> {
81
+ readonly object: 'list';
82
+ data: T[];
83
+ }
84
+
8
85
  type PaginationOptions = {
9
86
  /**
10
87
  * Maximum number of items to return (1-100, default: 20)
@@ -24,6 +101,13 @@ type PaginationOptions = {
24
101
  after?: never;
25
102
  });
26
103
 
104
+ interface PatchOptions {
105
+ query?: {
106
+ [key: string]: unknown;
107
+ };
108
+ headers?: HeadersInit;
109
+ }
110
+
27
111
  interface PostOptions {
28
112
  query?: {
29
113
  [key: string]: unknown;
@@ -38,29 +122,9 @@ interface PutOptions {
38
122
  headers?: HeadersInit;
39
123
  }
40
124
 
41
- declare const RESEND_ERROR_CODES_BY_KEY: {
42
- readonly missing_required_field: 422;
43
- readonly invalid_idempotency_key: 400;
44
- readonly invalid_idempotent_request: 409;
45
- readonly concurrent_idempotent_requests: 409;
46
- readonly invalid_access: 422;
47
- readonly invalid_parameter: 422;
48
- readonly invalid_region: 422;
49
- readonly rate_limit_exceeded: 429;
50
- readonly missing_api_key: 401;
51
- readonly invalid_api_key: 403;
52
- readonly invalid_from_address: 403;
53
- readonly validation_error: 403;
54
- readonly not_found: 404;
55
- readonly method_not_allowed: 405;
56
- readonly application_error: 500;
57
- readonly internal_server_error: 500;
58
- };
59
- type RESEND_ERROR_CODE_KEY = keyof typeof RESEND_ERROR_CODES_BY_KEY;
60
- interface ErrorResponse {
61
- message: string;
62
- name: RESEND_ERROR_CODE_KEY;
63
- }
125
+ type RequireAtLeastOne<T> = {
126
+ [K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>;
127
+ }[keyof T];
64
128
 
65
129
  interface CreateApiKeyOptions {
66
130
  name: string;
@@ -81,12 +145,6 @@ type CreateApiKeyResponse = {
81
145
  error: ErrorResponse;
82
146
  };
83
147
 
84
- interface ApiKey {
85
- created_at: string;
86
- id: string;
87
- name: string;
88
- }
89
-
90
148
  type ListApiKeysOptions = PaginationOptions;
91
149
  type ListApiKeysResponseSuccess = {
92
150
  object: 'list';
@@ -169,19 +227,6 @@ type RemoveAudiencesResponse = {
169
227
  error: ErrorResponse;
170
228
  };
171
229
 
172
- interface IdempotentRequest {
173
- /**
174
- * Unique key that ensures the same operation is not processed multiple times.
175
- * Allows for safe retries without duplicating operations.
176
- * If provided, will be sent as the `Idempotency-Key` header.
177
- */
178
- idempotencyKey?: string;
179
- }
180
-
181
- type RequireAtLeastOne<T> = {
182
- [K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>;
183
- }[keyof T];
184
-
185
230
  interface EmailRenderOptions$1 {
186
231
  /**
187
232
  * The React component used to write the message.
@@ -340,6 +385,20 @@ type CreateBatchResponse<Options extends CreateBatchRequestOptions> = {
340
385
  error: ErrorResponse;
341
386
  };
342
387
 
388
+ interface Broadcast {
389
+ id: string;
390
+ name: string;
391
+ audience_id: string | null;
392
+ from: string | null;
393
+ subject: string | null;
394
+ reply_to: string[] | null;
395
+ preview_text: string | null;
396
+ status: 'draft' | 'sent' | 'queued';
397
+ created_at: string;
398
+ scheduled_at: string | null;
399
+ sent_at: string | null;
400
+ }
401
+
343
402
  interface EmailRenderOptions {
344
403
  /**
345
404
  * The React component used to write the message.
@@ -413,6 +472,43 @@ type CreateBroadcastResponse = {
413
472
  error: ErrorResponse;
414
473
  };
415
474
 
475
+ interface GetBroadcastResponseSuccess extends Broadcast {
476
+ object: 'broadcast';
477
+ }
478
+ type GetBroadcastResponse = {
479
+ data: GetBroadcastResponseSuccess;
480
+ error: null;
481
+ } | {
482
+ data: null;
483
+ error: ErrorResponse;
484
+ };
485
+
486
+ type ListBroadcastsOptions = PaginationOptions;
487
+ type ListBroadcastsResponseSuccess = {
488
+ object: 'list';
489
+ has_more: boolean;
490
+ data: Pick<Broadcast, 'id' | 'name' | 'audience_id' | 'status' | 'created_at' | 'scheduled_at' | 'sent_at'>[];
491
+ };
492
+ type ListBroadcastsResponse = {
493
+ data: ListBroadcastsResponseSuccess;
494
+ error: null;
495
+ } | {
496
+ data: null;
497
+ error: ErrorResponse;
498
+ };
499
+
500
+ interface RemoveBroadcastResponseSuccess extends Pick<Broadcast, 'id'> {
501
+ object: 'broadcast';
502
+ deleted: boolean;
503
+ }
504
+ type RemoveBroadcastResponse = {
505
+ data: RemoveBroadcastResponseSuccess;
506
+ error: null;
507
+ } | {
508
+ data: null;
509
+ error: ErrorResponse;
510
+ };
511
+
416
512
  interface SendBroadcastBaseOptions {
417
513
  /**
418
514
  * Schedule email to be sent later.
@@ -438,6 +534,28 @@ type SendBroadcastResponse = {
438
534
  error: ErrorResponse;
439
535
  };
440
536
 
537
+ interface UpdateBroadcastResponseSuccess {
538
+ id: string;
539
+ }
540
+ type UpdateBroadcastOptions = {
541
+ name?: string;
542
+ audienceId?: string;
543
+ from?: string;
544
+ html?: string;
545
+ react?: React.ReactNode;
546
+ text?: string;
547
+ subject?: string;
548
+ replyTo?: string[];
549
+ previewText?: string;
550
+ };
551
+ type UpdateBroadcastResponse = {
552
+ data: UpdateBroadcastResponseSuccess;
553
+ error: null;
554
+ } | {
555
+ data: null;
556
+ error: ErrorResponse;
557
+ };
558
+
441
559
  interface Contact {
442
560
  created_at: string;
443
561
  id: string;
@@ -558,6 +676,7 @@ type UpdateContactResponse = {
558
676
  };
559
677
 
560
678
  type DomainRegion = 'us-east-1' | 'eu-west-1' | 'sa-east-1' | 'ap-northeast-1';
679
+ type DomainNameservers = 'Amazon Route 53' | 'Cloudflare' | 'Digital Ocean' | 'GoDaddy' | 'Google Domains' | 'Namecheap' | 'Unidentified' | 'Vercel';
561
680
  type DomainStatus = 'pending' | 'verified' | 'failed' | 'temporary_failure' | 'not_started';
562
681
  type DomainRecords = DomainSpfRecord | DomainDkimRecord;
563
682
  interface DomainSpfRecord {
@@ -674,6 +793,18 @@ type VerifyDomainsResponse = {
674
793
  error: ErrorResponse;
675
794
  };
676
795
 
796
+ interface CancelEmailResponseSuccess {
797
+ object: 'email';
798
+ id: string;
799
+ }
800
+ type CancelEmailResponse = {
801
+ data: CancelEmailResponseSuccess;
802
+ error: null;
803
+ } | {
804
+ data: null;
805
+ error: ErrorResponse;
806
+ };
807
+
677
808
  interface GetEmailResponseSuccess {
678
809
  bcc: string[] | null;
679
810
  cc: string[] | null;
@@ -701,6 +832,22 @@ type GetEmailResponse = {
701
832
  error: ErrorResponse;
702
833
  };
703
834
 
835
+ interface UpdateEmailOptions {
836
+ id: string;
837
+ scheduledAt: string;
838
+ }
839
+ interface UpdateEmailResponseSuccess {
840
+ id: string;
841
+ object: 'email';
842
+ }
843
+ type UpdateEmailResponse = {
844
+ data: UpdateEmailResponseSuccess;
845
+ error: null;
846
+ } | {
847
+ data: null;
848
+ error: ErrorResponse;
849
+ };
850
+
704
851
  declare class ApiKeys {
705
852
  private readonly resend;
706
853
  constructor(resend: Resend);
@@ -725,79 +872,6 @@ declare class Batch {
725
872
  create<Options extends CreateBatchRequestOptions>(payload: CreateBatchOptions, options?: Options): Promise<CreateBatchResponse<Options>>;
726
873
  }
727
874
 
728
- interface Broadcast {
729
- id: string;
730
- name: string;
731
- audience_id: string | null;
732
- from: string | null;
733
- subject: string | null;
734
- reply_to: string[] | null;
735
- preview_text: string | null;
736
- status: 'draft' | 'sent' | 'queued';
737
- created_at: string;
738
- scheduled_at: string | null;
739
- sent_at: string | null;
740
- }
741
-
742
- interface GetBroadcastResponseSuccess extends Broadcast {
743
- object: 'broadcast';
744
- }
745
- type GetBroadcastResponse = {
746
- data: GetBroadcastResponseSuccess;
747
- error: null;
748
- } | {
749
- data: null;
750
- error: ErrorResponse;
751
- };
752
-
753
- type ListBroadcastsOptions = PaginationOptions;
754
- type ListBroadcastsResponseSuccess = {
755
- object: 'list';
756
- has_more: boolean;
757
- data: Pick<Broadcast, 'id' | 'name' | 'audience_id' | 'status' | 'created_at' | 'scheduled_at' | 'sent_at'>[];
758
- };
759
- type ListBroadcastsResponse = {
760
- data: ListBroadcastsResponseSuccess;
761
- error: null;
762
- } | {
763
- data: null;
764
- error: ErrorResponse;
765
- };
766
-
767
- interface RemoveBroadcastResponseSuccess extends Pick<Broadcast, 'id'> {
768
- object: 'broadcast';
769
- deleted: boolean;
770
- }
771
- type RemoveBroadcastResponse = {
772
- data: RemoveBroadcastResponseSuccess;
773
- error: null;
774
- } | {
775
- data: null;
776
- error: ErrorResponse;
777
- };
778
-
779
- interface UpdateBroadcastResponseSuccess {
780
- id: string;
781
- }
782
- type UpdateBroadcastOptions = {
783
- name?: string;
784
- audienceId?: string;
785
- from?: string;
786
- html?: string;
787
- react?: React.ReactNode;
788
- text?: string;
789
- subject?: string;
790
- replyTo?: string[];
791
- previewText?: string;
792
- };
793
- type UpdateBroadcastResponse = {
794
- data: UpdateBroadcastResponseSuccess;
795
- error: null;
796
- } | {
797
- data: null;
798
- error: ErrorResponse;
799
- };
800
-
801
875
  declare class Broadcasts {
802
876
  private readonly resend;
803
877
  constructor(resend: Resend);
@@ -809,13 +883,6 @@ declare class Broadcasts {
809
883
  update(id: string, payload: UpdateBroadcastOptions): Promise<UpdateBroadcastResponse>;
810
884
  }
811
885
 
812
- interface PatchOptions {
813
- query?: {
814
- [key: string]: unknown;
815
- };
816
- headers?: HeadersInit;
817
- }
818
-
819
886
  declare class Contacts {
820
887
  private readonly resend;
821
888
  constructor(resend: Resend);
@@ -837,18 +904,6 @@ declare class Domains {
837
904
  verify(id: string): Promise<VerifyDomainsResponse>;
838
905
  }
839
906
 
840
- interface CancelEmailResponseSuccess {
841
- object: 'email';
842
- id: string;
843
- }
844
- type CancelEmailResponse = {
845
- data: CancelEmailResponseSuccess;
846
- error: null;
847
- } | {
848
- data: null;
849
- error: ErrorResponse;
850
- };
851
-
852
907
  type ListEmailsOptions = PaginationOptions;
853
908
  type ListEmail = Omit<GetEmailResponseSuccess, 'html' | 'text' | 'tags' | 'object'>;
854
909
  type ListEmailsResponseSuccess = {
@@ -864,22 +919,6 @@ type ListEmailsResponse = {
864
919
  error: ErrorResponse;
865
920
  };
866
921
 
867
- interface UpdateEmailOptions {
868
- id: string;
869
- scheduledAt: string;
870
- }
871
- interface UpdateEmailResponseSuccess {
872
- id: string;
873
- object: 'email';
874
- }
875
- type UpdateEmailResponse = {
876
- data: UpdateEmailResponseSuccess;
877
- error: null;
878
- } | {
879
- data: null;
880
- error: ErrorResponse;
881
- };
882
-
883
922
  declare class Emails {
884
923
  private readonly resend;
885
924
  constructor(resend: Resend);
@@ -946,4 +985,4 @@ declare class Resend {
946
985
  }>;
947
986
  }
948
987
 
949
- export { type Attachment, type CreateApiKeyOptions, type CreateApiKeyRequestOptions, type CreateApiKeyResponse, type CreateApiKeyResponseSuccess, type CreateAudienceOptions, type CreateAudienceRequestOptions, type CreateAudienceResponse, type CreateAudienceResponseSuccess, 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 ErrorResponse, type GetAudienceResponse, type GetAudienceResponseSuccess, type GetContactOptions, type GetContactResponse, type GetContactResponseSuccess, type GetDomainResponse, type GetDomainResponseSuccess, type GetEmailResponse, type GetEmailResponseSuccess, type ListApiKeysOptions, type ListApiKeysResponse, type ListApiKeysResponseSuccess, type ListAudiencesOptions, type ListAudiencesResponse, type ListAudiencesResponseSuccess, type ListContactsOptions, type ListContactsResponse, type ListContactsResponseSuccess, type ListDomainsOptions, type ListDomainsResponse, type ListDomainsResponseSuccess, type PaginationOptions, type RemoveApiKeyResponse, type RemoveApiKeyResponseSuccess, type RemoveAudiencesResponse, type RemoveAudiencesResponseSuccess, type RemoveContactOptions, type RemoveContactsResponse, type RemoveContactsResponseSuccess, type RemoveDomainsResponse, type RemoveDomainsResponseSuccess, Resend, type SendBroadcastOptions, type SendBroadcastRequestOptions, type SendBroadcastResponse, type SendBroadcastResponseSuccess, type Tag, type UpdateContactOptions, type UpdateContactResponse, type UpdateContactResponseSuccess, type UpdateDomainsOptions, type UpdateDomainsResponse, type UpdateDomainsResponseSuccess, type VerifyDomainsResponse, type VerifyDomainsResponseSuccess };
988
+ export { type ApiKey, type Attachment, type Audience, type Broadcast, type CancelEmailResponse, type CancelEmailResponseSuccess, type Contact, type CreateApiKeyOptions, type CreateApiKeyRequestOptions, type CreateApiKeyResponse, type CreateApiKeyResponseSuccess, type CreateAudienceOptions, type CreateAudienceRequestOptions, type CreateAudienceResponse, type CreateAudienceResponseSuccess, 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 Domain, type DomainApiOptions, type DomainDkimRecord, type DomainNameservers, type DomainRecords, type DomainRegion, type DomainSpfRecord, type DomainStatus, type EmailApiAttachment, type EmailApiOptions, type ErrorResponse, type GetAudienceResponse, type GetAudienceResponseSuccess, type GetBroadcastResponse, type GetBroadcastResponseSuccess, type GetContactOptions, type GetContactResponse, type GetContactResponseSuccess, type GetDomainResponse, type GetDomainResponseSuccess, type GetEmailResponse, type GetEmailResponseSuccess, type GetOptions, type IdempotentRequest, type List, type ListApiKeysOptions, type ListApiKeysResponse, type ListApiKeysResponseSuccess, type ListAudiencesOptions, type ListAudiencesResponse, type ListAudiencesResponseSuccess, type ListBroadcastsOptions, type ListBroadcastsResponse, type ListBroadcastsResponseSuccess, type ListContactsOptions, type ListContactsResponse, type ListContactsResponseSuccess, type ListDomainsOptions, type ListDomainsResponse, type ListDomainsResponseSuccess, type PaginationOptions, type PatchOptions, type PostOptions, type PutOptions, type RemoveApiKeyResponse, type RemoveApiKeyResponseSuccess, type RemoveAudiencesResponse, type RemoveAudiencesResponseSuccess, type RemoveBroadcastResponse, type RemoveBroadcastResponseSuccess, type RemoveContactOptions, type RemoveContactsResponse, type RemoveContactsResponseSuccess, type RemoveDomainsResponse, type RemoveDomainsResponseSuccess, type RequireAtLeastOne, Resend, 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 VerifyDomainsResponse, type VerifyDomainsResponseSuccess };
package/dist/index.js CHANGED
@@ -84,7 +84,7 @@ __export(index_exports, {
84
84
  module.exports = __toCommonJS(index_exports);
85
85
 
86
86
  // package.json
87
- var version = "6.1.0";
87
+ var version = "6.1.2";
88
88
 
89
89
  // src/common/utils/build-pagination-query.ts
90
90
  function buildPaginationQuery(options) {
@@ -210,7 +210,7 @@ function render(node) {
210
210
  }).catch(() => {
211
211
  reject(
212
212
  Error(
213
- "Failed to render React component. Make sure to install `@react-email/render`"
213
+ "Failed to render React component. Make sure to install `@react-email/render` or `@react-email/components`."
214
214
  )
215
215
  );
216
216
  });
@@ -699,7 +699,8 @@ var Resend = class {
699
699
  return __async(this, null, function* () {
700
700
  const requestOptions = {
701
701
  method: "DELETE",
702
- body: JSON.stringify(query)
702
+ body: JSON.stringify(query),
703
+ headers: this.headers
703
704
  };
704
705
  return this.fetchRequest(path, requestOptions);
705
706
  });
package/dist/index.mjs CHANGED
@@ -51,7 +51,7 @@ var __async = (__this, __arguments, generator) => {
51
51
  };
52
52
 
53
53
  // package.json
54
- var version = "6.1.0";
54
+ var version = "6.1.2";
55
55
 
56
56
  // src/common/utils/build-pagination-query.ts
57
57
  function buildPaginationQuery(options) {
@@ -177,7 +177,7 @@ function render(node) {
177
177
  }).catch(() => {
178
178
  reject(
179
179
  Error(
180
- "Failed to render React component. Make sure to install `@react-email/render`"
180
+ "Failed to render React component. Make sure to install `@react-email/render` or `@react-email/components`."
181
181
  )
182
182
  );
183
183
  });
@@ -666,7 +666,8 @@ var Resend = class {
666
666
  return __async(this, null, function* () {
667
667
  const requestOptions = {
668
668
  method: "DELETE",
669
- body: JSON.stringify(query)
669
+ body: JSON.stringify(query),
670
+ headers: this.headers
670
671
  };
671
672
  return this.fetchRequest(path, requestOptions);
672
673
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resend",
3
- "version": "6.1.0",
3
+ "version": "6.1.2",
4
4
  "description": "Node.js library for the Resend API",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "homepage": "https://github.com/resendlabs/resend-node#readme",
36
36
  "peerDependencies": {
37
- "@react-email/render": "^1.1.0"
37
+ "@react-email/render": "*"
38
38
  },
39
39
  "peerDependenciesMeta": {
40
40
  "@react-email/render": {
@@ -43,9 +43,9 @@
43
43
  },
44
44
  "devDependencies": {
45
45
  "@biomejs/biome": "2.2.0",
46
- "@types/node": "22.17.2",
47
- "@types/react": "19.1.10",
48
- "pkg-pr-new": "0.0.56",
46
+ "@types/node": "22.18.6",
47
+ "@types/react": "19.1.15",
48
+ "pkg-pr-new": "0.0.60",
49
49
  "tsup": "8.5.0",
50
50
  "typescript": "5.9.2",
51
51
  "vitest": "3.2.4",
package/readme.md CHANGED
@@ -119,7 +119,20 @@ console.log(`Email ${data.id} with a React template has been sent`);
119
119
  ```
120
120
 
121
121
  > [!NOTE]
122
- > If your endpoint is a JS/TS file, render the template (i.e., pass `EmailTemplate({ firstName: "John", product: "MyApp" })` instead of the component).
122
+ > If you're sending emails from a file that doesn't have JSX transpilation set up (e.g., in a `.js`/`.ts` file instead of JSX/TSX), use React's `jsx` runtime function instead of passing the component as JSX:
123
+ >
124
+ >```js
125
+ >import { jsx } from 'react/jsx-runtime'
126
+ >import EmailTemplate from '../components/EmailTemplate';
127
+ >
128
+ >await resend.emails.send({
129
+ > from: 'you@example.com',
130
+ > to: 'user@gmail.com',
131
+ > replyTo: 'you@example.com',
132
+ > subject: 'hello world',
133
+ > react: jsx(EmailTemplate, { firstName:"John", product:"MyApp" }),
134
+ >});
135
+ >```
123
136
 
124
137
  ## License
125
138