resend 6.1.0-canary.0 → 6.1.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,43 @@
1
- import * as React from 'react';
1
+ import * as React$1 from 'react';
2
2
 
3
3
  interface GetOptions {
4
4
  query?: Record<string, unknown>;
5
+ headers?: HeadersInit;
5
6
  }
6
7
 
8
+ type PaginationOptions = {
9
+ /**
10
+ * Maximum number of items to return (1-100, default: 20)
11
+ */
12
+ limit?: number;
13
+ } & ({
14
+ /**
15
+ * Get items after this cursor (cannot be used with 'before')
16
+ */
17
+ after?: string;
18
+ before?: never;
19
+ } | {
20
+ /**
21
+ * Get items before this cursor (cannot be used with 'after')
22
+ */
23
+ before?: string;
24
+ after?: never;
25
+ });
26
+
7
27
  interface PostOptions {
8
28
  query?: {
9
29
  [key: string]: unknown;
10
30
  };
31
+ headers?: HeadersInit;
11
32
  }
12
33
 
13
34
  interface PutOptions {
14
35
  query?: {
15
36
  [key: string]: unknown;
16
37
  };
38
+ headers?: HeadersInit;
17
39
  }
18
40
 
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
41
  declare const RESEND_ERROR_CODES_BY_KEY: {
41
42
  readonly missing_required_field: 422;
42
43
  readonly invalid_idempotency_key: 400;
@@ -47,7 +48,7 @@ declare const RESEND_ERROR_CODES_BY_KEY: {
47
48
  readonly invalid_region: 422;
48
49
  readonly rate_limit_exceeded: 429;
49
50
  readonly missing_api_key: 401;
50
- readonly invalid_api_Key: 403;
51
+ readonly invalid_api_key: 403;
51
52
  readonly invalid_from_address: 403;
52
53
  readonly validation_error: 403;
53
54
  readonly not_found: 404;
@@ -56,26 +57,10 @@ declare const RESEND_ERROR_CODES_BY_KEY: {
56
57
  readonly internal_server_error: 500;
57
58
  };
58
59
  type RESEND_ERROR_CODE_KEY = keyof typeof RESEND_ERROR_CODES_BY_KEY;
59
- type ErrorResponse = {
60
- message: string;
61
- name: Exclude<RESEND_ERROR_CODE_KEY, 'rate_limit_exceeded'>;
62
- } | {
60
+ interface ErrorResponse {
63
61
  message: string;
64
- name: Extract<RESEND_ERROR_CODE_KEY, 'rate_limit_exceeded'>;
65
- /**
66
- * Time in seconds.
67
- */
68
- retryAfter: number;
69
- };
70
- type Response<Data> = {
71
- data: Data;
72
- rateLimiting: RateLimit;
73
- error: null;
74
- } | {
75
- data: null;
76
- rateLimiting: RateLimit | null;
77
- error: ErrorResponse;
78
- };
62
+ name: RESEND_ERROR_CODE_KEY;
63
+ }
79
64
 
80
65
  interface CreateApiKeyOptions {
81
66
  name: string;
@@ -88,7 +73,13 @@ interface CreateApiKeyResponseSuccess {
88
73
  token: string;
89
74
  id: string;
90
75
  }
91
- type CreateApiKeyResponse = Response<CreateApiKeyResponseSuccess>;
76
+ type CreateApiKeyResponse = {
77
+ data: CreateApiKeyResponseSuccess;
78
+ error: null;
79
+ } | {
80
+ data: null;
81
+ error: ErrorResponse;
82
+ };
92
83
 
93
84
  interface ApiKey {
94
85
  created_at: string;
@@ -96,19 +87,28 @@ interface ApiKey {
96
87
  name: string;
97
88
  }
98
89
 
99
- type ListApiKeysResponseSuccess = Pick<ApiKey, 'name' | 'id' | 'created_at'>[];
100
- type ListApiKeysResponse = Response<ListApiKeysResponseSuccess>;
90
+ type ListApiKeysOptions = PaginationOptions;
91
+ type ListApiKeysResponseSuccess = {
92
+ object: 'list';
93
+ has_more: boolean;
94
+ data: Pick<ApiKey, 'name' | 'id' | 'created_at'>[];
95
+ };
96
+ type ListApiKeysResponse = {
97
+ data: ListApiKeysResponseSuccess;
98
+ error: null;
99
+ } | {
100
+ data: null;
101
+ error: ErrorResponse;
102
+ };
101
103
 
102
104
  type RemoveApiKeyResponseSuccess = {};
103
- type RemoveApiKeyResponse = Response<RemoveApiKeyResponseSuccess>;
104
-
105
- declare class ApiKeys {
106
- private readonly resend;
107
- constructor(resend: Resend);
108
- create(payload: CreateApiKeyOptions, options?: CreateApiKeyRequestOptions): Promise<CreateApiKeyResponse>;
109
- list(): Promise<ListApiKeysResponse>;
110
- remove(id: string): Promise<RemoveApiKeyResponse>;
111
- }
105
+ type RemoveApiKeyResponse = {
106
+ data: RemoveApiKeyResponseSuccess;
107
+ error: null;
108
+ } | {
109
+ data: null;
110
+ error: ErrorResponse;
111
+ };
112
112
 
113
113
  interface Audience {
114
114
  created_at: string;
@@ -124,33 +124,50 @@ interface CreateAudienceRequestOptions extends PostOptions {
124
124
  interface CreateAudienceResponseSuccess extends Pick<Audience, 'name' | 'id'> {
125
125
  object: 'audience';
126
126
  }
127
- type CreateAudienceResponse = Response<CreateAudienceResponseSuccess>;
127
+ type CreateAudienceResponse = {
128
+ data: CreateAudienceResponseSuccess;
129
+ error: null;
130
+ } | {
131
+ data: null;
132
+ error: ErrorResponse;
133
+ };
128
134
 
129
135
  interface GetAudienceResponseSuccess extends Pick<Audience, 'id' | 'name' | 'created_at'> {
130
136
  object: 'audience';
131
137
  }
132
- type GetAudienceResponse = Response<GetAudienceResponseSuccess>;
138
+ type GetAudienceResponse = {
139
+ data: GetAudienceResponseSuccess;
140
+ error: null;
141
+ } | {
142
+ data: null;
143
+ error: ErrorResponse;
144
+ };
133
145
 
146
+ type ListAudiencesOptions = PaginationOptions;
134
147
  type ListAudiencesResponseSuccess = {
135
148
  object: 'list';
136
149
  data: Audience[];
150
+ has_more: boolean;
151
+ };
152
+ type ListAudiencesResponse = {
153
+ data: ListAudiencesResponseSuccess;
154
+ error: null;
155
+ } | {
156
+ data: null;
157
+ error: ErrorResponse;
137
158
  };
138
- type ListAudiencesResponse = Response<ListAudiencesResponseSuccess>;
139
159
 
140
160
  interface RemoveAudiencesResponseSuccess extends Pick<Audience, 'id'> {
141
161
  object: 'audience';
142
162
  deleted: boolean;
143
163
  }
144
- type RemoveAudiencesResponse = Response<RemoveAudiencesResponseSuccess>;
145
-
146
- declare class Audiences {
147
- private readonly resend;
148
- constructor(resend: Resend);
149
- create(payload: CreateAudienceOptions, options?: CreateAudienceRequestOptions): Promise<CreateAudienceResponse>;
150
- list(): Promise<ListAudiencesResponse>;
151
- get(id: string): Promise<GetAudienceResponse>;
152
- remove(id: string): Promise<RemoveAudiencesResponse>;
153
- }
164
+ type RemoveAudiencesResponse = {
165
+ data: RemoveAudiencesResponseSuccess;
166
+ error: null;
167
+ } | {
168
+ data: null;
169
+ error: ErrorResponse;
170
+ };
154
171
 
155
172
  interface IdempotentRequest {
156
173
  /**
@@ -171,7 +188,7 @@ interface EmailRenderOptions$1 {
171
188
  *
172
189
  * @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
173
190
  */
174
- react: React.ReactNode;
191
+ react: React$1.ReactNode;
175
192
  /**
176
193
  * The HTML version of the message.
177
194
  *
@@ -255,7 +272,13 @@ interface CreateEmailResponseSuccess {
255
272
  /** The ID of the newly created email. */
256
273
  id: string;
257
274
  }
258
- type CreateEmailResponse = Response<CreateEmailResponseSuccess>;
275
+ type CreateEmailResponse = {
276
+ data: CreateEmailResponseSuccess;
277
+ error: null;
278
+ } | {
279
+ data: null;
280
+ error: ErrorResponse;
281
+ };
259
282
  interface Attachment {
260
283
  /** Content of an attached file. */
261
284
  content?: string | Buffer;
@@ -284,22 +307,38 @@ type Tag = {
284
307
 
285
308
  type CreateBatchOptions = CreateEmailOptions[];
286
309
  interface CreateBatchRequestOptions extends PostOptions, IdempotentRequest {
310
+ /**
311
+ * @default 'strict'
312
+ */
313
+ batchValidation?: 'strict' | 'permissive';
287
314
  }
288
- interface CreateBatchSuccessResponse {
315
+ type CreateBatchSuccessResponse<Options extends CreateBatchRequestOptions = CreateBatchRequestOptions> = {
289
316
  data: {
290
317
  /** The ID of the newly created email. */
291
318
  id: string;
292
319
  }[];
293
- }
294
- type CreateBatchResponse = Response<CreateBatchSuccessResponse>;
295
-
296
- declare class Batch {
297
- private readonly resend;
298
- private renderAsync?;
299
- constructor(resend: Resend);
300
- send(payload: CreateBatchOptions, options?: CreateBatchRequestOptions): Promise<CreateBatchResponse>;
301
- create(payload: CreateBatchOptions, options?: CreateBatchRequestOptions): Promise<CreateBatchResponse>;
302
- }
320
+ } & (Options['batchValidation'] extends 'permissive' ? {
321
+ /**
322
+ * Only present when header "x-batch-validation" is set to 'permissive'.
323
+ */
324
+ errors: {
325
+ /**
326
+ * The index of the failed email in the batch
327
+ */
328
+ index: number;
329
+ /**
330
+ * The error message for the failed email
331
+ */
332
+ message: string;
333
+ }[];
334
+ } : Record<string, never>);
335
+ type CreateBatchResponse<Options extends CreateBatchRequestOptions> = {
336
+ data: CreateBatchSuccessResponse<Options>;
337
+ error: null;
338
+ } | {
339
+ data: null;
340
+ error: ErrorResponse;
341
+ };
303
342
 
304
343
  interface EmailRenderOptions {
305
344
  /**
@@ -307,7 +346,7 @@ interface EmailRenderOptions {
307
346
  *
308
347
  * @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
309
348
  */
310
- react: React.ReactNode;
349
+ react: React$1.ReactNode;
311
350
  /**
312
351
  * The HTML version of the message.
313
352
  *
@@ -366,38 +405,13 @@ interface CreateBroadcastResponseSuccess {
366
405
  /** The ID of the newly sent broadcasts. */
367
406
  id: string;
368
407
  }
369
- type CreateBroadcastResponse = Response<CreateBroadcastResponseSuccess>;
370
-
371
- interface Broadcast {
372
- id: string;
373
- name: string;
374
- audience_id: string | null;
375
- from: string | null;
376
- subject: string | null;
377
- reply_to: string[] | null;
378
- preview_text: string | null;
379
- status: 'draft' | 'sent' | 'queued';
380
- created_at: string;
381
- scheduled_at: string | null;
382
- sent_at: string | null;
383
- }
384
-
385
- interface GetBroadcastResponseSuccess extends Broadcast {
386
- object: 'broadcast';
387
- }
388
- type GetBroadcastResponse = Response<GetBroadcastResponseSuccess>;
389
-
390
- type ListBroadcastsResponseSuccess = {
391
- object: 'list';
392
- data: Pick<Broadcast, 'id' | 'name' | 'audience_id' | 'status' | 'created_at' | 'scheduled_at' | 'sent_at'>[];
408
+ type CreateBroadcastResponse = {
409
+ data: CreateBroadcastResponseSuccess;
410
+ error: null;
411
+ } | {
412
+ data: null;
413
+ error: ErrorResponse;
393
414
  };
394
- type ListBroadcastsResponse = Response<ListBroadcastsResponseSuccess>;
395
-
396
- interface RemoveBroadcastResponseSuccess extends Pick<Broadcast, 'id'> {
397
- object: 'broadcast';
398
- deleted: boolean;
399
- }
400
- type RemoveBroadcastResponse = Response<RemoveBroadcastResponseSuccess>;
401
415
 
402
416
  interface SendBroadcastBaseOptions {
403
417
  /**
@@ -416,40 +430,13 @@ interface SendBroadcastResponseSuccess {
416
430
  /** The ID of the sent broadcast. */
417
431
  id: string;
418
432
  }
419
- type SendBroadcastResponse = Response<SendBroadcastResponseSuccess>;
420
-
421
- interface UpdateBroadcastResponseSuccess {
422
- id: string;
423
- }
424
- interface UpdateBroadcastOptions {
425
- name?: string;
426
- audienceId?: string;
427
- from?: string;
428
- html?: string;
429
- text?: string;
430
- subject?: string;
431
- replyTo?: string[];
432
- previewText?: string;
433
- }
434
- type UpdateBroadcastResponse = Response<UpdateBroadcastResponseSuccess>;
435
-
436
- declare class Broadcasts {
437
- private readonly resend;
438
- private renderAsync?;
439
- constructor(resend: Resend);
440
- create(payload: CreateBroadcastOptions, options?: CreateBroadcastRequestOptions): Promise<SendBroadcastResponse>;
441
- send(id: string, payload?: SendBroadcastOptions): Promise<SendBroadcastResponse>;
442
- list(): Promise<ListBroadcastsResponse>;
443
- get(id: string): Promise<GetBroadcastResponse>;
444
- remove(id: string): Promise<RemoveBroadcastResponse>;
445
- update(id: string, payload: UpdateBroadcastOptions): Promise<UpdateBroadcastResponse>;
446
- }
447
-
448
- interface PatchOptions {
449
- query?: {
450
- [key: string]: unknown;
451
- };
452
- }
433
+ type SendBroadcastResponse = {
434
+ data: SendBroadcastResponseSuccess;
435
+ error: null;
436
+ } | {
437
+ data: null;
438
+ error: ErrorResponse;
439
+ };
453
440
 
454
441
  interface Contact {
455
442
  created_at: string;
@@ -499,7 +486,13 @@ interface CreateContactRequestOptions extends PostOptions {
499
486
  interface CreateContactResponseSuccess extends Pick<Contact, 'id'> {
500
487
  object: 'contact';
501
488
  }
502
- type CreateContactResponse = Response<CreateContactResponseSuccess>;
489
+ type CreateContactResponse = {
490
+ data: CreateContactResponseSuccess;
491
+ error: null;
492
+ } | {
493
+ data: null;
494
+ error: ErrorResponse;
495
+ };
503
496
 
504
497
  type GetContactOptions = {
505
498
  audienceId: string;
@@ -507,16 +500,29 @@ type GetContactOptions = {
507
500
  interface GetContactResponseSuccess extends Pick<Contact, 'id' | 'email' | 'created_at' | 'first_name' | 'last_name' | 'unsubscribed'> {
508
501
  object: 'contact';
509
502
  }
510
- type GetContactResponse = Response<GetContactResponseSuccess>;
503
+ type GetContactResponse = {
504
+ data: GetContactResponseSuccess;
505
+ error: null;
506
+ } | {
507
+ data: null;
508
+ error: ErrorResponse;
509
+ };
511
510
 
512
- interface ListContactsOptions {
511
+ type ListContactsOptions = {
513
512
  audienceId: string;
514
- }
513
+ } & PaginationOptions;
515
514
  interface ListContactsResponseSuccess {
516
515
  object: 'list';
517
516
  data: Contact[];
517
+ has_more: boolean;
518
518
  }
519
- type ListContactsResponse = Response<ListContactsResponseSuccess>;
519
+ type ListContactsResponse = {
520
+ data: ListContactsResponseSuccess;
521
+ error: null;
522
+ } | {
523
+ data: null;
524
+ error: ErrorResponse;
525
+ };
520
526
 
521
527
  type RemoveContactsResponseSuccess = {
522
528
  object: 'contact';
@@ -526,7 +532,13 @@ type RemoveContactsResponseSuccess = {
526
532
  type RemoveContactOptions = SelectingField & {
527
533
  audienceId: string;
528
534
  };
529
- type RemoveContactsResponse = Response<RemoveContactsResponseSuccess>;
535
+ type RemoveContactsResponse = {
536
+ data: RemoveContactsResponseSuccess;
537
+ error: null;
538
+ } | {
539
+ data: null;
540
+ error: ErrorResponse;
541
+ };
530
542
 
531
543
  type UpdateContactOptions = {
532
544
  audienceId: string;
@@ -537,17 +549,13 @@ type UpdateContactOptions = {
537
549
  type UpdateContactResponseSuccess = Pick<Contact, 'id'> & {
538
550
  object: 'contact';
539
551
  };
540
- type UpdateContactResponse = Response<UpdateContactResponseSuccess>;
541
-
542
- declare class Contacts {
543
- private readonly resend;
544
- constructor(resend: Resend);
545
- create(payload: CreateContactOptions, options?: CreateContactRequestOptions): Promise<CreateContactResponse>;
546
- list(options: ListContactsOptions): Promise<ListContactsResponse>;
547
- get(options: GetContactOptions): Promise<GetContactResponse>;
548
- update(options: UpdateContactOptions): Promise<UpdateContactResponse>;
549
- remove(payload: RemoveContactOptions): Promise<RemoveContactsResponse>;
550
- }
552
+ type UpdateContactResponse = {
553
+ data: UpdateContactResponseSuccess;
554
+ error: null;
555
+ } | {
556
+ data: null;
557
+ error: ErrorResponse;
558
+ };
551
559
 
552
560
  type DomainRegion = 'us-east-1' | 'eu-west-1' | 'sa-east-1' | 'ap-northeast-1';
553
561
  type DomainStatus = 'pending' | 'verified' | 'failed' | 'temporary_failure' | 'not_started';
@@ -592,24 +600,51 @@ interface CreateDomainRequestOptions extends PostOptions {
592
600
  interface CreateDomainResponseSuccess extends Pick<Domain, 'name' | 'id' | 'status' | 'created_at' | 'region'> {
593
601
  records: DomainRecords[];
594
602
  }
595
- type CreateDomainResponse = Response<CreateDomainResponseSuccess>;
603
+ type CreateDomainResponse = {
604
+ data: CreateDomainResponseSuccess;
605
+ error: null;
606
+ } | {
607
+ data: null;
608
+ error: ErrorResponse;
609
+ };
596
610
 
597
611
  interface GetDomainResponseSuccess extends Pick<Domain, 'id' | 'name' | 'created_at' | 'region' | 'status'> {
598
612
  object: 'domain';
599
613
  records: DomainRecords[];
600
614
  }
601
- type GetDomainResponse = Response<GetDomainResponseSuccess>;
615
+ type GetDomainResponse = {
616
+ data: GetDomainResponseSuccess;
617
+ error: null;
618
+ } | {
619
+ data: null;
620
+ error: ErrorResponse;
621
+ };
602
622
 
623
+ type ListDomainsOptions = PaginationOptions;
603
624
  type ListDomainsResponseSuccess = {
604
625
  data: Domain[];
626
+ object: 'list';
627
+ has_more: boolean;
628
+ };
629
+ type ListDomainsResponse = {
630
+ data: ListDomainsResponseSuccess;
631
+ error: null;
632
+ } | {
633
+ data: null;
634
+ error: ErrorResponse;
605
635
  };
606
- type ListDomainsResponse = Response<ListDomainsResponseSuccess>;
607
636
 
608
637
  type RemoveDomainsResponseSuccess = Pick<Domain, 'id'> & {
609
638
  object: 'domain';
610
639
  deleted: boolean;
611
640
  };
612
- type RemoveDomainsResponse = Response<RemoveDomainsResponseSuccess>;
641
+ type RemoveDomainsResponse = {
642
+ data: RemoveDomainsResponseSuccess;
643
+ error: null;
644
+ } | {
645
+ data: null;
646
+ error: ErrorResponse;
647
+ };
613
648
 
614
649
  interface UpdateDomainsOptions {
615
650
  id: string;
@@ -620,29 +655,24 @@ interface UpdateDomainsOptions {
620
655
  type UpdateDomainsResponseSuccess = Pick<Domain, 'id'> & {
621
656
  object: 'domain';
622
657
  };
623
- type UpdateDomainsResponse = Response<UpdateDomainsResponseSuccess>;
658
+ type UpdateDomainsResponse = {
659
+ data: UpdateDomainsResponseSuccess;
660
+ error: null;
661
+ } | {
662
+ data: null;
663
+ error: ErrorResponse;
664
+ };
624
665
 
625
666
  type VerifyDomainsResponseSuccess = Pick<Domain, 'id'> & {
626
667
  object: 'domain';
627
668
  };
628
- type VerifyDomainsResponse = Response<VerifyDomainsResponseSuccess>;
629
-
630
- declare class Domains {
631
- private readonly resend;
632
- constructor(resend: Resend);
633
- create(payload: CreateDomainOptions, options?: CreateDomainRequestOptions): Promise<CreateDomainResponse>;
634
- list(): Promise<ListDomainsResponse>;
635
- get(id: string): Promise<GetDomainResponse>;
636
- update(payload: UpdateDomainsOptions): Promise<UpdateDomainsResponse>;
637
- remove(id: string): Promise<RemoveDomainsResponse>;
638
- verify(id: string): Promise<VerifyDomainsResponse>;
639
- }
640
-
641
- interface CancelEmailResponseSuccess {
642
- object: 'email';
643
- id: string;
644
- }
645
- type CancelEmailResponse = Response<CancelEmailResponseSuccess>;
669
+ type VerifyDomainsResponse = {
670
+ data: VerifyDomainsResponseSuccess;
671
+ error: null;
672
+ } | {
673
+ data: null;
674
+ error: ErrorResponse;
675
+ };
646
676
 
647
677
  interface GetEmailResponseSuccess {
648
678
  bcc: string[] | null;
@@ -663,7 +693,176 @@ interface GetEmailResponseSuccess {
663
693
  scheduled_at: string | null;
664
694
  object: 'email';
665
695
  }
666
- type GetEmailResponse = Response<GetEmailResponseSuccess>;
696
+ type GetEmailResponse = {
697
+ data: GetEmailResponseSuccess;
698
+ error: null;
699
+ } | {
700
+ data: null;
701
+ error: ErrorResponse;
702
+ };
703
+
704
+ declare class ApiKeys {
705
+ private readonly resend;
706
+ constructor(resend: Resend);
707
+ create(payload: CreateApiKeyOptions, options?: CreateApiKeyRequestOptions): Promise<CreateApiKeyResponse>;
708
+ list(options?: ListApiKeysOptions): Promise<ListApiKeysResponse>;
709
+ remove(id: string): Promise<RemoveApiKeyResponse>;
710
+ }
711
+
712
+ declare class Audiences {
713
+ private readonly resend;
714
+ constructor(resend: Resend);
715
+ create(payload: CreateAudienceOptions, options?: CreateAudienceRequestOptions): Promise<CreateAudienceResponse>;
716
+ list(options?: ListAudiencesOptions): Promise<ListAudiencesResponse>;
717
+ get(id: string): Promise<GetAudienceResponse>;
718
+ remove(id: string): Promise<RemoveAudiencesResponse>;
719
+ }
720
+
721
+ declare class Batch {
722
+ private readonly resend;
723
+ constructor(resend: Resend);
724
+ send<Options extends CreateBatchRequestOptions>(payload: CreateBatchOptions, options?: Options): Promise<CreateBatchResponse<Options>>;
725
+ create<Options extends CreateBatchRequestOptions>(payload: CreateBatchOptions, options?: Options): Promise<CreateBatchResponse<Options>>;
726
+ }
727
+
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
+ declare class Broadcasts {
802
+ private readonly resend;
803
+ constructor(resend: Resend);
804
+ create(payload: CreateBroadcastOptions, options?: CreateBroadcastRequestOptions): Promise<SendBroadcastResponse>;
805
+ send(id: string, payload?: SendBroadcastOptions): Promise<SendBroadcastResponse>;
806
+ list(options?: ListBroadcastsOptions): Promise<ListBroadcastsResponse>;
807
+ get(id: string): Promise<GetBroadcastResponse>;
808
+ remove(id: string): Promise<RemoveBroadcastResponse>;
809
+ update(id: string, payload: UpdateBroadcastOptions): Promise<UpdateBroadcastResponse>;
810
+ }
811
+
812
+ interface PatchOptions {
813
+ query?: {
814
+ [key: string]: unknown;
815
+ };
816
+ headers?: HeadersInit;
817
+ }
818
+
819
+ declare class Contacts {
820
+ private readonly resend;
821
+ constructor(resend: Resend);
822
+ create(payload: CreateContactOptions, options?: CreateContactRequestOptions): Promise<CreateContactResponse>;
823
+ list(options: ListContactsOptions): Promise<ListContactsResponse>;
824
+ get(options: GetContactOptions): Promise<GetContactResponse>;
825
+ update(options: UpdateContactOptions): Promise<UpdateContactResponse>;
826
+ remove(payload: RemoveContactOptions): Promise<RemoveContactsResponse>;
827
+ }
828
+
829
+ declare class Domains {
830
+ private readonly resend;
831
+ constructor(resend: Resend);
832
+ create(payload: CreateDomainOptions, options?: CreateDomainRequestOptions): Promise<CreateDomainResponse>;
833
+ list(options?: ListDomainsOptions): Promise<ListDomainsResponse>;
834
+ get(id: string): Promise<GetDomainResponse>;
835
+ update(payload: UpdateDomainsOptions): Promise<UpdateDomainsResponse>;
836
+ remove(id: string): Promise<RemoveDomainsResponse>;
837
+ verify(id: string): Promise<VerifyDomainsResponse>;
838
+ }
839
+
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
+ type ListEmailsOptions = PaginationOptions;
853
+ type ListEmail = Omit<GetEmailResponseSuccess, 'html' | 'text' | 'tags' | 'object'>;
854
+ type ListEmailsResponseSuccess = {
855
+ object: 'list';
856
+ has_more: boolean;
857
+ data: ListEmail[];
858
+ };
859
+ type ListEmailsResponse = {
860
+ data: ListEmailsResponseSuccess;
861
+ error: null;
862
+ } | {
863
+ data: null;
864
+ error: ErrorResponse;
865
+ };
667
866
 
668
867
  interface UpdateEmailOptions {
669
868
  id: string;
@@ -673,15 +872,21 @@ interface UpdateEmailResponseSuccess {
673
872
  id: string;
674
873
  object: 'email';
675
874
  }
676
- type UpdateEmailResponse = Response<UpdateEmailResponseSuccess>;
875
+ type UpdateEmailResponse = {
876
+ data: UpdateEmailResponseSuccess;
877
+ error: null;
878
+ } | {
879
+ data: null;
880
+ error: ErrorResponse;
881
+ };
677
882
 
678
883
  declare class Emails {
679
884
  private readonly resend;
680
- private renderAsync?;
681
885
  constructor(resend: Resend);
682
886
  send(payload: CreateEmailOptions, options?: CreateEmailRequestOptions): Promise<CreateEmailResponse>;
683
887
  create(payload: CreateEmailOptions, options?: CreateEmailRequestOptions): Promise<CreateEmailResponse>;
684
888
  get(id: string): Promise<GetEmailResponse>;
889
+ list(options?: ListEmailsOptions): Promise<ListEmailsResponse>;
685
890
  update(payload: UpdateEmailOptions): Promise<UpdateEmailResponse>;
686
891
  cancel(id: string): Promise<CancelEmailResponse>;
687
892
  }
@@ -697,12 +902,48 @@ declare class Resend {
697
902
  readonly domains: Domains;
698
903
  readonly emails: Emails;
699
904
  constructor(key?: string | undefined);
700
- fetchRequest<T>(path: string, options?: {}): Promise<Response<T>>;
701
- post<T>(path: string, entity?: unknown, options?: PostOptions & IdempotentRequest): Promise<Response<T>>;
702
- get<T>(path: string, options?: GetOptions): Promise<Response<T>>;
703
- put<T>(path: string, entity: unknown, options?: PutOptions): Promise<Response<T>>;
704
- patch<T>(path: string, entity: unknown, options?: PatchOptions): Promise<Response<T>>;
705
- delete<T>(path: string, query?: unknown): Promise<Response<T>>;
706
- }
707
-
708
- export { Attachment, CreateApiKeyOptions, CreateApiKeyRequestOptions, CreateApiKeyResponse, CreateApiKeyResponseSuccess, CreateAudienceOptions, CreateAudienceRequestOptions, CreateAudienceResponse, CreateAudienceResponseSuccess, CreateBatchOptions, CreateBatchRequestOptions, CreateBatchResponse, CreateBatchSuccessResponse, CreateBroadcastOptions, CreateBroadcastRequestOptions, CreateBroadcastResponse, CreateBroadcastResponseSuccess, CreateContactOptions, CreateContactRequestOptions, CreateContactResponse, CreateContactResponseSuccess, CreateDomainOptions, CreateDomainRequestOptions, CreateDomainResponse, CreateDomainResponseSuccess, CreateEmailOptions, CreateEmailRequestOptions, CreateEmailResponse, CreateEmailResponseSuccess, ErrorResponse, GetAudienceResponse, GetAudienceResponseSuccess, GetContactOptions, GetContactResponse, GetContactResponseSuccess, GetDomainResponse, GetDomainResponseSuccess, GetEmailResponse, GetEmailResponseSuccess, ListApiKeysResponse, ListApiKeysResponseSuccess, ListAudiencesResponse, ListAudiencesResponseSuccess, ListContactsOptions, ListContactsResponse, ListContactsResponseSuccess, ListDomainsResponse, ListDomainsResponseSuccess, RemoveApiKeyResponse, RemoveApiKeyResponseSuccess, RemoveAudiencesResponse, RemoveAudiencesResponseSuccess, RemoveContactOptions, RemoveContactsResponse, RemoveContactsResponseSuccess, RemoveDomainsResponse, RemoveDomainsResponseSuccess, Resend, SendBroadcastOptions, SendBroadcastRequestOptions, SendBroadcastResponse, SendBroadcastResponseSuccess, Tag, UpdateContactOptions, UpdateContactResponse, UpdateContactResponseSuccess, UpdateDomainsOptions, UpdateDomainsResponse, UpdateDomainsResponseSuccess, VerifyDomainsResponse, VerifyDomainsResponseSuccess };
905
+ fetchRequest<T>(path: string, options?: {}): Promise<{
906
+ data: T;
907
+ error: null;
908
+ } | {
909
+ data: null;
910
+ error: ErrorResponse;
911
+ }>;
912
+ post<T>(path: string, entity?: unknown, options?: PostOptions & IdempotentRequest): Promise<{
913
+ data: null;
914
+ error: ErrorResponse;
915
+ } | {
916
+ data: T;
917
+ error: null;
918
+ }>;
919
+ get<T>(path: string, options?: GetOptions): Promise<{
920
+ data: null;
921
+ error: ErrorResponse;
922
+ } | {
923
+ data: T;
924
+ error: null;
925
+ }>;
926
+ put<T>(path: string, entity: unknown, options?: PutOptions): Promise<{
927
+ data: null;
928
+ error: ErrorResponse;
929
+ } | {
930
+ data: T;
931
+ error: null;
932
+ }>;
933
+ patch<T>(path: string, entity: unknown, options?: PatchOptions): Promise<{
934
+ data: null;
935
+ error: ErrorResponse;
936
+ } | {
937
+ data: T;
938
+ error: null;
939
+ }>;
940
+ delete<T>(path: string, query?: unknown): Promise<{
941
+ data: null;
942
+ error: ErrorResponse;
943
+ } | {
944
+ data: T;
945
+ error: null;
946
+ }>;
947
+ }
948
+
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 };