smartletter 0.0.0-stage → 1.0.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.
@@ -0,0 +1,3950 @@
1
+ type KeyTree = {
2
+ [camelKey: string]: {
3
+ wire: string;
4
+ props?: KeyTree;
5
+ items?: KeyTree;
6
+ };
7
+ };
8
+ interface Operation {
9
+ id: string;
10
+ method: "GET" | "POST" | "PATCH" | "DELETE";
11
+ path: string;
12
+ pathParams: string[];
13
+ body?: KeyTree;
14
+ bodyIsArray?: boolean;
15
+ /** Body is raw bytes (images.create), not JSON. */
16
+ rawBody?: boolean;
17
+ query?: KeyTree;
18
+ paginated: boolean;
19
+ idempotent: boolean;
20
+ /** Response body is returned as text (non-JSON content type, e.g. CSV). */
21
+ responseType?: "text";
22
+ }
23
+
24
+ interface RequestOptions {
25
+ idempotencyKey?: string;
26
+ headers?: HeadersInit;
27
+ signal?: AbortSignal;
28
+ }
29
+ type ErrorResponse = {
30
+ name: string;
31
+ message: string;
32
+ statusCode: number | null;
33
+ };
34
+ type Response<T> = {
35
+ data: T;
36
+ error: null;
37
+ headers: Record<string, string> | null;
38
+ } | {
39
+ data: null;
40
+ error: ErrorResponse;
41
+ headers: Record<string, string> | null;
42
+ };
43
+
44
+ declare class Client {
45
+ readonly key: string;
46
+ readonly baseUrl: string;
47
+ private readonly userAgent;
48
+ constructor(key?: string, options?: {
49
+ baseUrl?: string;
50
+ userAgent?: string;
51
+ });
52
+ call(op: Operation, args: Record<string, unknown> | unknown[] | BodyInit | undefined, options?: RequestOptions): Promise<Response<unknown>>;
53
+ }
54
+
55
+ interface EmailsSendParams {
56
+ /**
57
+ * `Name <address@your-domain>`; the domain must be verified. Optional with a template that has one.
58
+ */
59
+ from: string;
60
+ /**
61
+ * Up to 50 addresses.
62
+ */
63
+ to: string | string[];
64
+ /**
65
+ * Optional with a template that has one.
66
+ */
67
+ subject: string;
68
+ /**
69
+ * Send a published template instead of `html` / `text` (which are then refused). `from`, `subject` and `reply_to` override the template's.
70
+ */
71
+ template?: {
72
+ /**
73
+ * Id or alias of a published template.
74
+ */
75
+ id: string;
76
+ variables?: {
77
+ [k: string]: string | number;
78
+ };
79
+ };
80
+ html?: string;
81
+ /**
82
+ * Generated from `html` when absent; `""` sends HTML only.
83
+ */
84
+ text?: string;
85
+ cc?: string | string[];
86
+ bcc?: string | string[];
87
+ replyTo?: string | string[];
88
+ headers?: {
89
+ [k: string]: string;
90
+ };
91
+ tags?: {
92
+ name: string;
93
+ value: string;
94
+ }[];
95
+ /**
96
+ * Send later: ISO 8601 (`2026-10-20T09:00:00Z`) or English like `in 1 hour`, `tomorrow at 9am`. Up to 30 days.
97
+ */
98
+ scheduledAt?: string;
99
+ /**
100
+ * Up to 20 files, 10 MB in total. Executable types (.exe, .js, .bat…) are refused.
101
+ */
102
+ attachments?: {
103
+ /**
104
+ * File content in base64. Give `content` or `path`.
105
+ */
106
+ content?: string;
107
+ /**
108
+ * https URL of the file. We download it (10 s max, redirects not followed).
109
+ */
110
+ path?: string;
111
+ /**
112
+ * Required with `content`. Taken from the URL with `path`.
113
+ */
114
+ filename?: string;
115
+ /**
116
+ * Derived from the file name when absent.
117
+ */
118
+ contentType?: string;
119
+ /**
120
+ * Makes the file an inline image: reference it as `<img src="cid:…">` in the html.
121
+ */
122
+ contentId?: string;
123
+ }[];
124
+ }
125
+ type EmailsSendResponse = {
126
+ id: string;
127
+ };
128
+ type BatchSendParams = {
129
+ /**
130
+ * `Name <address@your-domain>`; the domain must be verified. Optional with a template that has one.
131
+ */
132
+ from: string;
133
+ /**
134
+ * Up to 50 addresses.
135
+ */
136
+ to: string | string[];
137
+ /**
138
+ * Optional with a template that has one.
139
+ */
140
+ subject: string;
141
+ /**
142
+ * Send a published template instead of `html` / `text` (which are then refused). `from`, `subject` and `reply_to` override the template's.
143
+ */
144
+ template?: {
145
+ /**
146
+ * Id or alias of a published template.
147
+ */
148
+ id: string;
149
+ variables?: {
150
+ [k: string]: string | number;
151
+ };
152
+ };
153
+ html?: string;
154
+ /**
155
+ * Generated from `html` when absent; `""` sends HTML only.
156
+ */
157
+ text?: string;
158
+ cc?: string | string[];
159
+ bcc?: string | string[];
160
+ replyTo?: string | string[];
161
+ headers?: {
162
+ [k: string]: string;
163
+ };
164
+ tags?: {
165
+ name: string;
166
+ value: string;
167
+ }[];
168
+ /**
169
+ * Send later: ISO 8601 (`2026-10-20T09:00:00Z`) or English like `in 1 hour`, `tomorrow at 9am`. Up to 30 days.
170
+ */
171
+ scheduledAt?: string;
172
+ }[];
173
+ type BatchSendResponse = {
174
+ data: {
175
+ id: string;
176
+ }[];
177
+ errors?: {
178
+ index: number;
179
+ message: string;
180
+ }[];
181
+ };
182
+ interface EmailsListParams {
183
+ /**
184
+ * 1–100, default 20.
185
+ */
186
+ limit?: number;
187
+ /**
188
+ * Id of the last item of the previous page (older items).
189
+ */
190
+ after?: string;
191
+ /**
192
+ * Id of the first item of the previous page (newer items).
193
+ */
194
+ before?: string;
195
+ }
196
+ type EmailsListResponse = {
197
+ object: string;
198
+ has_more: boolean;
199
+ data: {
200
+ object: string;
201
+ id: string;
202
+ message_id: string | null;
203
+ to: string[];
204
+ from: string;
205
+ created_at: string;
206
+ subject: string;
207
+ bcc: string[];
208
+ cc: string[];
209
+ reply_to: string[];
210
+ last_event: string;
211
+ scheduled_at: string | null;
212
+ }[];
213
+ };
214
+ interface EmailsGetParams {
215
+ id: string;
216
+ }
217
+ type EmailsGetResponse = {
218
+ object: string;
219
+ id: string;
220
+ message_id: string | null;
221
+ to: string[];
222
+ from: string;
223
+ created_at: string;
224
+ subject: string;
225
+ bcc: string[];
226
+ cc: string[];
227
+ reply_to: string[];
228
+ last_event: string;
229
+ scheduled_at: string | null;
230
+ html: string | null;
231
+ text: string | null;
232
+ tags: {
233
+ name: string;
234
+ value: string;
235
+ }[];
236
+ status: string;
237
+ created_via: string;
238
+ attachments: {
239
+ filename: string;
240
+ content_type: string;
241
+ content_id: string | null;
242
+ size: number;
243
+ }[];
244
+ recipients: {
245
+ email: string;
246
+ type: string;
247
+ status: string;
248
+ reason: string | null;
249
+ bounce_type: string | null;
250
+ smtp_status: string | null;
251
+ diagnostic_code: string | null;
252
+ delay_type: string | null;
253
+ delay_expires_at: string | null;
254
+ last_event_at: string | null;
255
+ }[];
256
+ smtp?: {
257
+ client_ip: string | null;
258
+ message_id: string | null;
259
+ };
260
+ };
261
+ type EmailsUpdateParams = {
262
+ id: string;
263
+ } & {
264
+ /**
265
+ * New send time: ISO 8601 or English like `in 2 hours`. Up to 30 days.
266
+ */
267
+ scheduledAt: string;
268
+ };
269
+ type EmailsUpdateResponse = {
270
+ object: string;
271
+ id: string;
272
+ };
273
+ interface EmailsCancelParams {
274
+ id: string;
275
+ }
276
+ type EmailsCancelResponse = {
277
+ object: string;
278
+ id: string;
279
+ };
280
+ interface TemplatesCreateParams {
281
+ name: string;
282
+ /**
283
+ * Unique in the workspace; use it instead of the id (`/templates/order-receipt`). Letters, digits, `.`, `_`, `-`.
284
+ */
285
+ alias?: string | null;
286
+ /**
287
+ * Default sender; the send's `from` wins.
288
+ */
289
+ from?: string | null;
290
+ /**
291
+ * Default subject; the send's `subject` wins. May use variables.
292
+ */
293
+ subject?: string | null;
294
+ replyTo?: (string | string[]) | null;
295
+ /**
296
+ * Variables as `{{{KEY}}}` or `{{KEY}}`; values are HTML-escaped.
297
+ */
298
+ html: string;
299
+ /**
300
+ * Generated from the HTML when absent; `""` sends HTML only.
301
+ */
302
+ text?: string | null;
303
+ variables?: {
304
+ /**
305
+ * Letters, digits, underscore (`PRODUCT_NAME`). Reserved: FIRST_NAME, LAST_NAME, EMAIL, UNSUBSCRIBE_URL, contact, this.
306
+ */
307
+ key: string;
308
+ type: "string" | "number";
309
+ /**
310
+ * Used when the send gives no value. Must match `type`.
311
+ */
312
+ fallbackValue?: (string | number) | null;
313
+ /**
314
+ * Without a fallback: `true` (default) refuses a send without this value, `false` renders it empty.
315
+ */
316
+ required?: boolean;
317
+ }[];
318
+ }
319
+ type TemplatesCreateResponse = {
320
+ object: string;
321
+ id: string;
322
+ };
323
+ interface TemplatesListParams {
324
+ /**
325
+ * 1–100, default 20.
326
+ */
327
+ limit?: number;
328
+ /**
329
+ * Id of the last item of the previous page (older items).
330
+ */
331
+ after?: string;
332
+ /**
333
+ * Id of the first item of the previous page (newer items).
334
+ */
335
+ before?: string;
336
+ }
337
+ type TemplatesListResponse = {
338
+ object: string;
339
+ has_more: boolean;
340
+ data: {
341
+ id: string;
342
+ name: string;
343
+ alias: string | null;
344
+ status: string;
345
+ published_at: string | null;
346
+ archived: boolean;
347
+ created_at: string;
348
+ updated_at: string;
349
+ }[];
350
+ };
351
+ interface TemplatesGetParams {
352
+ id: string;
353
+ }
354
+ type TemplatesGetResponse = {
355
+ object: string;
356
+ id: string;
357
+ current_version_id: string | null;
358
+ current_version_number: number | null;
359
+ published_version_id: string | null;
360
+ published_version_number: number | null;
361
+ alias: string | null;
362
+ name: string;
363
+ created_at: string;
364
+ updated_at: string;
365
+ status: string;
366
+ published_at: string | null;
367
+ archived: boolean;
368
+ from: string | null;
369
+ subject: string | null;
370
+ reply_to: string[] | null;
371
+ html: string;
372
+ text: string | null;
373
+ variables: {
374
+ id: string;
375
+ key: string;
376
+ type: string;
377
+ fallback_value: string | number | null;
378
+ required: boolean;
379
+ created_at: string;
380
+ updated_at: string;
381
+ }[];
382
+ has_unpublished_versions: boolean;
383
+ };
384
+ type TemplatesUpdateParams = {
385
+ id: string;
386
+ } & {
387
+ name?: string;
388
+ /**
389
+ * Unique in the workspace; use it instead of the id (`/templates/order-receipt`). Letters, digits, `.`, `_`, `-`.
390
+ */
391
+ alias?: string | null;
392
+ /**
393
+ * Default sender; the send's `from` wins.
394
+ */
395
+ from?: string | null;
396
+ /**
397
+ * Default subject; the send's `subject` wins. May use variables.
398
+ */
399
+ subject?: string | null;
400
+ replyTo?: (string | string[]) | null;
401
+ /**
402
+ * Variables as `{{{KEY}}}` or `{{KEY}}`; values are HTML-escaped.
403
+ */
404
+ html?: string;
405
+ /**
406
+ * Generated from the HTML when absent; `""` sends HTML only.
407
+ */
408
+ text?: string | null;
409
+ variables?: {
410
+ /**
411
+ * Letters, digits, underscore (`PRODUCT_NAME`). Reserved: FIRST_NAME, LAST_NAME, EMAIL, UNSUBSCRIBE_URL, contact, this.
412
+ */
413
+ key: string;
414
+ type: "string" | "number";
415
+ /**
416
+ * Used when the send gives no value. Must match `type`.
417
+ */
418
+ fallbackValue?: (string | number) | null;
419
+ /**
420
+ * Without a fallback: `true` (default) refuses a send without this value, `false` renders it empty.
421
+ */
422
+ required?: boolean;
423
+ }[];
424
+ /**
425
+ * Saved with the new version (history).
426
+ */
427
+ changeNote?: string;
428
+ };
429
+ type TemplatesUpdateResponse = {
430
+ object: string;
431
+ id: string;
432
+ };
433
+ interface TemplatesRemoveParams {
434
+ id: string;
435
+ }
436
+ type TemplatesRemoveResponse = {
437
+ object: string;
438
+ id: string;
439
+ deleted: boolean;
440
+ };
441
+ type TemplatesPublishParams = {
442
+ id: string;
443
+ } & {
444
+ /**
445
+ * Publish this version instead of the latest (rollback).
446
+ */
447
+ versionId?: string;
448
+ };
449
+ type TemplatesPublishResponse = {
450
+ object: string;
451
+ id: string;
452
+ };
453
+ interface TemplatesDuplicateParams {
454
+ id: string;
455
+ }
456
+ type TemplatesDuplicateResponse = {
457
+ object: string;
458
+ id: string;
459
+ };
460
+ type TemplatesVersionsParams = {
461
+ id: string;
462
+ } & {
463
+ /**
464
+ * 1–100, default 20.
465
+ */
466
+ limit?: number;
467
+ /**
468
+ * Id of the last item of the previous page (older items).
469
+ */
470
+ after?: string;
471
+ /**
472
+ * Id of the first item of the previous page (newer items).
473
+ */
474
+ before?: string;
475
+ };
476
+ type TemplatesVersionsResponse = {
477
+ object: string;
478
+ has_more: boolean;
479
+ data: {
480
+ object: string;
481
+ id: string;
482
+ number: number;
483
+ subject: string | null;
484
+ source: string;
485
+ change_note: string | null;
486
+ created_via: string;
487
+ published: boolean;
488
+ created_at: string;
489
+ }[];
490
+ };
491
+ interface NewslettersListParams {
492
+ /**
493
+ * 1–100, default 20.
494
+ */
495
+ limit?: number;
496
+ /**
497
+ * Id of the last item of the previous page (older items).
498
+ */
499
+ after?: string;
500
+ /**
501
+ * Id of the first item of the previous page (newer items).
502
+ */
503
+ before?: string;
504
+ status?: "draft" | "scheduled" | "sending" | "paused" | "sent" | "failed" | "held";
505
+ }
506
+ type NewslettersListResponse = {
507
+ object: string;
508
+ has_more: boolean;
509
+ data: {
510
+ object: string;
511
+ id: string;
512
+ segment_id: string;
513
+ topic_id: unknown;
514
+ subject: string;
515
+ preheader: string;
516
+ status: string;
517
+ body: {
518
+ format: string;
519
+ content: unknown;
520
+ blocks: {
521
+ blockId: string;
522
+ kind: string;
523
+ text: string;
524
+ }[];
525
+ };
526
+ audience_limit: unknown;
527
+ scheduled_for: unknown;
528
+ pause_reason: unknown;
529
+ recipient_estimate: unknown;
530
+ ab_test: unknown;
531
+ ab_winner: unknown;
532
+ created_at: string;
533
+ updated_at: string;
534
+ }[];
535
+ };
536
+ interface NewslettersCreateParams {
537
+ /**
538
+ * Subject line.
539
+ */
540
+ subject: string;
541
+ /**
542
+ * Preview text shown after the subject.
543
+ */
544
+ preheader?: string | null;
545
+ /**
546
+ * Newsletter (segment) to send from. Optional when the workspace has a single active newsletter.
547
+ */
548
+ segmentId?: string;
549
+ /**
550
+ * Topic of that newsletter; its subscribers receive the issue.
551
+ */
552
+ topicId?: string;
553
+ /**
554
+ * Body in Markdown. Give one of `markdown`, `html` or `blocks`.
555
+ */
556
+ markdown?: string;
557
+ /**
558
+ * Body in HTML (one raw HTML block). The platform footer is added around it.
559
+ */
560
+ html?: string;
561
+ /**
562
+ * Body as blocks: heading, text, list, quote, image, button, product, divider, columns (2–4) or html. Texts accept **bold**, *italic* and [links](https://…).
563
+ */
564
+ blocks?: ({
565
+ kind: "heading";
566
+ level: 1 | 2 | 3;
567
+ text: string;
568
+ } | {
569
+ kind: "text";
570
+ text: string;
571
+ } | {
572
+ kind: "list";
573
+ ordered: boolean;
574
+ items: string[];
575
+ } | {
576
+ kind: "quote";
577
+ text: string;
578
+ } | {
579
+ kind: "image";
580
+ url: string;
581
+ alt?: string;
582
+ } | {
583
+ kind: "button";
584
+ label: string;
585
+ url: string;
586
+ } | {
587
+ kind: "product";
588
+ title: string;
589
+ url: string;
590
+ imageUrl?: string;
591
+ price?: string;
592
+ description?: string;
593
+ ctaLabel?: string;
594
+ } | {
595
+ kind: "divider";
596
+ } | {
597
+ kind: "html";
598
+ html: string;
599
+ } | {
600
+ kind: "columns";
601
+ columns: ({
602
+ kind: "heading";
603
+ level: 1 | 2 | 3;
604
+ text: string;
605
+ } | {
606
+ kind: "text";
607
+ text: string;
608
+ } | {
609
+ kind: "list";
610
+ ordered: boolean;
611
+ items: string[];
612
+ } | {
613
+ kind: "quote";
614
+ text: string;
615
+ } | {
616
+ kind: "image";
617
+ url: string;
618
+ alt?: string;
619
+ } | {
620
+ kind: "button";
621
+ label: string;
622
+ url: string;
623
+ } | {
624
+ kind: "product";
625
+ title: string;
626
+ url: string;
627
+ imageUrl?: string;
628
+ price?: string;
629
+ description?: string;
630
+ ctaLabel?: string;
631
+ } | {
632
+ kind: "divider";
633
+ } | {
634
+ kind: "html";
635
+ html: string;
636
+ })[][];
637
+ })[];
638
+ /**
639
+ * Saved filter (`/audience-filters`): only the matching contacts of the topic receive the issue.
640
+ */
641
+ audienceFilterId?: string | null;
642
+ /**
643
+ * Subject A/B test (Pro plan or higher): 1 to 3 alternative subjects tested against the issue's own on a random sample; after the wait the rest gets the winner. `null` removes the test.
644
+ */
645
+ abTest?: {
646
+ /**
647
+ * The alternative subjects B, C, D (1 to 3). Variant A is the issue's own subject and preheader.
648
+ */
649
+ variants: {
650
+ /**
651
+ * Subject line of this variant.
652
+ */
653
+ subject: string;
654
+ /**
655
+ * Preview text of this variant (defaults to the issue's).
656
+ */
657
+ preheader?: string | null;
658
+ }[];
659
+ /**
660
+ * Share of the audience in the test sample, in percent (10–50, default 20).
661
+ */
662
+ samplePct?: number;
663
+ /**
664
+ * Winner criterion: unique `opens` (default; inflated by Apple Mail Privacy Protection) or unique `clicks`.
665
+ */
666
+ metric?: "opens" | "clicks";
667
+ /**
668
+ * Hours between the end of the sample and the choice (1–48, default 4).
669
+ */
670
+ waitHours?: number;
671
+ /**
672
+ * `auto` (default) picks the best rate; `manual` waits for your choice (auto pick 24 h after the wait).
673
+ */
674
+ winnerMode?: "auto" | "manual";
675
+ } | null;
676
+ }
677
+ type NewslettersCreateResponse = {
678
+ object: string;
679
+ id: string;
680
+ segment_id: string;
681
+ topic_id: unknown;
682
+ subject: string;
683
+ preheader: string;
684
+ status: string;
685
+ body: {
686
+ format: string;
687
+ content: unknown;
688
+ blocks: {
689
+ blockId: string;
690
+ kind: string;
691
+ text: string;
692
+ }[];
693
+ };
694
+ audience_limit: unknown;
695
+ scheduled_for: unknown;
696
+ pause_reason: unknown;
697
+ recipient_estimate: unknown;
698
+ ab_test: unknown;
699
+ ab_winner: unknown;
700
+ created_at: string;
701
+ updated_at: string;
702
+ };
703
+ interface NewslettersGetParams {
704
+ id: string;
705
+ }
706
+ type NewslettersGetResponse = {
707
+ object: string;
708
+ id: string;
709
+ segment_id: string;
710
+ topic_id: unknown;
711
+ subject: string;
712
+ preheader: string;
713
+ status: string;
714
+ body: {
715
+ format: string;
716
+ content: unknown;
717
+ blocks: {
718
+ blockId: string;
719
+ kind: string;
720
+ text: string;
721
+ }[];
722
+ };
723
+ audience_limit: unknown;
724
+ scheduled_for: unknown;
725
+ pause_reason: unknown;
726
+ recipient_estimate: unknown;
727
+ ab_test: unknown;
728
+ ab_winner: unknown;
729
+ created_at: string;
730
+ updated_at: string;
731
+ };
732
+ type NewslettersUpdateParams = {
733
+ id: string;
734
+ } & {
735
+ subject?: string;
736
+ preheader?: string | null;
737
+ topicId?: string;
738
+ markdown?: string;
739
+ html?: string;
740
+ /**
741
+ * Body as blocks: heading, text, list, quote, image, button, product, divider, columns (2–4) or html. Texts accept **bold**, *italic* and [links](https://…).
742
+ */
743
+ blocks?: ({
744
+ kind: "heading";
745
+ level: 1 | 2 | 3;
746
+ text: string;
747
+ } | {
748
+ kind: "text";
749
+ text: string;
750
+ } | {
751
+ kind: "list";
752
+ ordered: boolean;
753
+ items: string[];
754
+ } | {
755
+ kind: "quote";
756
+ text: string;
757
+ } | {
758
+ kind: "image";
759
+ url: string;
760
+ alt?: string;
761
+ } | {
762
+ kind: "button";
763
+ label: string;
764
+ url: string;
765
+ } | {
766
+ kind: "product";
767
+ title: string;
768
+ url: string;
769
+ imageUrl?: string;
770
+ price?: string;
771
+ description?: string;
772
+ ctaLabel?: string;
773
+ } | {
774
+ kind: "divider";
775
+ } | {
776
+ kind: "html";
777
+ html: string;
778
+ } | {
779
+ kind: "columns";
780
+ columns: ({
781
+ kind: "heading";
782
+ level: 1 | 2 | 3;
783
+ text: string;
784
+ } | {
785
+ kind: "text";
786
+ text: string;
787
+ } | {
788
+ kind: "list";
789
+ ordered: boolean;
790
+ items: string[];
791
+ } | {
792
+ kind: "quote";
793
+ text: string;
794
+ } | {
795
+ kind: "image";
796
+ url: string;
797
+ alt?: string;
798
+ } | {
799
+ kind: "button";
800
+ label: string;
801
+ url: string;
802
+ } | {
803
+ kind: "product";
804
+ title: string;
805
+ url: string;
806
+ imageUrl?: string;
807
+ price?: string;
808
+ description?: string;
809
+ ctaLabel?: string;
810
+ } | {
811
+ kind: "divider";
812
+ } | {
813
+ kind: "html";
814
+ html: string;
815
+ })[][];
816
+ })[];
817
+ /**
818
+ * Saved filter of the issue; `null` sends to the whole topic again.
819
+ */
820
+ audienceFilterId?: string | null;
821
+ /**
822
+ * Subject A/B test (Pro plan or higher): 1 to 3 alternative subjects tested against the issue's own on a random sample; after the wait the rest gets the winner. `null` removes the test.
823
+ */
824
+ abTest?: {
825
+ /**
826
+ * The alternative subjects B, C, D (1 to 3). Variant A is the issue's own subject and preheader.
827
+ */
828
+ variants: {
829
+ /**
830
+ * Subject line of this variant.
831
+ */
832
+ subject: string;
833
+ /**
834
+ * Preview text of this variant (defaults to the issue's).
835
+ */
836
+ preheader?: string | null;
837
+ }[];
838
+ /**
839
+ * Share of the audience in the test sample, in percent (10–50, default 20).
840
+ */
841
+ samplePct?: number;
842
+ /**
843
+ * Winner criterion: unique `opens` (default; inflated by Apple Mail Privacy Protection) or unique `clicks`.
844
+ */
845
+ metric?: "opens" | "clicks";
846
+ /**
847
+ * Hours between the end of the sample and the choice (1–48, default 4).
848
+ */
849
+ waitHours?: number;
850
+ /**
851
+ * `auto` (default) picks the best rate; `manual` waits for your choice (auto pick 24 h after the wait).
852
+ */
853
+ winnerMode?: "auto" | "manual";
854
+ } | null;
855
+ };
856
+ type NewslettersUpdateResponse = {
857
+ object: string;
858
+ id: string;
859
+ segment_id: string;
860
+ topic_id: unknown;
861
+ subject: string;
862
+ preheader: string;
863
+ status: string;
864
+ body: {
865
+ format: string;
866
+ content: unknown;
867
+ blocks: {
868
+ blockId: string;
869
+ kind: string;
870
+ text: string;
871
+ }[];
872
+ };
873
+ audience_limit: unknown;
874
+ scheduled_for: unknown;
875
+ pause_reason: unknown;
876
+ recipient_estimate: unknown;
877
+ ab_test: unknown;
878
+ ab_winner: unknown;
879
+ created_at: string;
880
+ updated_at: string;
881
+ };
882
+ interface NewslettersRemoveParams {
883
+ id: string;
884
+ }
885
+ type NewslettersRemoveResponse = {
886
+ object: string;
887
+ id: string;
888
+ deleted: boolean;
889
+ };
890
+ interface NewslettersDuplicateParams {
891
+ id: string;
892
+ }
893
+ type NewslettersDuplicateResponse = {
894
+ object: string;
895
+ id: string;
896
+ segment_id: string;
897
+ topic_id: unknown;
898
+ subject: string;
899
+ preheader: string;
900
+ status: string;
901
+ body: {
902
+ format: string;
903
+ content: unknown;
904
+ blocks: {
905
+ blockId: string;
906
+ kind: string;
907
+ text: string;
908
+ }[];
909
+ };
910
+ audience_limit: unknown;
911
+ scheduled_for: unknown;
912
+ pause_reason: unknown;
913
+ recipient_estimate: unknown;
914
+ ab_test: unknown;
915
+ ab_winner: unknown;
916
+ created_at: string;
917
+ updated_at: string;
918
+ };
919
+ interface NewslettersReviewParams {
920
+ id: string;
921
+ }
922
+ type NewslettersReviewResponse = {
923
+ object: string;
924
+ blocking: boolean;
925
+ items: {
926
+ id: string;
927
+ level: string;
928
+ values?: {
929
+ kb: number;
930
+ };
931
+ }[];
932
+ };
933
+ interface NewslettersTestParams {
934
+ id: string;
935
+ }
936
+ type NewslettersTestResponse = {
937
+ object: string;
938
+ to: string;
939
+ };
940
+ type NewslettersSendParams = {
941
+ id: string;
942
+ } & {
943
+ /**
944
+ * Send only to the N most engaged contacts now; the rest can follow with send-more.
945
+ */
946
+ audienceLimit?: number;
947
+ };
948
+ type NewslettersSendResponse = {
949
+ object: string;
950
+ id: string;
951
+ status: string;
952
+ };
953
+ type NewslettersScheduleParams = {
954
+ id: string;
955
+ } & {
956
+ /**
957
+ * ISO 8601 date, in the future, at most one year ahead.
958
+ */
959
+ scheduledAt: string;
960
+ /**
961
+ * Send only to the N most engaged contacts now; the rest can follow with send-more.
962
+ */
963
+ audienceLimit?: number;
964
+ };
965
+ type NewslettersScheduleResponse = {
966
+ object: string;
967
+ id: string;
968
+ status: string;
969
+ scheduled_for: string;
970
+ };
971
+ interface NewslettersUnscheduleParams {
972
+ id: string;
973
+ }
974
+ type NewslettersUnscheduleResponse = {
975
+ object: string;
976
+ id: string;
977
+ status: string;
978
+ };
979
+ interface NewslettersPauseParams {
980
+ id: string;
981
+ }
982
+ type NewslettersPauseResponse = {
983
+ object: string;
984
+ id: string;
985
+ status: string;
986
+ };
987
+ interface NewslettersResumeParams {
988
+ id: string;
989
+ }
990
+ type NewslettersResumeResponse = {
991
+ object: string;
992
+ id: string;
993
+ status: string;
994
+ };
995
+ type NewslettersSendMoreParams = {
996
+ id: string;
997
+ } & {
998
+ /**
999
+ * How many of the next most engaged contacts to add.
1000
+ */
1001
+ count: number;
1002
+ };
1003
+ type NewslettersSendMoreResponse = {
1004
+ object: string;
1005
+ id: string;
1006
+ status: string;
1007
+ };
1008
+ interface NewslettersReportParams {
1009
+ id: string;
1010
+ }
1011
+ type NewslettersReportResponse = {
1012
+ object: string;
1013
+ id: string;
1014
+ status: string;
1015
+ totals: {
1016
+ sent: number;
1017
+ delivered: number;
1018
+ opened: number;
1019
+ clicked: number;
1020
+ bounced: number;
1021
+ complained: number;
1022
+ unsubscribed: number;
1023
+ };
1024
+ rates: {
1025
+ delivery: number;
1026
+ open: number;
1027
+ click: number;
1028
+ bounce: number;
1029
+ complaint: number;
1030
+ unsubscribe: number;
1031
+ };
1032
+ progress: {
1033
+ attempted: number;
1034
+ recipient_estimate: number;
1035
+ audience_limit: unknown;
1036
+ };
1037
+ providers: {
1038
+ provider: string;
1039
+ sent: number;
1040
+ delivered: number;
1041
+ opened: number;
1042
+ clicked: number;
1043
+ bounced: number;
1044
+ complained: number;
1045
+ }[];
1046
+ ab_test: {
1047
+ phase: string;
1048
+ sample_pct: number;
1049
+ metric: string;
1050
+ wait_hours: number;
1051
+ winner_mode: string;
1052
+ winner: unknown;
1053
+ decided_at: unknown;
1054
+ decided_by: unknown;
1055
+ decide_at: string;
1056
+ variants: {
1057
+ key: string;
1058
+ subject: string;
1059
+ preheader: string;
1060
+ total: {
1061
+ attempted: number;
1062
+ sent: number;
1063
+ delivered: number;
1064
+ opened: number;
1065
+ clicked: number;
1066
+ hard_bounced: number;
1067
+ complained: number;
1068
+ unsubscribed: number;
1069
+ };
1070
+ }[];
1071
+ report: {
1072
+ metric: string;
1073
+ leader: string;
1074
+ winner: unknown;
1075
+ p_value: number;
1076
+ significant: boolean;
1077
+ variants: {
1078
+ variant: string;
1079
+ sent: number;
1080
+ opened: number;
1081
+ clicked: number;
1082
+ open_rate: number;
1083
+ click_rate: number;
1084
+ ci_low: number;
1085
+ ci_high: number;
1086
+ leader: boolean;
1087
+ }[];
1088
+ };
1089
+ };
1090
+ links: {
1091
+ url: string;
1092
+ label: string;
1093
+ clicks: number;
1094
+ unique_clickers: number;
1095
+ share: number;
1096
+ }[];
1097
+ links_total: number;
1098
+ };
1099
+ type NewslettersAbWinnerParams = {
1100
+ id: string;
1101
+ } & {
1102
+ /**
1103
+ * The winning variant: `A` (the issue's own subject), `B`, `C` or `D`.
1104
+ */
1105
+ variant: "A" | "B" | "C" | "D";
1106
+ };
1107
+ type NewslettersAbWinnerResponse = {
1108
+ object: string;
1109
+ id: string;
1110
+ segment_id: string;
1111
+ topic_id: unknown;
1112
+ subject: string;
1113
+ preheader: string;
1114
+ status: string;
1115
+ body: {
1116
+ format: string;
1117
+ content: unknown;
1118
+ blocks: {
1119
+ blockId: string;
1120
+ kind: string;
1121
+ text: string;
1122
+ }[];
1123
+ };
1124
+ audience_limit: unknown;
1125
+ scheduled_for: unknown;
1126
+ pause_reason: unknown;
1127
+ recipient_estimate: unknown;
1128
+ ab_test: unknown;
1129
+ ab_winner: string;
1130
+ created_at: string;
1131
+ updated_at: string;
1132
+ };
1133
+ interface ContactsListParams {
1134
+ /**
1135
+ * 1–100, default 20.
1136
+ */
1137
+ limit?: number;
1138
+ /**
1139
+ * Id of the last item of the previous page (older items).
1140
+ */
1141
+ after?: string;
1142
+ /**
1143
+ * Id of the first item of the previous page (newer items).
1144
+ */
1145
+ before?: string;
1146
+ segmentId?: string;
1147
+ status?: "active" | "pending" | "unsubscribed" | "bounced" | "complained" | "dormant";
1148
+ /**
1149
+ * Substring of the email address.
1150
+ */
1151
+ search?: string;
1152
+ /**
1153
+ * Only contacts with this tag (case-insensitive).
1154
+ */
1155
+ tag?: string;
1156
+ }
1157
+ type ContactsListResponse = {
1158
+ object: string;
1159
+ has_more: boolean;
1160
+ data: {
1161
+ object: string;
1162
+ id: string;
1163
+ email: string;
1164
+ status: string;
1165
+ segment_id: string;
1166
+ }[];
1167
+ };
1168
+ interface ContactsCreateParams {
1169
+ email: string;
1170
+ /**
1171
+ * Optional when the workspace has a single active newsletter.
1172
+ */
1173
+ segmentId?: string;
1174
+ name?: string;
1175
+ /**
1176
+ * Used by `{{first_name}}` in your issues.
1177
+ */
1178
+ firstName?: string;
1179
+ lastName?: string;
1180
+ language?: string;
1181
+ /**
1182
+ * Custom field values by key (`/contact-fields`): text, number, `YYYY-MM-DD` date, boolean or one of the choices. `null` erases a value.
1183
+ */
1184
+ customFields?: {
1185
+ [k: string]: string | number | boolean | null;
1186
+ };
1187
+ /**
1188
+ * Added to the contact's tags (also when the contact already exists).
1189
+ */
1190
+ tags?: string[];
1191
+ }
1192
+ type ContactsCreateResponse = {
1193
+ object: string;
1194
+ id: string;
1195
+ email: string;
1196
+ status: string;
1197
+ existed: boolean;
1198
+ };
1199
+ interface ContactsImportParams {
1200
+ segmentId?: string;
1201
+ /**
1202
+ * You confirm every contact opted in to receive this newsletter (no bought, rented or scraped list).
1203
+ */
1204
+ consent: true;
1205
+ contacts: {
1206
+ /**
1207
+ * Checked by the import cleaning; an invalid address is reported, not an error.
1208
+ */
1209
+ email: string;
1210
+ name?: string | null;
1211
+ firstName?: string | null;
1212
+ lastName?: string | null;
1213
+ language?: string | null;
1214
+ customFields?: {
1215
+ [k: string]: string | number | boolean | null;
1216
+ } | null;
1217
+ /**
1218
+ * Open rate on your previous platform (0–1).
1219
+ */
1220
+ openRate?: number | null;
1221
+ /**
1222
+ * Click rate on your previous platform (0–1).
1223
+ */
1224
+ clickRate?: number | null;
1225
+ /**
1226
+ * Last open or click on your previous platform.
1227
+ */
1228
+ lastActivityAt?: string | null;
1229
+ /**
1230
+ * Merged into the tags of a contact already in the newsletter (never replaced).
1231
+ */
1232
+ tags?: string[] | null;
1233
+ /**
1234
+ * `unsubscribed` keeps a contact who left on your previous platform: stored unsubscribed, never emailed, and a contact already in the newsletter is unsubscribed too. Default `active`.
1235
+ */
1236
+ status?: ("active" | "unsubscribed") | null;
1237
+ /**
1238
+ * When they unsubscribed on the previous platform (with `status: "unsubscribed"`); default: the import time.
1239
+ */
1240
+ unsubscribedAt?: string | null;
1241
+ }[];
1242
+ }
1243
+ type ContactsImportResponse = {
1244
+ object: string;
1245
+ total: number;
1246
+ inserted: number;
1247
+ rejected: number;
1248
+ reasons: {
1249
+ invalid: number;
1250
+ typo: number;
1251
+ spam_trap: number;
1252
+ role: number;
1253
+ disposable: number;
1254
+ no_mx: number;
1255
+ duplicate: number;
1256
+ suppressed: number;
1257
+ capped: number;
1258
+ };
1259
+ rejected_rows: {
1260
+ line: number;
1261
+ email: string;
1262
+ reason: string;
1263
+ suggestion?: string;
1264
+ }[];
1265
+ pending_review: boolean;
1266
+ };
1267
+ interface ContactsExportParams {
1268
+ segmentId?: string;
1269
+ status?: "active" | "pending" | "unsubscribed" | "bounced" | "complained" | "dormant";
1270
+ }
1271
+ type ContactsExportResponse = string;
1272
+ interface ContactsGetParams {
1273
+ id: string;
1274
+ }
1275
+ type ContactsGetResponse = {
1276
+ object: string;
1277
+ id: string;
1278
+ email: string;
1279
+ status: string;
1280
+ engagement: {
1281
+ emails_sent: number;
1282
+ emails_opened: number;
1283
+ emails_clicked: number;
1284
+ };
1285
+ status_history: {
1286
+ at: string;
1287
+ from_status: string;
1288
+ to_status: string;
1289
+ source: string;
1290
+ actor: string;
1291
+ detail: unknown;
1292
+ }[];
1293
+ };
1294
+ interface ContactsUnsubscribeParams {
1295
+ id: string;
1296
+ }
1297
+ type ContactsUnsubscribeResponse = {
1298
+ object: string;
1299
+ id: string;
1300
+ status: string;
1301
+ };
1302
+ interface ContactsReactivateParams {
1303
+ id: string;
1304
+ }
1305
+ type ContactsReactivateResponse = {
1306
+ object: string;
1307
+ id: string;
1308
+ status: string;
1309
+ };
1310
+ interface ContactsRemoveParams {
1311
+ id: string;
1312
+ }
1313
+ type ContactsRemoveResponse = {
1314
+ object: string;
1315
+ id: string;
1316
+ deleted: boolean;
1317
+ };
1318
+ type ContactsUpdateParams = {
1319
+ id: string;
1320
+ } & {
1321
+ firstName?: string | null;
1322
+ lastName?: string | null;
1323
+ name?: string | null;
1324
+ language?: string | null;
1325
+ /**
1326
+ * Merged into the stored values; `null` erases a key.
1327
+ */
1328
+ customFields?: {
1329
+ [k: string]: string | number | boolean | null;
1330
+ };
1331
+ /**
1332
+ * Replaces every tag of the contact; `null` or `[]` removes them all.
1333
+ */
1334
+ tags?: string[] | null;
1335
+ /**
1336
+ * Added to the current tags.
1337
+ */
1338
+ addTags?: string[];
1339
+ /**
1340
+ * Removed from the current tags.
1341
+ */
1342
+ removeTags?: string[];
1343
+ };
1344
+ type ContactsUpdateResponse = {
1345
+ object: string;
1346
+ id: string;
1347
+ first_name: string;
1348
+ custom_fields: {
1349
+ plan: string;
1350
+ };
1351
+ };
1352
+ type ContactFieldsListParams = Record<string, never>;
1353
+ type ContactFieldsListResponse = {
1354
+ object: string;
1355
+ has_more: boolean;
1356
+ data: {
1357
+ object: string;
1358
+ id: string;
1359
+ key: string;
1360
+ label: string;
1361
+ type: string;
1362
+ options: string[];
1363
+ default_value: unknown;
1364
+ in_signup: boolean;
1365
+ position: number;
1366
+ created_at: string;
1367
+ }[];
1368
+ };
1369
+ interface ContactFieldsCreateParams {
1370
+ /**
1371
+ * Lowercase letters, digits, `_`. Used as `{{custom.<key>}}`. Immutable.
1372
+ */
1373
+ key: string;
1374
+ label: string;
1375
+ /**
1376
+ * Immutable.
1377
+ */
1378
+ type: "text" | "number" | "date" | "boolean" | "choice";
1379
+ /**
1380
+ * Choices of a `choice` field (1–50).
1381
+ */
1382
+ options?: string[];
1383
+ /**
1384
+ * Used by personalization when a contact has no value.
1385
+ */
1386
+ defaultValue?: string | number | boolean | null;
1387
+ /**
1388
+ * Accepted from signup forms (`POST /signups`).
1389
+ */
1390
+ inSignup?: boolean;
1391
+ }
1392
+ type ContactFieldsCreateResponse = {
1393
+ object: string;
1394
+ id: string;
1395
+ key: string;
1396
+ label: string;
1397
+ type: string;
1398
+ options: string[];
1399
+ default_value: unknown;
1400
+ in_signup: boolean;
1401
+ position: number;
1402
+ created_at: string;
1403
+ };
1404
+ type ContactFieldsUpdateParams = {
1405
+ id: string;
1406
+ } & {
1407
+ label?: string;
1408
+ options?: string[];
1409
+ defaultValue?: string | number | boolean | null;
1410
+ inSignup?: boolean;
1411
+ position?: number;
1412
+ };
1413
+ type ContactFieldsUpdateResponse = {
1414
+ object: string;
1415
+ id: string;
1416
+ key: string;
1417
+ label: string;
1418
+ type: string;
1419
+ options: string[];
1420
+ default_value: unknown;
1421
+ in_signup: boolean;
1422
+ position: number;
1423
+ created_at: string;
1424
+ };
1425
+ interface ContactFieldsRemoveParams {
1426
+ id: string;
1427
+ }
1428
+ type ContactFieldsRemoveResponse = {
1429
+ object: string;
1430
+ id: string;
1431
+ deleted: boolean;
1432
+ };
1433
+ interface EventsSendParams {
1434
+ /**
1435
+ * Give `email` or `contact_id`.
1436
+ */
1437
+ email?: string;
1438
+ contactId?: string;
1439
+ /**
1440
+ * Name like `purchase` or `trial.started` (letters, digits, `_ . : -`). `email.` and `contact.` are reserved.
1441
+ */
1442
+ event: string;
1443
+ /**
1444
+ * Free JSON object, 4 KB max.
1445
+ */
1446
+ properties?: {
1447
+ [k: string]: unknown;
1448
+ };
1449
+ /**
1450
+ * Defaults to now. Up to 13 months back, 1 hour ahead.
1451
+ */
1452
+ occurredAt?: string;
1453
+ /**
1454
+ * Create the contact when the address is unknown (as `POST /contacts`). Default `false`: 404.
1455
+ */
1456
+ createContact?: boolean;
1457
+ /**
1458
+ * Newsletter of a contact created with `create_contact`.
1459
+ */
1460
+ segmentId?: string;
1461
+ }
1462
+ type EventsSendResponse = {
1463
+ object: string;
1464
+ id: string;
1465
+ email: string;
1466
+ event: string;
1467
+ properties: {
1468
+ plan: string;
1469
+ amount: number;
1470
+ };
1471
+ occurred_at: string;
1472
+ contact_created: boolean;
1473
+ };
1474
+ interface AudienceFiltersListParams {
1475
+ /**
1476
+ * 1–100, default 20.
1477
+ */
1478
+ limit?: number;
1479
+ /**
1480
+ * Id of the last item of the previous page (older items).
1481
+ */
1482
+ after?: string;
1483
+ /**
1484
+ * Id of the first item of the previous page (newer items).
1485
+ */
1486
+ before?: string;
1487
+ }
1488
+ type AudienceFiltersListResponse = {
1489
+ object: string;
1490
+ has_more: boolean;
1491
+ data: {
1492
+ object: string;
1493
+ id: string;
1494
+ name: string;
1495
+ description: unknown;
1496
+ rules: {
1497
+ op: string;
1498
+ rules: {
1499
+ field?: string;
1500
+ op: string;
1501
+ value?: string;
1502
+ event?: string;
1503
+ within_days?: number;
1504
+ }[];
1505
+ };
1506
+ created_at: string;
1507
+ updated_at: string;
1508
+ }[];
1509
+ };
1510
+ interface AudienceFiltersCreateParams {
1511
+ name: string;
1512
+ description?: string | null;
1513
+ /**
1514
+ * AND/OR tree: `{"op":"and","rules":[{"field":"custom.plan","op":"eq","value":"pro"},{"event":"email.clicked","op":"performed","within_days":30}]}`. See the guide.
1515
+ */
1516
+ rules: {
1517
+ [k: string]: unknown;
1518
+ };
1519
+ }
1520
+ type AudienceFiltersCreateResponse = {
1521
+ object: string;
1522
+ id: string;
1523
+ name: string;
1524
+ description: unknown;
1525
+ rules: {
1526
+ op: string;
1527
+ rules: {
1528
+ field?: string;
1529
+ op: string;
1530
+ value?: string;
1531
+ event?: string;
1532
+ within_days?: number;
1533
+ }[];
1534
+ };
1535
+ created_at: string;
1536
+ updated_at: string;
1537
+ };
1538
+ interface AudienceFiltersGetParams {
1539
+ id: string;
1540
+ }
1541
+ type AudienceFiltersGetResponse = {
1542
+ object: string;
1543
+ id: string;
1544
+ name: string;
1545
+ description: unknown;
1546
+ rules: {
1547
+ op: string;
1548
+ rules: {
1549
+ field?: string;
1550
+ op: string;
1551
+ value?: string;
1552
+ event?: string;
1553
+ within_days?: number;
1554
+ }[];
1555
+ };
1556
+ created_at: string;
1557
+ updated_at: string;
1558
+ };
1559
+ type AudienceFiltersUpdateParams = {
1560
+ id: string;
1561
+ } & {
1562
+ name?: string;
1563
+ description?: string | null;
1564
+ /**
1565
+ * AND/OR tree: `{"op":"and","rules":[{"field":"custom.plan","op":"eq","value":"pro"},{"event":"email.clicked","op":"performed","within_days":30}]}`. See the guide.
1566
+ */
1567
+ rules?: {
1568
+ [k: string]: unknown;
1569
+ };
1570
+ };
1571
+ type AudienceFiltersUpdateResponse = {
1572
+ object: string;
1573
+ id: string;
1574
+ name: string;
1575
+ description: unknown;
1576
+ rules: {
1577
+ op: string;
1578
+ rules: {
1579
+ field?: string;
1580
+ op: string;
1581
+ value?: string;
1582
+ event?: string;
1583
+ within_days?: number;
1584
+ }[];
1585
+ };
1586
+ created_at: string;
1587
+ updated_at: string;
1588
+ };
1589
+ interface AudienceFiltersRemoveParams {
1590
+ id: string;
1591
+ }
1592
+ type AudienceFiltersRemoveResponse = {
1593
+ object: string;
1594
+ id: string;
1595
+ deleted: boolean;
1596
+ };
1597
+ interface AudienceFiltersCountParams {
1598
+ /**
1599
+ * A saved filter. Give `filter_id` or `rules`.
1600
+ */
1601
+ filterId?: string;
1602
+ /**
1603
+ * AND/OR tree: `{"op":"and","rules":[{"field":"custom.plan","op":"eq","value":"pro"},{"event":"email.clicked","op":"performed","within_days":30}]}`. See the guide.
1604
+ */
1605
+ rules?: {
1606
+ [k: string]: unknown;
1607
+ };
1608
+ /**
1609
+ * Count within one newsletter only.
1610
+ */
1611
+ segmentId?: string;
1612
+ }
1613
+ type AudienceFiltersCountResponse = {
1614
+ object: string;
1615
+ total: number;
1616
+ active: number;
1617
+ };
1618
+ interface SignupsCreateParams {
1619
+ email: string;
1620
+ name?: string;
1621
+ firstName?: string;
1622
+ /**
1623
+ * Optional when the workspace has a single active newsletter.
1624
+ */
1625
+ segmentId?: string;
1626
+ language?: string;
1627
+ /**
1628
+ * Page the form was on (attribution).
1629
+ */
1630
+ sourceUrl?: string;
1631
+ /**
1632
+ * Only fields marked `in_signup` are kept; other keys and invalid values are silently dropped.
1633
+ */
1634
+ customFields?: {
1635
+ [k: string]: string | number | boolean | null;
1636
+ };
1637
+ }
1638
+ type SignupsCreateResponse = {
1639
+ object: string;
1640
+ status: string;
1641
+ };
1642
+ interface SegmentsListParams {
1643
+ /**
1644
+ * 1–100, default 20.
1645
+ */
1646
+ limit?: number;
1647
+ /**
1648
+ * Id of the last item of the previous page (older items).
1649
+ */
1650
+ after?: string;
1651
+ /**
1652
+ * Id of the first item of the previous page (newer items).
1653
+ */
1654
+ before?: string;
1655
+ }
1656
+ type SegmentsListResponse = {
1657
+ object: string;
1658
+ has_more: boolean;
1659
+ data: {
1660
+ object: string;
1661
+ id: string;
1662
+ name: string;
1663
+ slug: string;
1664
+ }[];
1665
+ };
1666
+ interface SegmentsCreateParams {
1667
+ name: string;
1668
+ slug: string;
1669
+ language?: string;
1670
+ description?: string;
1671
+ themes?: string[];
1672
+ }
1673
+ type SegmentsCreateResponse = {
1674
+ object: string;
1675
+ id: string;
1676
+ name: string;
1677
+ slug: string;
1678
+ };
1679
+ interface TopicsListParams {
1680
+ segmentId: string;
1681
+ }
1682
+ type TopicsListResponse = {
1683
+ object: string;
1684
+ has_more: boolean;
1685
+ data: {
1686
+ object: string;
1687
+ id: string;
1688
+ segment_id: string;
1689
+ name: string;
1690
+ }[];
1691
+ };
1692
+ interface SegmentsArchiveGetParams {
1693
+ id: string;
1694
+ }
1695
+ type SegmentsArchiveGetResponse = {
1696
+ object: string;
1697
+ segment_id: string;
1698
+ enabled: boolean;
1699
+ slug: string;
1700
+ url: string;
1701
+ custom_domain: string;
1702
+ description: string;
1703
+ author: string;
1704
+ about: unknown;
1705
+ avatar_url: unknown;
1706
+ links: {
1707
+ x: string;
1708
+ };
1709
+ };
1710
+ type SegmentsArchiveUpdateParams = {
1711
+ id: string;
1712
+ } & {
1713
+ /**
1714
+ * Publish the sent issues of this newsletter on its public archive.
1715
+ */
1716
+ enabled?: boolean;
1717
+ /**
1718
+ * Archive address: `smartletter.ai/<locale>/n/<slug>`. Unique across Smartletter.
1719
+ */
1720
+ slug?: string;
1721
+ /**
1722
+ * One-line description (also the meta description).
1723
+ */
1724
+ description?: string | null;
1725
+ author?: string | null;
1726
+ /**
1727
+ * Text of the About page (plain text, blank lines between paragraphs).
1728
+ */
1729
+ about?: string | null;
1730
+ /**
1731
+ * https URL of an avatar or logo.
1732
+ */
1733
+ avatarUrl?: string | null;
1734
+ /**
1735
+ * Social links (https). Replaces the whole set.
1736
+ */
1737
+ links?: {
1738
+ website?: string | null;
1739
+ x?: string | null;
1740
+ linkedin?: string | null;
1741
+ youtube?: string | null;
1742
+ instagram?: string | null;
1743
+ github?: string | null;
1744
+ bluesky?: string | null;
1745
+ };
1746
+ };
1747
+ type SegmentsArchiveUpdateResponse = {
1748
+ object: string;
1749
+ segment_id: string;
1750
+ enabled: boolean;
1751
+ slug: string;
1752
+ url: string;
1753
+ custom_domain: string;
1754
+ description: string;
1755
+ author: string;
1756
+ about: unknown;
1757
+ avatar_url: unknown;
1758
+ links: {
1759
+ x: string;
1760
+ };
1761
+ };
1762
+ type NewslettersArchiveUpdateParams = {
1763
+ id: string;
1764
+ } & {
1765
+ /**
1766
+ * Pin at the top of the archive (3 pinned issues max per newsletter).
1767
+ */
1768
+ pinned?: boolean;
1769
+ /**
1770
+ * Hide this issue from the public archive.
1771
+ */
1772
+ hidden?: boolean;
1773
+ };
1774
+ type NewslettersArchiveUpdateResponse = {
1775
+ object: string;
1776
+ id: string;
1777
+ pinned: boolean;
1778
+ hidden: boolean;
1779
+ };
1780
+ interface SegmentsDomainGetParams {
1781
+ id: string;
1782
+ }
1783
+ type SegmentsDomainGetResponse = {
1784
+ object: string;
1785
+ id: string;
1786
+ segment_id: string;
1787
+ domain: string;
1788
+ status: string;
1789
+ uses: string[];
1790
+ records: {
1791
+ type: string;
1792
+ name: string;
1793
+ value: string;
1794
+ }[];
1795
+ last_checked_at: unknown;
1796
+ verified_at: unknown;
1797
+ last_error: unknown;
1798
+ created_at: string;
1799
+ };
1800
+ type SegmentsDomainSetParams = {
1801
+ id: string;
1802
+ } & {
1803
+ /**
1804
+ * Subdomain you own, e.g. `news.acme.com` (a CNAME to Vercel).
1805
+ */
1806
+ domain: string;
1807
+ };
1808
+ type SegmentsDomainSetResponse = {
1809
+ object: string;
1810
+ id: string;
1811
+ segment_id: string;
1812
+ domain: string;
1813
+ status: string;
1814
+ uses: string[];
1815
+ records: {
1816
+ type: string;
1817
+ name: string;
1818
+ value: string;
1819
+ }[];
1820
+ last_checked_at: unknown;
1821
+ verified_at: unknown;
1822
+ last_error: unknown;
1823
+ created_at: string;
1824
+ };
1825
+ interface SegmentsDomainRemoveParams {
1826
+ id: string;
1827
+ }
1828
+ type SegmentsDomainRemoveResponse = {
1829
+ object: string;
1830
+ segment_id: string;
1831
+ deleted: boolean;
1832
+ };
1833
+ interface SuppressionsListParams {
1834
+ /**
1835
+ * 1–100, default 20.
1836
+ */
1837
+ limit?: number;
1838
+ /**
1839
+ * Id of the last item of the previous page (older items).
1840
+ */
1841
+ after?: string;
1842
+ /**
1843
+ * Id of the first item of the previous page (newer items).
1844
+ */
1845
+ before?: string;
1846
+ reason?: "bounced" | "complained" | "user_unsub" | "admin" | "gdpr" | "ses_suppressed" | "soft_bounce_repeated";
1847
+ }
1848
+ type SuppressionsListResponse = {
1849
+ object: string;
1850
+ has_more: boolean;
1851
+ data: {
1852
+ object: string;
1853
+ id: string;
1854
+ email: string;
1855
+ reason: string;
1856
+ expires_at: string;
1857
+ }[];
1858
+ };
1859
+ interface SuppressionsCreateParams {
1860
+ email: string;
1861
+ reason?: "bounced" | "complained" | "user_unsub" | "admin" | "gdpr";
1862
+ notes?: string;
1863
+ }
1864
+ type SuppressionsCreateResponse = {
1865
+ object: string;
1866
+ id: string;
1867
+ email: string;
1868
+ reason: string;
1869
+ };
1870
+ interface SuppressionsRemoveParams {
1871
+ id: string;
1872
+ }
1873
+ type SuppressionsRemoveResponse = {
1874
+ object: string;
1875
+ id: string;
1876
+ deleted: boolean;
1877
+ };
1878
+ interface ImagesListParams {
1879
+ /**
1880
+ * 1–100, default 20.
1881
+ */
1882
+ limit?: number;
1883
+ /**
1884
+ * Id of the last item of the previous page (older items).
1885
+ */
1886
+ after?: string;
1887
+ /**
1888
+ * Id of the first item of the previous page (newer items).
1889
+ */
1890
+ before?: string;
1891
+ }
1892
+ type ImagesListResponse = {
1893
+ object: string;
1894
+ has_more: boolean;
1895
+ data: {
1896
+ object: string;
1897
+ id: string;
1898
+ url: string;
1899
+ }[];
1900
+ };
1901
+ type ImagesCreateParams = Blob | ArrayBuffer | Uint8Array | string;
1902
+ type ImagesCreateResponse = {
1903
+ object: string;
1904
+ id: string;
1905
+ url: string;
1906
+ content_type: string;
1907
+ size_bytes: number;
1908
+ };
1909
+ type StatsOverviewParams = Record<string, never>;
1910
+ type StatsOverviewResponse = {
1911
+ object: string;
1912
+ subscribers: {
1913
+ active: number;
1914
+ new_last_30_days: number;
1915
+ unsubscribed_last_30_days: number;
1916
+ };
1917
+ daily: {
1918
+ date: string;
1919
+ new_subscribers: number;
1920
+ unsubscribed: number;
1921
+ emails_sent: number;
1922
+ }[];
1923
+ emails: {
1924
+ sent_this_month: number;
1925
+ sent_last_30_days: number;
1926
+ newsletters_sent_last_30_days: number;
1927
+ };
1928
+ };
1929
+ interface DomainsCreateParams {
1930
+ name: string;
1931
+ trackingSubdomain?: string;
1932
+ }
1933
+ type DomainsCreateResponse = {
1934
+ object: string;
1935
+ id: string;
1936
+ name: string;
1937
+ status: string;
1938
+ created_at: string;
1939
+ region: string;
1940
+ records: {
1941
+ record: string;
1942
+ name: string;
1943
+ type: string;
1944
+ ttl: string;
1945
+ status: string;
1946
+ value: string;
1947
+ priority?: number;
1948
+ }[];
1949
+ tracking_subdomain?: string;
1950
+ };
1951
+ interface DomainsListParams {
1952
+ /**
1953
+ * 1–100, default 20.
1954
+ */
1955
+ limit?: number;
1956
+ /**
1957
+ * Id of the last item of the previous page (older items).
1958
+ */
1959
+ after?: string;
1960
+ /**
1961
+ * Id of the first item of the previous page (newer items).
1962
+ */
1963
+ before?: string;
1964
+ }
1965
+ type DomainsListResponse = {
1966
+ object: string;
1967
+ has_more: boolean;
1968
+ data: {
1969
+ id: string;
1970
+ name: string;
1971
+ status: string;
1972
+ created_at: string;
1973
+ region: string;
1974
+ }[];
1975
+ };
1976
+ interface DomainsGetParams {
1977
+ id: string;
1978
+ }
1979
+ type DomainsGetResponse = {
1980
+ object: string;
1981
+ id: string;
1982
+ name: string;
1983
+ status: string;
1984
+ created_at: string;
1985
+ region: string;
1986
+ records: {
1987
+ record: string;
1988
+ name: string;
1989
+ type: string;
1990
+ ttl: string;
1991
+ status: string;
1992
+ value: string;
1993
+ priority?: number;
1994
+ }[];
1995
+ };
1996
+ interface DomainsVerifyParams {
1997
+ id: string;
1998
+ }
1999
+ type DomainsVerifyResponse = {
2000
+ object: string;
2001
+ id: string;
2002
+ };
2003
+ interface ApiKeysCreateParams {
2004
+ name: string;
2005
+ permission?: "full_access" | "sending_access" | "signups";
2006
+ /**
2007
+ * Restricts a `sending_access` key to one verified domain.
2008
+ */
2009
+ domainId?: string;
2010
+ }
2011
+ type ApiKeysCreateResponse = {
2012
+ id: string;
2013
+ token: string;
2014
+ };
2015
+ interface ApiKeysListParams {
2016
+ /**
2017
+ * 1–100, default 20.
2018
+ */
2019
+ limit?: number;
2020
+ /**
2021
+ * Id of the last item of the previous page (older items).
2022
+ */
2023
+ after?: string;
2024
+ /**
2025
+ * Id of the first item of the previous page (newer items).
2026
+ */
2027
+ before?: string;
2028
+ }
2029
+ type ApiKeysListResponse = {
2030
+ object: string;
2031
+ has_more: boolean;
2032
+ data: {
2033
+ id: string;
2034
+ name: string;
2035
+ created_at: string;
2036
+ last_used_at: string | null;
2037
+ }[];
2038
+ };
2039
+ type ApiKeysUpdateParams = {
2040
+ id: string;
2041
+ } & {
2042
+ name: string;
2043
+ };
2044
+ type ApiKeysUpdateResponse = {
2045
+ object: string;
2046
+ id: string;
2047
+ };
2048
+ interface ApiKeysRemoveParams {
2049
+ id: string;
2050
+ }
2051
+ type ApiKeysRemoveResponse = {
2052
+ object: string;
2053
+ id: string;
2054
+ deleted: boolean;
2055
+ };
2056
+ interface LogsListParams {
2057
+ /**
2058
+ * 1–100, default 20.
2059
+ */
2060
+ limit?: number;
2061
+ /**
2062
+ * Id of the last item of the previous page (older items).
2063
+ */
2064
+ after?: string;
2065
+ /**
2066
+ * Id of the first item of the previous page (newer items).
2067
+ */
2068
+ before?: string;
2069
+ }
2070
+ type LogsListResponse = {
2071
+ object: string;
2072
+ has_more: boolean;
2073
+ data: {
2074
+ id: string;
2075
+ endpoint: string;
2076
+ method: string;
2077
+ response_status: number;
2078
+ source: string;
2079
+ }[];
2080
+ };
2081
+ interface LogsGetParams {
2082
+ id: string;
2083
+ }
2084
+ type LogsGetResponse = {
2085
+ object: string;
2086
+ id: string;
2087
+ endpoint: string;
2088
+ request_body: Record<string, unknown>;
2089
+ response_body: Record<string, unknown>;
2090
+ };
2091
+ type UsageGetParams = Record<string, never>;
2092
+ type UsageGetResponse = {
2093
+ object: string;
2094
+ emails: {
2095
+ monthly: {
2096
+ used: number;
2097
+ limit: number;
2098
+ };
2099
+ };
2100
+ contacts: {
2101
+ used: number;
2102
+ limit: unknown;
2103
+ };
2104
+ };
2105
+ interface SequencesListParams {
2106
+ /**
2107
+ * Archived sequences are hidden unless `true`.
2108
+ */
2109
+ includeArchived?: "true" | "false";
2110
+ }
2111
+ type SequencesListResponse = {
2112
+ object: string;
2113
+ has_more: boolean;
2114
+ data: {
2115
+ object: string;
2116
+ id: string;
2117
+ name: string;
2118
+ description: unknown;
2119
+ status: string;
2120
+ segment_id: string;
2121
+ topic_id: unknown;
2122
+ trigger: {
2123
+ type: string;
2124
+ lead_magnet_id: unknown;
2125
+ };
2126
+ reentry: {
2127
+ mode: string;
2128
+ days: unknown;
2129
+ };
2130
+ exit: {
2131
+ events: string[];
2132
+ filter_id: unknown;
2133
+ };
2134
+ steps: {
2135
+ id: string;
2136
+ type: string;
2137
+ subject?: string;
2138
+ preheader?: unknown;
2139
+ doc?: {
2140
+ type: string;
2141
+ content: unknown[];
2142
+ };
2143
+ amount?: number;
2144
+ unit?: string;
2145
+ }[];
2146
+ published_version: {
2147
+ id: string;
2148
+ number: number;
2149
+ };
2150
+ has_unpublished_changes: boolean;
2151
+ activated_at: string;
2152
+ archived_at: unknown;
2153
+ created_at: string;
2154
+ updated_at: string;
2155
+ }[];
2156
+ };
2157
+ interface SequencesCreateParams {
2158
+ name: string;
2159
+ description?: string | null;
2160
+ /**
2161
+ * The newsletter the emails belong to (sender, footer, unsubscribe).
2162
+ */
2163
+ segmentId: string;
2164
+ /**
2165
+ * A topic of that newsletter: a contact who leaves it leaves the sequence.
2166
+ */
2167
+ topicId?: string | null;
2168
+ /**
2169
+ * Default `{type: "manual"}`.
2170
+ */
2171
+ trigger?: {
2172
+ type: "subscribed" | "topic_subscribed" | "lead_magnet" | "event" | "email_opened" | "email_clicked" | "filter" | "manual";
2173
+ /**
2174
+ * subscribed: imported contacts enter too (default `false`).
2175
+ */
2176
+ includeImports?: boolean;
2177
+ /**
2178
+ * topic_subscribed.
2179
+ */
2180
+ topicId?: string;
2181
+ /**
2182
+ * lead_magnet: `null` = any lead magnet.
2183
+ */
2184
+ leadMagnetId?: string | null;
2185
+ /**
2186
+ * event: the custom event name.
2187
+ */
2188
+ event?: string;
2189
+ /**
2190
+ * email_opened / email_clicked: `null` = any issue.
2191
+ */
2192
+ newsletterId?: string | null;
2193
+ /**
2194
+ * filter: the saved filter whose new matches enter (checked every 15 minutes).
2195
+ */
2196
+ filterId?: string;
2197
+ /**
2198
+ * filter: contacts already matching at activation enter too (default `false`).
2199
+ */
2200
+ includeExisting?: boolean;
2201
+ [k: string]: unknown;
2202
+ };
2203
+ /**
2204
+ * Can a contact go through again? Default `once`.
2205
+ */
2206
+ reentry?: {
2207
+ mode: "once" | "always" | "after_days";
2208
+ days?: number | null;
2209
+ };
2210
+ exit?: {
2211
+ /**
2212
+ * Custom events that take the contact out.
2213
+ */
2214
+ events?: string[];
2215
+ /**
2216
+ * A saved filter: a contact who matches it leaves.
2217
+ */
2218
+ filterId?: string | null;
2219
+ };
2220
+ /**
2221
+ * The draft tree. Activate to publish it.
2222
+ */
2223
+ steps?: {
2224
+ /**
2225
+ * Your id for the step, unique in the sequence: letters, digits, `_`, `-`. Keep it when you edit (stats follow it).
2226
+ */
2227
+ id: string;
2228
+ type: "email" | "delay" | "wait_event" | "condition" | "update_contact" | "webhook" | "exit";
2229
+ /**
2230
+ * email: the subject (personalization tags allowed).
2231
+ */
2232
+ subject?: string;
2233
+ /**
2234
+ * email: preview text.
2235
+ */
2236
+ preheader?: string | null;
2237
+ /**
2238
+ * email: body in Markdown (stored as a visual-editor document).
2239
+ */
2240
+ markdown?: string;
2241
+ /**
2242
+ * email: body in HTML (stored as one HTML block).
2243
+ */
2244
+ html?: string;
2245
+ /**
2246
+ * email: a visual-editor document (`{type: "doc", content}`).
2247
+ */
2248
+ doc?: {
2249
+ [k: string]: unknown;
2250
+ };
2251
+ /**
2252
+ * email: a published transactional template instead of a body.
2253
+ */
2254
+ templateId?: string;
2255
+ /**
2256
+ * delay: how many `unit` (5 minutes to 365 days).
2257
+ */
2258
+ amount?: number;
2259
+ unit?: "minutes" | "hours" | "days";
2260
+ /**
2261
+ * delay: wait until the next time of day instead of a fixed duration.
2262
+ */
2263
+ until?: {
2264
+ /**
2265
+ * `HH:MM`
2266
+ */
2267
+ time: string;
2268
+ /**
2269
+ * 0 = Sunday … 6; all days when absent.
2270
+ */
2271
+ weekdays?: number[];
2272
+ /**
2273
+ * `contact`: the custom field `timezone` (IANA), else the newsletter's.
2274
+ */
2275
+ timezone: "contact" | "newsletter";
2276
+ };
2277
+ /**
2278
+ * wait_event: a custom event name, `email.opened` or `email.clicked`.
2279
+ */
2280
+ event?: string;
2281
+ /**
2282
+ * wait_event: 1 to 720.
2283
+ */
2284
+ timeoutHours?: number;
2285
+ onTimeout?: "continue" | "exit";
2286
+ /**
2287
+ * condition: a saved filter (or give `rule`).
2288
+ */
2289
+ filterId?: string;
2290
+ /**
2291
+ * condition: a rule like the audience filters'.
2292
+ */
2293
+ rule?: {
2294
+ [k: string]: unknown;
2295
+ };
2296
+ /**
2297
+ * condition: steps when it matches; both branches join after the condition.
2298
+ */
2299
+ yes?: {
2300
+ [k: string]: unknown;
2301
+ }[];
2302
+ no?: {
2303
+ [k: string]: unknown;
2304
+ }[];
2305
+ /**
2306
+ * update_contact.
2307
+ */
2308
+ action?: "set_field" | "subscribe_topic" | "unsubscribe_topic";
2309
+ /**
2310
+ * update_contact set_field: the custom field key.
2311
+ */
2312
+ key?: string;
2313
+ /**
2314
+ * update_contact set_field: `null` clears it.
2315
+ */
2316
+ value?: (string | number | boolean) | null;
2317
+ /**
2318
+ * update_contact (un)subscribe_topic.
2319
+ */
2320
+ topicId?: string;
2321
+ /**
2322
+ * webhook: one of your webhook endpoints (event `sequence.step`).
2323
+ */
2324
+ webhookId?: string;
2325
+ [k: string]: unknown;
2326
+ }[];
2327
+ }
2328
+ type SequencesCreateResponse = {
2329
+ object: string;
2330
+ id: string;
2331
+ name: string;
2332
+ description: unknown;
2333
+ status: string;
2334
+ segment_id: string;
2335
+ topic_id: unknown;
2336
+ trigger: {
2337
+ type: string;
2338
+ lead_magnet_id: unknown;
2339
+ };
2340
+ reentry: {
2341
+ mode: string;
2342
+ days: unknown;
2343
+ };
2344
+ exit: {
2345
+ events: string[];
2346
+ filter_id: unknown;
2347
+ };
2348
+ steps: {
2349
+ id: string;
2350
+ type: string;
2351
+ subject?: string;
2352
+ preheader?: unknown;
2353
+ doc?: {
2354
+ type: string;
2355
+ content: unknown[];
2356
+ };
2357
+ amount?: number;
2358
+ unit?: string;
2359
+ }[];
2360
+ published_version: unknown;
2361
+ has_unpublished_changes: boolean;
2362
+ activated_at: string;
2363
+ archived_at: unknown;
2364
+ created_at: string;
2365
+ updated_at: string;
2366
+ };
2367
+ interface SequencesGetParams {
2368
+ id: string;
2369
+ }
2370
+ type SequencesGetResponse = {
2371
+ object: string;
2372
+ id: string;
2373
+ name: string;
2374
+ description: unknown;
2375
+ status: string;
2376
+ segment_id: string;
2377
+ topic_id: unknown;
2378
+ trigger: {
2379
+ type: string;
2380
+ lead_magnet_id: unknown;
2381
+ };
2382
+ reentry: {
2383
+ mode: string;
2384
+ days: unknown;
2385
+ };
2386
+ exit: {
2387
+ events: string[];
2388
+ filter_id: unknown;
2389
+ };
2390
+ steps: {
2391
+ id: string;
2392
+ type: string;
2393
+ subject?: string;
2394
+ preheader?: unknown;
2395
+ doc?: {
2396
+ type: string;
2397
+ content: unknown[];
2398
+ };
2399
+ amount?: number;
2400
+ unit?: string;
2401
+ }[];
2402
+ published_version: {
2403
+ id: string;
2404
+ number: number;
2405
+ };
2406
+ has_unpublished_changes: boolean;
2407
+ activated_at: string;
2408
+ archived_at: unknown;
2409
+ created_at: string;
2410
+ updated_at: string;
2411
+ };
2412
+ type SequencesUpdateParams = {
2413
+ id: string;
2414
+ } & {
2415
+ name?: string;
2416
+ description?: string | null;
2417
+ /**
2418
+ * Only while the sequence is a draft.
2419
+ */
2420
+ segmentId?: string;
2421
+ /**
2422
+ * A topic of that newsletter: a contact who leaves it leaves the sequence.
2423
+ */
2424
+ topicId?: string | null;
2425
+ /**
2426
+ * Default `{type: "manual"}`.
2427
+ */
2428
+ trigger?: {
2429
+ type: "subscribed" | "topic_subscribed" | "lead_magnet" | "event" | "email_opened" | "email_clicked" | "filter" | "manual";
2430
+ /**
2431
+ * subscribed: imported contacts enter too (default `false`).
2432
+ */
2433
+ includeImports?: boolean;
2434
+ /**
2435
+ * topic_subscribed.
2436
+ */
2437
+ topicId?: string;
2438
+ /**
2439
+ * lead_magnet: `null` = any lead magnet.
2440
+ */
2441
+ leadMagnetId?: string | null;
2442
+ /**
2443
+ * event: the custom event name.
2444
+ */
2445
+ event?: string;
2446
+ /**
2447
+ * email_opened / email_clicked: `null` = any issue.
2448
+ */
2449
+ newsletterId?: string | null;
2450
+ /**
2451
+ * filter: the saved filter whose new matches enter (checked every 15 minutes).
2452
+ */
2453
+ filterId?: string;
2454
+ /**
2455
+ * filter: contacts already matching at activation enter too (default `false`).
2456
+ */
2457
+ includeExisting?: boolean;
2458
+ [k: string]: unknown;
2459
+ };
2460
+ /**
2461
+ * Can a contact go through again? Default `once`.
2462
+ */
2463
+ reentry?: {
2464
+ mode: "once" | "always" | "after_days";
2465
+ days?: number | null;
2466
+ };
2467
+ exit?: {
2468
+ /**
2469
+ * Custom events that take the contact out.
2470
+ */
2471
+ events?: string[];
2472
+ /**
2473
+ * A saved filter: a contact who matches it leaves.
2474
+ */
2475
+ filterId?: string | null;
2476
+ };
2477
+ /**
2478
+ * The draft tree. Activate to publish it.
2479
+ */
2480
+ steps?: {
2481
+ /**
2482
+ * Your id for the step, unique in the sequence: letters, digits, `_`, `-`. Keep it when you edit (stats follow it).
2483
+ */
2484
+ id: string;
2485
+ type: "email" | "delay" | "wait_event" | "condition" | "update_contact" | "webhook" | "exit";
2486
+ /**
2487
+ * email: the subject (personalization tags allowed).
2488
+ */
2489
+ subject?: string;
2490
+ /**
2491
+ * email: preview text.
2492
+ */
2493
+ preheader?: string | null;
2494
+ /**
2495
+ * email: body in Markdown (stored as a visual-editor document).
2496
+ */
2497
+ markdown?: string;
2498
+ /**
2499
+ * email: body in HTML (stored as one HTML block).
2500
+ */
2501
+ html?: string;
2502
+ /**
2503
+ * email: a visual-editor document (`{type: "doc", content}`).
2504
+ */
2505
+ doc?: {
2506
+ [k: string]: unknown;
2507
+ };
2508
+ /**
2509
+ * email: a published transactional template instead of a body.
2510
+ */
2511
+ templateId?: string;
2512
+ /**
2513
+ * delay: how many `unit` (5 minutes to 365 days).
2514
+ */
2515
+ amount?: number;
2516
+ unit?: "minutes" | "hours" | "days";
2517
+ /**
2518
+ * delay: wait until the next time of day instead of a fixed duration.
2519
+ */
2520
+ until?: {
2521
+ /**
2522
+ * `HH:MM`
2523
+ */
2524
+ time: string;
2525
+ /**
2526
+ * 0 = Sunday … 6; all days when absent.
2527
+ */
2528
+ weekdays?: number[];
2529
+ /**
2530
+ * `contact`: the custom field `timezone` (IANA), else the newsletter's.
2531
+ */
2532
+ timezone: "contact" | "newsletter";
2533
+ };
2534
+ /**
2535
+ * wait_event: a custom event name, `email.opened` or `email.clicked`.
2536
+ */
2537
+ event?: string;
2538
+ /**
2539
+ * wait_event: 1 to 720.
2540
+ */
2541
+ timeoutHours?: number;
2542
+ onTimeout?: "continue" | "exit";
2543
+ /**
2544
+ * condition: a saved filter (or give `rule`).
2545
+ */
2546
+ filterId?: string;
2547
+ /**
2548
+ * condition: a rule like the audience filters'.
2549
+ */
2550
+ rule?: {
2551
+ [k: string]: unknown;
2552
+ };
2553
+ /**
2554
+ * condition: steps when it matches; both branches join after the condition.
2555
+ */
2556
+ yes?: {
2557
+ [k: string]: unknown;
2558
+ }[];
2559
+ no?: {
2560
+ [k: string]: unknown;
2561
+ }[];
2562
+ /**
2563
+ * update_contact.
2564
+ */
2565
+ action?: "set_field" | "subscribe_topic" | "unsubscribe_topic";
2566
+ /**
2567
+ * update_contact set_field: the custom field key.
2568
+ */
2569
+ key?: string;
2570
+ /**
2571
+ * update_contact set_field: `null` clears it.
2572
+ */
2573
+ value?: (string | number | boolean) | null;
2574
+ /**
2575
+ * update_contact (un)subscribe_topic.
2576
+ */
2577
+ topicId?: string;
2578
+ /**
2579
+ * webhook: one of your webhook endpoints (event `sequence.step`).
2580
+ */
2581
+ webhookId?: string;
2582
+ [k: string]: unknown;
2583
+ }[];
2584
+ };
2585
+ type SequencesUpdateResponse = {
2586
+ object: string;
2587
+ id: string;
2588
+ name: string;
2589
+ description: unknown;
2590
+ status: string;
2591
+ segment_id: string;
2592
+ topic_id: unknown;
2593
+ trigger: {
2594
+ type: string;
2595
+ lead_magnet_id: unknown;
2596
+ };
2597
+ reentry: {
2598
+ mode: string;
2599
+ days: unknown;
2600
+ };
2601
+ exit: {
2602
+ events: string[];
2603
+ filter_id: unknown;
2604
+ };
2605
+ steps: {
2606
+ id: string;
2607
+ type: string;
2608
+ subject?: string;
2609
+ preheader?: unknown;
2610
+ doc?: {
2611
+ type: string;
2612
+ content: unknown[];
2613
+ };
2614
+ amount?: number;
2615
+ unit?: string;
2616
+ }[];
2617
+ published_version: {
2618
+ id: string;
2619
+ number: number;
2620
+ };
2621
+ has_unpublished_changes: boolean;
2622
+ activated_at: string;
2623
+ archived_at: unknown;
2624
+ created_at: string;
2625
+ updated_at: string;
2626
+ };
2627
+ interface SequencesRemoveParams {
2628
+ id: string;
2629
+ }
2630
+ type SequencesRemoveResponse = {
2631
+ object: string;
2632
+ id: string;
2633
+ deleted: boolean;
2634
+ };
2635
+ interface SequencesActivateParams {
2636
+ id: string;
2637
+ }
2638
+ type SequencesActivateResponse = {
2639
+ object: string;
2640
+ id: string;
2641
+ name: string;
2642
+ description: unknown;
2643
+ status: string;
2644
+ segment_id: string;
2645
+ topic_id: unknown;
2646
+ trigger: {
2647
+ type: string;
2648
+ lead_magnet_id: unknown;
2649
+ };
2650
+ reentry: {
2651
+ mode: string;
2652
+ days: unknown;
2653
+ };
2654
+ exit: {
2655
+ events: string[];
2656
+ filter_id: unknown;
2657
+ };
2658
+ steps: {
2659
+ id: string;
2660
+ type: string;
2661
+ subject?: string;
2662
+ preheader?: unknown;
2663
+ doc?: {
2664
+ type: string;
2665
+ content: unknown[];
2666
+ };
2667
+ amount?: number;
2668
+ unit?: string;
2669
+ }[];
2670
+ published_version: {
2671
+ id: string;
2672
+ number: number;
2673
+ };
2674
+ has_unpublished_changes: boolean;
2675
+ activated_at: string;
2676
+ archived_at: unknown;
2677
+ created_at: string;
2678
+ updated_at: string;
2679
+ };
2680
+ interface SequencesPauseParams {
2681
+ id: string;
2682
+ }
2683
+ type SequencesPauseResponse = {
2684
+ object: string;
2685
+ id: string;
2686
+ name: string;
2687
+ description: unknown;
2688
+ status: string;
2689
+ segment_id: string;
2690
+ topic_id: unknown;
2691
+ trigger: {
2692
+ type: string;
2693
+ lead_magnet_id: unknown;
2694
+ };
2695
+ reentry: {
2696
+ mode: string;
2697
+ days: unknown;
2698
+ };
2699
+ exit: {
2700
+ events: string[];
2701
+ filter_id: unknown;
2702
+ };
2703
+ steps: {
2704
+ id: string;
2705
+ type: string;
2706
+ subject?: string;
2707
+ preheader?: unknown;
2708
+ doc?: {
2709
+ type: string;
2710
+ content: unknown[];
2711
+ };
2712
+ amount?: number;
2713
+ unit?: string;
2714
+ }[];
2715
+ published_version: {
2716
+ id: string;
2717
+ number: number;
2718
+ };
2719
+ has_unpublished_changes: boolean;
2720
+ activated_at: string;
2721
+ archived_at: unknown;
2722
+ created_at: string;
2723
+ updated_at: string;
2724
+ };
2725
+ interface SequencesArchiveParams {
2726
+ id: string;
2727
+ }
2728
+ type SequencesArchiveResponse = {
2729
+ object: string;
2730
+ id: string;
2731
+ name: string;
2732
+ description: unknown;
2733
+ status: string;
2734
+ segment_id: string;
2735
+ topic_id: unknown;
2736
+ trigger: {
2737
+ type: string;
2738
+ lead_magnet_id: unknown;
2739
+ };
2740
+ reentry: {
2741
+ mode: string;
2742
+ days: unknown;
2743
+ };
2744
+ exit: {
2745
+ events: string[];
2746
+ filter_id: unknown;
2747
+ };
2748
+ steps: {
2749
+ id: string;
2750
+ type: string;
2751
+ subject?: string;
2752
+ preheader?: unknown;
2753
+ doc?: {
2754
+ type: string;
2755
+ content: unknown[];
2756
+ };
2757
+ amount?: number;
2758
+ unit?: string;
2759
+ }[];
2760
+ published_version: {
2761
+ id: string;
2762
+ number: number;
2763
+ };
2764
+ has_unpublished_changes: boolean;
2765
+ activated_at: string;
2766
+ archived_at: string;
2767
+ created_at: string;
2768
+ updated_at: string;
2769
+ };
2770
+ type SequencesEnrollmentsParams = {
2771
+ id: string;
2772
+ } & {
2773
+ status?: "active" | "completed" | "exited";
2774
+ /**
2775
+ * Newest first, 1–100 (default 100).
2776
+ */
2777
+ limit?: number;
2778
+ };
2779
+ type SequencesEnrollmentsResponse = {
2780
+ object: string;
2781
+ has_more: boolean;
2782
+ data: {
2783
+ object: string;
2784
+ id: string;
2785
+ sequence_id: string;
2786
+ contact_id: string;
2787
+ email: string;
2788
+ status: string;
2789
+ exit_reason: unknown;
2790
+ current_step_id: string;
2791
+ next_run_at: string;
2792
+ source: string;
2793
+ entered_at: string;
2794
+ completed_at: unknown;
2795
+ exited_at: unknown;
2796
+ }[];
2797
+ };
2798
+ type SequencesEnrollParams = {
2799
+ id: string;
2800
+ } & {
2801
+ /**
2802
+ * Give `email` or `contact_id` (a contact of the sequence's newsletter).
2803
+ */
2804
+ email?: string;
2805
+ contactId?: string;
2806
+ };
2807
+ type SequencesEnrollResponse = {
2808
+ object: string;
2809
+ id: string;
2810
+ sequence_id: string;
2811
+ contact_id: string;
2812
+ status: string;
2813
+ };
2814
+ interface SequencesUnenrollParams {
2815
+ id: string;
2816
+ enrollmentId: string;
2817
+ }
2818
+ type SequencesUnenrollResponse = {
2819
+ object: string;
2820
+ id: string;
2821
+ sequence_id: string;
2822
+ status: string;
2823
+ };
2824
+ interface SequencesStatsParams {
2825
+ id: string;
2826
+ }
2827
+ type SequencesStatsResponse = {
2828
+ object: string;
2829
+ sequence_id: string;
2830
+ entered: number;
2831
+ active: number;
2832
+ completed: number;
2833
+ exited: number;
2834
+ steps: {
2835
+ step_id: string;
2836
+ passed: number;
2837
+ waiting: number;
2838
+ sent: number;
2839
+ opened: number;
2840
+ clicked: number;
2841
+ bounced: number;
2842
+ unsubscribed: number;
2843
+ }[];
2844
+ };
2845
+ interface WebhooksCreateParams {
2846
+ /**
2847
+ * Public `https://` URL that receives the events.
2848
+ */
2849
+ endpoint: string;
2850
+ /**
2851
+ * Event types to receive.
2852
+ */
2853
+ events: ("email.sent" | "email.delivered" | "email.delivery_delayed" | "email.bounced" | "email.complained" | "email.opened" | "email.clicked" | "email.failed" | "email.scheduled" | "contact.created" | "contact.updated" | "contact.deleted" | "domain.created" | "domain.updated" | "domain.deleted" | "sequence.entered" | "sequence.completed" | "sequence.exited" | "inbound.received")[];
2854
+ description?: string | null;
2855
+ /**
2856
+ * Also send the email events of your newsletter issues (one per recipient). Default `false`: transactional emails only.
2857
+ */
2858
+ includeNewsletters?: boolean;
2859
+ /**
2860
+ * Only newsletter events of these newsletters (segments). Empty = all.
2861
+ */
2862
+ segmentIds?: string[];
2863
+ /**
2864
+ * Only email events sent from these domains (domain of the From address). Empty = all.
2865
+ */
2866
+ domains?: string[];
2867
+ }
2868
+ type WebhooksCreateResponse = {
2869
+ object: string;
2870
+ id: string;
2871
+ signing_secret: string;
2872
+ };
2873
+ interface WebhooksListParams {
2874
+ /**
2875
+ * 1–100, default 20.
2876
+ */
2877
+ limit?: number;
2878
+ /**
2879
+ * Id of the last item of the previous page (older items).
2880
+ */
2881
+ after?: string;
2882
+ /**
2883
+ * Id of the first item of the previous page (newer items).
2884
+ */
2885
+ before?: string;
2886
+ }
2887
+ type WebhooksListResponse = {
2888
+ object: string;
2889
+ has_more: boolean;
2890
+ data: {
2891
+ object: string;
2892
+ id: string;
2893
+ endpoint: string;
2894
+ description: string;
2895
+ events: string[];
2896
+ include_newsletters: boolean;
2897
+ segment_ids: unknown[];
2898
+ domains: unknown[];
2899
+ status: string;
2900
+ disabled_reason: unknown;
2901
+ consecutive_failures: number;
2902
+ last_success_at: string;
2903
+ last_failure_at: unknown;
2904
+ created_at: string;
2905
+ }[];
2906
+ };
2907
+ interface WebhooksGetParams {
2908
+ id: string;
2909
+ }
2910
+ type WebhooksGetResponse = {
2911
+ object: string;
2912
+ id: string;
2913
+ endpoint: string;
2914
+ description: string;
2915
+ events: string[];
2916
+ include_newsletters: boolean;
2917
+ segment_ids: unknown[];
2918
+ domains: unknown[];
2919
+ status: string;
2920
+ disabled_reason: unknown;
2921
+ consecutive_failures: number;
2922
+ last_success_at: string;
2923
+ last_failure_at: unknown;
2924
+ created_at: string;
2925
+ };
2926
+ type WebhooksUpdateParams = {
2927
+ id: string;
2928
+ } & {
2929
+ /**
2930
+ * Public `https://` URL that receives the events.
2931
+ */
2932
+ endpoint?: string;
2933
+ /**
2934
+ * Event types to receive.
2935
+ */
2936
+ events?: ("email.sent" | "email.delivered" | "email.delivery_delayed" | "email.bounced" | "email.complained" | "email.opened" | "email.clicked" | "email.failed" | "email.scheduled" | "contact.created" | "contact.updated" | "contact.deleted" | "domain.created" | "domain.updated" | "domain.deleted" | "sequence.entered" | "sequence.completed" | "sequence.exited" | "inbound.received")[];
2937
+ status?: "enabled" | "disabled";
2938
+ description?: string | null;
2939
+ /**
2940
+ * Also send the email events of your newsletter issues (one per recipient). Default `false`: transactional emails only.
2941
+ */
2942
+ includeNewsletters?: boolean;
2943
+ /**
2944
+ * Only newsletter events of these newsletters (segments). Empty = all.
2945
+ */
2946
+ segmentIds?: string[];
2947
+ /**
2948
+ * Only email events sent from these domains (domain of the From address). Empty = all.
2949
+ */
2950
+ domains?: string[];
2951
+ };
2952
+ type WebhooksUpdateResponse = {
2953
+ object: string;
2954
+ id: string;
2955
+ };
2956
+ interface WebhooksRemoveParams {
2957
+ id: string;
2958
+ }
2959
+ type WebhooksRemoveResponse = {
2960
+ object: string;
2961
+ id: string;
2962
+ deleted: boolean;
2963
+ };
2964
+ interface WebhooksRotateSigningSecretParams {
2965
+ id: string;
2966
+ }
2967
+ type WebhooksRotateSigningSecretResponse = {
2968
+ object: string;
2969
+ id: string;
2970
+ signing_secret: string;
2971
+ previous_secret_expires_at: string;
2972
+ };
2973
+ type WebhooksTestParams = {
2974
+ id: string;
2975
+ } & {
2976
+ /**
2977
+ * Event type of the sample payload.
2978
+ */
2979
+ type?: "email.sent" | "email.delivered" | "email.delivery_delayed" | "email.bounced" | "email.complained" | "email.opened" | "email.clicked" | "email.failed" | "email.scheduled" | "contact.created" | "contact.updated" | "contact.deleted" | "domain.created" | "domain.updated" | "domain.deleted" | "sequence.entered" | "sequence.completed" | "sequence.exited" | "inbound.received";
2980
+ };
2981
+ type WebhooksTestResponse = {
2982
+ object: string;
2983
+ id: string;
2984
+ msg_id: string;
2985
+ webhook_id: string;
2986
+ event_type: string;
2987
+ status: string;
2988
+ attempts: number;
2989
+ next_attempt_at: unknown;
2990
+ last_status_code: number;
2991
+ last_response: string;
2992
+ last_error: unknown;
2993
+ last_duration_ms: number;
2994
+ payload: {
2995
+ type: string;
2996
+ created_at: string;
2997
+ data: {
2998
+ email_id: string;
2999
+ };
3000
+ };
3001
+ delivered_at: string;
3002
+ created_at: string;
3003
+ };
3004
+ type WebhooksDeliveriesParams = {
3005
+ id: string;
3006
+ } & {
3007
+ /**
3008
+ * 1–100, default 20.
3009
+ */
3010
+ limit?: number;
3011
+ /**
3012
+ * Id of the last item of the previous page (older items).
3013
+ */
3014
+ after?: string;
3015
+ /**
3016
+ * Id of the first item of the previous page (newer items).
3017
+ */
3018
+ before?: string;
3019
+ status?: "pending" | "processing" | "delivered" | "failed";
3020
+ };
3021
+ type WebhooksDeliveriesResponse = {
3022
+ object: string;
3023
+ has_more: boolean;
3024
+ data: {
3025
+ object: string;
3026
+ id: string;
3027
+ msg_id: string;
3028
+ webhook_id: string;
3029
+ event_type: string;
3030
+ status: string;
3031
+ attempts: number;
3032
+ next_attempt_at: unknown;
3033
+ last_status_code: number;
3034
+ last_response: string;
3035
+ last_error: unknown;
3036
+ last_duration_ms: number;
3037
+ payload: {
3038
+ type: string;
3039
+ created_at: string;
3040
+ data: {
3041
+ email_id: string;
3042
+ };
3043
+ };
3044
+ delivered_at: string;
3045
+ created_at: string;
3046
+ }[];
3047
+ };
3048
+ interface WebhooksRetryDeliveryParams {
3049
+ id: string;
3050
+ deliveryId: string;
3051
+ }
3052
+ type WebhooksRetryDeliveryResponse = {
3053
+ object: string;
3054
+ id: string;
3055
+ msg_id: string;
3056
+ webhook_id: string;
3057
+ event_type: string;
3058
+ status: string;
3059
+ attempts: number;
3060
+ next_attempt_at: unknown;
3061
+ last_status_code: number;
3062
+ last_response: string;
3063
+ last_error: unknown;
3064
+ last_duration_ms: number;
3065
+ payload: {
3066
+ type: string;
3067
+ created_at: string;
3068
+ data: {
3069
+ email_id: string;
3070
+ };
3071
+ };
3072
+ delivered_at: string;
3073
+ created_at: string;
3074
+ };
3075
+ type InboxesListParams = Record<string, never>;
3076
+ type InboxesListResponse = {
3077
+ object: string;
3078
+ has_more: boolean;
3079
+ data: {
3080
+ object: string;
3081
+ id: string;
3082
+ address: string;
3083
+ name: string;
3084
+ display_name: string;
3085
+ description: string;
3086
+ reply_from: unknown;
3087
+ status: string;
3088
+ custom_domain: boolean;
3089
+ domain_id: unknown;
3090
+ dropped_count: number;
3091
+ last_dropped_at: unknown;
3092
+ created_at: string;
3093
+ updated_at: string;
3094
+ }[];
3095
+ };
3096
+ interface InboxesCreateParams {
3097
+ /**
3098
+ * Local part: `support` gives `support-<workspace>@in.smartletter.ai` (or `support@<your receiving domain>` with `domain_id`).
3099
+ */
3100
+ name: string;
3101
+ /**
3102
+ * The agent's name, shown as the sender of its replies.
3103
+ */
3104
+ displayName?: string | null;
3105
+ /**
3106
+ * What this agent does — readable by an LLM.
3107
+ */
3108
+ description?: string | null;
3109
+ /**
3110
+ * A verified receiving domain of the workspace (dashboard: Settings > Inboxes).
3111
+ */
3112
+ domainId?: string | null;
3113
+ /**
3114
+ * Send replies from this address (a verified sending domain) instead of the inbox address. Reply-To stays the inbox.
3115
+ */
3116
+ replyFrom?: string | null;
3117
+ }
3118
+ type InboxesCreateResponse = {
3119
+ object: string;
3120
+ id: string;
3121
+ address: string;
3122
+ name: string;
3123
+ display_name: string;
3124
+ description: string;
3125
+ reply_from: unknown;
3126
+ status: string;
3127
+ custom_domain: boolean;
3128
+ domain_id: unknown;
3129
+ dropped_count: number;
3130
+ last_dropped_at: unknown;
3131
+ created_at: string;
3132
+ updated_at: string;
3133
+ };
3134
+ interface InboxesGetParams {
3135
+ id: string;
3136
+ }
3137
+ type InboxesGetResponse = {
3138
+ object: string;
3139
+ id: string;
3140
+ address: string;
3141
+ name: string;
3142
+ display_name: string;
3143
+ description: string;
3144
+ reply_from: unknown;
3145
+ status: string;
3146
+ custom_domain: boolean;
3147
+ domain_id: unknown;
3148
+ dropped_count: number;
3149
+ last_dropped_at: unknown;
3150
+ created_at: string;
3151
+ updated_at: string;
3152
+ };
3153
+ type InboxesUpdateParams = {
3154
+ id: string;
3155
+ } & {
3156
+ /**
3157
+ * The agent's name, shown as the sender of its replies.
3158
+ */
3159
+ displayName?: string | null;
3160
+ /**
3161
+ * What this agent does — readable by an LLM.
3162
+ */
3163
+ description?: string | null;
3164
+ /**
3165
+ * Send replies from this address (a verified sending domain) instead of the inbox address. Reply-To stays the inbox.
3166
+ */
3167
+ replyFrom?: string | null;
3168
+ /**
3169
+ * A disabled inbox drops incoming mail and cannot reply.
3170
+ */
3171
+ status?: "active" | "disabled";
3172
+ };
3173
+ type InboxesUpdateResponse = {
3174
+ object: string;
3175
+ id: string;
3176
+ address: string;
3177
+ name: string;
3178
+ display_name: string;
3179
+ description: string;
3180
+ reply_from: unknown;
3181
+ status: string;
3182
+ custom_domain: boolean;
3183
+ domain_id: unknown;
3184
+ dropped_count: number;
3185
+ last_dropped_at: unknown;
3186
+ created_at: string;
3187
+ updated_at: string;
3188
+ };
3189
+ interface InboxesRemoveParams {
3190
+ id: string;
3191
+ }
3192
+ type InboxesRemoveResponse = {
3193
+ object: string;
3194
+ id: string;
3195
+ deleted: boolean;
3196
+ };
3197
+ interface ThreadsListParams {
3198
+ inboxId?: string;
3199
+ /**
3200
+ * Default: every status but `archived`.
3201
+ */
3202
+ status?: "open" | "pending" | "done" | "archived" | "all";
3203
+ label?: string;
3204
+ /**
3205
+ * Default `exclude`.
3206
+ */
3207
+ spam?: "exclude" | "only" | "include";
3208
+ assigneeAgent?: string;
3209
+ unread?: "true" | "false";
3210
+ /**
3211
+ * 1–100, default 20.
3212
+ */
3213
+ limit?: number;
3214
+ /**
3215
+ * Id of the last thread of the previous page.
3216
+ */
3217
+ after?: string;
3218
+ }
3219
+ type ThreadsListResponse = {
3220
+ object: string;
3221
+ has_more: boolean;
3222
+ data: {
3223
+ object: string;
3224
+ id: string;
3225
+ inbox_id: string;
3226
+ subject: string;
3227
+ status: string;
3228
+ spam: boolean;
3229
+ labels: unknown[];
3230
+ assignee_user_id: unknown;
3231
+ assignee_agent: unknown;
3232
+ message_count: number;
3233
+ unread: boolean;
3234
+ participants: string[];
3235
+ last_message_at: string;
3236
+ last_inbound_at: string;
3237
+ created_at: string;
3238
+ updated_at: string;
3239
+ last_message: {
3240
+ id: string;
3241
+ direction: string;
3242
+ from: string;
3243
+ snippet: string;
3244
+ received_at: string;
3245
+ };
3246
+ }[];
3247
+ };
3248
+ interface ThreadsGetParams {
3249
+ id: string;
3250
+ }
3251
+ type ThreadsGetResponse = {
3252
+ object: string;
3253
+ id: string;
3254
+ inbox_id: string;
3255
+ subject: string;
3256
+ status: string;
3257
+ spam: boolean;
3258
+ labels: unknown[];
3259
+ assignee_user_id: unknown;
3260
+ assignee_agent: unknown;
3261
+ message_count: number;
3262
+ unread: boolean;
3263
+ participants: string[];
3264
+ last_message_at: string;
3265
+ last_inbound_at: string;
3266
+ created_at: string;
3267
+ updated_at: string;
3268
+ messages: {
3269
+ object: string;
3270
+ id: string;
3271
+ thread_id: string;
3272
+ inbox_id: string;
3273
+ direction: string;
3274
+ status: string;
3275
+ from: string;
3276
+ from_address: string;
3277
+ from_name: string;
3278
+ to: string[];
3279
+ cc: unknown[];
3280
+ reply_to: unknown[];
3281
+ subject: string;
3282
+ text: string;
3283
+ html: string;
3284
+ snippet: string;
3285
+ remote_images: number;
3286
+ body_truncated: boolean;
3287
+ message_id: string;
3288
+ in_reply_to: unknown;
3289
+ references: unknown[];
3290
+ spam: {
3291
+ score: number;
3292
+ verdict: string;
3293
+ virus: string;
3294
+ spf: string;
3295
+ dkim: string;
3296
+ dmarc: string;
3297
+ reasons: unknown[];
3298
+ };
3299
+ auto_submitted: boolean;
3300
+ automation_reason: unknown;
3301
+ attachments: {
3302
+ id: string;
3303
+ filename: string;
3304
+ content_type: string;
3305
+ size: number;
3306
+ inline: boolean;
3307
+ content_id: unknown;
3308
+ available: boolean;
3309
+ expires_at: string;
3310
+ }[];
3311
+ received_at: string;
3312
+ created_at: string;
3313
+ }[];
3314
+ };
3315
+ type ThreadsUpdateParams = {
3316
+ id: string;
3317
+ } & {
3318
+ status?: "open" | "pending" | "done" | "archived";
3319
+ /**
3320
+ * Replaces every label.
3321
+ */
3322
+ labels?: string[];
3323
+ addLabels?: string[];
3324
+ removeLabels?: string[];
3325
+ /**
3326
+ * An agent name, or `null`.
3327
+ */
3328
+ assigneeAgent?: string | null;
3329
+ /**
3330
+ * A member of the workspace, or `null`.
3331
+ */
3332
+ assigneeUserId?: string | null;
3333
+ /**
3334
+ * `true` moves every inbound message to spam; `false` back to the inbox.
3335
+ */
3336
+ spam?: boolean;
3337
+ unread?: boolean;
3338
+ };
3339
+ type ThreadsUpdateResponse = {
3340
+ object: string;
3341
+ id: string;
3342
+ inbox_id: string;
3343
+ subject: string;
3344
+ status: string;
3345
+ spam: boolean;
3346
+ labels: string[];
3347
+ assignee_user_id: unknown;
3348
+ assignee_agent: string;
3349
+ message_count: number;
3350
+ unread: boolean;
3351
+ participants: string[];
3352
+ last_message_at: string;
3353
+ last_inbound_at: string;
3354
+ created_at: string;
3355
+ updated_at: string;
3356
+ };
3357
+ type ThreadsReplyParams = {
3358
+ id: string;
3359
+ } & {
3360
+ /**
3361
+ * Plain-text answer. Give `text`, `html` or both.
3362
+ */
3363
+ text?: string;
3364
+ html?: string;
3365
+ /**
3366
+ * The message answered. Default: the latest inbound message.
3367
+ */
3368
+ messageId?: string;
3369
+ /**
3370
+ * Also answer the original To / Cc (never the inbox itself).
3371
+ */
3372
+ replyAll?: boolean;
3373
+ cc?: string[];
3374
+ /**
3375
+ * Quote the answered message under the answer. Default `true`.
3376
+ */
3377
+ quote?: boolean;
3378
+ /**
3379
+ * Save a draft instead of sending.
3380
+ */
3381
+ draft?: boolean;
3382
+ /**
3383
+ * Thread status after sending. Default `pending`.
3384
+ */
3385
+ status?: "open" | "pending" | "done" | "archived";
3386
+ };
3387
+ type ThreadsReplyResponse = {
3388
+ object: string;
3389
+ id: string;
3390
+ thread_id: string;
3391
+ inbox_id: string;
3392
+ direction: string;
3393
+ status: string;
3394
+ from: string;
3395
+ from_address: string;
3396
+ from_name: string;
3397
+ to: string[];
3398
+ cc: unknown[];
3399
+ reply_to: unknown[];
3400
+ subject: string;
3401
+ text: string;
3402
+ html: string;
3403
+ snippet: string;
3404
+ remote_images: number;
3405
+ body_truncated: boolean;
3406
+ message_id: string;
3407
+ in_reply_to: unknown;
3408
+ references: unknown[];
3409
+ spam: {
3410
+ score: number;
3411
+ verdict: string;
3412
+ virus: string;
3413
+ spf: string;
3414
+ dkim: string;
3415
+ dmarc: string;
3416
+ reasons: unknown[];
3417
+ };
3418
+ auto_submitted: boolean;
3419
+ automation_reason: unknown;
3420
+ attachments: {
3421
+ id: string;
3422
+ filename: string;
3423
+ content_type: string;
3424
+ size: number;
3425
+ inline: boolean;
3426
+ content_id: unknown;
3427
+ available: boolean;
3428
+ expires_at: string;
3429
+ }[];
3430
+ received_at: string;
3431
+ created_at: string;
3432
+ email_id: string;
3433
+ delivery: string;
3434
+ };
3435
+ interface MessagesGetParams {
3436
+ id: string;
3437
+ }
3438
+ type MessagesGetResponse = {
3439
+ object: string;
3440
+ id: string;
3441
+ thread_id: string;
3442
+ inbox_id: string;
3443
+ direction: string;
3444
+ status: string;
3445
+ from: string;
3446
+ from_address: string;
3447
+ from_name: string;
3448
+ to: string[];
3449
+ cc: unknown[];
3450
+ reply_to: unknown[];
3451
+ subject: string;
3452
+ text: string;
3453
+ html: string;
3454
+ snippet: string;
3455
+ remote_images: number;
3456
+ body_truncated: boolean;
3457
+ message_id: string;
3458
+ in_reply_to: unknown;
3459
+ references: unknown[];
3460
+ spam: {
3461
+ score: number;
3462
+ verdict: string;
3463
+ virus: string;
3464
+ spf: string;
3465
+ dkim: string;
3466
+ dmarc: string;
3467
+ reasons: unknown[];
3468
+ };
3469
+ auto_submitted: boolean;
3470
+ automation_reason: unknown;
3471
+ attachments: {
3472
+ id: string;
3473
+ filename: string;
3474
+ content_type: string;
3475
+ size: number;
3476
+ inline: boolean;
3477
+ content_id: unknown;
3478
+ available: boolean;
3479
+ expires_at: string;
3480
+ }[];
3481
+ received_at: string;
3482
+ created_at: string;
3483
+ };
3484
+ type MessagesUpdateParams = {
3485
+ id: string;
3486
+ } & {
3487
+ text?: string | null;
3488
+ html?: string | null;
3489
+ cc?: string[];
3490
+ };
3491
+ type MessagesUpdateResponse = {
3492
+ object: string;
3493
+ id: string;
3494
+ thread_id: string;
3495
+ inbox_id: string;
3496
+ direction: string;
3497
+ status: string;
3498
+ from: string;
3499
+ from_address: string;
3500
+ from_name: string;
3501
+ to: string[];
3502
+ cc: unknown[];
3503
+ reply_to: unknown[];
3504
+ subject: string;
3505
+ text: string;
3506
+ html: string;
3507
+ snippet: string;
3508
+ remote_images: number;
3509
+ body_truncated: boolean;
3510
+ message_id: string;
3511
+ in_reply_to: unknown;
3512
+ references: unknown[];
3513
+ spam: {
3514
+ score: number;
3515
+ verdict: string;
3516
+ virus: string;
3517
+ spf: string;
3518
+ dkim: string;
3519
+ dmarc: string;
3520
+ reasons: unknown[];
3521
+ };
3522
+ auto_submitted: boolean;
3523
+ automation_reason: unknown;
3524
+ attachments: {
3525
+ id: string;
3526
+ filename: string;
3527
+ content_type: string;
3528
+ size: number;
3529
+ inline: boolean;
3530
+ content_id: unknown;
3531
+ available: boolean;
3532
+ expires_at: string;
3533
+ }[];
3534
+ received_at: string;
3535
+ created_at: string;
3536
+ };
3537
+ type MessagesSendParams = {
3538
+ id: string;
3539
+ } & {
3540
+ status?: "open" | "pending" | "done" | "archived";
3541
+ };
3542
+ type MessagesSendResponse = {
3543
+ object: string;
3544
+ id: string;
3545
+ thread_id: string;
3546
+ inbox_id: string;
3547
+ direction: string;
3548
+ status: string;
3549
+ from: string;
3550
+ from_address: string;
3551
+ from_name: string;
3552
+ to: string[];
3553
+ cc: unknown[];
3554
+ reply_to: unknown[];
3555
+ subject: string;
3556
+ text: string;
3557
+ html: string;
3558
+ snippet: string;
3559
+ remote_images: number;
3560
+ body_truncated: boolean;
3561
+ message_id: string;
3562
+ in_reply_to: unknown;
3563
+ references: unknown[];
3564
+ spam: {
3565
+ score: number;
3566
+ verdict: string;
3567
+ virus: string;
3568
+ spf: string;
3569
+ dkim: string;
3570
+ dmarc: string;
3571
+ reasons: unknown[];
3572
+ };
3573
+ auto_submitted: boolean;
3574
+ automation_reason: unknown;
3575
+ attachments: {
3576
+ id: string;
3577
+ filename: string;
3578
+ content_type: string;
3579
+ size: number;
3580
+ inline: boolean;
3581
+ content_id: unknown;
3582
+ available: boolean;
3583
+ expires_at: string;
3584
+ }[];
3585
+ received_at: string;
3586
+ created_at: string;
3587
+ };
3588
+ interface MessagesRemoveParams {
3589
+ id: string;
3590
+ }
3591
+ type MessagesRemoveResponse = {
3592
+ object: string;
3593
+ id: string;
3594
+ deleted: boolean;
3595
+ };
3596
+ interface MessagesAttachmentParams {
3597
+ id: string;
3598
+ attachmentId: string;
3599
+ }
3600
+ type MessagesAttachmentResponse = {
3601
+ object: string;
3602
+ id: string;
3603
+ filename: string;
3604
+ content_type: string;
3605
+ size: number;
3606
+ url: string;
3607
+ expires_at: string;
3608
+ };
3609
+
3610
+ interface SmartletterResources {
3611
+ emails: {
3612
+ send(params: EmailsSendParams, options?: RequestOptions): Promise<Response<EmailsSendResponse>>;
3613
+ list(params?: EmailsListParams, options?: RequestOptions): Promise<Response<EmailsListResponse>>;
3614
+ get(id: string, options?: RequestOptions): Promise<Response<EmailsGetResponse>>;
3615
+ update(params: EmailsUpdateParams, options?: RequestOptions): Promise<Response<EmailsUpdateResponse>>;
3616
+ cancel(id: string, options?: RequestOptions): Promise<Response<EmailsCancelResponse>>;
3617
+ };
3618
+ batch: {
3619
+ send(items: BatchSendParams, options?: RequestOptions): Promise<Response<BatchSendResponse>>;
3620
+ };
3621
+ templates: {
3622
+ create(params: TemplatesCreateParams, options?: RequestOptions): Promise<Response<TemplatesCreateResponse>>;
3623
+ list(params?: TemplatesListParams, options?: RequestOptions): Promise<Response<TemplatesListResponse>>;
3624
+ get(id: string, options?: RequestOptions): Promise<Response<TemplatesGetResponse>>;
3625
+ update(params: TemplatesUpdateParams, options?: RequestOptions): Promise<Response<TemplatesUpdateResponse>>;
3626
+ remove(id: string, options?: RequestOptions): Promise<Response<TemplatesRemoveResponse>>;
3627
+ publish(params: TemplatesPublishParams, options?: RequestOptions): Promise<Response<TemplatesPublishResponse>>;
3628
+ duplicate(id: string, options?: RequestOptions): Promise<Response<TemplatesDuplicateResponse>>;
3629
+ versions(params: TemplatesVersionsParams, options?: RequestOptions): Promise<Response<TemplatesVersionsResponse>>;
3630
+ };
3631
+ newsletters: {
3632
+ list(params?: NewslettersListParams, options?: RequestOptions): Promise<Response<NewslettersListResponse>>;
3633
+ create(params: NewslettersCreateParams, options?: RequestOptions): Promise<Response<NewslettersCreateResponse>>;
3634
+ get(id: string, options?: RequestOptions): Promise<Response<NewslettersGetResponse>>;
3635
+ update(params: NewslettersUpdateParams, options?: RequestOptions): Promise<Response<NewslettersUpdateResponse>>;
3636
+ remove(id: string, options?: RequestOptions): Promise<Response<NewslettersRemoveResponse>>;
3637
+ duplicate(id: string, options?: RequestOptions): Promise<Response<NewslettersDuplicateResponse>>;
3638
+ review(id: string, options?: RequestOptions): Promise<Response<NewslettersReviewResponse>>;
3639
+ test(id: string, options?: RequestOptions): Promise<Response<NewslettersTestResponse>>;
3640
+ send(params: NewslettersSendParams, options?: RequestOptions): Promise<Response<NewslettersSendResponse>>;
3641
+ schedule(params: NewslettersScheduleParams, options?: RequestOptions): Promise<Response<NewslettersScheduleResponse>>;
3642
+ unschedule(id: string, options?: RequestOptions): Promise<Response<NewslettersUnscheduleResponse>>;
3643
+ pause(id: string, options?: RequestOptions): Promise<Response<NewslettersPauseResponse>>;
3644
+ resume(id: string, options?: RequestOptions): Promise<Response<NewslettersResumeResponse>>;
3645
+ sendMore(params: NewslettersSendMoreParams, options?: RequestOptions): Promise<Response<NewslettersSendMoreResponse>>;
3646
+ report(id: string, options?: RequestOptions): Promise<Response<NewslettersReportResponse>>;
3647
+ abWinner(params: NewslettersAbWinnerParams, options?: RequestOptions): Promise<Response<NewslettersAbWinnerResponse>>;
3648
+ archive: {
3649
+ update(params: NewslettersArchiveUpdateParams, options?: RequestOptions): Promise<Response<NewslettersArchiveUpdateResponse>>;
3650
+ };
3651
+ };
3652
+ contacts: {
3653
+ list(params?: ContactsListParams, options?: RequestOptions): Promise<Response<ContactsListResponse>>;
3654
+ create(params: ContactsCreateParams, options?: RequestOptions): Promise<Response<ContactsCreateResponse>>;
3655
+ import(params: ContactsImportParams, options?: RequestOptions): Promise<Response<ContactsImportResponse>>;
3656
+ export(params?: ContactsExportParams, options?: RequestOptions): Promise<Response<ContactsExportResponse>>;
3657
+ get(id: string, options?: RequestOptions): Promise<Response<ContactsGetResponse>>;
3658
+ unsubscribe(id: string, options?: RequestOptions): Promise<Response<ContactsUnsubscribeResponse>>;
3659
+ reactivate(id: string, options?: RequestOptions): Promise<Response<ContactsReactivateResponse>>;
3660
+ remove(id: string, options?: RequestOptions): Promise<Response<ContactsRemoveResponse>>;
3661
+ update(params: ContactsUpdateParams, options?: RequestOptions): Promise<Response<ContactsUpdateResponse>>;
3662
+ };
3663
+ contactFields: {
3664
+ list(params?: ContactFieldsListParams, options?: RequestOptions): Promise<Response<ContactFieldsListResponse>>;
3665
+ create(params: ContactFieldsCreateParams, options?: RequestOptions): Promise<Response<ContactFieldsCreateResponse>>;
3666
+ update(params: ContactFieldsUpdateParams, options?: RequestOptions): Promise<Response<ContactFieldsUpdateResponse>>;
3667
+ remove(id: string, options?: RequestOptions): Promise<Response<ContactFieldsRemoveResponse>>;
3668
+ };
3669
+ events: {
3670
+ send(params: EventsSendParams, options?: RequestOptions): Promise<Response<EventsSendResponse>>;
3671
+ };
3672
+ audienceFilters: {
3673
+ list(params?: AudienceFiltersListParams, options?: RequestOptions): Promise<Response<AudienceFiltersListResponse>>;
3674
+ create(params: AudienceFiltersCreateParams, options?: RequestOptions): Promise<Response<AudienceFiltersCreateResponse>>;
3675
+ get(id: string, options?: RequestOptions): Promise<Response<AudienceFiltersGetResponse>>;
3676
+ update(params: AudienceFiltersUpdateParams, options?: RequestOptions): Promise<Response<AudienceFiltersUpdateResponse>>;
3677
+ remove(id: string, options?: RequestOptions): Promise<Response<AudienceFiltersRemoveResponse>>;
3678
+ count(params?: AudienceFiltersCountParams, options?: RequestOptions): Promise<Response<AudienceFiltersCountResponse>>;
3679
+ };
3680
+ signups: {
3681
+ create(params: SignupsCreateParams, options?: RequestOptions): Promise<Response<SignupsCreateResponse>>;
3682
+ };
3683
+ segments: {
3684
+ list(params?: SegmentsListParams, options?: RequestOptions): Promise<Response<SegmentsListResponse>>;
3685
+ create(params: SegmentsCreateParams, options?: RequestOptions): Promise<Response<SegmentsCreateResponse>>;
3686
+ archive: {
3687
+ get(id: string, options?: RequestOptions): Promise<Response<SegmentsArchiveGetResponse>>;
3688
+ update(params: SegmentsArchiveUpdateParams, options?: RequestOptions): Promise<Response<SegmentsArchiveUpdateResponse>>;
3689
+ };
3690
+ domain: {
3691
+ get(id: string, options?: RequestOptions): Promise<Response<SegmentsDomainGetResponse>>;
3692
+ set(params: SegmentsDomainSetParams, options?: RequestOptions): Promise<Response<SegmentsDomainSetResponse>>;
3693
+ remove(id: string, options?: RequestOptions): Promise<Response<SegmentsDomainRemoveResponse>>;
3694
+ };
3695
+ };
3696
+ topics: {
3697
+ list(params: TopicsListParams, options?: RequestOptions): Promise<Response<TopicsListResponse>>;
3698
+ };
3699
+ suppressions: {
3700
+ list(params?: SuppressionsListParams, options?: RequestOptions): Promise<Response<SuppressionsListResponse>>;
3701
+ create(params: SuppressionsCreateParams, options?: RequestOptions): Promise<Response<SuppressionsCreateResponse>>;
3702
+ remove(id: string, options?: RequestOptions): Promise<Response<SuppressionsRemoveResponse>>;
3703
+ };
3704
+ images: {
3705
+ list(params?: ImagesListParams, options?: RequestOptions): Promise<Response<ImagesListResponse>>;
3706
+ create(file: ImagesCreateParams, options?: RequestOptions): Promise<Response<ImagesCreateResponse>>;
3707
+ };
3708
+ stats: {
3709
+ overview(params?: StatsOverviewParams, options?: RequestOptions): Promise<Response<StatsOverviewResponse>>;
3710
+ };
3711
+ domains: {
3712
+ create(params: DomainsCreateParams, options?: RequestOptions): Promise<Response<DomainsCreateResponse>>;
3713
+ list(params?: DomainsListParams, options?: RequestOptions): Promise<Response<DomainsListResponse>>;
3714
+ get(id: string, options?: RequestOptions): Promise<Response<DomainsGetResponse>>;
3715
+ verify(id: string, options?: RequestOptions): Promise<Response<DomainsVerifyResponse>>;
3716
+ };
3717
+ apiKeys: {
3718
+ create(params: ApiKeysCreateParams, options?: RequestOptions): Promise<Response<ApiKeysCreateResponse>>;
3719
+ list(params?: ApiKeysListParams, options?: RequestOptions): Promise<Response<ApiKeysListResponse>>;
3720
+ update(params: ApiKeysUpdateParams, options?: RequestOptions): Promise<Response<ApiKeysUpdateResponse>>;
3721
+ remove(id: string, options?: RequestOptions): Promise<Response<ApiKeysRemoveResponse>>;
3722
+ };
3723
+ logs: {
3724
+ list(params?: LogsListParams, options?: RequestOptions): Promise<Response<LogsListResponse>>;
3725
+ get(id: string, options?: RequestOptions): Promise<Response<LogsGetResponse>>;
3726
+ };
3727
+ usage: {
3728
+ get(params?: UsageGetParams, options?: RequestOptions): Promise<Response<UsageGetResponse>>;
3729
+ };
3730
+ sequences: {
3731
+ list(params?: SequencesListParams, options?: RequestOptions): Promise<Response<SequencesListResponse>>;
3732
+ create(params: SequencesCreateParams, options?: RequestOptions): Promise<Response<SequencesCreateResponse>>;
3733
+ get(id: string, options?: RequestOptions): Promise<Response<SequencesGetResponse>>;
3734
+ update(params: SequencesUpdateParams, options?: RequestOptions): Promise<Response<SequencesUpdateResponse>>;
3735
+ remove(id: string, options?: RequestOptions): Promise<Response<SequencesRemoveResponse>>;
3736
+ activate(id: string, options?: RequestOptions): Promise<Response<SequencesActivateResponse>>;
3737
+ pause(id: string, options?: RequestOptions): Promise<Response<SequencesPauseResponse>>;
3738
+ archive(id: string, options?: RequestOptions): Promise<Response<SequencesArchiveResponse>>;
3739
+ enrollments(params: SequencesEnrollmentsParams, options?: RequestOptions): Promise<Response<SequencesEnrollmentsResponse>>;
3740
+ enroll(params: SequencesEnrollParams, options?: RequestOptions): Promise<Response<SequencesEnrollResponse>>;
3741
+ unenroll(params: SequencesUnenrollParams, options?: RequestOptions): Promise<Response<SequencesUnenrollResponse>>;
3742
+ stats(id: string, options?: RequestOptions): Promise<Response<SequencesStatsResponse>>;
3743
+ };
3744
+ webhooks: {
3745
+ create(params: WebhooksCreateParams, options?: RequestOptions): Promise<Response<WebhooksCreateResponse>>;
3746
+ list(params?: WebhooksListParams, options?: RequestOptions): Promise<Response<WebhooksListResponse>>;
3747
+ get(id: string, options?: RequestOptions): Promise<Response<WebhooksGetResponse>>;
3748
+ update(params: WebhooksUpdateParams, options?: RequestOptions): Promise<Response<WebhooksUpdateResponse>>;
3749
+ remove(id: string, options?: RequestOptions): Promise<Response<WebhooksRemoveResponse>>;
3750
+ rotateSigningSecret(id: string, options?: RequestOptions): Promise<Response<WebhooksRotateSigningSecretResponse>>;
3751
+ test(params: WebhooksTestParams, options?: RequestOptions): Promise<Response<WebhooksTestResponse>>;
3752
+ deliveries(params: WebhooksDeliveriesParams, options?: RequestOptions): Promise<Response<WebhooksDeliveriesResponse>>;
3753
+ retryDelivery(params: WebhooksRetryDeliveryParams, options?: RequestOptions): Promise<Response<WebhooksRetryDeliveryResponse>>;
3754
+ };
3755
+ inboxes: {
3756
+ list(params?: InboxesListParams, options?: RequestOptions): Promise<Response<InboxesListResponse>>;
3757
+ create(params: InboxesCreateParams, options?: RequestOptions): Promise<Response<InboxesCreateResponse>>;
3758
+ get(id: string, options?: RequestOptions): Promise<Response<InboxesGetResponse>>;
3759
+ update(params: InboxesUpdateParams, options?: RequestOptions): Promise<Response<InboxesUpdateResponse>>;
3760
+ remove(id: string, options?: RequestOptions): Promise<Response<InboxesRemoveResponse>>;
3761
+ };
3762
+ threads: {
3763
+ list(params?: ThreadsListParams, options?: RequestOptions): Promise<Response<ThreadsListResponse>>;
3764
+ get(id: string, options?: RequestOptions): Promise<Response<ThreadsGetResponse>>;
3765
+ update(params: ThreadsUpdateParams, options?: RequestOptions): Promise<Response<ThreadsUpdateResponse>>;
3766
+ reply(params: ThreadsReplyParams, options?: RequestOptions): Promise<Response<ThreadsReplyResponse>>;
3767
+ };
3768
+ messages: {
3769
+ get(id: string, options?: RequestOptions): Promise<Response<MessagesGetResponse>>;
3770
+ update(params: MessagesUpdateParams, options?: RequestOptions): Promise<Response<MessagesUpdateResponse>>;
3771
+ send(params: MessagesSendParams, options?: RequestOptions): Promise<Response<MessagesSendResponse>>;
3772
+ remove(id: string, options?: RequestOptions): Promise<Response<MessagesRemoveResponse>>;
3773
+ attachment(params: MessagesAttachmentParams, options?: RequestOptions): Promise<Response<MessagesAttachmentResponse>>;
3774
+ };
3775
+ }
3776
+
3777
+ type SendAttachment = Omit<NonNullable<EmailsSendParams["attachments"]>[number], "content"> & {
3778
+ content?: string | Uint8Array;
3779
+ };
3780
+ type ContentKeys = "from" | "subject" | "template" | "html" | "text";
3781
+ type EmailTemplate = NonNullable<EmailsSendParams["template"]>;
3782
+ /**
3783
+ * Comme `CreateEmailOptions` de Resend 6.32 : soit un contenu (`html`, `text` ou `react`) avec `from` et
3784
+ * `subject` obligatoires, soit un `template` publié qui fournit `from` et `subject` s'ils manquent.
3785
+ */
3786
+ type WithContent<Base> = (Base & {
3787
+ from: string;
3788
+ subject: string;
3789
+ html?: string;
3790
+ text?: string;
3791
+ react?: unknown;
3792
+ template?: never;
3793
+ }) | (Base & {
3794
+ from?: string;
3795
+ subject?: string;
3796
+ template: EmailTemplate;
3797
+ html?: never;
3798
+ text?: never;
3799
+ react?: never;
3800
+ });
3801
+ /** Même charge utile que `emails.send` de Resend : `react`, contenu binaire et envoi par template. */
3802
+ type SendEmailParams = WithContent<Omit<EmailsSendParams, ContentKeys | "attachments"> & {
3803
+ attachments?: SendAttachment[];
3804
+ }>;
3805
+ /** Un email de `batch.send` : comme `emails.send`, sans pièces jointes. */
3806
+ type BatchEmailParams = WithContent<Omit<BatchSendParams[number], ContentKeys>>;
3807
+ type BatchSendOptions = RequestOptions & {
3808
+ batchValidation?: "strict" | "permissive";
3809
+ };
3810
+
3811
+ declare class WebhookVerificationError extends Error {
3812
+ constructor(message: string);
3813
+ }
3814
+ type WebhookEvent = {
3815
+ type: string;
3816
+ created_at: string;
3817
+ data: Record<string, unknown>;
3818
+ };
3819
+ interface VerifyWebhookInput {
3820
+ payload: string;
3821
+ headers: {
3822
+ id: string;
3823
+ timestamp: string;
3824
+ signature: string;
3825
+ };
3826
+ webhookSecret: string;
3827
+ }
3828
+
3829
+ type CreateEmailOptions = SendEmailParams;
3830
+ type CreateEmailRequestOptions = RequestOptions;
3831
+ type CreateEmailResponseSuccess = EmailsSendResponse;
3832
+ type CreateEmailResponse = Response<CreateEmailResponseSuccess>;
3833
+ type GetEmailResponseSuccess = EmailsGetResponse;
3834
+ type GetEmailResponse = Response<GetEmailResponseSuccess>;
3835
+ type ListEmailsOptions = EmailsListParams;
3836
+ type ListEmail = EmailsListResponse["data"][number];
3837
+ type ListEmailsResponseSuccess = EmailsListResponse;
3838
+ type ListEmailsResponse = Response<ListEmailsResponseSuccess>;
3839
+ type UpdateEmailOptions = EmailsUpdateParams;
3840
+ type UpdateEmailResponseSuccess = EmailsUpdateResponse;
3841
+ type UpdateEmailResponse = Response<UpdateEmailResponseSuccess>;
3842
+ type CancelEmailResponseSuccess = EmailsCancelResponse;
3843
+ type CancelEmailResponse = Response<CancelEmailResponseSuccess>;
3844
+ type CreateBatchEmailOptions = BatchEmailParams;
3845
+ type CreateBatchOptions = BatchEmailParams[];
3846
+ type CreateBatchRequestOptions = BatchSendOptions;
3847
+ type CreateBatchSuccessResponse<_Options extends CreateBatchRequestOptions = CreateBatchRequestOptions> = BatchSendResponse;
3848
+ type CreateBatchResponse<Options extends CreateBatchRequestOptions = CreateBatchRequestOptions> = Response<CreateBatchSuccessResponse<Options>>;
3849
+ type CreateDomainOptions = DomainsCreateParams;
3850
+ type CreateDomainRequestOptions = RequestOptions;
3851
+ type CreateDomainResponseSuccess = DomainsCreateResponse;
3852
+ type CreateDomainResponse = Response<CreateDomainResponseSuccess>;
3853
+ type GetDomainResponseSuccess = DomainsGetResponse;
3854
+ type GetDomainResponse = Response<GetDomainResponseSuccess>;
3855
+ type ListDomainsOptions = DomainsListParams;
3856
+ type ListDomainsResponseSuccess = DomainsListResponse;
3857
+ type ListDomainsResponse = Response<ListDomainsResponseSuccess>;
3858
+ type VerifyDomainsResponseSuccess = DomainsVerifyResponse;
3859
+ type VerifyDomainsResponse = Response<VerifyDomainsResponseSuccess>;
3860
+ type CreateApiKeyOptions = ApiKeysCreateParams;
3861
+ type CreateApiKeyRequestOptions = RequestOptions;
3862
+ type CreateApiKeyResponseSuccess = ApiKeysCreateResponse;
3863
+ type CreateApiKeyResponse = Response<CreateApiKeyResponseSuccess>;
3864
+ type ListApiKeysOptions = ApiKeysListParams;
3865
+ type ListApiKeysResponseSuccess = ApiKeysListResponse;
3866
+ type ListApiKeysResponse = Response<ListApiKeysResponseSuccess>;
3867
+ type UpdateApiKeyOptions = Omit<ApiKeysUpdateParams, "id">;
3868
+ type UpdateApiKeyResponseSuccess = ApiKeysUpdateResponse;
3869
+ type UpdateApiKeyResponse = Response<UpdateApiKeyResponseSuccess>;
3870
+ type RemoveApiKeyResponseSuccess = ApiKeysRemoveResponse;
3871
+ type RemoveApiKeyResponse = Response<RemoveApiKeyResponseSuccess>;
3872
+ type CreateTemplateOptions = CreateTemplateParams;
3873
+ type CreateTemplateRequestOptions = RequestOptions;
3874
+ type CreateTemplateResponseSuccess = TemplatesCreateResponse;
3875
+ type CreateTemplateResponse = Response<CreateTemplateResponseSuccess>;
3876
+ type DuplicateTemplateResponseSuccess = TemplatesDuplicateResponse;
3877
+ type DuplicateTemplateResponse = Response<DuplicateTemplateResponseSuccess>;
3878
+ type PublishTemplateResponseSuccess = TemplatesPublishResponse;
3879
+ type PublishTemplateResponse = Response<PublishTemplateResponseSuccess>;
3880
+ type GetTemplateResponseSuccess = TemplatesGetResponse;
3881
+ type GetTemplateResponse = Response<GetTemplateResponseSuccess>;
3882
+ type ListTemplatesOptions = TemplatesListParams;
3883
+ type ListTemplatesResponseSuccess = TemplatesListResponse;
3884
+ type ListTemplatesResponse = Response<ListTemplatesResponseSuccess>;
3885
+ type UpdateTemplateOptions = Omit<TemplatesUpdateParams, "id">;
3886
+ type UpdateTemplateResponseSuccess = TemplatesUpdateResponse;
3887
+ type UpdateTemplateResponse = Response<UpdateTemplateResponseSuccess>;
3888
+ type RemoveTemplateResponseSuccess = TemplatesRemoveResponse;
3889
+ type RemoveTemplateResponse = Response<RemoveTemplateResponseSuccess>;
3890
+ type CreateWebhookOptions = WebhooksCreateParams;
3891
+ type CreateWebhookRequestOptions = RequestOptions;
3892
+ type CreateWebhookResponseSuccess = WebhooksCreateResponse;
3893
+ type CreateWebhookResponse = Response<CreateWebhookResponseSuccess>;
3894
+ type GetWebhookResponseSuccess = WebhooksGetResponse;
3895
+ type GetWebhookResponse = Response<GetWebhookResponseSuccess>;
3896
+ type ListWebhooksOptions = WebhooksListParams;
3897
+ type ListWebhooksResponseSuccess = WebhooksListResponse;
3898
+ type ListWebhooksResponse = Response<ListWebhooksResponseSuccess>;
3899
+ type UpdateWebhookOptions = Omit<WebhooksUpdateParams, "id">;
3900
+ type UpdateWebhookResponseSuccess = WebhooksUpdateResponse;
3901
+ type UpdateWebhookResponse = Response<UpdateWebhookResponseSuccess>;
3902
+ type RemoveWebhookResponseSuccess = WebhooksRemoveResponse;
3903
+ type RemoveWebhookResponse = Response<RemoveWebhookResponseSuccess>;
3904
+ type RotateWebhookSigningSecretResponseSuccess = WebhooksRotateSigningSecretResponse;
3905
+ type RotateWebhookSigningSecretResponse = Response<RotateWebhookSigningSecretResponseSuccess>;
3906
+
3907
+ /** Résultat de `templates.create` / `templates.duplicate` : une promesse qu'on peut enchaîner avec `.publish()`. */
3908
+ type ChainableTemplateResult<T> = Promise<Response<T>> & {
3909
+ publish(options?: RequestOptions): Promise<Response<TemplatesPublishResponse>>;
3910
+ };
3911
+ /** Comme Resend : `react` rendu en `html` via `@react-email/render`, l'un ou l'autre. */
3912
+ type CreateTemplateParams = Omit<TemplatesCreateParams, "html"> & {
3913
+ html?: string;
3914
+ react?: unknown;
3915
+ };
3916
+ type SendEmail = (payload: SendEmailParams, options?: RequestOptions) => Promise<Response<EmailsSendResponse>>;
3917
+ type SendBatch = (emails: BatchEmailParams[], options?: BatchSendOptions) => Promise<Response<BatchSendResponse>>;
3918
+ /** Méthodes dont Resend 6.32 impose la forme : elles remplacent celles du catalogue. */
3919
+ interface Smartletter extends Omit<SmartletterResources, "emails" | "batch" | "apiKeys" | "templates" | "webhooks"> {
3920
+ emails: Omit<SmartletterResources["emails"], "send"> & {
3921
+ send: SendEmail;
3922
+ create: SendEmail;
3923
+ };
3924
+ batch: {
3925
+ send: SendBatch;
3926
+ create: SendBatch;
3927
+ };
3928
+ apiKeys: Omit<SmartletterResources["apiKeys"], "update"> & {
3929
+ update(id: string, payload: Omit<ApiKeysUpdateParams, "id">, options?: RequestOptions): Promise<Response<ApiKeysUpdateResponse>>;
3930
+ };
3931
+ templates: Omit<SmartletterResources["templates"], "create" | "duplicate" | "publish" | "update"> & {
3932
+ create(payload: CreateTemplateParams, options?: RequestOptions): ChainableTemplateResult<TemplatesCreateResponse>;
3933
+ duplicate(id: string, options?: RequestOptions): ChainableTemplateResult<TemplatesDuplicateResponse>;
3934
+ publish(id: string, options?: RequestOptions): Promise<Response<TemplatesPublishResponse>>;
3935
+ update(id: string, payload: Omit<TemplatesUpdateParams, "id">, options?: RequestOptions): Promise<Response<TemplatesUpdateResponse>>;
3936
+ };
3937
+ webhooks: Omit<SmartletterResources["webhooks"], "update"> & {
3938
+ update(id: string, payload: Omit<WebhooksUpdateParams, "id">, options?: RequestOptions): Promise<Response<WebhooksUpdateResponse>>;
3939
+ verify(input: VerifyWebhookInput): WebhookEvent;
3940
+ };
3941
+ }
3942
+ declare class Smartletter extends Client {
3943
+ constructor(key?: string, options?: {
3944
+ baseUrl?: string;
3945
+ userAgent?: string;
3946
+ });
3947
+ }
3948
+
3949
+ export { Smartletter as Resend, Smartletter, WebhookVerificationError };
3950
+ export type { ApiKeysCreateParams, ApiKeysCreateResponse, ApiKeysListParams, ApiKeysListResponse, ApiKeysRemoveParams, ApiKeysRemoveResponse, ApiKeysUpdateParams, ApiKeysUpdateResponse, AudienceFiltersCountParams, AudienceFiltersCountResponse, AudienceFiltersCreateParams, AudienceFiltersCreateResponse, AudienceFiltersGetParams, AudienceFiltersGetResponse, AudienceFiltersListParams, AudienceFiltersListResponse, AudienceFiltersRemoveParams, AudienceFiltersRemoveResponse, AudienceFiltersUpdateParams, AudienceFiltersUpdateResponse, BatchEmailParams, BatchSendOptions, BatchSendParams, BatchSendResponse, CancelEmailResponse, CancelEmailResponseSuccess, ChainableTemplateResult, ContactFieldsCreateParams, ContactFieldsCreateResponse, ContactFieldsListParams, ContactFieldsListResponse, ContactFieldsRemoveParams, ContactFieldsRemoveResponse, ContactFieldsUpdateParams, ContactFieldsUpdateResponse, ContactsCreateParams, ContactsCreateResponse, ContactsExportParams, ContactsExportResponse, ContactsGetParams, ContactsGetResponse, ContactsImportParams, ContactsImportResponse, ContactsListParams, ContactsListResponse, ContactsReactivateParams, ContactsReactivateResponse, ContactsRemoveParams, ContactsRemoveResponse, ContactsUnsubscribeParams, ContactsUnsubscribeResponse, ContactsUpdateParams, ContactsUpdateResponse, CreateApiKeyOptions, CreateApiKeyRequestOptions, CreateApiKeyResponse, CreateApiKeyResponseSuccess, CreateBatchEmailOptions, CreateBatchOptions, CreateBatchRequestOptions, CreateBatchResponse, CreateBatchSuccessResponse, CreateDomainOptions, CreateDomainRequestOptions, CreateDomainResponse, CreateDomainResponseSuccess, CreateEmailOptions, CreateEmailRequestOptions, CreateEmailResponse, CreateEmailResponseSuccess, CreateTemplateOptions, CreateTemplateParams, CreateTemplateRequestOptions, CreateTemplateResponse, CreateTemplateResponseSuccess, CreateWebhookOptions, CreateWebhookRequestOptions, CreateWebhookResponse, CreateWebhookResponseSuccess, DomainsCreateParams, DomainsCreateResponse, DomainsGetParams, DomainsGetResponse, DomainsListParams, DomainsListResponse, DomainsVerifyParams, DomainsVerifyResponse, DuplicateTemplateResponse, DuplicateTemplateResponseSuccess, EmailsCancelParams, EmailsCancelResponse, EmailsGetParams, EmailsGetResponse, EmailsListParams, EmailsListResponse, EmailsSendParams, EmailsSendResponse, EmailsUpdateParams, EmailsUpdateResponse, ErrorResponse, EventsSendParams, EventsSendResponse, GetDomainResponse, GetDomainResponseSuccess, GetEmailResponse, GetEmailResponseSuccess, GetTemplateResponse, GetTemplateResponseSuccess, GetWebhookResponse, GetWebhookResponseSuccess, ImagesCreateParams, ImagesCreateResponse, ImagesListParams, ImagesListResponse, InboxesCreateParams, InboxesCreateResponse, InboxesGetParams, InboxesGetResponse, InboxesListParams, InboxesListResponse, InboxesRemoveParams, InboxesRemoveResponse, InboxesUpdateParams, InboxesUpdateResponse, ListApiKeysOptions, ListApiKeysResponse, ListApiKeysResponseSuccess, ListDomainsOptions, ListDomainsResponse, ListDomainsResponseSuccess, ListEmail, ListEmailsOptions, ListEmailsResponse, ListEmailsResponseSuccess, ListTemplatesOptions, ListTemplatesResponse, ListTemplatesResponseSuccess, ListWebhooksOptions, ListWebhooksResponse, ListWebhooksResponseSuccess, LogsGetParams, LogsGetResponse, LogsListParams, LogsListResponse, MessagesAttachmentParams, MessagesAttachmentResponse, MessagesGetParams, MessagesGetResponse, MessagesRemoveParams, MessagesRemoveResponse, MessagesSendParams, MessagesSendResponse, MessagesUpdateParams, MessagesUpdateResponse, NewslettersAbWinnerParams, NewslettersAbWinnerResponse, NewslettersArchiveUpdateParams, NewslettersArchiveUpdateResponse, NewslettersCreateParams, NewslettersCreateResponse, NewslettersDuplicateParams, NewslettersDuplicateResponse, NewslettersGetParams, NewslettersGetResponse, NewslettersListParams, NewslettersListResponse, NewslettersPauseParams, NewslettersPauseResponse, NewslettersRemoveParams, NewslettersRemoveResponse, NewslettersReportParams, NewslettersReportResponse, NewslettersResumeParams, NewslettersResumeResponse, NewslettersReviewParams, NewslettersReviewResponse, NewslettersScheduleParams, NewslettersScheduleResponse, NewslettersSendMoreParams, NewslettersSendMoreResponse, NewslettersSendParams, NewslettersSendResponse, NewslettersTestParams, NewslettersTestResponse, NewslettersUnscheduleParams, NewslettersUnscheduleResponse, NewslettersUpdateParams, NewslettersUpdateResponse, PublishTemplateResponse, PublishTemplateResponseSuccess, RemoveApiKeyResponse, RemoveApiKeyResponseSuccess, RemoveTemplateResponse, RemoveTemplateResponseSuccess, RemoveWebhookResponse, RemoveWebhookResponseSuccess, RequestOptions, Response, RotateWebhookSigningSecretResponse, RotateWebhookSigningSecretResponseSuccess, SegmentsArchiveGetParams, SegmentsArchiveGetResponse, SegmentsArchiveUpdateParams, SegmentsArchiveUpdateResponse, SegmentsCreateParams, SegmentsCreateResponse, SegmentsDomainGetParams, SegmentsDomainGetResponse, SegmentsDomainRemoveParams, SegmentsDomainRemoveResponse, SegmentsDomainSetParams, SegmentsDomainSetResponse, SegmentsListParams, SegmentsListResponse, SendEmailParams, SequencesActivateParams, SequencesActivateResponse, SequencesArchiveParams, SequencesArchiveResponse, SequencesCreateParams, SequencesCreateResponse, SequencesEnrollParams, SequencesEnrollResponse, SequencesEnrollmentsParams, SequencesEnrollmentsResponse, SequencesGetParams, SequencesGetResponse, SequencesListParams, SequencesListResponse, SequencesPauseParams, SequencesPauseResponse, SequencesRemoveParams, SequencesRemoveResponse, SequencesStatsParams, SequencesStatsResponse, SequencesUnenrollParams, SequencesUnenrollResponse, SequencesUpdateParams, SequencesUpdateResponse, SignupsCreateParams, SignupsCreateResponse, StatsOverviewParams, StatsOverviewResponse, SuppressionsCreateParams, SuppressionsCreateResponse, SuppressionsListParams, SuppressionsListResponse, SuppressionsRemoveParams, SuppressionsRemoveResponse, TemplatesCreateParams, TemplatesCreateResponse, TemplatesDuplicateParams, TemplatesDuplicateResponse, TemplatesGetParams, TemplatesGetResponse, TemplatesListParams, TemplatesListResponse, TemplatesPublishParams, TemplatesPublishResponse, TemplatesRemoveParams, TemplatesRemoveResponse, TemplatesUpdateParams, TemplatesUpdateResponse, TemplatesVersionsParams, TemplatesVersionsResponse, ThreadsGetParams, ThreadsGetResponse, ThreadsListParams, ThreadsListResponse, ThreadsReplyParams, ThreadsReplyResponse, ThreadsUpdateParams, ThreadsUpdateResponse, TopicsListParams, TopicsListResponse, UpdateApiKeyOptions, UpdateApiKeyResponse, UpdateApiKeyResponseSuccess, UpdateEmailOptions, UpdateEmailResponse, UpdateEmailResponseSuccess, UpdateTemplateOptions, UpdateTemplateResponse, UpdateTemplateResponseSuccess, UpdateWebhookOptions, UpdateWebhookResponse, UpdateWebhookResponseSuccess, UsageGetParams, UsageGetResponse, VerifyDomainsResponse, VerifyDomainsResponseSuccess, VerifyWebhookInput, WebhookEvent, WebhooksCreateParams, WebhooksCreateResponse, WebhooksDeliveriesParams, WebhooksDeliveriesResponse, WebhooksGetParams, WebhooksGetResponse, WebhooksListParams, WebhooksListResponse, WebhooksRemoveParams, WebhooksRemoveResponse, WebhooksRetryDeliveryParams, WebhooksRetryDeliveryResponse, WebhooksRotateSigningSecretParams, WebhooksRotateSigningSecretResponse, WebhooksTestParams, WebhooksTestResponse, WebhooksUpdateParams, WebhooksUpdateResponse };