resend 6.3.0 → 6.4.0-canary.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
@@ -10,6 +10,7 @@ interface DomainApiOptions {
10
10
  name: string;
11
11
  region?: string;
12
12
  custom_return_path?: string;
13
+ capability?: 'send' | 'receive' | 'send-and-receive';
13
14
  }
14
15
 
15
16
  declare const RESEND_ERROR_CODES_BY_KEY: {
@@ -32,6 +33,15 @@ declare const RESEND_ERROR_CODES_BY_KEY: {
32
33
  readonly internal_server_error: 500;
33
34
  };
34
35
  type RESEND_ERROR_CODE_KEY = keyof typeof RESEND_ERROR_CODES_BY_KEY;
36
+ type Response<T> = ({
37
+ data: T;
38
+ error: null;
39
+ } | {
40
+ error: ErrorResponse;
41
+ data: null;
42
+ }) & {
43
+ headers: Record<string, string> | null;
44
+ };
35
45
  type ErrorResponse = {
36
46
  message: string;
37
47
  statusCode: number | null;
@@ -50,9 +60,9 @@ interface EmailApiAttachment {
50
60
  content_id?: string;
51
61
  }
52
62
  interface EmailApiOptions {
53
- from: string;
63
+ from?: string;
54
64
  to: string | string[];
55
- subject: string;
65
+ subject?: string;
56
66
  region?: string;
57
67
  headers?: Record<string, string>;
58
68
  html?: string;
@@ -60,9 +70,14 @@ interface EmailApiOptions {
60
70
  bcc?: string | string[];
61
71
  cc?: string | string[];
62
72
  reply_to?: string | string[];
73
+ topic_id?: string | null;
63
74
  scheduled_at?: string;
64
75
  tags?: Tag$1[];
65
76
  attachments?: EmailApiAttachment[];
77
+ template?: {
78
+ id: string;
79
+ variables?: Record<string, string | number>;
80
+ };
66
81
  }
67
82
 
68
83
  interface GetOptions {
@@ -79,11 +94,6 @@ interface IdempotentRequest {
79
94
  idempotencyKey?: string;
80
95
  }
81
96
 
82
- interface List<T> {
83
- readonly object: 'list';
84
- data: T[];
85
- }
86
-
87
97
  type PaginationOptions = {
88
98
  /**
89
99
  * Maximum number of items to return (1-100, default: 20)
@@ -102,6 +112,11 @@ type PaginationOptions = {
102
112
  before?: string;
103
113
  after?: never;
104
114
  });
115
+ type PaginatedData<Data> = {
116
+ object: 'list';
117
+ data: Data;
118
+ has_more: boolean;
119
+ };
105
120
 
106
121
  interface PatchOptions {
107
122
  query?: {
@@ -139,13 +154,7 @@ interface CreateApiKeyResponseSuccess {
139
154
  token: string;
140
155
  id: string;
141
156
  }
142
- type CreateApiKeyResponse = {
143
- data: CreateApiKeyResponseSuccess;
144
- error: null;
145
- } | {
146
- data: null;
147
- error: ErrorResponse;
148
- };
157
+ type CreateApiKeyResponse = Response<CreateApiKeyResponseSuccess>;
149
158
 
150
159
  type ListApiKeysOptions = PaginationOptions;
151
160
  type ListApiKeysResponseSuccess = {
@@ -153,81 +162,10 @@ type ListApiKeysResponseSuccess = {
153
162
  has_more: boolean;
154
163
  data: Pick<ApiKey, 'name' | 'id' | 'created_at'>[];
155
164
  };
156
- type ListApiKeysResponse = {
157
- data: ListApiKeysResponseSuccess;
158
- error: null;
159
- } | {
160
- data: null;
161
- error: ErrorResponse;
162
- };
165
+ type ListApiKeysResponse = Response<ListApiKeysResponseSuccess>;
163
166
 
164
167
  type RemoveApiKeyResponseSuccess = {};
165
- type RemoveApiKeyResponse = {
166
- data: RemoveApiKeyResponseSuccess;
167
- error: null;
168
- } | {
169
- data: null;
170
- error: ErrorResponse;
171
- };
172
-
173
- interface Audience {
174
- created_at: string;
175
- id: string;
176
- name: string;
177
- }
178
-
179
- interface CreateAudienceOptions {
180
- name: string;
181
- }
182
- interface CreateAudienceRequestOptions extends PostOptions {
183
- }
184
- interface CreateAudienceResponseSuccess extends Pick<Audience, 'name' | 'id'> {
185
- object: 'audience';
186
- }
187
- type CreateAudienceResponse = {
188
- data: CreateAudienceResponseSuccess;
189
- error: null;
190
- } | {
191
- data: null;
192
- error: ErrorResponse;
193
- };
194
-
195
- interface GetAudienceResponseSuccess extends Pick<Audience, 'id' | 'name' | 'created_at'> {
196
- object: 'audience';
197
- }
198
- type GetAudienceResponse = {
199
- data: GetAudienceResponseSuccess;
200
- error: null;
201
- } | {
202
- data: null;
203
- error: ErrorResponse;
204
- };
205
-
206
- type ListAudiencesOptions = PaginationOptions;
207
- type ListAudiencesResponseSuccess = {
208
- object: 'list';
209
- data: Audience[];
210
- has_more: boolean;
211
- };
212
- type ListAudiencesResponse = {
213
- data: ListAudiencesResponseSuccess;
214
- error: null;
215
- } | {
216
- data: null;
217
- error: ErrorResponse;
218
- };
219
-
220
- interface RemoveAudiencesResponseSuccess extends Pick<Audience, 'id'> {
221
- object: 'audience';
222
- deleted: boolean;
223
- }
224
- type RemoveAudiencesResponse = {
225
- data: RemoveAudiencesResponseSuccess;
226
- error: null;
227
- } | {
228
- data: null;
229
- error: ErrorResponse;
230
- };
168
+ type RemoveApiKeyResponse = Response<RemoveApiKeyResponseSuccess>;
231
169
 
232
170
  interface EmailRenderOptions$1 {
233
171
  /**
@@ -249,13 +187,23 @@ interface EmailRenderOptions$1 {
249
187
  */
250
188
  text: string;
251
189
  }
190
+ interface EmailTemplateOptions {
191
+ template: {
192
+ id: string;
193
+ variables?: Record<string, string | number>;
194
+ };
195
+ }
196
+ interface CreateEmailBaseOptionsWithTemplate extends Omit<CreateEmailBaseOptions, 'from' | 'subject'> {
197
+ from?: string;
198
+ subject?: string;
199
+ }
252
200
  interface CreateEmailBaseOptions {
253
201
  /**
254
202
  * Filename and content of attachments (max 40mb per email)
255
203
  *
256
204
  * @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
257
205
  */
258
- attachments?: Attachment[];
206
+ attachments?: Attachment$1[];
259
207
  /**
260
208
  * Blind carbon copy recipient email address. For multiple addresses, send as an array of strings.
261
209
  *
@@ -304,6 +252,12 @@ interface CreateEmailBaseOptions {
304
252
  * @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
305
253
  */
306
254
  to: string | string[];
255
+ /**
256
+ * The id of the topic you want to send to
257
+ *
258
+ * @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
259
+ */
260
+ topicId?: string | null;
307
261
  /**
308
262
  * Schedule email to be sent later.
309
263
  * The date should be in ISO 8601 format (e.g: 2024-08-05T11:52:01.858Z).
@@ -312,21 +266,21 @@ interface CreateEmailBaseOptions {
312
266
  */
313
267
  scheduledAt?: string;
314
268
  }
315
- type CreateEmailOptions = RequireAtLeastOne<EmailRenderOptions$1> & CreateEmailBaseOptions;
269
+ type CreateEmailOptions = ((RequireAtLeastOne<EmailRenderOptions$1> & CreateEmailBaseOptions) & {
270
+ template?: never;
271
+ }) | ((EmailTemplateOptions & CreateEmailBaseOptionsWithTemplate) & {
272
+ react?: never;
273
+ html?: never;
274
+ text?: never;
275
+ });
316
276
  interface CreateEmailRequestOptions extends PostOptions, IdempotentRequest {
317
277
  }
318
278
  interface CreateEmailResponseSuccess {
319
279
  /** The ID of the newly created email. */
320
280
  id: string;
321
281
  }
322
- type CreateEmailResponse = {
323
- data: CreateEmailResponseSuccess;
324
- error: null;
325
- } | {
326
- data: null;
327
- error: ErrorResponse;
328
- };
329
- interface Attachment {
282
+ type CreateEmailResponse = Response<CreateEmailResponseSuccess>;
283
+ interface Attachment$1 {
330
284
  /** Content of an attached file. */
331
285
  content?: string | Buffer;
332
286
  /** Name of attached file. */
@@ -379,17 +333,12 @@ type CreateBatchSuccessResponse<Options extends CreateBatchRequestOptions = Crea
379
333
  message: string;
380
334
  }[];
381
335
  } : Record<string, never>);
382
- type CreateBatchResponse<Options extends CreateBatchRequestOptions> = {
383
- data: CreateBatchSuccessResponse<Options>;
384
- error: null;
385
- } | {
386
- data: null;
387
- error: ErrorResponse;
388
- };
336
+ type CreateBatchResponse<Options extends CreateBatchRequestOptions> = Response<CreateBatchSuccessResponse<Options>>;
389
337
 
390
338
  interface Broadcast {
391
339
  id: string;
392
340
  name: string;
341
+ segment_id: string | null;
393
342
  audience_id: string | null;
394
343
  from: string | null;
395
344
  subject: string | null;
@@ -399,6 +348,7 @@ interface Broadcast {
399
348
  created_at: string;
400
349
  scheduled_at: string | null;
401
350
  sent_at: string | null;
351
+ topic_id?: string | null;
402
352
  html: string | null;
403
353
  text: string | null;
404
354
  }
@@ -423,19 +373,25 @@ interface EmailRenderOptions {
423
373
  */
424
374
  text: string;
425
375
  }
426
- interface CreateBroadcastBaseOptions {
376
+ interface SegmentOptions {
427
377
  /**
428
- * The name of the broadcast
378
+ * The id of the segment you want to send to
429
379
  *
430
380
  * @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
431
381
  */
432
- name?: string;
382
+ segmentId: string;
383
+ /**
384
+ * @deprecated Use segmentId instead
385
+ */
386
+ audienceId: string;
387
+ }
388
+ interface CreateBroadcastBaseOptions {
433
389
  /**
434
- * The id of the audience you want to send to
390
+ * The name of the broadcast
435
391
  *
436
392
  * @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
437
393
  */
438
- audienceId: string;
394
+ name?: string;
439
395
  /**
440
396
  * A short snippet of text displayed as a preview in recipients' inboxes, often shown below or beside the subject line.
441
397
  *
@@ -460,58 +416,40 @@ interface CreateBroadcastBaseOptions {
460
416
  * @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
461
417
  */
462
418
  subject: string;
419
+ /**
420
+ * The id of the topic you want to send to
421
+ *
422
+ * @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
423
+ */
424
+ topicId?: string | null;
463
425
  }
464
- type CreateBroadcastOptions = RequireAtLeastOne<EmailRenderOptions> & CreateBroadcastBaseOptions;
426
+ type CreateBroadcastOptions = RequireAtLeastOne<EmailRenderOptions> & RequireAtLeastOne<SegmentOptions> & CreateBroadcastBaseOptions;
465
427
  interface CreateBroadcastRequestOptions extends PostOptions {
466
428
  }
467
429
  interface CreateBroadcastResponseSuccess {
468
430
  /** The ID of the newly sent broadcasts. */
469
431
  id: string;
470
432
  }
471
- type CreateBroadcastResponse = {
472
- data: CreateBroadcastResponseSuccess;
473
- error: null;
474
- } | {
475
- data: null;
476
- error: ErrorResponse;
477
- };
433
+ type CreateBroadcastResponse = Response<CreateBroadcastResponseSuccess>;
478
434
 
479
435
  interface GetBroadcastResponseSuccess extends Broadcast {
480
436
  object: 'broadcast';
481
437
  }
482
- type GetBroadcastResponse = {
483
- data: GetBroadcastResponseSuccess;
484
- error: null;
485
- } | {
486
- data: null;
487
- error: ErrorResponse;
488
- };
438
+ type GetBroadcastResponse = Response<GetBroadcastResponseSuccess>;
489
439
 
490
440
  type ListBroadcastsOptions = PaginationOptions;
491
441
  type ListBroadcastsResponseSuccess = {
492
442
  object: 'list';
493
443
  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;
444
+ data: Pick<Broadcast, 'id' | 'name' | 'audience_id' | 'segment_id' | 'status' | 'created_at' | 'scheduled_at' | 'sent_at'>[];
502
445
  };
446
+ type ListBroadcastsResponse = Response<ListBroadcastsResponseSuccess>;
503
447
 
504
448
  interface RemoveBroadcastResponseSuccess extends Pick<Broadcast, 'id'> {
505
449
  object: 'broadcast';
506
450
  deleted: boolean;
507
451
  }
508
- type RemoveBroadcastResponse = {
509
- data: RemoveBroadcastResponseSuccess;
510
- error: null;
511
- } | {
512
- data: null;
513
- error: ErrorResponse;
514
- };
452
+ type RemoveBroadcastResponse = Response<RemoveBroadcastResponseSuccess>;
515
453
 
516
454
  interface SendBroadcastBaseOptions {
517
455
  /**
@@ -530,19 +468,17 @@ interface SendBroadcastResponseSuccess {
530
468
  /** The ID of the sent broadcast. */
531
469
  id: string;
532
470
  }
533
- type SendBroadcastResponse = {
534
- data: SendBroadcastResponseSuccess;
535
- error: null;
536
- } | {
537
- data: null;
538
- error: ErrorResponse;
539
- };
471
+ type SendBroadcastResponse = Response<SendBroadcastResponseSuccess>;
540
472
 
541
473
  interface UpdateBroadcastResponseSuccess {
542
474
  id: string;
543
475
  }
544
476
  type UpdateBroadcastOptions = {
545
477
  name?: string;
478
+ segmentId?: string;
479
+ /**
480
+ * @deprecated Use segmentId instead
481
+ */
546
482
  audienceId?: string;
547
483
  from?: string;
548
484
  html?: string;
@@ -551,14 +487,9 @@ type UpdateBroadcastOptions = {
551
487
  subject?: string;
552
488
  replyTo?: string[];
553
489
  previewText?: string;
490
+ topicId?: string | null;
554
491
  };
555
- type UpdateBroadcastResponse = {
556
- data: UpdateBroadcastResponseSuccess;
557
- error: null;
558
- } | {
559
- data: null;
560
- error: ErrorResponse;
561
- };
492
+ type UpdateBroadcastResponse = Response<UpdateBroadcastResponseSuccess>;
562
493
 
563
494
  interface Contact {
564
495
  created_at: string;
@@ -597,7 +528,7 @@ type SelectingField = {
597
528
  };
598
529
 
599
530
  interface CreateContactOptions {
600
- audienceId: string;
531
+ audienceId?: string;
601
532
  email: string;
602
533
  unsubscribed?: boolean;
603
534
  firstName?: string;
@@ -608,62 +539,41 @@ interface CreateContactRequestOptions extends PostOptions {
608
539
  interface CreateContactResponseSuccess extends Pick<Contact, 'id'> {
609
540
  object: 'contact';
610
541
  }
611
- type CreateContactResponse = {
612
- data: CreateContactResponseSuccess;
613
- error: null;
614
- } | {
615
- data: null;
616
- error: ErrorResponse;
617
- };
542
+ type CreateContactResponse = Response<CreateContactResponseSuccess>;
618
543
 
619
- type GetContactOptions = {
620
- audienceId: string;
621
- } & SelectingField;
544
+ type GetContactOptions = string | ({
545
+ audienceId?: string;
546
+ } & SelectingField);
622
547
  interface GetContactResponseSuccess extends Pick<Contact, 'id' | 'email' | 'created_at' | 'first_name' | 'last_name' | 'unsubscribed'> {
623
548
  object: 'contact';
624
549
  }
625
- type GetContactResponse = {
626
- data: GetContactResponseSuccess;
627
- error: null;
628
- } | {
629
- data: null;
630
- error: ErrorResponse;
631
- };
550
+ type GetContactResponse = Response<GetContactResponseSuccess>;
632
551
 
633
- type ListContactsOptions = {
552
+ type ListAudienceContactsOptions = {
634
553
  audienceId: string;
635
554
  } & PaginationOptions;
555
+ type ListContactsOptions = PaginationOptions & {
556
+ audienceId?: string;
557
+ };
636
558
  interface ListContactsResponseSuccess {
637
559
  object: 'list';
638
560
  data: Contact[];
639
561
  has_more: boolean;
640
562
  }
641
- type ListContactsResponse = {
642
- data: ListContactsResponseSuccess;
643
- error: null;
644
- } | {
645
- data: null;
646
- error: ErrorResponse;
647
- };
563
+ type ListContactsResponse = Response<ListContactsResponseSuccess>;
648
564
 
649
565
  type RemoveContactsResponseSuccess = {
650
566
  object: 'contact';
651
567
  deleted: boolean;
652
568
  contact: string;
653
569
  };
654
- type RemoveContactOptions = SelectingField & {
655
- audienceId: string;
656
- };
657
- type RemoveContactsResponse = {
658
- data: RemoveContactsResponseSuccess;
659
- error: null;
660
- } | {
661
- data: null;
662
- error: ErrorResponse;
663
- };
570
+ type RemoveContactOptions = string | (SelectingField & {
571
+ audienceId?: string;
572
+ });
573
+ type RemoveContactsResponse = Response<RemoveContactsResponseSuccess>;
664
574
 
665
575
  type UpdateContactOptions = {
666
- audienceId: string;
576
+ audienceId?: string;
667
577
  unsubscribed?: boolean;
668
578
  firstName?: string;
669
579
  lastName?: string;
@@ -671,18 +581,12 @@ type UpdateContactOptions = {
671
581
  type UpdateContactResponseSuccess = Pick<Contact, 'id'> & {
672
582
  object: 'contact';
673
583
  };
674
- type UpdateContactResponse = {
675
- data: UpdateContactResponseSuccess;
676
- error: null;
677
- } | {
678
- data: null;
679
- error: ErrorResponse;
680
- };
584
+ type UpdateContactResponse = Response<UpdateContactResponseSuccess>;
681
585
 
682
586
  type DomainRegion = 'us-east-1' | 'eu-west-1' | 'sa-east-1' | 'ap-northeast-1';
683
587
  type DomainNameservers = 'Amazon Route 53' | 'Cloudflare' | 'Digital Ocean' | 'GoDaddy' | 'Google Domains' | 'Namecheap' | 'Unidentified' | 'Vercel';
684
588
  type DomainStatus = 'pending' | 'verified' | 'failed' | 'temporary_failure' | 'not_started';
685
- type DomainRecords = DomainSpfRecord | DomainDkimRecord;
589
+ type DomainRecords = DomainSpfRecord | DomainDkimRecord | ReceivingRecord;
686
590
  interface DomainSpfRecord {
687
591
  record: 'SPF';
688
592
  name: string;
@@ -705,43 +609,42 @@ interface DomainDkimRecord {
705
609
  priority?: number;
706
610
  proxy_status?: 'enable' | 'disable';
707
611
  }
612
+ interface ReceivingRecord {
613
+ record: 'Receiving';
614
+ name: string;
615
+ value: string;
616
+ type: 'MX';
617
+ ttl: string;
618
+ status: DomainStatus;
619
+ priority: number;
620
+ }
708
621
  interface Domain {
709
622
  id: string;
710
623
  name: string;
711
624
  status: DomainStatus;
712
625
  created_at: string;
713
626
  region: DomainRegion;
627
+ capability: 'send' | 'receive' | 'send-and-receive';
714
628
  }
715
629
 
716
630
  interface CreateDomainOptions {
717
631
  name: string;
718
632
  region?: DomainRegion;
719
633
  customReturnPath?: string;
634
+ capability?: 'send' | 'receive' | 'send-and-receive';
720
635
  }
721
636
  interface CreateDomainRequestOptions extends PostOptions {
722
637
  }
723
- interface CreateDomainResponseSuccess extends Pick<Domain, 'name' | 'id' | 'status' | 'created_at' | 'region'> {
638
+ interface CreateDomainResponseSuccess extends Pick<Domain, 'name' | 'id' | 'status' | 'created_at' | 'region' | 'capability'> {
724
639
  records: DomainRecords[];
725
640
  }
726
- type CreateDomainResponse = {
727
- data: CreateDomainResponseSuccess;
728
- error: null;
729
- } | {
730
- data: null;
731
- error: ErrorResponse;
732
- };
641
+ type CreateDomainResponse = Response<CreateDomainResponseSuccess>;
733
642
 
734
- interface GetDomainResponseSuccess extends Pick<Domain, 'id' | 'name' | 'created_at' | 'region' | 'status'> {
643
+ interface GetDomainResponseSuccess extends Pick<Domain, 'id' | 'name' | 'created_at' | 'region' | 'status' | 'capability'> {
735
644
  object: 'domain';
736
645
  records: DomainRecords[];
737
646
  }
738
- type GetDomainResponse = {
739
- data: GetDomainResponseSuccess;
740
- error: null;
741
- } | {
742
- data: null;
743
- error: ErrorResponse;
744
- };
647
+ type GetDomainResponse = Response<GetDomainResponseSuccess>;
745
648
 
746
649
  type ListDomainsOptions = PaginationOptions;
747
650
  type ListDomainsResponseSuccess = {
@@ -749,25 +652,13 @@ type ListDomainsResponseSuccess = {
749
652
  object: 'list';
750
653
  has_more: boolean;
751
654
  };
752
- type ListDomainsResponse = {
753
- data: ListDomainsResponseSuccess;
754
- error: null;
755
- } | {
756
- data: null;
757
- error: ErrorResponse;
758
- };
655
+ type ListDomainsResponse = Response<ListDomainsResponseSuccess>;
759
656
 
760
657
  type RemoveDomainsResponseSuccess = Pick<Domain, 'id'> & {
761
658
  object: 'domain';
762
659
  deleted: boolean;
763
660
  };
764
- type RemoveDomainsResponse = {
765
- data: RemoveDomainsResponseSuccess;
766
- error: null;
767
- } | {
768
- data: null;
769
- error: ErrorResponse;
770
- };
661
+ type RemoveDomainsResponse = Response<RemoveDomainsResponseSuccess>;
771
662
 
772
663
  interface UpdateDomainsOptions {
773
664
  id: string;
@@ -778,36 +669,53 @@ interface UpdateDomainsOptions {
778
669
  type UpdateDomainsResponseSuccess = Pick<Domain, 'id'> & {
779
670
  object: 'domain';
780
671
  };
781
- type UpdateDomainsResponse = {
782
- data: UpdateDomainsResponseSuccess;
783
- error: null;
784
- } | {
785
- data: null;
786
- error: ErrorResponse;
787
- };
672
+ type UpdateDomainsResponse = Response<UpdateDomainsResponseSuccess>;
788
673
 
789
674
  type VerifyDomainsResponseSuccess = Pick<Domain, 'id'> & {
790
675
  object: 'domain';
791
676
  };
792
- type VerifyDomainsResponse = {
793
- data: VerifyDomainsResponseSuccess;
794
- error: null;
795
- } | {
796
- data: null;
797
- error: ErrorResponse;
677
+ type VerifyDomainsResponse = Response<VerifyDomainsResponseSuccess>;
678
+
679
+ interface Attachment {
680
+ id: string;
681
+ filename?: string;
682
+ size: number;
683
+ content_type: string;
684
+ content_disposition: 'inline' | 'attachment';
685
+ content_id?: string;
686
+ download_url: string;
687
+ expires_at: string;
688
+ }
689
+
690
+ interface GetAttachmentOptions {
691
+ emailId: string;
692
+ id: string;
693
+ }
694
+ type GetAttachmentResponseSuccess = {
695
+ object: 'attachment';
696
+ } & Attachment;
697
+ type GetAttachmentResponse = Response<GetAttachmentResponseSuccess>;
698
+
699
+ type ListAttachmentsOptions = PaginationOptions & {
700
+ emailId: string;
798
701
  };
702
+ interface ListAttachmentsApiResponse {
703
+ object: 'list';
704
+ has_more: boolean;
705
+ data: Attachment[];
706
+ }
707
+ interface ListAttachmentsResponseSuccess {
708
+ object: 'list';
709
+ has_more: boolean;
710
+ data: Attachment[];
711
+ }
712
+ type ListAttachmentsResponse = Response<ListAttachmentsResponseSuccess>;
799
713
 
800
714
  interface CancelEmailResponseSuccess {
801
715
  object: 'email';
802
716
  id: string;
803
717
  }
804
- type CancelEmailResponse = {
805
- data: CancelEmailResponseSuccess;
806
- error: null;
807
- } | {
808
- data: null;
809
- error: ErrorResponse;
810
- };
718
+ type CancelEmailResponse = Response<CancelEmailResponseSuccess>;
811
719
 
812
720
  interface GetEmailResponseSuccess {
813
721
  bcc: string[] | null;
@@ -825,16 +733,11 @@ interface GetEmailResponseSuccess {
825
733
  value: string;
826
734
  }[];
827
735
  to: string[];
736
+ topic_id?: string | null;
828
737
  scheduled_at: string | null;
829
738
  object: 'email';
830
739
  }
831
- type GetEmailResponse = {
832
- data: GetEmailResponseSuccess;
833
- error: null;
834
- } | {
835
- data: null;
836
- error: ErrorResponse;
837
- };
740
+ type GetEmailResponse = Response<GetEmailResponseSuccess>;
838
741
 
839
742
  interface UpdateEmailOptions {
840
743
  id: string;
@@ -844,142 +747,220 @@ interface UpdateEmailResponseSuccess {
844
747
  id: string;
845
748
  object: 'email';
846
749
  }
847
- type UpdateEmailResponse = {
848
- data: UpdateEmailResponseSuccess;
750
+ type UpdateEmailResponse = Response<UpdateEmailResponseSuccess>;
751
+
752
+ interface GetReceivingEmailResponseSuccess {
753
+ object: 'email';
754
+ id: string;
755
+ to: string[];
756
+ from: string;
757
+ created_at: string;
758
+ subject: string;
759
+ bcc: string[] | null;
760
+ cc: string[] | null;
761
+ reply_to: string[] | null;
762
+ html: string | null;
763
+ text: string | null;
764
+ headers: Record<string, string>;
765
+ message_id: string;
766
+ attachments: Array<{
767
+ id: string;
768
+ filename: string;
769
+ size: number;
770
+ content_type: string;
771
+ content_id: string;
772
+ content_disposition: string;
773
+ }>;
774
+ }
775
+ type GetReceivingEmailResponse = Response<GetReceivingEmailResponseSuccess>;
776
+
777
+ type ListReceivingEmailsOptions = PaginationOptions;
778
+ type ListReceivingEmail = Omit<GetReceivingEmailResponseSuccess, 'html' | 'text' | 'headers' | 'object'>;
779
+ interface ListReceivingEmailsResponseSuccess {
780
+ object: 'list';
781
+ has_more: boolean;
782
+ data: ListReceivingEmail[];
783
+ }
784
+ type ListReceivingEmailsResponse = {
785
+ data: ListReceivingEmailsResponseSuccess;
849
786
  error: null;
850
787
  } | {
851
788
  data: null;
852
789
  error: ErrorResponse;
853
790
  };
854
791
 
855
- type WebhookEvent = 'email.sent' | 'email.delivered' | 'email.delivery_delayed' | 'email.complained' | 'email.bounced' | 'email.opened' | 'email.clicked' | 'email.received' | 'email.failed' | 'contact.created' | 'contact.updated' | 'contact.deleted' | 'domain.created' | 'domain.updated' | 'domain.deleted';
792
+ declare class ApiKeys {
793
+ private readonly resend;
794
+ constructor(resend: Resend);
795
+ create(payload: CreateApiKeyOptions, options?: CreateApiKeyRequestOptions): Promise<CreateApiKeyResponse>;
796
+ list(options?: ListApiKeysOptions): Promise<ListApiKeysResponse>;
797
+ remove(id: string): Promise<RemoveApiKeyResponse>;
798
+ }
856
799
 
857
- interface CreateWebhookOptions {
858
- endpoint: string;
859
- events: WebhookEvent[];
800
+ declare class Batch {
801
+ private readonly resend;
802
+ constructor(resend: Resend);
803
+ send<Options extends CreateBatchRequestOptions>(payload: CreateBatchOptions, options?: Options): Promise<CreateBatchResponse<Options>>;
804
+ create<Options extends CreateBatchRequestOptions>(payload: CreateBatchOptions, options?: Options): Promise<CreateBatchResponse<Options>>;
860
805
  }
861
- interface CreateWebhookRequestOptions extends PostOptions {
806
+
807
+ declare class Broadcasts {
808
+ private readonly resend;
809
+ constructor(resend: Resend);
810
+ create(payload: CreateBroadcastOptions, options?: CreateBroadcastRequestOptions): Promise<SendBroadcastResponse>;
811
+ send(id: string, payload?: SendBroadcastOptions): Promise<SendBroadcastResponse>;
812
+ list(options?: ListBroadcastsOptions): Promise<ListBroadcastsResponse>;
813
+ get(id: string): Promise<GetBroadcastResponse>;
814
+ remove(id: string): Promise<RemoveBroadcastResponse>;
815
+ update(id: string, payload: UpdateBroadcastOptions): Promise<UpdateBroadcastResponse>;
862
816
  }
863
- interface CreateWebhookResponseSuccess {
864
- object: 'webhook';
817
+
818
+ type StringBaseContactProperty = {
819
+ type: 'string';
820
+ fallbackValue: string | null;
821
+ };
822
+ type NumberBaseContactProperty = {
823
+ type: 'number';
824
+ fallbackValue: number | null;
825
+ };
826
+ type ContactProperty = {
865
827
  id: string;
866
- signing_secret: string;
867
- }
868
- type CreateWebhookResponse = {
869
- data: CreateWebhookResponseSuccess;
870
- error: null;
871
- } | {
872
- data: null;
873
- error: ErrorResponse;
828
+ object: 'contact_property';
829
+ createdAt: string;
830
+ key: string;
831
+ } & (StringBaseContactProperty | NumberBaseContactProperty);
832
+
833
+ type StringBaseContactPropertyOptions = {
834
+ type: 'string';
835
+ fallbackValue?: string | null;
836
+ };
837
+ type NumberBaseContactPropertyOptions = {
838
+ type: 'number';
839
+ fallbackValue?: number | null;
874
840
  };
841
+ type CreateContactPropertyOptions = {
842
+ key: string;
843
+ } & (StringBaseContactPropertyOptions | NumberBaseContactPropertyOptions);
844
+ type CreateContactPropertyResponseSuccess = Pick<ContactProperty, 'id' | 'object'>;
845
+ type CreateContactPropertyResponse = Response<CreateContactPropertyResponseSuccess>;
875
846
 
876
- interface GetWebhookResponseSuccess {
877
- object: 'webhook';
878
- id: string;
879
- created_at: string;
880
- status: 'enabled' | 'disabled';
881
- endpoint: string;
882
- events: WebhookEvent[] | null;
883
- signing_secret: string;
884
- }
885
- type GetWebhookResponse = {
886
- data: GetWebhookResponseSuccess;
887
- error: null;
888
- } | {
889
- data: null;
890
- error: ErrorResponse;
847
+ type RemoveContactPropertyResponseSuccess = Pick<ContactProperty, 'id' | 'object'> & {
848
+ deleted: boolean;
891
849
  };
850
+ type RemoveContactPropertyResponse = Response<RemoveContactPropertyResponseSuccess>;
892
851
 
893
- type ListWebhooksOptions = PaginationOptions;
894
- interface Webhook {
895
- id: string;
896
- endpoint: string;
897
- created_at: string;
898
- status: 'enabled' | 'disabled';
899
- events: WebhookEvent[] | null;
900
- }
901
- type ListWebhooksResponseSuccess = {
852
+ type GetContactPropertyResponse = Response<ContactProperty>;
853
+
854
+ type ListContactPropertiesOptions = PaginationOptions;
855
+ type ListContactPropertiesResponse = Response<{
902
856
  object: 'list';
903
857
  has_more: boolean;
904
- data: Webhook[];
905
- };
906
- type ListWebhooksResponse = {
907
- data: ListWebhooksResponseSuccess;
908
- error: null;
909
- } | {
910
- data: null;
911
- error: ErrorResponse;
912
- };
858
+ data: ContactProperty[];
859
+ }>;
913
860
 
914
- type RemoveWebhookResponseSuccess = Pick<Webhook, 'id'> & {
915
- object: 'webhook';
916
- deleted: boolean;
861
+ type UpdateContactPropertyOptions = {
862
+ id: string;
863
+ fallbackValue?: string | number | null;
917
864
  };
918
- type RemoveWebhookResponse = {
919
- data: RemoveWebhookResponseSuccess;
920
- error: null;
865
+ type UpdateContactPropertyResponseSuccess = Pick<ContactProperty, 'id' | 'object'>;
866
+ type UpdateContactPropertyResponse = Response<UpdateContactPropertyResponseSuccess>;
867
+
868
+ declare class ContactProperties {
869
+ private readonly resend;
870
+ constructor(resend: Resend);
871
+ create(options: CreateContactPropertyOptions): Promise<CreateContactPropertyResponse>;
872
+ list(options?: ListContactPropertiesOptions): Promise<ListContactPropertiesResponse>;
873
+ get(id: string): Promise<GetContactPropertyResponse>;
874
+ update(payload: UpdateContactPropertyOptions): Promise<UpdateContactPropertyResponse>;
875
+ remove(id: string): Promise<RemoveContactPropertyResponse>;
876
+ }
877
+
878
+ type ContactSegmentsBaseOptions = {
879
+ contactId: string;
880
+ email?: never;
921
881
  } | {
922
- data: null;
923
- error: ErrorResponse;
882
+ contactId?: never;
883
+ email: string;
924
884
  };
925
885
 
926
- interface UpdateWebhookOptions {
927
- endpoint?: string;
928
- events?: WebhookEvent[];
929
- status?: 'enabled' | 'disabled';
886
+ type AddContactSegmentOptions = ContactSegmentsBaseOptions & {
887
+ segmentId: string;
888
+ };
889
+ interface AddContactSegmentResponseSuccess {
890
+ id: string;
930
891
  }
931
- interface UpdateWebhookResponseSuccess {
932
- object: 'webhook';
892
+ type AddContactSegmentResponse = Response<AddContactSegmentResponseSuccess>;
893
+
894
+ interface Segment {
895
+ created_at: string;
933
896
  id: string;
897
+ name: string;
934
898
  }
935
- type UpdateWebhookResponse = {
936
- data: UpdateWebhookResponseSuccess;
937
- error: null;
938
- } | {
939
- data: null;
940
- error: ErrorResponse;
899
+
900
+ type ListContactSegmentsOptions = PaginationOptions & ContactSegmentsBaseOptions;
901
+ type ListContactSegmentsResponseSuccess = PaginatedData<Segment[]>;
902
+ type ListContactSegmentsResponse = Response<ListContactSegmentsResponseSuccess>;
903
+
904
+ type RemoveContactSegmentOptions = ContactSegmentsBaseOptions & {
905
+ segmentId: string;
941
906
  };
907
+ interface RemoveContactSegmentResponseSuccess {
908
+ id: string;
909
+ deleted: boolean;
910
+ }
911
+ type RemoveContactSegmentResponse = Response<RemoveContactSegmentResponseSuccess>;
942
912
 
943
- declare class ApiKeys {
913
+ declare class ContactSegments {
944
914
  private readonly resend;
945
915
  constructor(resend: Resend);
946
- create(payload: CreateApiKeyOptions, options?: CreateApiKeyRequestOptions): Promise<CreateApiKeyResponse>;
947
- list(options?: ListApiKeysOptions): Promise<ListApiKeysResponse>;
948
- remove(id: string): Promise<RemoveApiKeyResponse>;
916
+ list(options: ListContactSegmentsOptions): Promise<ListContactSegmentsResponse>;
917
+ add(options: AddContactSegmentOptions): Promise<AddContactSegmentResponse>;
918
+ remove(options: RemoveContactSegmentOptions): Promise<RemoveContactSegmentResponse>;
949
919
  }
950
920
 
951
- declare class Audiences {
952
- private readonly resend;
953
- constructor(resend: Resend);
954
- create(payload: CreateAudienceOptions, options?: CreateAudienceRequestOptions): Promise<CreateAudienceResponse>;
955
- list(options?: ListAudiencesOptions): Promise<ListAudiencesResponse>;
956
- get(id: string): Promise<GetAudienceResponse>;
957
- remove(id: string): Promise<RemoveAudiencesResponse>;
921
+ interface ListContactTopicsBaseOptions {
922
+ id?: string;
923
+ email?: string;
958
924
  }
925
+ type ListContactTopicsOptions = ListContactTopicsBaseOptions & PaginationOptions;
926
+ interface ContactTopic {
927
+ id: string;
928
+ name: string;
929
+ description: string | null;
930
+ subscription: 'opt_in' | 'opt_out';
931
+ }
932
+ type ListContactTopicsResponseSuccess = PaginatedData<ContactTopic[]>;
933
+ type ListContactTopicsResponse = Response<ListContactTopicsResponseSuccess>;
959
934
 
960
- declare class Batch {
961
- private readonly resend;
962
- constructor(resend: Resend);
963
- send<Options extends CreateBatchRequestOptions>(payload: CreateBatchOptions, options?: Options): Promise<CreateBatchResponse<Options>>;
964
- create<Options extends CreateBatchRequestOptions>(payload: CreateBatchOptions, options?: Options): Promise<CreateBatchResponse<Options>>;
935
+ interface UpdateContactTopicsBaseOptions {
936
+ id?: string;
937
+ email?: string;
938
+ }
939
+ interface UpdateContactTopicsOptions extends UpdateContactTopicsBaseOptions {
940
+ topics: {
941
+ id: string;
942
+ subscription: 'opt_in' | 'opt_out';
943
+ }[];
965
944
  }
945
+ interface UpdateContactTopicsResponseSuccess {
946
+ id: string;
947
+ }
948
+ type UpdateContactTopicsResponse = Response<UpdateContactTopicsResponseSuccess>;
966
949
 
967
- declare class Broadcasts {
950
+ declare class ContactTopics {
968
951
  private readonly resend;
969
952
  constructor(resend: Resend);
970
- create(payload: CreateBroadcastOptions, options?: CreateBroadcastRequestOptions): Promise<SendBroadcastResponse>;
971
- send(id: string, payload?: SendBroadcastOptions): Promise<SendBroadcastResponse>;
972
- list(options?: ListBroadcastsOptions): Promise<ListBroadcastsResponse>;
973
- get(id: string): Promise<GetBroadcastResponse>;
974
- remove(id: string): Promise<RemoveBroadcastResponse>;
975
- update(id: string, payload: UpdateBroadcastOptions): Promise<UpdateBroadcastResponse>;
953
+ update(payload: UpdateContactTopicsOptions): Promise<UpdateContactTopicsResponse>;
954
+ list(options: ListContactTopicsOptions): Promise<ListContactTopicsResponse>;
976
955
  }
977
956
 
978
957
  declare class Contacts {
979
958
  private readonly resend;
959
+ readonly topics: ContactTopics;
960
+ readonly segments: ContactSegments;
980
961
  constructor(resend: Resend);
981
962
  create(payload: CreateContactOptions, options?: CreateContactRequestOptions): Promise<CreateContactResponse>;
982
- list(options: ListContactsOptions): Promise<ListContactsResponse>;
963
+ list(options?: ListContactsOptions | ListAudienceContactsOptions): Promise<ListContactsResponse>;
983
964
  get(options: GetContactOptions): Promise<GetContactResponse>;
984
965
  update(options: UpdateContactOptions): Promise<UpdateContactResponse>;
985
966
  remove(payload: RemoveContactOptions): Promise<RemoveContactsResponse>;
@@ -996,6 +977,13 @@ declare class Domains {
996
977
  verify(id: string): Promise<VerifyDomainsResponse>;
997
978
  }
998
979
 
980
+ declare class Attachments$1 {
981
+ private readonly resend;
982
+ constructor(resend: Resend);
983
+ get(options: GetAttachmentOptions): Promise<GetAttachmentResponse>;
984
+ list(options: ListAttachmentsOptions): Promise<ListAttachmentsResponse>;
985
+ }
986
+
999
987
  type ListEmailsOptions = PaginationOptions;
1000
988
  type ListEmail = Omit<GetEmailResponseSuccess, 'html' | 'text' | 'tags' | 'object'>;
1001
989
  type ListEmailsResponseSuccess = {
@@ -1003,16 +991,27 @@ type ListEmailsResponseSuccess = {
1003
991
  has_more: boolean;
1004
992
  data: ListEmail[];
1005
993
  };
1006
- type ListEmailsResponse = {
1007
- data: ListEmailsResponseSuccess;
1008
- error: null;
1009
- } | {
1010
- data: null;
1011
- error: ErrorResponse;
1012
- };
994
+ type ListEmailsResponse = Response<ListEmailsResponseSuccess>;
995
+
996
+ declare class Attachments {
997
+ private readonly resend;
998
+ constructor(resend: Resend);
999
+ get(options: GetAttachmentOptions): Promise<GetAttachmentResponse>;
1000
+ list(options: ListAttachmentsOptions): Promise<ListAttachmentsResponse>;
1001
+ }
1002
+
1003
+ declare class Receiving {
1004
+ private readonly resend;
1005
+ readonly attachments: Attachments;
1006
+ constructor(resend: Resend);
1007
+ get(id: string): Promise<GetReceivingEmailResponse>;
1008
+ list(options?: ListReceivingEmailsOptions): Promise<ListReceivingEmailsResponse>;
1009
+ }
1013
1010
 
1014
1011
  declare class Emails {
1015
1012
  private readonly resend;
1013
+ readonly attachments: Attachments$1;
1014
+ readonly receiving: Receiving;
1016
1015
  constructor(resend: Resend);
1017
1016
  send(payload: CreateEmailOptions, options?: CreateEmailRequestOptions): Promise<CreateEmailResponse>;
1018
1017
  create(payload: CreateEmailOptions, options?: CreateEmailRequestOptions): Promise<CreateEmailResponse>;
@@ -1022,6 +1021,265 @@ declare class Emails {
1022
1021
  cancel(id: string): Promise<CancelEmailResponse>;
1023
1022
  }
1024
1023
 
1024
+ interface CreateSegmentOptions {
1025
+ name: string;
1026
+ }
1027
+ interface CreateSegmentRequestOptions extends PostOptions {
1028
+ }
1029
+ interface CreateSegmentResponseSuccess extends Pick<Segment, 'name' | 'id'> {
1030
+ object: 'segment';
1031
+ }
1032
+ type CreateSegmentResponse = Response<CreateSegmentResponseSuccess>;
1033
+
1034
+ interface GetSegmentResponseSuccess extends Pick<Segment, 'id' | 'name' | 'created_at'> {
1035
+ object: 'segment';
1036
+ }
1037
+ type GetSegmentResponse = Response<GetSegmentResponseSuccess>;
1038
+
1039
+ type ListSegmentsOptions = PaginationOptions;
1040
+ type ListSegmentsResponseSuccess = {
1041
+ object: 'list';
1042
+ data: Segment[];
1043
+ has_more: boolean;
1044
+ };
1045
+ type ListSegmentsResponse = Response<ListSegmentsResponseSuccess>;
1046
+
1047
+ interface RemoveSegmentResponseSuccess extends Pick<Segment, 'id'> {
1048
+ object: 'segment';
1049
+ deleted: boolean;
1050
+ }
1051
+ type RemoveSegmentResponse = Response<RemoveSegmentResponseSuccess>;
1052
+
1053
+ declare class Segments {
1054
+ private readonly resend;
1055
+ constructor(resend: Resend);
1056
+ create(payload: CreateSegmentOptions, options?: CreateSegmentRequestOptions): Promise<CreateSegmentResponse>;
1057
+ list(options?: ListSegmentsOptions): Promise<ListSegmentsResponse>;
1058
+ get(id: string): Promise<GetSegmentResponse>;
1059
+ remove(id: string): Promise<RemoveSegmentResponse>;
1060
+ }
1061
+
1062
+ interface Template {
1063
+ id: string;
1064
+ name: string;
1065
+ subject: string | null;
1066
+ html: string;
1067
+ text: string | null;
1068
+ status: 'draft' | 'published';
1069
+ variables: TemplateVariable[] | null;
1070
+ alias: string | null;
1071
+ from: string | null;
1072
+ reply_to: string[] | null;
1073
+ published_at: string | null;
1074
+ created_at: string;
1075
+ updated_at: string;
1076
+ has_unpublished_versions: boolean;
1077
+ current_version_id: string;
1078
+ }
1079
+ interface TemplateVariable {
1080
+ key: string;
1081
+ fallback_value: string | number | null;
1082
+ type: 'string' | 'number';
1083
+ created_at: string;
1084
+ updated_at: string;
1085
+ }
1086
+
1087
+ type TemplateContentCreationOptions = RequireAtLeastOne<{
1088
+ html: string;
1089
+ react: React.ReactNode;
1090
+ }>;
1091
+ type TemplateVariableCreationOptions = Pick<TemplateVariable, 'key' | 'type'> & ({
1092
+ type: 'string';
1093
+ fallbackValue?: string | null;
1094
+ } | {
1095
+ type: 'number';
1096
+ fallbackValue?: number | null;
1097
+ });
1098
+ type TemplateOptionalFieldsForCreation = Partial<Pick<Template, 'subject' | 'text' | 'alias' | 'from'>> & {
1099
+ replyTo?: string[] | string;
1100
+ variables?: TemplateVariableCreationOptions[];
1101
+ };
1102
+ type CreateTemplateOptions = Pick<Template, 'name'> & TemplateOptionalFieldsForCreation & TemplateContentCreationOptions;
1103
+ interface CreateTemplateResponseSuccess extends Pick<Template, 'id'> {
1104
+ object: 'template';
1105
+ }
1106
+ type CreateTemplateResponse = Response<CreateTemplateResponseSuccess>;
1107
+
1108
+ interface DuplicateTemplateResponseSuccess extends Pick<Template, 'id'> {
1109
+ object: 'template';
1110
+ }
1111
+ type DuplicateTemplateResponse = Response<DuplicateTemplateResponseSuccess>;
1112
+
1113
+ interface PublishTemplateResponseSuccess extends Pick<Template, 'id'> {
1114
+ object: 'template';
1115
+ }
1116
+ type PublishTemplateResponse = Response<PublishTemplateResponseSuccess>;
1117
+
1118
+ declare class ChainableTemplateResult<T extends CreateTemplateResponse | DuplicateTemplateResponse> implements PromiseLike<T> {
1119
+ private readonly promise;
1120
+ private readonly publishFn;
1121
+ constructor(promise: Promise<T>, publishFn: (id: string) => Promise<PublishTemplateResponse>);
1122
+ then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
1123
+ publish(): Promise<PublishTemplateResponse>;
1124
+ }
1125
+
1126
+ interface GetTemplateResponseSuccess extends Template {
1127
+ object: 'template';
1128
+ }
1129
+ type GetTemplateResponse = Response<GetTemplateResponseSuccess>;
1130
+
1131
+ interface TemplateListItem extends Pick<Template, 'id' | 'name' | 'created_at' | 'updated_at' | 'status' | 'published_at' | 'alias'> {
1132
+ }
1133
+ interface ListTemplatesResponseSuccess {
1134
+ object: 'list';
1135
+ data: TemplateListItem[];
1136
+ has_more: boolean;
1137
+ }
1138
+ type ListTemplatesResponse = Response<ListTemplatesResponseSuccess>;
1139
+
1140
+ interface RemoveTemplateResponseSuccess {
1141
+ object: 'template';
1142
+ id: string;
1143
+ deleted: boolean;
1144
+ }
1145
+ type RemoveTemplateResponse = Response<RemoveTemplateResponseSuccess>;
1146
+
1147
+ type TemplateVariableUpdateOptions = Pick<TemplateVariable, 'key' | 'type'> & ({
1148
+ type: 'string';
1149
+ fallbackValue?: string | null;
1150
+ } | {
1151
+ type: 'number';
1152
+ fallbackValue?: number | null;
1153
+ });
1154
+ interface UpdateTemplateOptions extends Partial<Pick<Template, 'name' | 'subject' | 'html' | 'text' | 'from' | 'alias'>> {
1155
+ variables?: TemplateVariableUpdateOptions[];
1156
+ replyTo?: string[] | string;
1157
+ }
1158
+ interface UpdateTemplateResponseSuccess extends Pick<Template, 'id'> {
1159
+ object: 'template';
1160
+ }
1161
+ type UpdateTemplateResponse = Response<UpdateTemplateResponseSuccess>;
1162
+
1163
+ declare class Templates {
1164
+ private readonly resend;
1165
+ private renderAsync?;
1166
+ constructor(resend: Resend);
1167
+ create(payload: CreateTemplateOptions): ChainableTemplateResult<CreateTemplateResponse>;
1168
+ private performCreate;
1169
+ remove(identifier: string): Promise<RemoveTemplateResponse>;
1170
+ get(identifier: string): Promise<GetTemplateResponse>;
1171
+ list(options?: PaginationOptions): Promise<ListTemplatesResponse>;
1172
+ duplicate(identifier: string): ChainableTemplateResult<DuplicateTemplateResponse>;
1173
+ publish(identifier: string): Promise<PublishTemplateResponse>;
1174
+ update(identifier: string, payload: UpdateTemplateOptions): Promise<UpdateTemplateResponse>;
1175
+ }
1176
+
1177
+ interface Topic {
1178
+ id: string;
1179
+ name: string;
1180
+ description?: string;
1181
+ defaultSubscription: 'opt_in' | 'opt_out';
1182
+ created_at: string;
1183
+ }
1184
+
1185
+ interface CreateTopicOptions {
1186
+ name: string;
1187
+ description?: string;
1188
+ defaultSubscription: 'opt_in' | 'opt_out';
1189
+ }
1190
+ type CreateTopicResponseSuccess = Pick<Topic, 'id'>;
1191
+ type CreateTopicResponse = Response<CreateTopicResponseSuccess>;
1192
+
1193
+ type GetTopicResponseSuccess = Topic;
1194
+ type GetTopicResponse = Response<GetTopicResponseSuccess>;
1195
+
1196
+ interface ListTopicsResponseSuccess {
1197
+ data: Topic[];
1198
+ }
1199
+ type ListTopicsResponse = Response<ListTopicsResponseSuccess>;
1200
+
1201
+ type RemoveTopicResponseSuccess = Pick<Topic, 'id'> & {
1202
+ object: 'topic';
1203
+ deleted: boolean;
1204
+ };
1205
+ type RemoveTopicResponse = Response<RemoveTopicResponseSuccess>;
1206
+
1207
+ interface UpdateTopicOptions {
1208
+ id: string;
1209
+ name?: string;
1210
+ description?: string;
1211
+ }
1212
+ type UpdateTopicResponseSuccess = Pick<Topic, 'id'>;
1213
+ type UpdateTopicResponse = Response<UpdateTopicResponseSuccess>;
1214
+
1215
+ declare class Topics {
1216
+ private readonly resend;
1217
+ constructor(resend: Resend);
1218
+ create(payload: CreateTopicOptions): Promise<CreateTopicResponse>;
1219
+ list(): Promise<ListTopicsResponse>;
1220
+ get(id: string): Promise<GetTopicResponse>;
1221
+ update(payload: UpdateTopicOptions): Promise<UpdateTopicResponse>;
1222
+ remove(id: string): Promise<RemoveTopicResponse>;
1223
+ }
1224
+
1225
+ type WebhookEvent = 'email.sent' | 'email.delivered' | 'email.delivery_delayed' | 'email.complained' | 'email.bounced' | 'email.opened' | 'email.clicked' | 'email.received' | 'email.failed' | 'contact.created' | 'contact.updated' | 'contact.deleted' | 'domain.created' | 'domain.updated' | 'domain.deleted';
1226
+
1227
+ interface CreateWebhookOptions {
1228
+ endpoint: string;
1229
+ events: WebhookEvent[];
1230
+ }
1231
+ interface CreateWebhookRequestOptions extends PostOptions {
1232
+ }
1233
+ interface CreateWebhookResponseSuccess {
1234
+ object: 'webhook';
1235
+ id: string;
1236
+ signing_secret: string;
1237
+ }
1238
+ type CreateWebhookResponse = Response<CreateWebhookResponseSuccess>;
1239
+
1240
+ interface GetWebhookResponseSuccess {
1241
+ object: 'webhook';
1242
+ id: string;
1243
+ created_at: string;
1244
+ status: 'enabled' | 'disabled';
1245
+ endpoint: string;
1246
+ events: WebhookEvent[] | null;
1247
+ signing_secret: string;
1248
+ }
1249
+ type GetWebhookResponse = Response<GetWebhookResponseSuccess>;
1250
+
1251
+ type ListWebhooksOptions = PaginationOptions;
1252
+ interface Webhook {
1253
+ id: string;
1254
+ endpoint: string;
1255
+ created_at: string;
1256
+ status: 'enabled' | 'disabled';
1257
+ events: WebhookEvent[] | null;
1258
+ }
1259
+ type ListWebhooksResponseSuccess = {
1260
+ object: 'list';
1261
+ has_more: boolean;
1262
+ data: Webhook[];
1263
+ };
1264
+ type ListWebhooksResponse = Response<ListWebhooksResponseSuccess>;
1265
+
1266
+ type RemoveWebhookResponseSuccess = Pick<Webhook, 'id'> & {
1267
+ object: 'webhook';
1268
+ deleted: boolean;
1269
+ };
1270
+ type RemoveWebhookResponse = Response<RemoveWebhookResponseSuccess>;
1271
+
1272
+ interface UpdateWebhookOptions {
1273
+ endpoint?: string;
1274
+ events?: WebhookEvent[];
1275
+ status?: 'enabled' | 'disabled';
1276
+ }
1277
+ interface UpdateWebhookResponseSuccess {
1278
+ object: 'webhook';
1279
+ id: string;
1280
+ }
1281
+ type UpdateWebhookResponse = Response<UpdateWebhookResponseSuccess>;
1282
+
1025
1283
  interface Headers {
1026
1284
  id: string;
1027
1285
  timestamp: string;
@@ -1047,56 +1305,27 @@ declare class Resend {
1047
1305
  readonly key?: string | undefined;
1048
1306
  private readonly headers;
1049
1307
  readonly apiKeys: ApiKeys;
1050
- readonly audiences: Audiences;
1308
+ readonly segments: Segments;
1309
+ /**
1310
+ * @deprecated Use segments instead
1311
+ */
1312
+ readonly audiences: Segments;
1051
1313
  readonly batch: Batch;
1052
1314
  readonly broadcasts: Broadcasts;
1053
1315
  readonly contacts: Contacts;
1316
+ readonly contactProperties: ContactProperties;
1054
1317
  readonly domains: Domains;
1055
1318
  readonly emails: Emails;
1056
1319
  readonly webhooks: Webhooks;
1320
+ readonly templates: Templates;
1321
+ readonly topics: Topics;
1057
1322
  constructor(key?: string | undefined);
1058
- fetchRequest<T>(path: string, options?: {}): Promise<{
1059
- data: T;
1060
- error: null;
1061
- } | {
1062
- data: null;
1063
- error: ErrorResponse;
1064
- }>;
1065
- post<T>(path: string, entity?: unknown, options?: PostOptions & IdempotentRequest): Promise<{
1066
- data: null;
1067
- error: ErrorResponse;
1068
- } | {
1069
- data: T;
1070
- error: null;
1071
- }>;
1072
- get<T>(path: string, options?: GetOptions): Promise<{
1073
- data: null;
1074
- error: ErrorResponse;
1075
- } | {
1076
- data: T;
1077
- error: null;
1078
- }>;
1079
- put<T>(path: string, entity: unknown, options?: PutOptions): Promise<{
1080
- data: null;
1081
- error: ErrorResponse;
1082
- } | {
1083
- data: T;
1084
- error: null;
1085
- }>;
1086
- patch<T>(path: string, entity: unknown, options?: PatchOptions): Promise<{
1087
- data: null;
1088
- error: ErrorResponse;
1089
- } | {
1090
- data: T;
1091
- error: null;
1092
- }>;
1093
- delete<T>(path: string, query?: unknown): Promise<{
1094
- data: null;
1095
- error: ErrorResponse;
1096
- } | {
1097
- data: T;
1098
- error: null;
1099
- }>;
1323
+ fetchRequest<T>(path: string, options?: {}): Promise<Response<T>>;
1324
+ post<T>(path: string, entity?: unknown, options?: PostOptions & IdempotentRequest): Promise<Response<T>>;
1325
+ get<T>(path: string, options?: GetOptions): Promise<Response<T>>;
1326
+ put<T>(path: string, entity: unknown, options?: PutOptions): Promise<Response<T>>;
1327
+ patch<T>(path: string, entity: unknown, options?: PatchOptions): Promise<Response<T>>;
1328
+ delete<T>(path: string, query?: unknown): Promise<Response<T>>;
1100
1329
  }
1101
1330
 
1102
- 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 CreateWebhookOptions, type CreateWebhookRequestOptions, type CreateWebhookResponse, type CreateWebhookResponseSuccess, type Domain, type DomainApiOptions, type DomainDkimRecord, type DomainNameservers, type DomainRecords, type DomainRegion, type DomainSpfRecord, type DomainStatus, type EmailApiAttachment, type EmailApiOptions, type ErrorResponse, type GetAudienceResponse, type GetAudienceResponseSuccess, type GetBroadcastResponse, type GetBroadcastResponseSuccess, type GetContactOptions, type GetContactResponse, type GetContactResponseSuccess, type GetDomainResponse, type GetDomainResponseSuccess, type GetEmailResponse, type GetEmailResponseSuccess, type GetOptions, type GetWebhookResponse, type GetWebhookResponseSuccess, 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 ListWebhooksOptions, type ListWebhooksResponse, type ListWebhooksResponseSuccess, 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 RemoveWebhookResponse, type RemoveWebhookResponseSuccess, 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 UpdateWebhookOptions, type UpdateWebhookResponse, type UpdateWebhookResponseSuccess, type VerifyDomainsResponse, type VerifyDomainsResponseSuccess, type Webhook, type WebhookEvent };
1331
+ export { type ApiKey, type Attachment$1 as Attachment, type Broadcast, type CancelEmailResponse, type CancelEmailResponseSuccess, type Contact, type CreateApiKeyOptions, type CreateApiKeyRequestOptions, type CreateApiKeyResponse, type CreateApiKeyResponseSuccess, type CreateBatchOptions, type CreateBatchRequestOptions, type CreateBatchResponse, type CreateBatchSuccessResponse, type CreateBroadcastOptions, type CreateBroadcastRequestOptions, type CreateBroadcastResponse, type CreateBroadcastResponseSuccess, type CreateContactOptions, type CreateContactRequestOptions, type CreateContactResponse, type CreateContactResponseSuccess, type CreateDomainOptions, type CreateDomainRequestOptions, type CreateDomainResponse, type CreateDomainResponseSuccess, type CreateEmailOptions, type CreateEmailRequestOptions, type CreateEmailResponse, type CreateEmailResponseSuccess, type CreateSegmentOptions, type CreateSegmentRequestOptions, type CreateSegmentResponse, type CreateSegmentResponseSuccess, type CreateWebhookOptions, type CreateWebhookRequestOptions, type CreateWebhookResponse, type CreateWebhookResponseSuccess, type Domain, type DomainApiOptions, type DomainDkimRecord, type DomainNameservers, type DomainRecords, type DomainRegion, type DomainSpfRecord, type DomainStatus, type EmailApiAttachment, type EmailApiOptions, type ErrorResponse, type GetAttachmentOptions, type GetAttachmentResponse, type GetAttachmentResponseSuccess, type GetBroadcastResponse, type GetBroadcastResponseSuccess, type GetContactOptions, type GetContactResponse, type GetContactResponseSuccess, type GetDomainResponse, type GetDomainResponseSuccess, type GetEmailResponse, type GetEmailResponseSuccess, type GetOptions, type GetReceivingEmailResponse, type GetReceivingEmailResponseSuccess, type GetSegmentResponse, type GetSegmentResponseSuccess, type GetWebhookResponse, type GetWebhookResponseSuccess, type IdempotentRequest, type ListApiKeysOptions, type ListApiKeysResponse, type ListApiKeysResponseSuccess, type ListAttachmentsApiResponse, type ListAttachmentsOptions, type ListAttachmentsResponse, type ListAttachmentsResponseSuccess, type ListAudienceContactsOptions, type ListBroadcastsOptions, type ListBroadcastsResponse, type ListBroadcastsResponseSuccess, type ListContactsOptions, type ListContactsResponse, type ListContactsResponseSuccess, type ListDomainsOptions, type ListDomainsResponse, type ListDomainsResponseSuccess, type ListReceivingEmail, type ListReceivingEmailsOptions, type ListReceivingEmailsResponse, type ListReceivingEmailsResponseSuccess, type ListSegmentsOptions, type ListSegmentsResponse, type ListSegmentsResponseSuccess, type ListWebhooksOptions, type ListWebhooksResponse, type ListWebhooksResponseSuccess, type PaginatedData, type PaginationOptions, type PatchOptions, type PostOptions, type PutOptions, type ReceivingRecord, type RemoveApiKeyResponse, type RemoveApiKeyResponseSuccess, type RemoveBroadcastResponse, type RemoveBroadcastResponseSuccess, type RemoveContactOptions, type RemoveContactsResponse, type RemoveContactsResponseSuccess, type RemoveDomainsResponse, type RemoveDomainsResponseSuccess, type RemoveSegmentResponse, type RemoveSegmentResponseSuccess, type RemoveWebhookResponse, type RemoveWebhookResponseSuccess, type RequireAtLeastOne, Resend, type Segment, type SelectingField, type SendBroadcastOptions, type SendBroadcastRequestOptions, type SendBroadcastResponse, type SendBroadcastResponseSuccess, type Tag, type UpdateBroadcastOptions, type UpdateBroadcastResponse, type UpdateBroadcastResponseSuccess, type UpdateContactOptions, type UpdateContactResponse, type UpdateContactResponseSuccess, type UpdateDomainsOptions, type UpdateDomainsResponse, type UpdateDomainsResponseSuccess, type UpdateEmailOptions, type UpdateEmailResponse, type UpdateEmailResponseSuccess, type UpdateWebhookOptions, type UpdateWebhookResponse, type UpdateWebhookResponseSuccess, type VerifyDomainsResponse, type VerifyDomainsResponseSuccess, type Webhook, type WebhookEvent };