resend 6.2.0-preview-contacts.0 → 6.2.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
@@ -1,42 +1,17 @@
1
1
  import * as React$1 from 'react';
2
2
 
3
- interface GetOptions {
4
- query?: Record<string, unknown>;
5
- }
6
-
7
- interface PostOptions {
8
- query?: {
9
- [key: string]: unknown;
10
- };
3
+ interface ApiKey {
4
+ created_at: string;
5
+ id: string;
6
+ name: string;
11
7
  }
12
8
 
13
- interface PutOptions {
14
- query?: {
15
- [key: string]: unknown;
16
- };
9
+ interface DomainApiOptions {
10
+ name: string;
11
+ region?: string;
12
+ custom_return_path?: string;
17
13
  }
18
14
 
19
- type RateLimit = {
20
- /**
21
- * The maximum amount of requests that can be made in the time window of {@link shouldResetAfter}.
22
- */
23
- limit: number;
24
- /**
25
- * The amount of requests that can still be made before hitting {@link RateLimit.limit}.
26
- *
27
- * Resets after the seconds in {@link RateLimit.shouldResetAfter} go by.
28
- */
29
- remainingRequests: number;
30
- /**
31
- * The number of seconds after which the rate limiting will reset,
32
- * and {@link RateLimit.remainingRequests} goes back to the value of
33
- * {@link RateLimit.limit}.
34
- *
35
- * @see {@link import('./interfaces').Response.retryAfter}
36
- */
37
- shouldResetAfter: number;
38
- };
39
-
40
15
  declare const RESEND_ERROR_CODES_BY_KEY: {
41
16
  readonly missing_required_field: 422;
42
17
  readonly invalid_idempotency_key: 400;
@@ -47,7 +22,8 @@ declare const RESEND_ERROR_CODES_BY_KEY: {
47
22
  readonly invalid_region: 422;
48
23
  readonly rate_limit_exceeded: 429;
49
24
  readonly missing_api_key: 401;
50
- readonly invalid_api_Key: 403;
25
+ readonly invalid_api_key: 403;
26
+ readonly suspended_api_key: 403;
51
27
  readonly invalid_from_address: 403;
52
28
  readonly validation_error: 403;
53
29
  readonly not_found: 404;
@@ -56,26 +32,100 @@ declare const RESEND_ERROR_CODES_BY_KEY: {
56
32
  readonly internal_server_error: 500;
57
33
  };
58
34
  type RESEND_ERROR_CODE_KEY = keyof typeof RESEND_ERROR_CODES_BY_KEY;
59
- type ErrorResponse = {
35
+ interface ErrorResponse {
60
36
  message: string;
61
- name: Exclude<RESEND_ERROR_CODE_KEY, 'rate_limit_exceeded'>;
62
- } | {
63
- message: string;
64
- name: Extract<RESEND_ERROR_CODE_KEY, 'rate_limit_exceeded'>;
37
+ name: RESEND_ERROR_CODE_KEY;
38
+ }
39
+ type Tag$1 = {
40
+ name: string;
41
+ value: string;
42
+ };
43
+
44
+ interface EmailApiAttachment {
45
+ content?: string | Buffer;
46
+ filename?: string | false | undefined;
47
+ path?: string;
48
+ content_type?: string;
49
+ content_id?: string;
50
+ }
51
+ interface EmailApiOptions {
52
+ from: string;
53
+ to: string | string[];
54
+ subject: string;
55
+ region?: string;
56
+ headers?: Record<string, string>;
57
+ html?: string;
58
+ text?: string;
59
+ bcc?: string | string[];
60
+ cc?: string | string[];
61
+ reply_to?: string | string[];
62
+ scheduled_at?: string;
63
+ tags?: Tag$1[];
64
+ attachments?: EmailApiAttachment[];
65
+ }
66
+
67
+ interface GetOptions {
68
+ query?: Record<string, unknown>;
69
+ headers?: HeadersInit;
70
+ }
71
+
72
+ interface IdempotentRequest {
65
73
  /**
66
- * Time in seconds.
74
+ * Unique key that ensures the same operation is not processed multiple times.
75
+ * Allows for safe retries without duplicating operations.
76
+ * If provided, will be sent as the `Idempotency-Key` header.
67
77
  */
68
- retryAfter: number;
69
- };
70
- type Response<Data> = {
71
- data: Data;
72
- rateLimiting: RateLimit;
73
- error: null;
78
+ idempotencyKey?: string;
79
+ }
80
+
81
+ interface List<T> {
82
+ readonly object: 'list';
83
+ data: T[];
84
+ }
85
+
86
+ type PaginationOptions = {
87
+ /**
88
+ * Maximum number of items to return (1-100, default: 20)
89
+ */
90
+ limit?: number;
91
+ } & ({
92
+ /**
93
+ * Get items after this cursor (cannot be used with 'before')
94
+ */
95
+ after?: string;
96
+ before?: never;
74
97
  } | {
75
- data: null;
76
- rateLimiting: RateLimit | null;
77
- error: ErrorResponse;
78
- };
98
+ /**
99
+ * Get items before this cursor (cannot be used with 'after')
100
+ */
101
+ before?: string;
102
+ after?: never;
103
+ });
104
+
105
+ interface PatchOptions {
106
+ query?: {
107
+ [key: string]: unknown;
108
+ };
109
+ headers?: HeadersInit;
110
+ }
111
+
112
+ interface PostOptions {
113
+ query?: {
114
+ [key: string]: unknown;
115
+ };
116
+ headers?: HeadersInit;
117
+ }
118
+
119
+ interface PutOptions {
120
+ query?: {
121
+ [key: string]: unknown;
122
+ };
123
+ headers?: HeadersInit;
124
+ }
125
+
126
+ type RequireAtLeastOne<T> = {
127
+ [K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>;
128
+ }[keyof T];
79
129
 
80
130
  interface CreateApiKeyOptions {
81
131
  name: string;
@@ -88,19 +138,36 @@ interface CreateApiKeyResponseSuccess {
88
138
  token: string;
89
139
  id: string;
90
140
  }
91
- type CreateApiKeyResponse = Response<CreateApiKeyResponseSuccess>;
92
-
93
- interface ApiKey {
94
- created_at: string;
95
- id: string;
96
- name: string;
97
- }
141
+ type CreateApiKeyResponse = {
142
+ data: CreateApiKeyResponseSuccess;
143
+ error: null;
144
+ } | {
145
+ data: null;
146
+ error: ErrorResponse;
147
+ };
98
148
 
99
- type ListApiKeysResponseSuccess = Pick<ApiKey, 'name' | 'id' | 'created_at'>[];
100
- type ListApiKeysResponse = Response<ListApiKeysResponseSuccess>;
149
+ type ListApiKeysOptions = PaginationOptions;
150
+ type ListApiKeysResponseSuccess = {
151
+ object: 'list';
152
+ has_more: boolean;
153
+ data: Pick<ApiKey, 'name' | 'id' | 'created_at'>[];
154
+ };
155
+ type ListApiKeysResponse = {
156
+ data: ListApiKeysResponseSuccess;
157
+ error: null;
158
+ } | {
159
+ data: null;
160
+ error: ErrorResponse;
161
+ };
101
162
 
102
163
  type RemoveApiKeyResponseSuccess = {};
103
- type RemoveApiKeyResponse = Response<RemoveApiKeyResponseSuccess>;
164
+ type RemoveApiKeyResponse = {
165
+ data: RemoveApiKeyResponseSuccess;
166
+ error: null;
167
+ } | {
168
+ data: null;
169
+ error: ErrorResponse;
170
+ };
104
171
 
105
172
  interface Audience {
106
173
  created_at: string;
@@ -116,37 +183,50 @@ interface CreateAudienceRequestOptions extends PostOptions {
116
183
  interface CreateAudienceResponseSuccess extends Pick<Audience, 'name' | 'id'> {
117
184
  object: 'audience';
118
185
  }
119
- type CreateAudienceResponse = Response<CreateAudienceResponseSuccess>;
186
+ type CreateAudienceResponse = {
187
+ data: CreateAudienceResponseSuccess;
188
+ error: null;
189
+ } | {
190
+ data: null;
191
+ error: ErrorResponse;
192
+ };
120
193
 
121
194
  interface GetAudienceResponseSuccess extends Pick<Audience, 'id' | 'name' | 'created_at'> {
122
195
  object: 'audience';
123
196
  }
124
- type GetAudienceResponse = Response<GetAudienceResponseSuccess>;
197
+ type GetAudienceResponse = {
198
+ data: GetAudienceResponseSuccess;
199
+ error: null;
200
+ } | {
201
+ data: null;
202
+ error: ErrorResponse;
203
+ };
125
204
 
205
+ type ListAudiencesOptions = PaginationOptions;
126
206
  type ListAudiencesResponseSuccess = {
127
207
  object: 'list';
128
208
  data: Audience[];
209
+ has_more: boolean;
210
+ };
211
+ type ListAudiencesResponse = {
212
+ data: ListAudiencesResponseSuccess;
213
+ error: null;
214
+ } | {
215
+ data: null;
216
+ error: ErrorResponse;
129
217
  };
130
- type ListAudiencesResponse = Response<ListAudiencesResponseSuccess>;
131
218
 
132
219
  interface RemoveAudiencesResponseSuccess extends Pick<Audience, 'id'> {
133
220
  object: 'audience';
134
221
  deleted: boolean;
135
222
  }
136
- type RemoveAudiencesResponse = Response<RemoveAudiencesResponseSuccess>;
137
-
138
- interface IdempotentRequest {
139
- /**
140
- * Unique key that ensures the same operation is not processed multiple times.
141
- * Allows for safe retries without duplicating operations.
142
- * If provided, will be sent as the `Idempotency-Key` header.
143
- */
144
- idempotencyKey?: string;
145
- }
146
-
147
- type RequireAtLeastOne<T> = {
148
- [K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>;
149
- }[keyof T];
223
+ type RemoveAudiencesResponse = {
224
+ data: RemoveAudiencesResponseSuccess;
225
+ error: null;
226
+ } | {
227
+ data: null;
228
+ error: ErrorResponse;
229
+ };
150
230
 
151
231
  interface EmailRenderOptions$1 {
152
232
  /**
@@ -223,12 +303,6 @@ interface CreateEmailBaseOptions {
223
303
  * @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
224
304
  */
225
305
  to: string | string[];
226
- /**
227
- * The id of the topic you want to send to
228
- *
229
- * @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
230
- */
231
- topicId?: string | null;
232
306
  /**
233
307
  * Schedule email to be sent later.
234
308
  * The date should be in ISO 8601 format (e.g: 2024-08-05T11:52:01.858Z).
@@ -244,7 +318,13 @@ interface CreateEmailResponseSuccess {
244
318
  /** The ID of the newly created email. */
245
319
  id: string;
246
320
  }
247
- type CreateEmailResponse = Response<CreateEmailResponseSuccess>;
321
+ type CreateEmailResponse = {
322
+ data: CreateEmailResponseSuccess;
323
+ error: null;
324
+ } | {
325
+ data: null;
326
+ error: ErrorResponse;
327
+ };
248
328
  interface Attachment {
249
329
  /** Content of an attached file. */
250
330
  content?: string | Buffer;
@@ -273,14 +353,54 @@ type Tag = {
273
353
 
274
354
  type CreateBatchOptions = CreateEmailOptions[];
275
355
  interface CreateBatchRequestOptions extends PostOptions, IdempotentRequest {
356
+ /**
357
+ * @default 'strict'
358
+ */
359
+ batchValidation?: 'strict' | 'permissive';
276
360
  }
277
- interface CreateBatchSuccessResponse {
361
+ type CreateBatchSuccessResponse<Options extends CreateBatchRequestOptions = CreateBatchRequestOptions> = {
278
362
  data: {
279
363
  /** The ID of the newly created email. */
280
364
  id: string;
281
365
  }[];
366
+ } & (Options['batchValidation'] extends 'permissive' ? {
367
+ /**
368
+ * Only present when header "x-batch-validation" is set to 'permissive'.
369
+ */
370
+ errors: {
371
+ /**
372
+ * The index of the failed email in the batch
373
+ */
374
+ index: number;
375
+ /**
376
+ * The error message for the failed email
377
+ */
378
+ message: string;
379
+ }[];
380
+ } : Record<string, never>);
381
+ type CreateBatchResponse<Options extends CreateBatchRequestOptions> = {
382
+ data: CreateBatchSuccessResponse<Options>;
383
+ error: null;
384
+ } | {
385
+ data: null;
386
+ error: ErrorResponse;
387
+ };
388
+
389
+ interface Broadcast {
390
+ id: string;
391
+ name: string;
392
+ audience_id: string | null;
393
+ from: string | null;
394
+ subject: string | null;
395
+ reply_to: string[] | null;
396
+ preview_text: string | null;
397
+ status: 'draft' | 'sent' | 'queued';
398
+ created_at: string;
399
+ scheduled_at: string | null;
400
+ sent_at: string | null;
401
+ html: string | null;
402
+ text: string | null;
282
403
  }
283
- type CreateBatchResponse = Response<CreateBatchSuccessResponse>;
284
404
 
285
405
  interface EmailRenderOptions {
286
406
  /**
@@ -339,12 +459,6 @@ interface CreateBroadcastBaseOptions {
339
459
  * @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
340
460
  */
341
461
  subject: string;
342
- /**
343
- * The id of the topic you want to send to
344
- *
345
- * @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
346
- */
347
- topicId?: string | null;
348
462
  }
349
463
  type CreateBroadcastOptions = RequireAtLeastOne<EmailRenderOptions> & CreateBroadcastBaseOptions;
350
464
  interface CreateBroadcastRequestOptions extends PostOptions {
@@ -353,7 +467,50 @@ interface CreateBroadcastResponseSuccess {
353
467
  /** The ID of the newly sent broadcasts. */
354
468
  id: string;
355
469
  }
356
- type CreateBroadcastResponse = Response<CreateBroadcastResponseSuccess>;
470
+ type CreateBroadcastResponse = {
471
+ data: CreateBroadcastResponseSuccess;
472
+ error: null;
473
+ } | {
474
+ data: null;
475
+ error: ErrorResponse;
476
+ };
477
+
478
+ interface GetBroadcastResponseSuccess extends Broadcast {
479
+ object: 'broadcast';
480
+ }
481
+ type GetBroadcastResponse = {
482
+ data: GetBroadcastResponseSuccess;
483
+ error: null;
484
+ } | {
485
+ data: null;
486
+ error: ErrorResponse;
487
+ };
488
+
489
+ type ListBroadcastsOptions = PaginationOptions;
490
+ type ListBroadcastsResponseSuccess = {
491
+ object: 'list';
492
+ has_more: boolean;
493
+ data: Pick<Broadcast, 'id' | 'name' | 'audience_id' | 'status' | 'created_at' | 'scheduled_at' | 'sent_at'>[];
494
+ };
495
+ type ListBroadcastsResponse = {
496
+ data: ListBroadcastsResponseSuccess;
497
+ error: null;
498
+ } | {
499
+ data: null;
500
+ error: ErrorResponse;
501
+ };
502
+
503
+ interface RemoveBroadcastResponseSuccess extends Pick<Broadcast, 'id'> {
504
+ object: 'broadcast';
505
+ deleted: boolean;
506
+ }
507
+ type RemoveBroadcastResponse = {
508
+ data: RemoveBroadcastResponseSuccess;
509
+ error: null;
510
+ } | {
511
+ data: null;
512
+ error: ErrorResponse;
513
+ };
357
514
 
358
515
  interface SendBroadcastBaseOptions {
359
516
  /**
@@ -372,7 +529,35 @@ interface SendBroadcastResponseSuccess {
372
529
  /** The ID of the sent broadcast. */
373
530
  id: string;
374
531
  }
375
- type SendBroadcastResponse = Response<SendBroadcastResponseSuccess>;
532
+ type SendBroadcastResponse = {
533
+ data: SendBroadcastResponseSuccess;
534
+ error: null;
535
+ } | {
536
+ data: null;
537
+ error: ErrorResponse;
538
+ };
539
+
540
+ interface UpdateBroadcastResponseSuccess {
541
+ id: string;
542
+ }
543
+ type UpdateBroadcastOptions = {
544
+ name?: string;
545
+ audienceId?: string;
546
+ from?: string;
547
+ html?: string;
548
+ react?: React.ReactNode;
549
+ text?: string;
550
+ subject?: string;
551
+ replyTo?: string[];
552
+ previewText?: string;
553
+ };
554
+ type UpdateBroadcastResponse = {
555
+ data: UpdateBroadcastResponseSuccess;
556
+ error: null;
557
+ } | {
558
+ data: null;
559
+ error: ErrorResponse;
560
+ };
376
561
 
377
562
  interface Contact {
378
563
  created_at: string;
@@ -411,7 +596,7 @@ type SelectingField = {
411
596
  };
412
597
 
413
598
  interface CreateContactOptions {
414
- audienceId?: string;
599
+ audienceId: string;
415
600
  email: string;
416
601
  unsubscribed?: boolean;
417
602
  firstName?: string;
@@ -422,48 +607,43 @@ interface CreateContactRequestOptions extends PostOptions {
422
607
  interface CreateContactResponseSuccess extends Pick<Contact, 'id'> {
423
608
  object: 'contact';
424
609
  }
425
- type CreateContactResponse = Response<CreateContactResponseSuccess>;
610
+ type CreateContactResponse = {
611
+ data: CreateContactResponseSuccess;
612
+ error: null;
613
+ } | {
614
+ data: null;
615
+ error: ErrorResponse;
616
+ };
426
617
 
427
618
  type GetContactOptions = {
428
- audienceId?: string;
619
+ audienceId: string;
429
620
  } & SelectingField;
430
621
  interface GetContactResponseSuccess extends Pick<Contact, 'id' | 'email' | 'created_at' | 'first_name' | 'last_name' | 'unsubscribed'> {
431
622
  object: 'contact';
432
623
  }
433
- type GetContactResponse = Response<GetContactResponseSuccess>;
434
-
435
- type PaginationOptions<IdType> = {
436
- limit?: number;
437
- after?: IdType;
438
- before?: never;
624
+ type GetContactResponse = {
625
+ data: GetContactResponseSuccess;
626
+ error: null;
439
627
  } | {
440
- limit?: number;
441
- before?: IdType;
442
- after?: never;
443
- };
444
- type PaginatedData<Data> = {
445
- object: 'list';
446
- data: Data;
447
- hasMore: boolean;
448
- };
449
- type PaginatedApiResponse<Data> = {
450
- object: 'list';
451
- data: Data;
452
- has_more: boolean;
628
+ data: null;
629
+ error: ErrorResponse;
453
630
  };
454
631
 
455
- interface ListAudienceContactsOptions {
632
+ type ListContactsOptions = {
456
633
  audienceId: string;
457
- }
458
- type ListContactsOptions = PaginationOptions<string>;
459
- interface ListAudienceContactsResponseSuccess {
634
+ } & PaginationOptions;
635
+ interface ListContactsResponseSuccess {
460
636
  object: 'list';
461
637
  data: Contact[];
638
+ has_more: boolean;
462
639
  }
463
- type ListAudienceContactsResponse = Response<ListAudienceContactsResponseSuccess>;
464
- type ListContactsApiResponseSuccess = PaginatedApiResponse<Contact[]>;
465
- type ListContactsResponseSuccess = PaginatedData<Contact[]>;
466
- type ListContactsResponse = Response<ListContactsResponseSuccess>;
640
+ type ListContactsResponse = {
641
+ data: ListContactsResponseSuccess;
642
+ error: null;
643
+ } | {
644
+ data: null;
645
+ error: ErrorResponse;
646
+ };
467
647
 
468
648
  type RemoveContactsResponseSuccess = {
469
649
  object: 'contact';
@@ -471,12 +651,18 @@ type RemoveContactsResponseSuccess = {
471
651
  contact: string;
472
652
  };
473
653
  type RemoveContactOptions = SelectingField & {
474
- audienceId?: string;
654
+ audienceId: string;
655
+ };
656
+ type RemoveContactsResponse = {
657
+ data: RemoveContactsResponseSuccess;
658
+ error: null;
659
+ } | {
660
+ data: null;
661
+ error: ErrorResponse;
475
662
  };
476
- type RemoveContactsResponse = Response<RemoveContactsResponseSuccess>;
477
663
 
478
664
  type UpdateContactOptions = {
479
- audienceId?: string;
665
+ audienceId: string;
480
666
  unsubscribed?: boolean;
481
667
  firstName?: string;
482
668
  lastName?: string;
@@ -484,9 +670,16 @@ type UpdateContactOptions = {
484
670
  type UpdateContactResponseSuccess = Pick<Contact, 'id'> & {
485
671
  object: 'contact';
486
672
  };
487
- type UpdateContactResponse = Response<UpdateContactResponseSuccess>;
673
+ type UpdateContactResponse = {
674
+ data: UpdateContactResponseSuccess;
675
+ error: null;
676
+ } | {
677
+ data: null;
678
+ error: ErrorResponse;
679
+ };
488
680
 
489
681
  type DomainRegion = 'us-east-1' | 'eu-west-1' | 'sa-east-1' | 'ap-northeast-1';
682
+ type DomainNameservers = 'Amazon Route 53' | 'Cloudflare' | 'Digital Ocean' | 'GoDaddy' | 'Google Domains' | 'Namecheap' | 'Unidentified' | 'Vercel';
490
683
  type DomainStatus = 'pending' | 'verified' | 'failed' | 'temporary_failure' | 'not_started';
491
684
  type DomainRecords = DomainSpfRecord | DomainDkimRecord;
492
685
  interface DomainSpfRecord {
@@ -529,24 +722,51 @@ interface CreateDomainRequestOptions extends PostOptions {
529
722
  interface CreateDomainResponseSuccess extends Pick<Domain, 'name' | 'id' | 'status' | 'created_at' | 'region'> {
530
723
  records: DomainRecords[];
531
724
  }
532
- type CreateDomainResponse = Response<CreateDomainResponseSuccess>;
725
+ type CreateDomainResponse = {
726
+ data: CreateDomainResponseSuccess;
727
+ error: null;
728
+ } | {
729
+ data: null;
730
+ error: ErrorResponse;
731
+ };
533
732
 
534
733
  interface GetDomainResponseSuccess extends Pick<Domain, 'id' | 'name' | 'created_at' | 'region' | 'status'> {
535
734
  object: 'domain';
536
735
  records: DomainRecords[];
537
736
  }
538
- type GetDomainResponse = Response<GetDomainResponseSuccess>;
737
+ type GetDomainResponse = {
738
+ data: GetDomainResponseSuccess;
739
+ error: null;
740
+ } | {
741
+ data: null;
742
+ error: ErrorResponse;
743
+ };
539
744
 
745
+ type ListDomainsOptions = PaginationOptions;
540
746
  type ListDomainsResponseSuccess = {
541
747
  data: Domain[];
748
+ object: 'list';
749
+ has_more: boolean;
750
+ };
751
+ type ListDomainsResponse = {
752
+ data: ListDomainsResponseSuccess;
753
+ error: null;
754
+ } | {
755
+ data: null;
756
+ error: ErrorResponse;
542
757
  };
543
- type ListDomainsResponse = Response<ListDomainsResponseSuccess>;
544
758
 
545
759
  type RemoveDomainsResponseSuccess = Pick<Domain, 'id'> & {
546
760
  object: 'domain';
547
761
  deleted: boolean;
548
762
  };
549
- type RemoveDomainsResponse = Response<RemoveDomainsResponseSuccess>;
763
+ type RemoveDomainsResponse = {
764
+ data: RemoveDomainsResponseSuccess;
765
+ error: null;
766
+ } | {
767
+ data: null;
768
+ error: ErrorResponse;
769
+ };
550
770
 
551
771
  interface UpdateDomainsOptions {
552
772
  id: string;
@@ -557,12 +777,36 @@ interface UpdateDomainsOptions {
557
777
  type UpdateDomainsResponseSuccess = Pick<Domain, 'id'> & {
558
778
  object: 'domain';
559
779
  };
560
- type UpdateDomainsResponse = Response<UpdateDomainsResponseSuccess>;
780
+ type UpdateDomainsResponse = {
781
+ data: UpdateDomainsResponseSuccess;
782
+ error: null;
783
+ } | {
784
+ data: null;
785
+ error: ErrorResponse;
786
+ };
561
787
 
562
788
  type VerifyDomainsResponseSuccess = Pick<Domain, 'id'> & {
563
789
  object: 'domain';
564
790
  };
565
- type VerifyDomainsResponse = Response<VerifyDomainsResponseSuccess>;
791
+ type VerifyDomainsResponse = {
792
+ data: VerifyDomainsResponseSuccess;
793
+ error: null;
794
+ } | {
795
+ data: null;
796
+ error: ErrorResponse;
797
+ };
798
+
799
+ interface CancelEmailResponseSuccess {
800
+ object: 'email';
801
+ id: string;
802
+ }
803
+ type CancelEmailResponse = {
804
+ data: CancelEmailResponseSuccess;
805
+ error: null;
806
+ } | {
807
+ data: null;
808
+ error: ErrorResponse;
809
+ };
566
810
 
567
811
  interface GetEmailResponseSuccess {
568
812
  bcc: string[] | null;
@@ -580,17 +824,38 @@ interface GetEmailResponseSuccess {
580
824
  value: string;
581
825
  }[];
582
826
  to: string[];
583
- topic_id?: string | null;
584
827
  scheduled_at: string | null;
585
828
  object: 'email';
586
829
  }
587
- type GetEmailResponse = Response<GetEmailResponseSuccess>;
830
+ type GetEmailResponse = {
831
+ data: GetEmailResponseSuccess;
832
+ error: null;
833
+ } | {
834
+ data: null;
835
+ error: ErrorResponse;
836
+ };
837
+
838
+ interface UpdateEmailOptions {
839
+ id: string;
840
+ scheduledAt: string;
841
+ }
842
+ interface UpdateEmailResponseSuccess {
843
+ id: string;
844
+ object: 'email';
845
+ }
846
+ type UpdateEmailResponse = {
847
+ data: UpdateEmailResponseSuccess;
848
+ error: null;
849
+ } | {
850
+ data: null;
851
+ error: ErrorResponse;
852
+ };
588
853
 
589
854
  declare class ApiKeys {
590
855
  private readonly resend;
591
856
  constructor(resend: Resend);
592
857
  create(payload: CreateApiKeyOptions, options?: CreateApiKeyRequestOptions): Promise<CreateApiKeyResponse>;
593
- list(): Promise<ListApiKeysResponse>;
858
+ list(options?: ListApiKeysOptions): Promise<ListApiKeysResponse>;
594
859
  remove(id: string): Promise<RemoveApiKeyResponse>;
595
860
  }
596
861
 
@@ -598,177 +863,34 @@ declare class Audiences {
598
863
  private readonly resend;
599
864
  constructor(resend: Resend);
600
865
  create(payload: CreateAudienceOptions, options?: CreateAudienceRequestOptions): Promise<CreateAudienceResponse>;
601
- list(): Promise<ListAudiencesResponse>;
866
+ list(options?: ListAudiencesOptions): Promise<ListAudiencesResponse>;
602
867
  get(id: string): Promise<GetAudienceResponse>;
603
868
  remove(id: string): Promise<RemoveAudiencesResponse>;
604
869
  }
605
870
 
606
871
  declare class Batch {
607
872
  private readonly resend;
608
- private renderAsync?;
609
873
  constructor(resend: Resend);
610
- send(payload: CreateBatchOptions, options?: CreateBatchRequestOptions): Promise<CreateBatchResponse>;
611
- create(payload: CreateBatchOptions, options?: CreateBatchRequestOptions): Promise<CreateBatchResponse>;
874
+ send<Options extends CreateBatchRequestOptions>(payload: CreateBatchOptions, options?: Options): Promise<CreateBatchResponse<Options>>;
875
+ create<Options extends CreateBatchRequestOptions>(payload: CreateBatchOptions, options?: Options): Promise<CreateBatchResponse<Options>>;
612
876
  }
613
877
 
614
- interface Broadcast {
615
- id: string;
616
- name: string;
617
- audience_id: string | null;
618
- from: string | null;
619
- subject: string | null;
620
- reply_to: string[] | null;
621
- preview_text: string | null;
622
- status: 'draft' | 'sent' | 'queued';
623
- created_at: string;
624
- scheduled_at: string | null;
625
- sent_at: string | null;
626
- topic_id?: string | null;
627
- }
628
-
629
- interface GetBroadcastResponseSuccess extends Broadcast {
630
- object: 'broadcast';
631
- }
632
- type GetBroadcastResponse = Response<GetBroadcastResponseSuccess>;
633
-
634
- type ListBroadcastsResponseSuccess = {
635
- object: 'list';
636
- data: Pick<Broadcast, 'id' | 'name' | 'audience_id' | 'status' | 'created_at' | 'scheduled_at' | 'sent_at'>[];
637
- };
638
- type ListBroadcastsResponse = Response<ListBroadcastsResponseSuccess>;
639
-
640
- interface RemoveBroadcastResponseSuccess extends Pick<Broadcast, 'id'> {
641
- object: 'broadcast';
642
- deleted: boolean;
643
- }
644
- type RemoveBroadcastResponse = Response<RemoveBroadcastResponseSuccess>;
645
-
646
- interface UpdateBroadcastResponseSuccess {
647
- id: string;
648
- }
649
- type UpdateBroadcastOptions = {
650
- name?: string;
651
- audienceId?: string;
652
- from?: string;
653
- html?: string;
654
- react?: React.ReactNode;
655
- text?: string;
656
- subject?: string;
657
- replyTo?: string[];
658
- previewText?: string;
659
- topicId?: string | null;
660
- };
661
- type UpdateBroadcastResponse = Response<UpdateBroadcastResponseSuccess>;
662
-
663
878
  declare class Broadcasts {
664
879
  private readonly resend;
665
- private renderAsync?;
666
880
  constructor(resend: Resend);
667
881
  create(payload: CreateBroadcastOptions, options?: CreateBroadcastRequestOptions): Promise<SendBroadcastResponse>;
668
882
  send(id: string, payload?: SendBroadcastOptions): Promise<SendBroadcastResponse>;
669
- list(): Promise<ListBroadcastsResponse>;
883
+ list(options?: ListBroadcastsOptions): Promise<ListBroadcastsResponse>;
670
884
  get(id: string): Promise<GetBroadcastResponse>;
671
885
  remove(id: string): Promise<RemoveBroadcastResponse>;
672
886
  update(id: string, payload: UpdateBroadcastOptions): Promise<UpdateBroadcastResponse>;
673
887
  }
674
888
 
675
- interface PatchOptions {
676
- query?: {
677
- [key: string]: unknown;
678
- };
679
- }
680
-
681
- type ContactAudiencesBaseOptions = {
682
- contactId: string;
683
- email?: never;
684
- } | {
685
- contactId?: never;
686
- email: string;
687
- };
688
-
689
- type AddContactAudiencesResponse = Response<AddContactAudiencesResponseSuccess>;
690
- interface AddContactAudiencesResponseSuccess {
691
- id: string;
692
- }
693
- type AddContactAudiencesOptions = ContactAudiencesBaseOptions & {
694
- audienceId: string;
695
- };
696
-
697
- type ListContactAudiencesOptions = PaginationOptions<string> & ContactAudiencesBaseOptions;
698
- type ListContactAudiencesResponseSuccess = PaginatedData<Audience[]>;
699
- type ListContactAudiencesResponse = Response<ListContactAudiencesResponseSuccess>;
700
-
701
- type RemoveContactAudiencesResponse = Response<RemoveContactAudiencesResponseSuccess>;
702
- interface RemoveContactAudiencesResponseSuccess {
703
- id: string;
704
- deleted: boolean;
705
- }
706
- type RemoveContactAudiencesOptions = ContactAudiencesBaseOptions & {
707
- audienceId: string;
708
- };
709
-
710
- declare class ContactAudiences {
711
- private readonly resend;
712
- constructor(resend: Resend);
713
- list(options: ListContactAudiencesOptions): Promise<ListContactAudiencesResponse>;
714
- add(options: AddContactAudiencesOptions): Promise<AddContactAudiencesResponse>;
715
- remove(options: RemoveContactAudiencesOptions): Promise<RemoveContactAudiencesResponse>;
716
- }
717
-
718
- interface GetContactTopicsBaseOptions {
719
- id?: string;
720
- email?: string;
721
- }
722
- interface GetContactTopicsOptions extends GetContactTopicsBaseOptions {
723
- }
724
- interface ContactTopic {
725
- id: string;
726
- name: string;
727
- description: string | null;
728
- subscription: 'opt_in' | 'opt_out';
729
- }
730
- interface GetContactTopicsResponseSuccess {
731
- email: string;
732
- topics: ContactTopic[];
733
- }
734
- interface GetContactTopicsResponse {
735
- data: GetContactTopicsResponseSuccess | null;
736
- error: ErrorResponse | null;
737
- }
738
-
739
- interface UpdateContactTopicsBaseOptions {
740
- id?: string;
741
- email?: string;
742
- }
743
- interface UpdateContactTopicsOptions extends UpdateContactTopicsBaseOptions {
744
- topics: {
745
- id: string;
746
- subscription: 'opt_in' | 'opt_out';
747
- }[];
748
- }
749
- interface UpdateContactTopicsResponseSuccess {
750
- id: string;
751
- }
752
- interface UpdateContactTopicsResponse {
753
- data: UpdateContactTopicsResponseSuccess | null;
754
- error: ErrorResponse | null;
755
- }
756
-
757
- declare class ContactTopics {
758
- private readonly resend;
759
- constructor(resend: Resend);
760
- update(payload: UpdateContactTopicsOptions): Promise<UpdateContactTopicsResponse>;
761
- get(options: GetContactTopicsOptions): Promise<GetContactTopicsResponse>;
762
- }
763
-
764
889
  declare class Contacts {
765
890
  private readonly resend;
766
- readonly topics: ContactTopics;
767
- readonly audiences: ContactAudiences;
768
891
  constructor(resend: Resend);
769
892
  create(payload: CreateContactOptions, options?: CreateContactRequestOptions): Promise<CreateContactResponse>;
770
893
  list(options: ListContactsOptions): Promise<ListContactsResponse>;
771
- list(options: ListAudienceContactsOptions): Promise<ListAudienceContactsResponse>;
772
894
  get(options: GetContactOptions): Promise<GetContactResponse>;
773
895
  update(options: UpdateContactOptions): Promise<UpdateContactResponse>;
774
896
  remove(payload: RemoveContactOptions): Promise<RemoveContactsResponse>;
@@ -778,101 +900,51 @@ declare class Domains {
778
900
  private readonly resend;
779
901
  constructor(resend: Resend);
780
902
  create(payload: CreateDomainOptions, options?: CreateDomainRequestOptions): Promise<CreateDomainResponse>;
781
- list(): Promise<ListDomainsResponse>;
903
+ list(options?: ListDomainsOptions): Promise<ListDomainsResponse>;
782
904
  get(id: string): Promise<GetDomainResponse>;
783
905
  update(payload: UpdateDomainsOptions): Promise<UpdateDomainsResponse>;
784
906
  remove(id: string): Promise<RemoveDomainsResponse>;
785
907
  verify(id: string): Promise<VerifyDomainsResponse>;
786
908
  }
787
909
 
788
- interface CancelEmailResponseSuccess {
789
- object: 'email';
790
- id: string;
791
- }
792
- type CancelEmailResponse = Response<CancelEmailResponseSuccess>;
793
-
794
- interface UpdateEmailOptions {
795
- id: string;
796
- scheduledAt: string;
797
- }
798
- interface UpdateEmailResponseSuccess {
799
- id: string;
800
- object: 'email';
801
- }
802
- type UpdateEmailResponse = Response<UpdateEmailResponseSuccess>;
910
+ type ListEmailsOptions = PaginationOptions;
911
+ type ListEmail = Omit<GetEmailResponseSuccess, 'html' | 'text' | 'tags' | 'object'>;
912
+ type ListEmailsResponseSuccess = {
913
+ object: 'list';
914
+ has_more: boolean;
915
+ data: ListEmail[];
916
+ };
917
+ type ListEmailsResponse = {
918
+ data: ListEmailsResponseSuccess;
919
+ error: null;
920
+ } | {
921
+ data: null;
922
+ error: ErrorResponse;
923
+ };
803
924
 
804
925
  declare class Emails {
805
926
  private readonly resend;
806
- private renderAsync?;
807
927
  constructor(resend: Resend);
808
928
  send(payload: CreateEmailOptions, options?: CreateEmailRequestOptions): Promise<CreateEmailResponse>;
809
929
  create(payload: CreateEmailOptions, options?: CreateEmailRequestOptions): Promise<CreateEmailResponse>;
810
930
  get(id: string): Promise<GetEmailResponse>;
931
+ list(options?: ListEmailsOptions): Promise<ListEmailsResponse>;
811
932
  update(payload: UpdateEmailOptions): Promise<UpdateEmailResponse>;
812
933
  cancel(id: string): Promise<CancelEmailResponse>;
813
934
  }
814
935
 
815
- interface Topic {
816
- id: string;
817
- name: string;
818
- description?: string;
819
- default_subscription: 'opt_in' | 'opt_out';
820
- created_at: string;
821
- }
822
-
823
- interface CreateTopicOptions {
824
- name: string;
825
- description?: string;
826
- default_subscription: 'opt_in' | 'opt_out';
827
- }
828
- type CreateTopicResponseSuccess = Pick<Topic, 'id'>;
829
- interface CreateTopicResponse {
830
- data: CreateTopicResponseSuccess | null;
831
- error: ErrorResponse | null;
832
- }
833
-
834
- type GetTopicResponseSuccess = Topic;
835
- interface GetTopicResponse {
836
- data: GetTopicResponseSuccess | null;
837
- error: ErrorResponse | null;
838
- }
839
-
840
- interface ListTopicsResponseSuccess {
841
- data: Topic[];
842
- }
843
- interface ListTopicsResponse {
844
- data: ListTopicsResponseSuccess | null;
845
- error: ErrorResponse | null;
846
- }
847
-
848
- type RemoveTopicResponseSuccess = Pick<Topic, 'id'> & {
849
- object: 'topic';
850
- deleted: boolean;
851
- };
852
- interface RemoveTopicResponse {
853
- data: RemoveTopicResponseSuccess | null;
854
- error: ErrorResponse | null;
855
- }
856
-
857
- interface UpdateTopicOptions {
936
+ interface Headers {
858
937
  id: string;
859
- name?: string;
860
- description?: string;
938
+ timestamp: string;
939
+ signature: string;
861
940
  }
862
- type UpdateTopicResponseSuccess = Pick<Topic, 'id'>;
863
- interface UpdateTopicResponse {
864
- data: UpdateTopicResponseSuccess | null;
865
- error: ErrorResponse | null;
941
+ interface VerifyWebhookOptions {
942
+ payload: string;
943
+ headers: Headers;
944
+ webhookSecret: string;
866
945
  }
867
-
868
- declare class Topics {
869
- private readonly resend;
870
- constructor(resend: Resend);
871
- create(payload: CreateTopicOptions): Promise<CreateTopicResponse>;
872
- list(): Promise<ListTopicsResponse>;
873
- get(id: string): Promise<GetTopicResponse>;
874
- update(payload: UpdateTopicOptions): Promise<UpdateTopicResponse>;
875
- remove(id: string): Promise<RemoveTopicResponse>;
946
+ declare class Webhooks {
947
+ verify(payload: VerifyWebhookOptions): unknown;
876
948
  }
877
949
 
878
950
  declare class Resend {
@@ -885,14 +957,50 @@ declare class Resend {
885
957
  readonly contacts: Contacts;
886
958
  readonly domains: Domains;
887
959
  readonly emails: Emails;
888
- readonly topics: Topics;
960
+ readonly webhooks: Webhooks;
889
961
  constructor(key?: string | undefined);
890
- fetchRequest<T>(path: string, options?: {}): Promise<Response<T>>;
891
- post<T>(path: string, entity?: unknown, options?: PostOptions & IdempotentRequest): Promise<Response<T>>;
892
- get<T>(path: string, options?: GetOptions): Promise<Response<T>>;
893
- put<T>(path: string, entity: unknown, options?: PutOptions): Promise<Response<T>>;
894
- patch<T>(path: string, entity: unknown, options?: PatchOptions): Promise<Response<T>>;
895
- delete<T>(path: string, query?: unknown): Promise<Response<T>>;
896
- }
897
-
898
- 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 ListApiKeysResponse, type ListApiKeysResponseSuccess, type ListAudienceContactsOptions, type ListAudienceContactsResponse, type ListAudienceContactsResponseSuccess, type ListAudiencesResponse, type ListAudiencesResponseSuccess, type ListContactsApiResponseSuccess, type ListContactsOptions, type ListContactsResponse, type ListContactsResponseSuccess, type ListDomainsResponse, type ListDomainsResponseSuccess, 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 };
962
+ fetchRequest<T>(path: string, options?: {}): Promise<{
963
+ data: T;
964
+ error: null;
965
+ } | {
966
+ data: null;
967
+ error: ErrorResponse;
968
+ }>;
969
+ post<T>(path: string, entity?: unknown, options?: PostOptions & IdempotentRequest): Promise<{
970
+ data: null;
971
+ error: ErrorResponse;
972
+ } | {
973
+ data: T;
974
+ error: null;
975
+ }>;
976
+ get<T>(path: string, options?: GetOptions): Promise<{
977
+ data: null;
978
+ error: ErrorResponse;
979
+ } | {
980
+ data: T;
981
+ error: null;
982
+ }>;
983
+ put<T>(path: string, entity: unknown, options?: PutOptions): Promise<{
984
+ data: null;
985
+ error: ErrorResponse;
986
+ } | {
987
+ data: T;
988
+ error: null;
989
+ }>;
990
+ patch<T>(path: string, entity: unknown, options?: PatchOptions): Promise<{
991
+ data: null;
992
+ error: ErrorResponse;
993
+ } | {
994
+ data: T;
995
+ error: null;
996
+ }>;
997
+ delete<T>(path: string, query?: unknown): Promise<{
998
+ data: null;
999
+ error: ErrorResponse;
1000
+ } | {
1001
+ data: T;
1002
+ error: null;
1003
+ }>;
1004
+ }
1005
+
1006
+ 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 };