resend 6.2.0-preview-contacts.0 → 6.2.1

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