unitpost 0.0.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2456 @@
1
+ declare const SDK_VERSION = "0.1.0";
2
+ interface ApiFieldError {
3
+ /** Dotted path to the offending field, e.g. "template.variables.first_name". */
4
+ field: string;
5
+ message: string;
6
+ }
7
+ /** A structured API error. Returned in `{ data, error }`, never thrown by default. */
8
+ declare class UnitpostError extends Error {
9
+ readonly code: string;
10
+ readonly status: number;
11
+ readonly requestId: string | null;
12
+ /** Per-field validation problems (present on 422 validation_error). */
13
+ readonly details: ApiFieldError[];
14
+ constructor(args: {
15
+ code: string;
16
+ message: string;
17
+ status: number;
18
+ requestId: string | null;
19
+ details?: ApiFieldError[];
20
+ });
21
+ }
22
+ interface UnitpostOptions {
23
+ /** API key. Defaults to `process.env.UNITPOST_API_KEY`. */
24
+ apiKey?: string;
25
+ /** Override the API base URL (e.g. for a self-hosted / staging instance). */
26
+ baseUrl?: string;
27
+ /** Per-request timeout in milliseconds. Default 30000. */
28
+ timeout?: number;
29
+ /** Inject a custom fetch (tests / non-standard runtimes). Defaults to global fetch. */
30
+ fetch?: typeof fetch;
31
+ /** Extra headers added to every request. */
32
+ headers?: Record<string, string>;
33
+ /**
34
+ * Max automatic retries for transient failures (429, 5xx, timeouts, network
35
+ * errors). Default 2 (up to 3 attempts total). Set 0 to disable retries.
36
+ * See SECURITY.md §6: 429 honors `Retry-After`; 5xx/transport use exponential
37
+ * backoff with full jitter; 4xx (401/403/404/409/422) are never retried.
38
+ */
39
+ maxRetries?: number;
40
+ /** Base backoff delay in ms (doubles per attempt, full jitter applied). Default 500. */
41
+ retryBaseDelay?: number;
42
+ /** Upper bound on a single backoff/`Retry-After` wait in ms. Default 20000. */
43
+ maxRetryDelay?: number;
44
+ /** Injectable sleep (tests). Defaults to a real timer. */
45
+ sleep?: (ms: number) => Promise<void>;
46
+ }
47
+ interface RequestArgs {
48
+ method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
49
+ path: string;
50
+ query?: Record<string, unknown> | object;
51
+ body?: unknown;
52
+ /** Idempotency-Key header value (send/create paths). */
53
+ idempotencyKey?: string;
54
+ }
55
+ declare class HttpClient {
56
+ private readonly apiKey;
57
+ private readonly baseUrl;
58
+ private readonly timeout;
59
+ private readonly fetchImpl;
60
+ private readonly extraHeaders;
61
+ private readonly maxRetries;
62
+ private readonly retryBaseDelay;
63
+ private readonly maxRetryDelay;
64
+ private readonly sleep;
65
+ constructor(options?: UnitpostOptions);
66
+ /**
67
+ * Returns `{ data, error }` — never throws for an API-level error.
68
+ *
69
+ * Transient failures (429, 5xx, timeouts, network errors) are retried up to
70
+ * `maxRetries` times with backoff, but ONLY when the request is safe to
71
+ * replay: a GET, or a write that carries an `Idempotency-Key` (deduped
72
+ * server-side). A keyless write is never auto-retried. A 429/503 `Retry-After`
73
+ * is honored (clamped to `maxRetryDelay`); otherwise we use exponential
74
+ * backoff with full jitter.
75
+ */
76
+ request<T>(args: RequestArgs): Promise<{
77
+ data: T | null;
78
+ error: UnitpostError | null;
79
+ }>;
80
+ private backoffDelay;
81
+ private attempt;
82
+ private buildUrl;
83
+ }
84
+
85
+ interface ListResponse<T> {
86
+ object: "list";
87
+ has_more: boolean;
88
+ data: T[];
89
+ }
90
+ interface ListParams {
91
+ /** Max rows to return (default 20, max 100). */
92
+ limit?: number;
93
+ /** Return rows after this id (forward paging). */
94
+ after?: string;
95
+ /** Return rows before this id (backward paging). */
96
+ before?: string;
97
+ }
98
+
99
+ interface VerifyWebhookArgs {
100
+ /** The raw request body string, exactly as received. */
101
+ payload: string;
102
+ /** The endpoint signing secret (`whsec_…`) returned once on webhook create. */
103
+ secret: string;
104
+ /** The incoming request headers (svix-id / svix-timestamp / svix-signature). */
105
+ headers: Record<string, string | string[] | undefined>;
106
+ /** Reject timestamps more than this many seconds from now (default 300, ±5min). */
107
+ toleranceSeconds?: number;
108
+ }
109
+ declare class WebhookVerificationError extends Error {
110
+ constructor(message: string);
111
+ }
112
+ /**
113
+ * Verify a webhook delivery's signature and return the parsed JSON event.
114
+ * Throws WebhookVerificationError if the signature is missing/invalid or stale.
115
+ */
116
+ declare function verifyWebhook<T = unknown>(args: VerifyWebhookArgs): T;
117
+
118
+ type ApiKey = {
119
+ object: "api_key";
120
+ id: string;
121
+ name: string;
122
+ prefix: string;
123
+ scope: "full" | "sending" | "read_only";
124
+ capabilities: Array<string>;
125
+ last_used_at: string | null;
126
+ revoked_at: string | null;
127
+ created_at: string;
128
+ };
129
+ type ApiKeyCreate = {
130
+ name: string;
131
+ scope?: "full" | "sending" | "read_only";
132
+ capabilities?: Array<"contacts:read" | "contacts:write" | "suppressions:read" | "suppressions:write" | "segments:read" | "segments:write" | "topics:read" | "topics:write" | "templates:read" | "templates:write" | "components:read" | "components:write" | "campaigns:read" | "campaigns:write" | "campaigns:send" | "domains:read" | "domains:write" | "emails:read" | "emails:send" | "apikeys:read" | "apikeys:manage" | "webhooks:read" | "webhooks:manage" | "team:read" | "team:invite" | "team:manage_members" | "workspace:update" | "workspace:delete" | "billing:manage">;
133
+ };
134
+ type ApiKeyCreated = ApiKey & {
135
+ key: string;
136
+ };
137
+ type Batch = {
138
+ object: "batch";
139
+ id: string;
140
+ count: number;
141
+ scheduled_at: string | null;
142
+ created_at: string;
143
+ status_counts: Record<string, number>;
144
+ cancelable: number;
145
+ };
146
+ type BatchSend = Array<{
147
+ from: string;
148
+ to: string | Array<string>;
149
+ subject?: string;
150
+ cc?: string | Array<string>;
151
+ bcc?: string | Array<string>;
152
+ reply_to?: string | Array<string>;
153
+ in_reply_to?: string;
154
+ headers?: Record<string, string>;
155
+ tags?: Array<{
156
+ name: string;
157
+ value: string;
158
+ }>;
159
+ template?: {
160
+ id: string;
161
+ variables?: Record<string, string | number>;
162
+ };
163
+ html?: string;
164
+ text?: string;
165
+ open_tracking?: boolean;
166
+ click_tracking?: boolean;
167
+ }> | {
168
+ emails: Array<{
169
+ from: string;
170
+ to: string | Array<string>;
171
+ subject?: string;
172
+ cc?: string | Array<string>;
173
+ bcc?: string | Array<string>;
174
+ reply_to?: string | Array<string>;
175
+ in_reply_to?: string;
176
+ headers?: Record<string, string>;
177
+ tags?: Array<{
178
+ name: string;
179
+ value: string;
180
+ }>;
181
+ template?: {
182
+ id: string;
183
+ variables?: Record<string, string | number>;
184
+ };
185
+ html?: string;
186
+ text?: string;
187
+ open_tracking?: boolean;
188
+ click_tracking?: boolean;
189
+ }>;
190
+ scheduled_at?: string;
191
+ };
192
+ type BatchSendResult = {
193
+ object: "list";
194
+ batch_id: string;
195
+ status: "queued" | "scheduled";
196
+ scheduled_at: string | null;
197
+ data: Array<{
198
+ id: string;
199
+ }>;
200
+ failed: Array<{
201
+ index: number;
202
+ error: string;
203
+ }>;
204
+ };
205
+ type BrandKit = {
206
+ object: "brand_kit";
207
+ id: string;
208
+ name: string;
209
+ is_default: boolean;
210
+ website_url: string | null;
211
+ description: string | null;
212
+ tone: "NEUTRAL" | "FORMAL" | "FRIENDLY" | "PLAYFUL" | null;
213
+ voice_notes: string | null;
214
+ industry: string | null;
215
+ core_pages: Array<{
216
+ url: string;
217
+ title?: string;
218
+ }>;
219
+ extracted: {
220
+ colors?: Array<{
221
+ hex: string;
222
+ label?: string;
223
+ }>;
224
+ logo_urls?: Array<string>;
225
+ background_urls?: Array<string>;
226
+ fonts?: Array<string>;
227
+ };
228
+ graphics: Array<{
229
+ library_image_id: string;
230
+ role: "logo" | "logo_light" | "logo_dark" | "mark" | "background" | "other";
231
+ label?: string;
232
+ }>;
233
+ source: string | null;
234
+ updated_at: string | null;
235
+ };
236
+ type BrandKitList = {
237
+ object: "list";
238
+ data: Array<{
239
+ object: "brand_kit";
240
+ id: string;
241
+ name: string;
242
+ is_default: boolean;
243
+ website_url: string | null;
244
+ description: string | null;
245
+ tone: "NEUTRAL" | "FORMAL" | "FRIENDLY" | "PLAYFUL" | null;
246
+ voice_notes: string | null;
247
+ industry: string | null;
248
+ core_pages: Array<{
249
+ url: string;
250
+ title?: string;
251
+ }>;
252
+ extracted: {
253
+ colors?: Array<{
254
+ hex: string;
255
+ label?: string;
256
+ }>;
257
+ logo_urls?: Array<string>;
258
+ background_urls?: Array<string>;
259
+ fonts?: Array<string>;
260
+ };
261
+ graphics: Array<{
262
+ library_image_id: string;
263
+ role: "logo" | "logo_light" | "logo_dark" | "mark" | "background" | "other";
264
+ label?: string;
265
+ }>;
266
+ source: string | null;
267
+ updated_at: string | null;
268
+ }>;
269
+ default_id: string | null;
270
+ };
271
+ type Campaign = {
272
+ object: "campaign";
273
+ id: string;
274
+ name: string;
275
+ template_id: string;
276
+ segment_id: string;
277
+ topic_id: string | null;
278
+ from: string;
279
+ subject: string | null;
280
+ preview_text: string | null;
281
+ open_tracking: boolean | null;
282
+ click_tracking: boolean | null;
283
+ status: "draft" | "scheduled" | "sending" | "paused" | "sent" | "canceled" | "failed";
284
+ scheduled_at: string | null;
285
+ variable_fallbacks: Record<string, string>;
286
+ excluded_contact_ids: Array<string>;
287
+ total_recipients: number;
288
+ sent_count: number;
289
+ failed_count: number;
290
+ created_at: string;
291
+ updated_at: string;
292
+ };
293
+ type CampaignCreate = {
294
+ name: string;
295
+ template_id: string;
296
+ segment_id?: string;
297
+ recipients?: Array<string>;
298
+ topic_id?: string;
299
+ from: string;
300
+ subject?: string;
301
+ preview_text?: string;
302
+ scheduled_at?: string;
303
+ open_tracking?: boolean | null;
304
+ click_tracking?: boolean | null;
305
+ variable_fallbacks?: Record<string, string>;
306
+ excluded_contact_ids?: Array<string>;
307
+ };
308
+ type CampaignReschedule = {
309
+ scheduled_at: string;
310
+ };
311
+ type CampaignUpdate = {
312
+ archived?: boolean;
313
+ topic_id?: string | null;
314
+ open_tracking?: boolean | null;
315
+ click_tracking?: boolean | null;
316
+ variable_fallbacks?: Record<string, string>;
317
+ excluded_contact_ids?: Array<string>;
318
+ };
319
+ type Contact = {
320
+ object: "contact";
321
+ id: string;
322
+ email: string;
323
+ first_name: string | null;
324
+ last_name: string | null;
325
+ unsubscribed: boolean;
326
+ unsubscribed_at: string | null;
327
+ unsubscribe_reason: "USER" | "MANUAL" | "IMPORT" | "BOUNCE" | "COMPLAINT" | null;
328
+ custom_fields: Record<string, string | number | boolean | null>;
329
+ created_at: string;
330
+ updated_at: string;
331
+ };
332
+ type ContactCreate = {
333
+ email: string;
334
+ first_name?: string;
335
+ last_name?: string;
336
+ unsubscribed?: boolean;
337
+ custom_fields?: Record<string, string | number | boolean | null>;
338
+ };
339
+ type ContactField = {
340
+ object: "contact_field";
341
+ id: string;
342
+ key: string;
343
+ label: string;
344
+ type: "text" | "number" | "boolean" | "date";
345
+ default_value: string | null;
346
+ position: number;
347
+ created_at: string;
348
+ updated_at: string;
349
+ };
350
+ type ContactFieldCreate = {
351
+ key: string;
352
+ label: string;
353
+ type?: "text" | "number" | "boolean" | "date";
354
+ default_value?: string | null;
355
+ };
356
+ type ContactFieldRename = {
357
+ key: string;
358
+ };
359
+ type ContactFieldUpdate = {
360
+ label?: string;
361
+ type?: "text" | "number" | "boolean" | "date";
362
+ position?: number;
363
+ default_value?: string | null;
364
+ };
365
+ type ContactImport = {
366
+ object: "contact_import";
367
+ id: string;
368
+ status: "pending" | "processing" | "completed" | "failed";
369
+ total: number;
370
+ imported: number;
371
+ skipped: number;
372
+ failed: number;
373
+ invalid: Array<{
374
+ row: number;
375
+ reason: string;
376
+ }>;
377
+ error: string | null;
378
+ created_at: string;
379
+ updated_at: string;
380
+ };
381
+ type ContactImportCreate = {
382
+ contacts: Array<{
383
+ email: string;
384
+ first_name?: string;
385
+ last_name?: string;
386
+ custom_fields?: Record<string, string | number | boolean | null>;
387
+ }>;
388
+ };
389
+ type ContactTopic = {
390
+ object: "contact_topic";
391
+ topic_id: string;
392
+ subscribed: boolean;
393
+ status: "subscribed" | "unsubscribed";
394
+ source: "user" | "manual" | "import" | "api";
395
+ };
396
+ type ContactTopicSet = {
397
+ topic_id?: string;
398
+ topic?: string;
399
+ subscribed: boolean;
400
+ };
401
+ type ContactUpdate = {
402
+ first_name?: string | null;
403
+ last_name?: string | null;
404
+ unsubscribed?: boolean;
405
+ custom_fields?: Record<string, string | number | boolean | null>;
406
+ };
407
+ type Domain = {
408
+ object: "domain";
409
+ id: string;
410
+ name: string;
411
+ status: "pending" | "verifying" | "verified" | "degraded" | "failed";
412
+ records: Array<{
413
+ type: string;
414
+ name: string;
415
+ value: string;
416
+ priority?: number;
417
+ }> | null;
418
+ dkim_selector: string | null;
419
+ open_tracking: boolean | null;
420
+ click_tracking: boolean | null;
421
+ tls: "opportunistic" | "enforced";
422
+ tracking_subdomain: string | null;
423
+ tracking_verified_at: string | null;
424
+ verified_at: string | null;
425
+ created_at: string;
426
+ updated_at: string;
427
+ };
428
+ type DomainCreate = {
429
+ name: string;
430
+ };
431
+ type DomainUpdate = {
432
+ open_tracking?: boolean | null;
433
+ click_tracking?: boolean | null;
434
+ tls?: "opportunistic" | "enforced";
435
+ tracking_subdomain?: string | null;
436
+ };
437
+ type Email$1 = {
438
+ object: "email";
439
+ id: string;
440
+ to: Array<string>;
441
+ from: string;
442
+ subject: string;
443
+ template_id: string | null;
444
+ campaign_id: string | null;
445
+ status: "scheduled" | "queued" | "sent" | "delivered" | "bounced" | "complained" | "canceled" | "failed";
446
+ last_event: string;
447
+ scheduled_at: string | null;
448
+ sent_at: string | null;
449
+ delivered_at: string | null;
450
+ opened_at: string | null;
451
+ clicked_at: string | null;
452
+ canceled_at: string | null;
453
+ last_error: string | null;
454
+ created_at: string;
455
+ };
456
+ type EmailPatch = {
457
+ cancel?: true;
458
+ scheduled_at?: string;
459
+ };
460
+ type EmailStats = {
461
+ windowDays: number;
462
+ clampedToRetentionDays?: number | null;
463
+ totals: {
464
+ sent: number;
465
+ delivered: number;
466
+ opened: number;
467
+ clicked: number;
468
+ bounced: number;
469
+ complained: number;
470
+ failed: number;
471
+ };
472
+ rates: {
473
+ delivery: number;
474
+ open: number;
475
+ click: number;
476
+ bounce: number;
477
+ complaint: number;
478
+ };
479
+ };
480
+ type Error$1 = {
481
+ error: {
482
+ code: string;
483
+ message: string;
484
+ details?: Array<{
485
+ field: string;
486
+ message: string;
487
+ }>;
488
+ };
489
+ };
490
+ type ReceivedAttachmentUrl = {
491
+ object: "received_attachment_url";
492
+ url: string;
493
+ expires_at: string;
494
+ };
495
+ type ReceivedEmail = {
496
+ object: "received_email";
497
+ id: string;
498
+ from: string;
499
+ from_name: string | null;
500
+ to: Array<string>;
501
+ cc: Array<string>;
502
+ bcc: Array<string>;
503
+ message_id: string | null;
504
+ subject: string | null;
505
+ text: string | null;
506
+ html: string | null;
507
+ spam_verdict: string | null;
508
+ virus_verdict: string | null;
509
+ spf_verdict: string | null;
510
+ dkim_verdict: string | null;
511
+ dmarc_verdict: string | null;
512
+ size: number;
513
+ attachments: Array<{
514
+ object: "received_attachment";
515
+ id: string;
516
+ filename: string | null;
517
+ content_type: string | null;
518
+ content_disposition: string | null;
519
+ content_id: string | null;
520
+ size: number;
521
+ }>;
522
+ received_at: string;
523
+ created_at: string;
524
+ };
525
+ type ReceivedEmailSummary = {
526
+ object: "received_email";
527
+ id: string;
528
+ from: string;
529
+ from_name: string | null;
530
+ to: Array<string>;
531
+ cc: Array<string>;
532
+ bcc: Array<string>;
533
+ message_id: string | null;
534
+ subject: string | null;
535
+ spam_verdict: string | null;
536
+ virus_verdict: string | null;
537
+ spf_verdict: string | null;
538
+ dkim_verdict: string | null;
539
+ dmarc_verdict: string | null;
540
+ size: number;
541
+ received_at: string;
542
+ created_at: string;
543
+ attachment_count: number;
544
+ };
545
+ type Segment = {
546
+ object: "segment";
547
+ id: string;
548
+ name: string;
549
+ description: string | null;
550
+ type: "static" | "dynamic";
551
+ filter: unknown | null;
552
+ created_at: string;
553
+ updated_at: string;
554
+ };
555
+ type SegmentCreate = {
556
+ name: string;
557
+ description?: string;
558
+ type?: "static" | "dynamic";
559
+ filter?: unknown;
560
+ };
561
+ type SegmentMember = {
562
+ object: "segment_member";
563
+ contact_id: string;
564
+ subscribed: boolean;
565
+ unsubscribed_at: string | null;
566
+ };
567
+ type SegmentMemberAdd = {
568
+ contact: string;
569
+ subscribed?: boolean;
570
+ };
571
+ type SegmentUpdate = {
572
+ name?: string;
573
+ description?: string | null;
574
+ filter?: unknown;
575
+ };
576
+ type SendEmail = {
577
+ from: string;
578
+ to: string | Array<string>;
579
+ subject?: string;
580
+ cc?: string | Array<string>;
581
+ bcc?: string | Array<string>;
582
+ reply_to?: string | Array<string>;
583
+ in_reply_to?: string;
584
+ headers?: Record<string, string>;
585
+ tags?: Array<{
586
+ name: string;
587
+ value: string;
588
+ }>;
589
+ template?: {
590
+ id: string;
591
+ variables?: Record<string, string | number>;
592
+ };
593
+ html?: string;
594
+ text?: string;
595
+ attachments?: Array<{
596
+ filename: string;
597
+ content?: string;
598
+ path?: string;
599
+ content_type?: string;
600
+ content_id?: string;
601
+ }>;
602
+ open_tracking?: boolean;
603
+ click_tracking?: boolean;
604
+ scheduled_at?: string;
605
+ };
606
+ type SendResult = {
607
+ id: string;
608
+ status: "queued" | "scheduled";
609
+ scheduled_at: string | null;
610
+ };
611
+ type Suppression = {
612
+ object: "suppression";
613
+ id: string;
614
+ email: string;
615
+ scope: "workspace" | "platform";
616
+ reason: "bounce" | "complaint" | "unsubscribe" | "manual" | "import" | "api";
617
+ detail: string | null;
618
+ note: string | null;
619
+ created_at: string;
620
+ updated_at: string;
621
+ };
622
+ type SuppressionBulkResult = {
623
+ object: "list";
624
+ added: number;
625
+ skipped: number;
626
+ total: number;
627
+ };
628
+ type SuppressionCreate = {
629
+ email?: string;
630
+ emails?: Array<string>;
631
+ reason?: "manual" | "import" | "api";
632
+ note?: string;
633
+ };
634
+ type Template = {
635
+ object: "template";
636
+ id: string;
637
+ name: string;
638
+ subject: string | null;
639
+ mode: "code" | "visual";
640
+ status: "draft" | "published";
641
+ design?: unknown | null;
642
+ created_at: string;
643
+ updated_at: string;
644
+ };
645
+ type TemplateCreate = {
646
+ name: string;
647
+ subject?: string;
648
+ mode?: "code" | "visual";
649
+ category?: "transactional" | "marketing";
650
+ design?: {
651
+ version?: 5;
652
+ previewText?: string;
653
+ category?: "transactional" | "marketing";
654
+ openTracking?: boolean;
655
+ clickTracking?: boolean;
656
+ tracking?: boolean;
657
+ from?: string;
658
+ theme?: {
659
+ fontFamily?: string;
660
+ textColor?: string;
661
+ backgroundColor?: string;
662
+ bodyColor?: string;
663
+ linkColor?: string;
664
+ contentWidth?: number;
665
+ bodyPadding?: number;
666
+ bodyPaddingSides?: {
667
+ top?: number;
668
+ right?: number;
669
+ bottom?: number;
670
+ left?: number;
671
+ };
672
+ bodyRadius?: number;
673
+ };
674
+ variables?: Array<{
675
+ name: string;
676
+ type?: "string" | "number";
677
+ source?: "input" | "contact";
678
+ contactField?: string;
679
+ style?: {
680
+ bold?: boolean;
681
+ italic?: boolean;
682
+ underline?: boolean;
683
+ color?: string;
684
+ background?: string;
685
+ fontFamily?: string;
686
+ fontSize?: number;
687
+ href?: string;
688
+ };
689
+ }>;
690
+ className?: string;
691
+ blocks?: Array<unknown | {
692
+ type: "row";
693
+ id: string;
694
+ backgroundColor?: string;
695
+ border?: {
696
+ width?: number;
697
+ style?: "solid" | "dashed" | "dotted";
698
+ color?: string;
699
+ radius?: number;
700
+ };
701
+ paddingX?: number;
702
+ paddingY?: number;
703
+ columnGap?: number;
704
+ stackOnMobile?: boolean;
705
+ margin?: {
706
+ top?: number;
707
+ right?: number;
708
+ bottom?: number;
709
+ left?: number;
710
+ };
711
+ padding?: {
712
+ top?: number;
713
+ right?: number;
714
+ bottom?: number;
715
+ left?: number;
716
+ };
717
+ customCss?: string;
718
+ className?: string;
719
+ componentRef?: {
720
+ id: string;
721
+ name?: string;
722
+ unlocked?: boolean;
723
+ };
724
+ columns?: Array<{
725
+ type: "column";
726
+ id: string;
727
+ width?: number;
728
+ backgroundColor?: string;
729
+ border?: {
730
+ width?: number;
731
+ style?: "solid" | "dashed" | "dotted";
732
+ color?: string;
733
+ radius?: number;
734
+ };
735
+ paddingX?: number;
736
+ paddingY?: number;
737
+ margin?: {
738
+ top?: number;
739
+ right?: number;
740
+ bottom?: number;
741
+ left?: number;
742
+ };
743
+ padding?: {
744
+ top?: number;
745
+ right?: number;
746
+ bottom?: number;
747
+ left?: number;
748
+ };
749
+ customCss?: string;
750
+ className?: string;
751
+ componentRef?: {
752
+ id: string;
753
+ name?: string;
754
+ unlocked?: boolean;
755
+ };
756
+ children?: Array<{
757
+ type: "text";
758
+ id: string;
759
+ text?: string;
760
+ content?: Array<{
761
+ text?: string;
762
+ marks?: {
763
+ bold?: boolean;
764
+ italic?: boolean;
765
+ underline?: boolean;
766
+ link?: string;
767
+ color?: string;
768
+ background?: string;
769
+ fontFamily?: string;
770
+ fontSize?: number;
771
+ };
772
+ variable?: string;
773
+ }>;
774
+ align?: "left" | "center" | "right";
775
+ color?: string;
776
+ fontSize?: number;
777
+ fontFamily?: string;
778
+ lineHeight?: number | string;
779
+ letterSpacing?: number;
780
+ fontWeight?: string | number;
781
+ marginBottom?: number;
782
+ margin?: {
783
+ top?: number;
784
+ right?: number;
785
+ bottom?: number;
786
+ left?: number;
787
+ };
788
+ padding?: {
789
+ top?: number;
790
+ right?: number;
791
+ bottom?: number;
792
+ left?: number;
793
+ };
794
+ customCss?: string;
795
+ className?: string;
796
+ componentRef?: {
797
+ id: string;
798
+ name?: string;
799
+ unlocked?: boolean;
800
+ };
801
+ } | {
802
+ type: "heading";
803
+ id: string;
804
+ text?: string;
805
+ content?: Array<{
806
+ text?: string;
807
+ marks?: {
808
+ bold?: boolean;
809
+ italic?: boolean;
810
+ underline?: boolean;
811
+ link?: string;
812
+ color?: string;
813
+ background?: string;
814
+ fontFamily?: string;
815
+ fontSize?: number;
816
+ };
817
+ variable?: string;
818
+ }>;
819
+ level?: 1 | 2 | 3 | 4;
820
+ fontSize?: number;
821
+ align?: "left" | "center" | "right";
822
+ color?: string;
823
+ fontFamily?: string;
824
+ lineHeight?: number | string;
825
+ letterSpacing?: number;
826
+ fontWeight?: string | number;
827
+ marginBottom?: number;
828
+ margin?: {
829
+ top?: number;
830
+ right?: number;
831
+ bottom?: number;
832
+ left?: number;
833
+ };
834
+ padding?: {
835
+ top?: number;
836
+ right?: number;
837
+ bottom?: number;
838
+ left?: number;
839
+ };
840
+ customCss?: string;
841
+ className?: string;
842
+ componentRef?: {
843
+ id: string;
844
+ name?: string;
845
+ unlocked?: boolean;
846
+ };
847
+ } | {
848
+ type: "button";
849
+ id: string;
850
+ text?: string;
851
+ href?: string;
852
+ align?: "left" | "center" | "right";
853
+ backgroundColor?: string;
854
+ textColor?: string;
855
+ borderRadius?: number;
856
+ innerPaddingX?: number;
857
+ innerPaddingY?: number;
858
+ marginBottom?: number;
859
+ margin?: {
860
+ top?: number;
861
+ right?: number;
862
+ bottom?: number;
863
+ left?: number;
864
+ };
865
+ padding?: {
866
+ top?: number;
867
+ right?: number;
868
+ bottom?: number;
869
+ left?: number;
870
+ };
871
+ customCss?: string;
872
+ className?: string;
873
+ componentRef?: {
874
+ id: string;
875
+ name?: string;
876
+ unlocked?: boolean;
877
+ };
878
+ } | {
879
+ type: "image";
880
+ id: string;
881
+ src?: string;
882
+ alt?: string;
883
+ href?: string;
884
+ width?: number;
885
+ height?: number;
886
+ borderRadius?: number;
887
+ border?: {
888
+ width?: number;
889
+ style?: "solid" | "dashed" | "dotted";
890
+ color?: string;
891
+ radius?: number;
892
+ };
893
+ objectFit?: "cover" | "contain" | "fill";
894
+ backgroundColor?: string;
895
+ align?: "left" | "center" | "right";
896
+ marginBottom?: number;
897
+ margin?: {
898
+ top?: number;
899
+ right?: number;
900
+ bottom?: number;
901
+ left?: number;
902
+ };
903
+ padding?: {
904
+ top?: number;
905
+ right?: number;
906
+ bottom?: number;
907
+ left?: number;
908
+ };
909
+ customCss?: string;
910
+ className?: string;
911
+ componentRef?: {
912
+ id: string;
913
+ name?: string;
914
+ unlocked?: boolean;
915
+ };
916
+ } | {
917
+ type: "divider";
918
+ id: string;
919
+ color?: string;
920
+ marginBottom?: number;
921
+ margin?: {
922
+ top?: number;
923
+ right?: number;
924
+ bottom?: number;
925
+ left?: number;
926
+ };
927
+ padding?: {
928
+ top?: number;
929
+ right?: number;
930
+ bottom?: number;
931
+ left?: number;
932
+ };
933
+ customCss?: string;
934
+ className?: string;
935
+ componentRef?: {
936
+ id: string;
937
+ name?: string;
938
+ unlocked?: boolean;
939
+ };
940
+ } | {
941
+ type: "link";
942
+ id: string;
943
+ text?: string;
944
+ href?: string;
945
+ align?: "left" | "center" | "right";
946
+ color?: string;
947
+ fontSize?: number;
948
+ fontFamily?: string;
949
+ underline?: boolean;
950
+ marginBottom?: number;
951
+ margin?: {
952
+ top?: number;
953
+ right?: number;
954
+ bottom?: number;
955
+ left?: number;
956
+ };
957
+ padding?: {
958
+ top?: number;
959
+ right?: number;
960
+ bottom?: number;
961
+ left?: number;
962
+ };
963
+ customCss?: string;
964
+ className?: string;
965
+ componentRef?: {
966
+ id: string;
967
+ name?: string;
968
+ unlocked?: boolean;
969
+ };
970
+ } | {
971
+ type: "spacer";
972
+ id: string;
973
+ height?: number;
974
+ margin?: {
975
+ top?: number;
976
+ right?: number;
977
+ bottom?: number;
978
+ left?: number;
979
+ };
980
+ customCss?: string;
981
+ className?: string;
982
+ componentRef?: {
983
+ id: string;
984
+ name?: string;
985
+ unlocked?: boolean;
986
+ };
987
+ } | {
988
+ type: "markdown";
989
+ id: string;
990
+ markdown?: string;
991
+ align?: "left" | "center" | "right";
992
+ color?: string;
993
+ fontSize?: number;
994
+ marginBottom?: number;
995
+ margin?: {
996
+ top?: number;
997
+ right?: number;
998
+ bottom?: number;
999
+ left?: number;
1000
+ };
1001
+ padding?: {
1002
+ top?: number;
1003
+ right?: number;
1004
+ bottom?: number;
1005
+ left?: number;
1006
+ };
1007
+ customCss?: string;
1008
+ className?: string;
1009
+ componentRef?: {
1010
+ id: string;
1011
+ name?: string;
1012
+ unlocked?: boolean;
1013
+ };
1014
+ } | {
1015
+ type: "code";
1016
+ id: string;
1017
+ code?: string;
1018
+ backgroundColor?: string;
1019
+ color?: string;
1020
+ marginBottom?: number;
1021
+ margin?: {
1022
+ top?: number;
1023
+ right?: number;
1024
+ bottom?: number;
1025
+ left?: number;
1026
+ };
1027
+ padding?: {
1028
+ top?: number;
1029
+ right?: number;
1030
+ bottom?: number;
1031
+ left?: number;
1032
+ };
1033
+ customCss?: string;
1034
+ className?: string;
1035
+ componentRef?: {
1036
+ id: string;
1037
+ name?: string;
1038
+ unlocked?: boolean;
1039
+ };
1040
+ } | {
1041
+ type: "html";
1042
+ id: string;
1043
+ html?: string;
1044
+ marginBottom?: number;
1045
+ margin?: {
1046
+ top?: number;
1047
+ right?: number;
1048
+ bottom?: number;
1049
+ left?: number;
1050
+ };
1051
+ padding?: {
1052
+ top?: number;
1053
+ right?: number;
1054
+ bottom?: number;
1055
+ left?: number;
1056
+ };
1057
+ customCss?: string;
1058
+ className?: string;
1059
+ componentRef?: {
1060
+ id: string;
1061
+ name?: string;
1062
+ unlocked?: boolean;
1063
+ };
1064
+ }>;
1065
+ }>;
1066
+ } | {
1067
+ type: "text";
1068
+ id: string;
1069
+ text?: string;
1070
+ content?: Array<{
1071
+ text?: string;
1072
+ marks?: {
1073
+ bold?: boolean;
1074
+ italic?: boolean;
1075
+ underline?: boolean;
1076
+ link?: string;
1077
+ color?: string;
1078
+ background?: string;
1079
+ fontFamily?: string;
1080
+ fontSize?: number;
1081
+ };
1082
+ variable?: string;
1083
+ }>;
1084
+ align?: "left" | "center" | "right";
1085
+ color?: string;
1086
+ fontSize?: number;
1087
+ fontFamily?: string;
1088
+ lineHeight?: number | string;
1089
+ letterSpacing?: number;
1090
+ fontWeight?: string | number;
1091
+ marginBottom?: number;
1092
+ margin?: {
1093
+ top?: number;
1094
+ right?: number;
1095
+ bottom?: number;
1096
+ left?: number;
1097
+ };
1098
+ padding?: {
1099
+ top?: number;
1100
+ right?: number;
1101
+ bottom?: number;
1102
+ left?: number;
1103
+ };
1104
+ customCss?: string;
1105
+ className?: string;
1106
+ componentRef?: {
1107
+ id: string;
1108
+ name?: string;
1109
+ unlocked?: boolean;
1110
+ };
1111
+ } | {
1112
+ type: "heading";
1113
+ id: string;
1114
+ text?: string;
1115
+ content?: Array<{
1116
+ text?: string;
1117
+ marks?: {
1118
+ bold?: boolean;
1119
+ italic?: boolean;
1120
+ underline?: boolean;
1121
+ link?: string;
1122
+ color?: string;
1123
+ background?: string;
1124
+ fontFamily?: string;
1125
+ fontSize?: number;
1126
+ };
1127
+ variable?: string;
1128
+ }>;
1129
+ level?: 1 | 2 | 3 | 4;
1130
+ fontSize?: number;
1131
+ align?: "left" | "center" | "right";
1132
+ color?: string;
1133
+ fontFamily?: string;
1134
+ lineHeight?: number | string;
1135
+ letterSpacing?: number;
1136
+ fontWeight?: string | number;
1137
+ marginBottom?: number;
1138
+ margin?: {
1139
+ top?: number;
1140
+ right?: number;
1141
+ bottom?: number;
1142
+ left?: number;
1143
+ };
1144
+ padding?: {
1145
+ top?: number;
1146
+ right?: number;
1147
+ bottom?: number;
1148
+ left?: number;
1149
+ };
1150
+ customCss?: string;
1151
+ className?: string;
1152
+ componentRef?: {
1153
+ id: string;
1154
+ name?: string;
1155
+ unlocked?: boolean;
1156
+ };
1157
+ } | {
1158
+ type: "button";
1159
+ id: string;
1160
+ text?: string;
1161
+ href?: string;
1162
+ align?: "left" | "center" | "right";
1163
+ backgroundColor?: string;
1164
+ textColor?: string;
1165
+ borderRadius?: number;
1166
+ innerPaddingX?: number;
1167
+ innerPaddingY?: number;
1168
+ marginBottom?: number;
1169
+ margin?: {
1170
+ top?: number;
1171
+ right?: number;
1172
+ bottom?: number;
1173
+ left?: number;
1174
+ };
1175
+ padding?: {
1176
+ top?: number;
1177
+ right?: number;
1178
+ bottom?: number;
1179
+ left?: number;
1180
+ };
1181
+ customCss?: string;
1182
+ className?: string;
1183
+ componentRef?: {
1184
+ id: string;
1185
+ name?: string;
1186
+ unlocked?: boolean;
1187
+ };
1188
+ } | {
1189
+ type: "image";
1190
+ id: string;
1191
+ src?: string;
1192
+ alt?: string;
1193
+ href?: string;
1194
+ width?: number;
1195
+ height?: number;
1196
+ borderRadius?: number;
1197
+ border?: {
1198
+ width?: number;
1199
+ style?: "solid" | "dashed" | "dotted";
1200
+ color?: string;
1201
+ radius?: number;
1202
+ };
1203
+ objectFit?: "cover" | "contain" | "fill";
1204
+ backgroundColor?: string;
1205
+ align?: "left" | "center" | "right";
1206
+ marginBottom?: number;
1207
+ margin?: {
1208
+ top?: number;
1209
+ right?: number;
1210
+ bottom?: number;
1211
+ left?: number;
1212
+ };
1213
+ padding?: {
1214
+ top?: number;
1215
+ right?: number;
1216
+ bottom?: number;
1217
+ left?: number;
1218
+ };
1219
+ customCss?: string;
1220
+ className?: string;
1221
+ componentRef?: {
1222
+ id: string;
1223
+ name?: string;
1224
+ unlocked?: boolean;
1225
+ };
1226
+ } | {
1227
+ type: "divider";
1228
+ id: string;
1229
+ color?: string;
1230
+ marginBottom?: number;
1231
+ margin?: {
1232
+ top?: number;
1233
+ right?: number;
1234
+ bottom?: number;
1235
+ left?: number;
1236
+ };
1237
+ padding?: {
1238
+ top?: number;
1239
+ right?: number;
1240
+ bottom?: number;
1241
+ left?: number;
1242
+ };
1243
+ customCss?: string;
1244
+ className?: string;
1245
+ componentRef?: {
1246
+ id: string;
1247
+ name?: string;
1248
+ unlocked?: boolean;
1249
+ };
1250
+ } | {
1251
+ type: "link";
1252
+ id: string;
1253
+ text?: string;
1254
+ href?: string;
1255
+ align?: "left" | "center" | "right";
1256
+ color?: string;
1257
+ fontSize?: number;
1258
+ fontFamily?: string;
1259
+ underline?: boolean;
1260
+ marginBottom?: number;
1261
+ margin?: {
1262
+ top?: number;
1263
+ right?: number;
1264
+ bottom?: number;
1265
+ left?: number;
1266
+ };
1267
+ padding?: {
1268
+ top?: number;
1269
+ right?: number;
1270
+ bottom?: number;
1271
+ left?: number;
1272
+ };
1273
+ customCss?: string;
1274
+ className?: string;
1275
+ componentRef?: {
1276
+ id: string;
1277
+ name?: string;
1278
+ unlocked?: boolean;
1279
+ };
1280
+ } | {
1281
+ type: "spacer";
1282
+ id: string;
1283
+ height?: number;
1284
+ margin?: {
1285
+ top?: number;
1286
+ right?: number;
1287
+ bottom?: number;
1288
+ left?: number;
1289
+ };
1290
+ customCss?: string;
1291
+ className?: string;
1292
+ componentRef?: {
1293
+ id: string;
1294
+ name?: string;
1295
+ unlocked?: boolean;
1296
+ };
1297
+ } | {
1298
+ type: "markdown";
1299
+ id: string;
1300
+ markdown?: string;
1301
+ align?: "left" | "center" | "right";
1302
+ color?: string;
1303
+ fontSize?: number;
1304
+ marginBottom?: number;
1305
+ margin?: {
1306
+ top?: number;
1307
+ right?: number;
1308
+ bottom?: number;
1309
+ left?: number;
1310
+ };
1311
+ padding?: {
1312
+ top?: number;
1313
+ right?: number;
1314
+ bottom?: number;
1315
+ left?: number;
1316
+ };
1317
+ customCss?: string;
1318
+ className?: string;
1319
+ componentRef?: {
1320
+ id: string;
1321
+ name?: string;
1322
+ unlocked?: boolean;
1323
+ };
1324
+ } | {
1325
+ type: "code";
1326
+ id: string;
1327
+ code?: string;
1328
+ backgroundColor?: string;
1329
+ color?: string;
1330
+ marginBottom?: number;
1331
+ margin?: {
1332
+ top?: number;
1333
+ right?: number;
1334
+ bottom?: number;
1335
+ left?: number;
1336
+ };
1337
+ padding?: {
1338
+ top?: number;
1339
+ right?: number;
1340
+ bottom?: number;
1341
+ left?: number;
1342
+ };
1343
+ customCss?: string;
1344
+ className?: string;
1345
+ componentRef?: {
1346
+ id: string;
1347
+ name?: string;
1348
+ unlocked?: boolean;
1349
+ };
1350
+ } | {
1351
+ type: "html";
1352
+ id: string;
1353
+ html?: string;
1354
+ marginBottom?: number;
1355
+ margin?: {
1356
+ top?: number;
1357
+ right?: number;
1358
+ bottom?: number;
1359
+ left?: number;
1360
+ };
1361
+ padding?: {
1362
+ top?: number;
1363
+ right?: number;
1364
+ bottom?: number;
1365
+ left?: number;
1366
+ };
1367
+ customCss?: string;
1368
+ className?: string;
1369
+ componentRef?: {
1370
+ id: string;
1371
+ name?: string;
1372
+ unlocked?: boolean;
1373
+ };
1374
+ }>;
1375
+ };
1376
+ };
1377
+ type TemplateUpdate = {
1378
+ name?: string;
1379
+ subject?: string | null;
1380
+ mode?: "code" | "visual";
1381
+ status?: "draft" | "published";
1382
+ design?: {
1383
+ version?: 5;
1384
+ previewText?: string;
1385
+ category?: "transactional" | "marketing";
1386
+ openTracking?: boolean;
1387
+ clickTracking?: boolean;
1388
+ tracking?: boolean;
1389
+ from?: string;
1390
+ theme?: {
1391
+ fontFamily?: string;
1392
+ textColor?: string;
1393
+ backgroundColor?: string;
1394
+ bodyColor?: string;
1395
+ linkColor?: string;
1396
+ contentWidth?: number;
1397
+ bodyPadding?: number;
1398
+ bodyPaddingSides?: {
1399
+ top?: number;
1400
+ right?: number;
1401
+ bottom?: number;
1402
+ left?: number;
1403
+ };
1404
+ bodyRadius?: number;
1405
+ };
1406
+ variables?: Array<{
1407
+ name: string;
1408
+ type?: "string" | "number";
1409
+ source?: "input" | "contact";
1410
+ contactField?: string;
1411
+ style?: {
1412
+ bold?: boolean;
1413
+ italic?: boolean;
1414
+ underline?: boolean;
1415
+ color?: string;
1416
+ background?: string;
1417
+ fontFamily?: string;
1418
+ fontSize?: number;
1419
+ href?: string;
1420
+ };
1421
+ }>;
1422
+ className?: string;
1423
+ blocks?: Array<unknown | {
1424
+ type: "row";
1425
+ id: string;
1426
+ backgroundColor?: string;
1427
+ border?: {
1428
+ width?: number;
1429
+ style?: "solid" | "dashed" | "dotted";
1430
+ color?: string;
1431
+ radius?: number;
1432
+ };
1433
+ paddingX?: number;
1434
+ paddingY?: number;
1435
+ columnGap?: number;
1436
+ stackOnMobile?: boolean;
1437
+ margin?: {
1438
+ top?: number;
1439
+ right?: number;
1440
+ bottom?: number;
1441
+ left?: number;
1442
+ };
1443
+ padding?: {
1444
+ top?: number;
1445
+ right?: number;
1446
+ bottom?: number;
1447
+ left?: number;
1448
+ };
1449
+ customCss?: string;
1450
+ className?: string;
1451
+ componentRef?: {
1452
+ id: string;
1453
+ name?: string;
1454
+ unlocked?: boolean;
1455
+ };
1456
+ columns?: Array<{
1457
+ type: "column";
1458
+ id: string;
1459
+ width?: number;
1460
+ backgroundColor?: string;
1461
+ border?: {
1462
+ width?: number;
1463
+ style?: "solid" | "dashed" | "dotted";
1464
+ color?: string;
1465
+ radius?: number;
1466
+ };
1467
+ paddingX?: number;
1468
+ paddingY?: number;
1469
+ margin?: {
1470
+ top?: number;
1471
+ right?: number;
1472
+ bottom?: number;
1473
+ left?: number;
1474
+ };
1475
+ padding?: {
1476
+ top?: number;
1477
+ right?: number;
1478
+ bottom?: number;
1479
+ left?: number;
1480
+ };
1481
+ customCss?: string;
1482
+ className?: string;
1483
+ componentRef?: {
1484
+ id: string;
1485
+ name?: string;
1486
+ unlocked?: boolean;
1487
+ };
1488
+ children?: Array<{
1489
+ type: "text";
1490
+ id: string;
1491
+ text?: string;
1492
+ content?: Array<{
1493
+ text?: string;
1494
+ marks?: {
1495
+ bold?: boolean;
1496
+ italic?: boolean;
1497
+ underline?: boolean;
1498
+ link?: string;
1499
+ color?: string;
1500
+ background?: string;
1501
+ fontFamily?: string;
1502
+ fontSize?: number;
1503
+ };
1504
+ variable?: string;
1505
+ }>;
1506
+ align?: "left" | "center" | "right";
1507
+ color?: string;
1508
+ fontSize?: number;
1509
+ fontFamily?: string;
1510
+ lineHeight?: number | string;
1511
+ letterSpacing?: number;
1512
+ fontWeight?: string | number;
1513
+ marginBottom?: number;
1514
+ margin?: {
1515
+ top?: number;
1516
+ right?: number;
1517
+ bottom?: number;
1518
+ left?: number;
1519
+ };
1520
+ padding?: {
1521
+ top?: number;
1522
+ right?: number;
1523
+ bottom?: number;
1524
+ left?: number;
1525
+ };
1526
+ customCss?: string;
1527
+ className?: string;
1528
+ componentRef?: {
1529
+ id: string;
1530
+ name?: string;
1531
+ unlocked?: boolean;
1532
+ };
1533
+ } | {
1534
+ type: "heading";
1535
+ id: string;
1536
+ text?: string;
1537
+ content?: Array<{
1538
+ text?: string;
1539
+ marks?: {
1540
+ bold?: boolean;
1541
+ italic?: boolean;
1542
+ underline?: boolean;
1543
+ link?: string;
1544
+ color?: string;
1545
+ background?: string;
1546
+ fontFamily?: string;
1547
+ fontSize?: number;
1548
+ };
1549
+ variable?: string;
1550
+ }>;
1551
+ level?: 1 | 2 | 3 | 4;
1552
+ fontSize?: number;
1553
+ align?: "left" | "center" | "right";
1554
+ color?: string;
1555
+ fontFamily?: string;
1556
+ lineHeight?: number | string;
1557
+ letterSpacing?: number;
1558
+ fontWeight?: string | number;
1559
+ marginBottom?: number;
1560
+ margin?: {
1561
+ top?: number;
1562
+ right?: number;
1563
+ bottom?: number;
1564
+ left?: number;
1565
+ };
1566
+ padding?: {
1567
+ top?: number;
1568
+ right?: number;
1569
+ bottom?: number;
1570
+ left?: number;
1571
+ };
1572
+ customCss?: string;
1573
+ className?: string;
1574
+ componentRef?: {
1575
+ id: string;
1576
+ name?: string;
1577
+ unlocked?: boolean;
1578
+ };
1579
+ } | {
1580
+ type: "button";
1581
+ id: string;
1582
+ text?: string;
1583
+ href?: string;
1584
+ align?: "left" | "center" | "right";
1585
+ backgroundColor?: string;
1586
+ textColor?: string;
1587
+ borderRadius?: number;
1588
+ innerPaddingX?: number;
1589
+ innerPaddingY?: number;
1590
+ marginBottom?: number;
1591
+ margin?: {
1592
+ top?: number;
1593
+ right?: number;
1594
+ bottom?: number;
1595
+ left?: number;
1596
+ };
1597
+ padding?: {
1598
+ top?: number;
1599
+ right?: number;
1600
+ bottom?: number;
1601
+ left?: number;
1602
+ };
1603
+ customCss?: string;
1604
+ className?: string;
1605
+ componentRef?: {
1606
+ id: string;
1607
+ name?: string;
1608
+ unlocked?: boolean;
1609
+ };
1610
+ } | {
1611
+ type: "image";
1612
+ id: string;
1613
+ src?: string;
1614
+ alt?: string;
1615
+ href?: string;
1616
+ width?: number;
1617
+ height?: number;
1618
+ borderRadius?: number;
1619
+ border?: {
1620
+ width?: number;
1621
+ style?: "solid" | "dashed" | "dotted";
1622
+ color?: string;
1623
+ radius?: number;
1624
+ };
1625
+ objectFit?: "cover" | "contain" | "fill";
1626
+ backgroundColor?: string;
1627
+ align?: "left" | "center" | "right";
1628
+ marginBottom?: number;
1629
+ margin?: {
1630
+ top?: number;
1631
+ right?: number;
1632
+ bottom?: number;
1633
+ left?: number;
1634
+ };
1635
+ padding?: {
1636
+ top?: number;
1637
+ right?: number;
1638
+ bottom?: number;
1639
+ left?: number;
1640
+ };
1641
+ customCss?: string;
1642
+ className?: string;
1643
+ componentRef?: {
1644
+ id: string;
1645
+ name?: string;
1646
+ unlocked?: boolean;
1647
+ };
1648
+ } | {
1649
+ type: "divider";
1650
+ id: string;
1651
+ color?: string;
1652
+ marginBottom?: number;
1653
+ margin?: {
1654
+ top?: number;
1655
+ right?: number;
1656
+ bottom?: number;
1657
+ left?: number;
1658
+ };
1659
+ padding?: {
1660
+ top?: number;
1661
+ right?: number;
1662
+ bottom?: number;
1663
+ left?: number;
1664
+ };
1665
+ customCss?: string;
1666
+ className?: string;
1667
+ componentRef?: {
1668
+ id: string;
1669
+ name?: string;
1670
+ unlocked?: boolean;
1671
+ };
1672
+ } | {
1673
+ type: "link";
1674
+ id: string;
1675
+ text?: string;
1676
+ href?: string;
1677
+ align?: "left" | "center" | "right";
1678
+ color?: string;
1679
+ fontSize?: number;
1680
+ fontFamily?: string;
1681
+ underline?: boolean;
1682
+ marginBottom?: number;
1683
+ margin?: {
1684
+ top?: number;
1685
+ right?: number;
1686
+ bottom?: number;
1687
+ left?: number;
1688
+ };
1689
+ padding?: {
1690
+ top?: number;
1691
+ right?: number;
1692
+ bottom?: number;
1693
+ left?: number;
1694
+ };
1695
+ customCss?: string;
1696
+ className?: string;
1697
+ componentRef?: {
1698
+ id: string;
1699
+ name?: string;
1700
+ unlocked?: boolean;
1701
+ };
1702
+ } | {
1703
+ type: "spacer";
1704
+ id: string;
1705
+ height?: number;
1706
+ margin?: {
1707
+ top?: number;
1708
+ right?: number;
1709
+ bottom?: number;
1710
+ left?: number;
1711
+ };
1712
+ customCss?: string;
1713
+ className?: string;
1714
+ componentRef?: {
1715
+ id: string;
1716
+ name?: string;
1717
+ unlocked?: boolean;
1718
+ };
1719
+ } | {
1720
+ type: "markdown";
1721
+ id: string;
1722
+ markdown?: string;
1723
+ align?: "left" | "center" | "right";
1724
+ color?: string;
1725
+ fontSize?: number;
1726
+ marginBottom?: number;
1727
+ margin?: {
1728
+ top?: number;
1729
+ right?: number;
1730
+ bottom?: number;
1731
+ left?: number;
1732
+ };
1733
+ padding?: {
1734
+ top?: number;
1735
+ right?: number;
1736
+ bottom?: number;
1737
+ left?: number;
1738
+ };
1739
+ customCss?: string;
1740
+ className?: string;
1741
+ componentRef?: {
1742
+ id: string;
1743
+ name?: string;
1744
+ unlocked?: boolean;
1745
+ };
1746
+ } | {
1747
+ type: "code";
1748
+ id: string;
1749
+ code?: string;
1750
+ backgroundColor?: string;
1751
+ color?: string;
1752
+ marginBottom?: number;
1753
+ margin?: {
1754
+ top?: number;
1755
+ right?: number;
1756
+ bottom?: number;
1757
+ left?: number;
1758
+ };
1759
+ padding?: {
1760
+ top?: number;
1761
+ right?: number;
1762
+ bottom?: number;
1763
+ left?: number;
1764
+ };
1765
+ customCss?: string;
1766
+ className?: string;
1767
+ componentRef?: {
1768
+ id: string;
1769
+ name?: string;
1770
+ unlocked?: boolean;
1771
+ };
1772
+ } | {
1773
+ type: "html";
1774
+ id: string;
1775
+ html?: string;
1776
+ marginBottom?: number;
1777
+ margin?: {
1778
+ top?: number;
1779
+ right?: number;
1780
+ bottom?: number;
1781
+ left?: number;
1782
+ };
1783
+ padding?: {
1784
+ top?: number;
1785
+ right?: number;
1786
+ bottom?: number;
1787
+ left?: number;
1788
+ };
1789
+ customCss?: string;
1790
+ className?: string;
1791
+ componentRef?: {
1792
+ id: string;
1793
+ name?: string;
1794
+ unlocked?: boolean;
1795
+ };
1796
+ }>;
1797
+ }>;
1798
+ } | {
1799
+ type: "text";
1800
+ id: string;
1801
+ text?: string;
1802
+ content?: Array<{
1803
+ text?: string;
1804
+ marks?: {
1805
+ bold?: boolean;
1806
+ italic?: boolean;
1807
+ underline?: boolean;
1808
+ link?: string;
1809
+ color?: string;
1810
+ background?: string;
1811
+ fontFamily?: string;
1812
+ fontSize?: number;
1813
+ };
1814
+ variable?: string;
1815
+ }>;
1816
+ align?: "left" | "center" | "right";
1817
+ color?: string;
1818
+ fontSize?: number;
1819
+ fontFamily?: string;
1820
+ lineHeight?: number | string;
1821
+ letterSpacing?: number;
1822
+ fontWeight?: string | number;
1823
+ marginBottom?: number;
1824
+ margin?: {
1825
+ top?: number;
1826
+ right?: number;
1827
+ bottom?: number;
1828
+ left?: number;
1829
+ };
1830
+ padding?: {
1831
+ top?: number;
1832
+ right?: number;
1833
+ bottom?: number;
1834
+ left?: number;
1835
+ };
1836
+ customCss?: string;
1837
+ className?: string;
1838
+ componentRef?: {
1839
+ id: string;
1840
+ name?: string;
1841
+ unlocked?: boolean;
1842
+ };
1843
+ } | {
1844
+ type: "heading";
1845
+ id: string;
1846
+ text?: string;
1847
+ content?: Array<{
1848
+ text?: string;
1849
+ marks?: {
1850
+ bold?: boolean;
1851
+ italic?: boolean;
1852
+ underline?: boolean;
1853
+ link?: string;
1854
+ color?: string;
1855
+ background?: string;
1856
+ fontFamily?: string;
1857
+ fontSize?: number;
1858
+ };
1859
+ variable?: string;
1860
+ }>;
1861
+ level?: 1 | 2 | 3 | 4;
1862
+ fontSize?: number;
1863
+ align?: "left" | "center" | "right";
1864
+ color?: string;
1865
+ fontFamily?: string;
1866
+ lineHeight?: number | string;
1867
+ letterSpacing?: number;
1868
+ fontWeight?: string | number;
1869
+ marginBottom?: number;
1870
+ margin?: {
1871
+ top?: number;
1872
+ right?: number;
1873
+ bottom?: number;
1874
+ left?: number;
1875
+ };
1876
+ padding?: {
1877
+ top?: number;
1878
+ right?: number;
1879
+ bottom?: number;
1880
+ left?: number;
1881
+ };
1882
+ customCss?: string;
1883
+ className?: string;
1884
+ componentRef?: {
1885
+ id: string;
1886
+ name?: string;
1887
+ unlocked?: boolean;
1888
+ };
1889
+ } | {
1890
+ type: "button";
1891
+ id: string;
1892
+ text?: string;
1893
+ href?: string;
1894
+ align?: "left" | "center" | "right";
1895
+ backgroundColor?: string;
1896
+ textColor?: string;
1897
+ borderRadius?: number;
1898
+ innerPaddingX?: number;
1899
+ innerPaddingY?: number;
1900
+ marginBottom?: number;
1901
+ margin?: {
1902
+ top?: number;
1903
+ right?: number;
1904
+ bottom?: number;
1905
+ left?: number;
1906
+ };
1907
+ padding?: {
1908
+ top?: number;
1909
+ right?: number;
1910
+ bottom?: number;
1911
+ left?: number;
1912
+ };
1913
+ customCss?: string;
1914
+ className?: string;
1915
+ componentRef?: {
1916
+ id: string;
1917
+ name?: string;
1918
+ unlocked?: boolean;
1919
+ };
1920
+ } | {
1921
+ type: "image";
1922
+ id: string;
1923
+ src?: string;
1924
+ alt?: string;
1925
+ href?: string;
1926
+ width?: number;
1927
+ height?: number;
1928
+ borderRadius?: number;
1929
+ border?: {
1930
+ width?: number;
1931
+ style?: "solid" | "dashed" | "dotted";
1932
+ color?: string;
1933
+ radius?: number;
1934
+ };
1935
+ objectFit?: "cover" | "contain" | "fill";
1936
+ backgroundColor?: string;
1937
+ align?: "left" | "center" | "right";
1938
+ marginBottom?: number;
1939
+ margin?: {
1940
+ top?: number;
1941
+ right?: number;
1942
+ bottom?: number;
1943
+ left?: number;
1944
+ };
1945
+ padding?: {
1946
+ top?: number;
1947
+ right?: number;
1948
+ bottom?: number;
1949
+ left?: number;
1950
+ };
1951
+ customCss?: string;
1952
+ className?: string;
1953
+ componentRef?: {
1954
+ id: string;
1955
+ name?: string;
1956
+ unlocked?: boolean;
1957
+ };
1958
+ } | {
1959
+ type: "divider";
1960
+ id: string;
1961
+ color?: string;
1962
+ marginBottom?: number;
1963
+ margin?: {
1964
+ top?: number;
1965
+ right?: number;
1966
+ bottom?: number;
1967
+ left?: number;
1968
+ };
1969
+ padding?: {
1970
+ top?: number;
1971
+ right?: number;
1972
+ bottom?: number;
1973
+ left?: number;
1974
+ };
1975
+ customCss?: string;
1976
+ className?: string;
1977
+ componentRef?: {
1978
+ id: string;
1979
+ name?: string;
1980
+ unlocked?: boolean;
1981
+ };
1982
+ } | {
1983
+ type: "link";
1984
+ id: string;
1985
+ text?: string;
1986
+ href?: string;
1987
+ align?: "left" | "center" | "right";
1988
+ color?: string;
1989
+ fontSize?: number;
1990
+ fontFamily?: string;
1991
+ underline?: boolean;
1992
+ marginBottom?: number;
1993
+ margin?: {
1994
+ top?: number;
1995
+ right?: number;
1996
+ bottom?: number;
1997
+ left?: number;
1998
+ };
1999
+ padding?: {
2000
+ top?: number;
2001
+ right?: number;
2002
+ bottom?: number;
2003
+ left?: number;
2004
+ };
2005
+ customCss?: string;
2006
+ className?: string;
2007
+ componentRef?: {
2008
+ id: string;
2009
+ name?: string;
2010
+ unlocked?: boolean;
2011
+ };
2012
+ } | {
2013
+ type: "spacer";
2014
+ id: string;
2015
+ height?: number;
2016
+ margin?: {
2017
+ top?: number;
2018
+ right?: number;
2019
+ bottom?: number;
2020
+ left?: number;
2021
+ };
2022
+ customCss?: string;
2023
+ className?: string;
2024
+ componentRef?: {
2025
+ id: string;
2026
+ name?: string;
2027
+ unlocked?: boolean;
2028
+ };
2029
+ } | {
2030
+ type: "markdown";
2031
+ id: string;
2032
+ markdown?: string;
2033
+ align?: "left" | "center" | "right";
2034
+ color?: string;
2035
+ fontSize?: number;
2036
+ marginBottom?: number;
2037
+ margin?: {
2038
+ top?: number;
2039
+ right?: number;
2040
+ bottom?: number;
2041
+ left?: number;
2042
+ };
2043
+ padding?: {
2044
+ top?: number;
2045
+ right?: number;
2046
+ bottom?: number;
2047
+ left?: number;
2048
+ };
2049
+ customCss?: string;
2050
+ className?: string;
2051
+ componentRef?: {
2052
+ id: string;
2053
+ name?: string;
2054
+ unlocked?: boolean;
2055
+ };
2056
+ } | {
2057
+ type: "code";
2058
+ id: string;
2059
+ code?: string;
2060
+ backgroundColor?: string;
2061
+ color?: string;
2062
+ marginBottom?: number;
2063
+ margin?: {
2064
+ top?: number;
2065
+ right?: number;
2066
+ bottom?: number;
2067
+ left?: number;
2068
+ };
2069
+ padding?: {
2070
+ top?: number;
2071
+ right?: number;
2072
+ bottom?: number;
2073
+ left?: number;
2074
+ };
2075
+ customCss?: string;
2076
+ className?: string;
2077
+ componentRef?: {
2078
+ id: string;
2079
+ name?: string;
2080
+ unlocked?: boolean;
2081
+ };
2082
+ } | {
2083
+ type: "html";
2084
+ id: string;
2085
+ html?: string;
2086
+ marginBottom?: number;
2087
+ margin?: {
2088
+ top?: number;
2089
+ right?: number;
2090
+ bottom?: number;
2091
+ left?: number;
2092
+ };
2093
+ padding?: {
2094
+ top?: number;
2095
+ right?: number;
2096
+ bottom?: number;
2097
+ left?: number;
2098
+ };
2099
+ customCss?: string;
2100
+ className?: string;
2101
+ componentRef?: {
2102
+ id: string;
2103
+ name?: string;
2104
+ unlocked?: boolean;
2105
+ };
2106
+ }>;
2107
+ };
2108
+ };
2109
+ type Topic = {
2110
+ object: "topic";
2111
+ id: string;
2112
+ name: string;
2113
+ description: string | null;
2114
+ default_opt_in: boolean;
2115
+ created_at: string;
2116
+ updated_at: string;
2117
+ };
2118
+ type TopicCreate = {
2119
+ name: string;
2120
+ description?: string;
2121
+ default_opt_in?: boolean;
2122
+ };
2123
+ type TopicUpdate = {
2124
+ name?: string;
2125
+ description?: string | null;
2126
+ default_opt_in?: boolean;
2127
+ };
2128
+ type Usage$1 = {
2129
+ object: "usage";
2130
+ plan: string;
2131
+ period_start: string;
2132
+ period_end: string;
2133
+ emails: {
2134
+ sent: number;
2135
+ included: number | null;
2136
+ daily_cap: number | null;
2137
+ sent_today: number;
2138
+ };
2139
+ wallet: {
2140
+ allowance_cents: number | null;
2141
+ used_cents: number;
2142
+ carryover_cents: number;
2143
+ purchased_credit_cents: number;
2144
+ overage_cents: number;
2145
+ overage_cap_cents: number | null;
2146
+ email_rate_per_1k_cents: number | null;
2147
+ } | null;
2148
+ };
2149
+ type Webhook = {
2150
+ object: "webhook";
2151
+ id: string;
2152
+ name: string;
2153
+ url: string;
2154
+ events: Array<string>;
2155
+ status: "enabled" | "disabled" | "suspended";
2156
+ created_at: string;
2157
+ updated_at: string;
2158
+ };
2159
+ type WebhookCreate = {
2160
+ url: string;
2161
+ events: Array<string>;
2162
+ name?: string;
2163
+ };
2164
+ type WebhookCreated = Webhook & {
2165
+ signing_secret: string;
2166
+ };
2167
+ type WebhookTestResult = {
2168
+ object: "webhook_test";
2169
+ delivered: boolean;
2170
+ response_status: number | null;
2171
+ event_type: string;
2172
+ error: string | null;
2173
+ };
2174
+ type WebhookUpdate = {
2175
+ url?: string;
2176
+ events?: Array<string>;
2177
+ name?: string;
2178
+ status?: "enabled" | "disabled";
2179
+ };
2180
+
2181
+ type models_ApiKey = ApiKey;
2182
+ type models_ApiKeyCreate = ApiKeyCreate;
2183
+ type models_ApiKeyCreated = ApiKeyCreated;
2184
+ type models_Batch = Batch;
2185
+ type models_BatchSend = BatchSend;
2186
+ type models_BatchSendResult = BatchSendResult;
2187
+ type models_BrandKit = BrandKit;
2188
+ type models_BrandKitList = BrandKitList;
2189
+ type models_Campaign = Campaign;
2190
+ type models_CampaignCreate = CampaignCreate;
2191
+ type models_CampaignReschedule = CampaignReschedule;
2192
+ type models_CampaignUpdate = CampaignUpdate;
2193
+ type models_Contact = Contact;
2194
+ type models_ContactCreate = ContactCreate;
2195
+ type models_ContactField = ContactField;
2196
+ type models_ContactFieldCreate = ContactFieldCreate;
2197
+ type models_ContactFieldRename = ContactFieldRename;
2198
+ type models_ContactFieldUpdate = ContactFieldUpdate;
2199
+ type models_ContactImport = ContactImport;
2200
+ type models_ContactImportCreate = ContactImportCreate;
2201
+ type models_ContactTopic = ContactTopic;
2202
+ type models_ContactTopicSet = ContactTopicSet;
2203
+ type models_ContactUpdate = ContactUpdate;
2204
+ type models_Domain = Domain;
2205
+ type models_DomainCreate = DomainCreate;
2206
+ type models_DomainUpdate = DomainUpdate;
2207
+ type models_EmailPatch = EmailPatch;
2208
+ type models_EmailStats = EmailStats;
2209
+ type models_ReceivedAttachmentUrl = ReceivedAttachmentUrl;
2210
+ type models_ReceivedEmail = ReceivedEmail;
2211
+ type models_ReceivedEmailSummary = ReceivedEmailSummary;
2212
+ type models_Segment = Segment;
2213
+ type models_SegmentCreate = SegmentCreate;
2214
+ type models_SegmentMember = SegmentMember;
2215
+ type models_SegmentMemberAdd = SegmentMemberAdd;
2216
+ type models_SegmentUpdate = SegmentUpdate;
2217
+ type models_SendEmail = SendEmail;
2218
+ type models_SendResult = SendResult;
2219
+ type models_Suppression = Suppression;
2220
+ type models_SuppressionBulkResult = SuppressionBulkResult;
2221
+ type models_SuppressionCreate = SuppressionCreate;
2222
+ type models_Template = Template;
2223
+ type models_TemplateCreate = TemplateCreate;
2224
+ type models_TemplateUpdate = TemplateUpdate;
2225
+ type models_Topic = Topic;
2226
+ type models_TopicCreate = TopicCreate;
2227
+ type models_TopicUpdate = TopicUpdate;
2228
+ type models_Webhook = Webhook;
2229
+ type models_WebhookCreate = WebhookCreate;
2230
+ type models_WebhookCreated = WebhookCreated;
2231
+ type models_WebhookTestResult = WebhookTestResult;
2232
+ type models_WebhookUpdate = WebhookUpdate;
2233
+ declare namespace models {
2234
+ export type { models_ApiKey as ApiKey, models_ApiKeyCreate as ApiKeyCreate, models_ApiKeyCreated as ApiKeyCreated, models_Batch as Batch, models_BatchSend as BatchSend, models_BatchSendResult as BatchSendResult, models_BrandKit as BrandKit, models_BrandKitList as BrandKitList, models_Campaign as Campaign, models_CampaignCreate as CampaignCreate, models_CampaignReschedule as CampaignReschedule, models_CampaignUpdate as CampaignUpdate, models_Contact as Contact, models_ContactCreate as ContactCreate, models_ContactField as ContactField, models_ContactFieldCreate as ContactFieldCreate, models_ContactFieldRename as ContactFieldRename, models_ContactFieldUpdate as ContactFieldUpdate, models_ContactImport as ContactImport, models_ContactImportCreate as ContactImportCreate, models_ContactTopic as ContactTopic, models_ContactTopicSet as ContactTopicSet, models_ContactUpdate as ContactUpdate, models_Domain as Domain, models_DomainCreate as DomainCreate, models_DomainUpdate as DomainUpdate, Email$1 as Email, models_EmailPatch as EmailPatch, models_EmailStats as EmailStats, Error$1 as Error, models_ReceivedAttachmentUrl as ReceivedAttachmentUrl, models_ReceivedEmail as ReceivedEmail, models_ReceivedEmailSummary as ReceivedEmailSummary, models_Segment as Segment, models_SegmentCreate as SegmentCreate, models_SegmentMember as SegmentMember, models_SegmentMemberAdd as SegmentMemberAdd, models_SegmentUpdate as SegmentUpdate, models_SendEmail as SendEmail, models_SendResult as SendResult, models_Suppression as Suppression, models_SuppressionBulkResult as SuppressionBulkResult, models_SuppressionCreate as SuppressionCreate, models_Template as Template, models_TemplateCreate as TemplateCreate, models_TemplateUpdate as TemplateUpdate, models_Topic as Topic, models_TopicCreate as TopicCreate, models_TopicUpdate as TopicUpdate, Usage$1 as Usage, models_Webhook as Webhook, models_WebhookCreate as WebhookCreate, models_WebhookCreated as WebhookCreated, models_WebhookTestResult as WebhookTestResult, models_WebhookUpdate as WebhookUpdate };
2235
+ }
2236
+
2237
+ type Result<T> = Promise<{
2238
+ data: T | null;
2239
+ error: UnitpostError | null;
2240
+ }>;
2241
+ interface SendOptions {
2242
+ idempotencyKey?: string;
2243
+ }
2244
+ declare class Resource {
2245
+ protected readonly http: HttpClient;
2246
+ constructor(http: HttpClient);
2247
+ }
2248
+ declare class Email extends Resource {
2249
+ readonly topics: Topics;
2250
+ readonly campaigns: Campaigns;
2251
+ readonly templates: Templates;
2252
+ readonly domains: Domains;
2253
+ constructor(http: HttpClient);
2254
+ /**
2255
+ * Send or schedule a transactional email.
2256
+ *
2257
+ * If you don't pass `idempotencyKey`, the SDK generates one automatically so
2258
+ * the request is safe to auto-retry (a network blip can't double-send). Pass
2259
+ * your own to dedupe across separate `send()` calls.
2260
+ */
2261
+ send(body: SendEmail, opts?: SendOptions): Result<SendResult>;
2262
+ /**
2263
+ * Send up to 100 emails in one request (all-or-nothing validation).
2264
+ *
2265
+ * Like `send()`, if you don't pass `idempotencyKey` the SDK generates one so a
2266
+ * transient failure can be safely auto-retried (the server dedupes the batch
2267
+ * on the key and replays the original result instead of re-sending). Pass your
2268
+ * own to dedupe across separate `batch()` calls.
2269
+ */
2270
+ batch(body: BatchSend, opts?: SendOptions): Result<BatchSendResult>;
2271
+ /** Retrieve a batch by id. */
2272
+ getBatch(id: string): Result<Batch>;
2273
+ /** Cancel every still-cancelable message in a batch. */
2274
+ cancelBatch(id: string): Result<Batch>;
2275
+ /** List sent/scheduled emails (cursor-paginated). */
2276
+ list(params?: ListParams & {
2277
+ status?: string;
2278
+ campaign_id?: string;
2279
+ batch_id?: string;
2280
+ }): Result<ListResponse<Email$1>>;
2281
+ /** Async-iterate every sent/scheduled email. */
2282
+ listAll(params?: ListParams): AsyncGenerator<Email$1, void, void>;
2283
+ /** Retrieve a sent or scheduled email. */
2284
+ get(id: string): Result<Email$1>;
2285
+ /** Cancel or reschedule a scheduled/queued email. */
2286
+ update(id: string, body: EmailPatch): Result<Email$1>;
2287
+ /**
2288
+ * Deliverability / engagement stats over a rolling window.
2289
+ *
2290
+ * `days` is the window size (1–365); defaults to 30 server-side.
2291
+ */
2292
+ stats(params?: {
2293
+ days?: number;
2294
+ }): Result<EmailStats>;
2295
+ receivedList(params?: ListParams): Result<ListResponse<ReceivedEmailSummary>>;
2296
+ receivedGet(id: string): Result<ReceivedEmail>;
2297
+ receivedAttachmentUrl(id: string, attachmentId: string): Result<ReceivedAttachmentUrl>;
2298
+ }
2299
+ declare class Contacts extends Resource {
2300
+ list(params?: ListParams): Result<ListResponse<Contact>>;
2301
+ listAll(params?: ListParams): AsyncGenerator<Contact, void, void>;
2302
+ create(body: ContactCreate): Result<Contact>;
2303
+ /** Retrieve by contact id or email. */
2304
+ get(idOrEmail: string): Result<Contact>;
2305
+ update(idOrEmail: string, body: ContactUpdate): Result<Contact>;
2306
+ delete(idOrEmail: string): Result<null>;
2307
+ /** Start an async contact import. */
2308
+ import(body: ContactImportCreate): Result<ContactImport>;
2309
+ listImports(params?: ListParams): Result<ListResponse<ContactImport>>;
2310
+ getImport(id: string): Result<ContactImport>;
2311
+ }
2312
+ declare class ContactFields extends Resource {
2313
+ list(params?: ListParams): Result<ListResponse<ContactField>>;
2314
+ listAll(params?: ListParams): AsyncGenerator<ContactField, void, void>;
2315
+ create(body: ContactFieldCreate): Result<ContactField>;
2316
+ get(id: string): Result<ContactField>;
2317
+ update(id: string, body: ContactFieldUpdate): Result<ContactField>;
2318
+ delete(id: string): Result<null>;
2319
+ rename(id: string, body: ContactFieldRename): Result<ContactField>;
2320
+ }
2321
+ declare class Segments extends Resource {
2322
+ list(params?: ListParams): Result<ListResponse<Segment>>;
2323
+ listAll(params?: ListParams): AsyncGenerator<Segment, void, void>;
2324
+ create(body: SegmentCreate): Result<Segment>;
2325
+ get(id: string): Result<Segment>;
2326
+ update(id: string, body: SegmentUpdate): Result<Segment>;
2327
+ delete(id: string): Result<null>;
2328
+ listMembers(id: string, params?: ListParams): Result<ListResponse<SegmentMember>>;
2329
+ /** Add a contact (by id or email) to the segment. Idempotent. */
2330
+ addMember(id: string, body: SegmentMemberAdd): Result<SegmentMember>;
2331
+ /** Remove a contact (by id or email) from the segment. */
2332
+ removeMember(id: string, contact: string): Result<null>;
2333
+ }
2334
+ declare class Topics extends Resource {
2335
+ list(params?: ListParams): Result<ListResponse<Topic>>;
2336
+ listAll(params?: ListParams): AsyncGenerator<Topic, void, void>;
2337
+ create(body: TopicCreate): Result<Topic>;
2338
+ get(id: string): Result<Topic>;
2339
+ update(id: string, body: TopicUpdate): Result<Topic>;
2340
+ delete(id: string): Result<null>;
2341
+ /** List a contact's effective topic subscriptions. */
2342
+ listTopics(contactId: string, params?: ListParams): Result<ListResponse<ContactTopic>>;
2343
+ /** Set a contact's preference for one topic. */
2344
+ setTopic(contactId: string, body: ContactTopicSet): Result<ContactTopic>;
2345
+ }
2346
+ declare class Campaigns extends Resource {
2347
+ list(params?: ListParams): Result<ListResponse<Campaign>>;
2348
+ listAll(params?: ListParams): AsyncGenerator<Campaign, void, void>;
2349
+ create(body: CampaignCreate): Result<Campaign>;
2350
+ get(id: string): Result<Campaign>;
2351
+ update(id: string, body: CampaignUpdate): Result<Campaign>;
2352
+ delete(id: string): Result<null>;
2353
+ send(id: string): Result<Campaign>;
2354
+ cancel(id: string): Result<Campaign>;
2355
+ /** Pause a scheduled/sending campaign; already-sent messages are untouched. */
2356
+ pause(id: string): Result<Campaign>;
2357
+ /** Resume a paused campaign; sending continues with the remaining recipients. */
2358
+ resume(id: string): Result<Campaign>;
2359
+ reschedule(id: string, body: CampaignReschedule): Result<Campaign>;
2360
+ /** Non-mutating pre-send validation report. */
2361
+ validate(id: string): Result<unknown>;
2362
+ }
2363
+ declare class Templates extends Resource {
2364
+ list(params?: ListParams): Result<ListResponse<Template>>;
2365
+ listAll(params?: ListParams): AsyncGenerator<Template, void, void>;
2366
+ create(body: TemplateCreate): Result<Template>;
2367
+ get(id: string): Result<Template>;
2368
+ update(id: string, body: TemplateUpdate): Result<Template>;
2369
+ delete(id: string): Result<null>;
2370
+ }
2371
+ /** Read-only Brand Kit profiles (voice, colors, pinned `/img/{id}` graphics). */
2372
+ declare class BrandKits extends Resource {
2373
+ /** List profiles (max 5). Optional `name` filters by display name. */
2374
+ list(params?: {
2375
+ name?: string;
2376
+ }): Result<BrandKitList>;
2377
+ /** Retrieve one profile by `bk_…` id. */
2378
+ get(id: string): Result<BrandKit>;
2379
+ }
2380
+ declare class Domains extends Resource {
2381
+ list(params?: ListParams): Result<ListResponse<Domain>>;
2382
+ listAll(params?: ListParams): AsyncGenerator<Domain, void, void>;
2383
+ create(body: DomainCreate): Result<Domain>;
2384
+ get(id: string): Result<Domain>;
2385
+ delete(id: string): Result<null>;
2386
+ update(id: string, body: DomainUpdate): Result<Domain>;
2387
+ /** Run an on-demand DNS/SES verification check. */
2388
+ verify(id: string): Result<Domain & {
2389
+ checks?: unknown;
2390
+ }>;
2391
+ }
2392
+ declare class Webhooks extends Resource {
2393
+ list(params?: ListParams): Result<ListResponse<Webhook>>;
2394
+ listAll(params?: ListParams): AsyncGenerator<Webhook, void, void>;
2395
+ /** Create an endpoint. The response includes `signing_secret` exactly once. */
2396
+ create(body: WebhookCreate): Result<WebhookCreated>;
2397
+ get(id: string): Result<Webhook>;
2398
+ update(id: string, body: WebhookUpdate): Result<Webhook>;
2399
+ delete(id: string): Result<null>;
2400
+ /** Fire a synchronous sample event at the endpoint. */
2401
+ test(id: string): Result<WebhookTestResult>;
2402
+ /**
2403
+ * Verify a webhook delivery's signature and return the parsed event. Throws
2404
+ * `WebhookVerificationError` on a missing/invalid/stale signature. Alias of the
2405
+ * top-level `verifyWebhook` for a Resend-style `unitpost.webhooks.verify(...)`.
2406
+ */
2407
+ verify<T = unknown>(args: VerifyWebhookArgs): T;
2408
+ }
2409
+ declare class ApiKeys extends Resource {
2410
+ list(params?: ListParams): Result<ListResponse<ApiKey>>;
2411
+ listAll(params?: ListParams): AsyncGenerator<ApiKey, void, void>;
2412
+ /** Create a key. The response includes the plaintext `key` exactly once. */
2413
+ create(body: ApiKeyCreate): Result<ApiKeyCreated>;
2414
+ delete(id: string): Result<null>;
2415
+ }
2416
+ declare class Suppressions extends Resource {
2417
+ /** List suppressed addresses (your own + read-only platform rows). */
2418
+ list(params?: ListParams & {
2419
+ scope?: "workspace" | "platform";
2420
+ }): Result<ListResponse<Suppression>>;
2421
+ /** Async-iterate every suppressed address. */
2422
+ listAll(params?: ListParams): AsyncGenerator<Suppression, void, void>;
2423
+ /**
2424
+ * Suppress one address (`{ email }`) or many (`{ emails: [...] }`). Idempotent
2425
+ * — re-suppressing an existing address is a no-op. The bulk form resolves to a
2426
+ * `{ object: "list", added, skipped, total }` summary.
2427
+ */
2428
+ create(body: SuppressionCreate): Result<Suppression | SuppressionBulkResult>;
2429
+ /** Retrieve a suppression by id (`supp_…`) or email. */
2430
+ get(idOrEmail: string): Result<Suppression>;
2431
+ /** Un-suppress an address by id or email. Idempotent on the email form. */
2432
+ delete(idOrEmail: string): Result<null>;
2433
+ }
2434
+ declare class Usage extends Resource {
2435
+ /**
2436
+ * Retrieve the current billing-period usage snapshot: plan, period window,
2437
+ * emails sent, and (on paid plans) the dollar sending wallet — allowance,
2438
+ * spend, purchased credit, and overage, all in integer USD cents.
2439
+ */
2440
+ get(): Result<Usage$1>;
2441
+ }
2442
+
2443
+ declare class Unitpost {
2444
+ readonly email: Email;
2445
+ readonly contacts: Contacts;
2446
+ readonly contactFields: ContactFields;
2447
+ readonly segments: Segments;
2448
+ readonly brandKits: BrandKits;
2449
+ readonly webhooks: Webhooks;
2450
+ readonly apiKeys: ApiKeys;
2451
+ readonly suppressions: Suppressions;
2452
+ readonly usage: Usage;
2453
+ constructor(apiKeyOrOptions?: string | UnitpostOptions);
2454
+ }
2455
+
2456
+ export { type ListParams, type ListResponse, models as Models, type Result, SDK_VERSION, type SendOptions, Unitpost, UnitpostError, type UnitpostOptions, type VerifyWebhookArgs, WebhookVerificationError, verifyWebhook };