unitpost 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,7 +1,9 @@
1
- declare const SDK_VERSION = "0.4.0";
1
+ declare const SDK_VERSION = "0.5.0";
2
2
  interface ApiFieldError {
3
3
  /** Dotted path to the offending field, e.g. "template.variables.first_name". */
4
4
  field: string;
5
+ /** A machine-readable reason for this entry, e.g. the SMS skip word on `to` (`out_of_reach`). */
6
+ code?: string;
5
7
  message: string;
6
8
  }
7
9
  /** A structured API error. Returned in `{ data, error }`, never thrown by default. */
@@ -11,12 +13,15 @@ declare class UnitpostError extends Error {
11
13
  readonly requestId: string | null;
12
14
  /** Per-field validation problems (present on 422 validation_error). */
13
15
  readonly details: ApiFieldError[];
16
+ /** A page that explains this error, when the API links one (e.g. `sending_paused`). */
17
+ readonly docUrl: string | null;
14
18
  constructor(args: {
15
19
  code: string;
16
20
  message: string;
17
21
  status: number;
18
22
  requestId: string | null;
19
23
  details?: ApiFieldError[];
24
+ docUrl?: string | null;
20
25
  });
21
26
  }
22
27
  interface UnitpostOptions {
@@ -44,6 +49,18 @@ interface UnitpostOptions {
44
49
  /** Injectable sleep (tests). Defaults to a real timer. */
45
50
  sleep?: (ms: number) => Promise<void>;
46
51
  }
52
+ /**
53
+ * What every call resolves to. `warning` is the response's `Unitpost-Warning`
54
+ * header, present only on a success that carried one: something the request
55
+ * left out or ignored without failing, e.g. a recipient on a reserved domain
56
+ * (example.com) that wasn't sent to, or a body field the operation ignored.
57
+ * Show it or log it; the call itself succeeded.
58
+ */
59
+ interface ApiResult<T> {
60
+ data: T | null;
61
+ error: UnitpostError | null;
62
+ warning?: string;
63
+ }
47
64
  interface RequestArgs {
48
65
  method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
49
66
  path: string;
@@ -73,12 +90,16 @@ declare class HttpClient {
73
90
  * is honored (clamped to `maxRetryDelay`); otherwise we use exponential
74
91
  * backoff with full jitter.
75
92
  */
76
- request<T>(args: RequestArgs): Promise<{
77
- data: T | null;
78
- error: UnitpostError | null;
79
- }>;
93
+ request<T>(args: RequestArgs): Promise<ApiResult<T>>;
80
94
  private backoffDelay;
81
95
  private attempt;
96
+ /**
97
+ * PUT bytes to a file's presigned upload URL (`files.upload`), with exactly
98
+ * the headers it was signed with: no API key, and no retries (storage
99
+ * refuses any other length or type). Returns the error, or `null` when
100
+ * storage took the bytes.
101
+ */
102
+ putBytes(url: string, headers: Record<string, string>, body: Uint8Array): Promise<UnitpostError | null>;
82
103
  private buildUrl;
83
104
  }
84
105
 
@@ -115,6 +136,34 @@ declare class WebhookVerificationError extends Error {
115
136
  */
116
137
  declare function verifyWebhook<T = unknown>(args: VerifyWebhookArgs): T;
117
138
 
139
+ type Activity = {
140
+ object: "activity";
141
+ id: string;
142
+ /** What happened, e.g. `contact_created`, `campaign_sent`, `domain_verified`. */
143
+ type: string;
144
+ /** The kind of record it happened to. */
145
+ subject: "contact" | "segment" | "topic" | "field" | "template" | "component" | "campaign" | "email" | "domain" | "sender_email" | "library_image" | "api_key" | "webhook" | "suppression" | "message" | "handle" | "workspace";
146
+ /** The record's id (prefixed where the record has a public id). */
147
+ subject_id: string | null;
148
+ /** The record's name at the time: a contact's email, a segment's name, …; a phone number is masked (`+1••••••7755`). */
149
+ subject_label: string | null;
150
+ contact_id: string | null;
151
+ /** The campaign the change is attributed to (e.g. an unsubscribe through its link). */
152
+ campaign_id: string | null;
153
+ actor: {
154
+ /** Who made the change: a teammate's name or email, `System`, `Carrier`, `Ask Unit`, or null. */
155
+ name: string | null;
156
+ /** For a change made over the API, MCP or Ask Unit: how, and which API key. */
157
+ via: {
158
+ surface: "api" | "mcp" | "unit";
159
+ credential: "api_key" | "oauth" | null;
160
+ api_key_id: string | null;
161
+ } | null;
162
+ };
163
+ /** Detail for the change, varying by `type`: a segment's or topic's name, a status before and after, a renamed field's keys, related ids (`campaign_id`, …). Descriptive keys only: addresses, URLs and error text stay in the dashboard. */
164
+ metadata: Record<string, unknown>;
165
+ created_at: string;
166
+ };
118
167
  type ApiKey = {
119
168
  object: "api_key";
120
169
  id: string;
@@ -129,12 +178,26 @@ type ApiKey = {
129
178
  type ApiKeyCreate = {
130
179
  name: string;
131
180
  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" | "sms:read" | "sms:send" | "sms:manage" | "sms:purchase" | "apikeys:read" | "apikeys:manage" | "webhooks:read" | "webhooks:manage" | "team:read" | "team:invite" | "team:manage_members" | "workspace:update" | "workspace:delete" | "billing:manage">;
181
+ capabilities?: Array<"contacts:read" | "contacts:write" | "suppressions:read" | "suppressions:write" | "segments:read" | "segments:write" | "topics:read" | "topics:write" | "templates:read" | "templates:write" | "campaigns:read" | "campaigns:write" | "campaigns:send" | "domains:read" | "domains:write" | "emails:read" | "emails:send" | "emails:read_content" | "sms:read" | "sms:send" | "sms:manage" | "sms:purchase" | "apikeys:read" | "apikeys:manage" | "webhooks:read" | "webhooks:manage" | "branding:write" | "activity:read" | "spend_caps:write" | "team:read" | "team:invite" | "team:manage_members" | "workspace:update" | "workspace:delete" | "billing:manage">;
133
182
  };
134
183
  type ApiKeyCreated = ApiKey & {
135
184
  /** The plaintext secret. Shown exactly once — store it now; it can never be retrieved again. */
136
185
  key: string;
137
186
  };
187
+ type ApiKeyUsage = {
188
+ object: "api_key_usage";
189
+ /** The key (`key_…`). */
190
+ id: string;
191
+ last_used_at: string | null;
192
+ /** Requests the key made in the last 24 hours, counted up to 100,000: `100001` means more than 100,000. */
193
+ requests_24h: number;
194
+ /** Of those, answered 4xx (`rate_limited_24h` included). Past the cap, these three count the latest 100,001 requests. */
195
+ client_errors_24h: number;
196
+ /** Of those, answered 5xx. */
197
+ server_errors_24h: number;
198
+ /** Of those, answered 429. */
199
+ rate_limited_24h: number;
200
+ };
138
201
  type Batch = {
139
202
  object: "batch";
140
203
  id: string;
@@ -212,11 +275,251 @@ type BatchSendResult = {
212
275
  data: Array<{
213
276
  id: string;
214
277
  }>;
278
+ /** Items that weren't sent, by their index in the request: one whose every `to` address is on a reserved domain (example.com, example.net, example.org), or one the sending engine couldn't take (retry just those). */
215
279
  failed: Array<{
216
280
  index: number;
217
281
  error: string;
218
282
  }>;
219
283
  };
284
+ type BrandImport = {
285
+ object: "brand_import";
286
+ id: string;
287
+ /** `preview_ready`: the proposal waits for an accept (review imports) or is being applied (one-shot); with an `error` on a one-shot import, applying it failed: accept or cancel it. */
288
+ status: "pending" | "running" | "preview_ready" | "completed" | "failed" | "cancelled";
289
+ /** Whether it waits for an accept (false: applied when the crawl lands). */
290
+ review: boolean;
291
+ source: {
292
+ kind: "url" | "text";
293
+ url: string | null;
294
+ };
295
+ /** The profile it fills. */
296
+ brand_kit_id: string | null;
297
+ /** What the import found, once ready. */
298
+ proposal: {
299
+ name: string | null;
300
+ website_url: string | null;
301
+ description: string | null;
302
+ tone: "NEUTRAL" | "FORMAL" | "FRIENDLY" | "PLAYFUL" | null;
303
+ voice_notes: string | null;
304
+ industry: string | null;
305
+ core_pages: Array<{
306
+ url: string;
307
+ title?: string;
308
+ }>;
309
+ extracted: {
310
+ colors?: Array<{
311
+ hex: string;
312
+ label?: string;
313
+ }>;
314
+ logo_urls?: Array<string>;
315
+ background_urls?: Array<string>;
316
+ fonts?: Array<string>;
317
+ };
318
+ memory_facts: Array<{
319
+ key: string;
320
+ content: string;
321
+ }>;
322
+ } | null;
323
+ warnings: Array<string>;
324
+ error: string | null;
325
+ created_at: string;
326
+ updated_at: string;
327
+ completed_at: string | null;
328
+ };
329
+ type BrandImportAccept = {
330
+ /** Apply to this profile instead of the one the import named. */
331
+ brand_kit_id?: string;
332
+ /** The profile's name (default: the one the import found). */
333
+ name?: string;
334
+ /** Also set the email branding's accent from the imported colors (the default profile only). */
335
+ sync_visual?: boolean;
336
+ };
337
+ type BrandImportAccepted = {
338
+ object: "brand_import";
339
+ id: string;
340
+ /** `preview_ready`: the proposal waits for an accept (review imports) or is being applied (one-shot); with an `error` on a one-shot import, applying it failed: accept or cancel it. */
341
+ status: "pending" | "running" | "preview_ready" | "completed" | "failed" | "cancelled";
342
+ /** Whether it waits for an accept (false: applied when the crawl lands). */
343
+ review: boolean;
344
+ source: {
345
+ kind: "url" | "text";
346
+ url: string | null;
347
+ };
348
+ /** The profile it fills. */
349
+ brand_kit_id: string | null;
350
+ /** What the import found, once ready. */
351
+ proposal: {
352
+ name: string | null;
353
+ website_url: string | null;
354
+ description: string | null;
355
+ tone: "NEUTRAL" | "FORMAL" | "FRIENDLY" | "PLAYFUL" | null;
356
+ voice_notes: string | null;
357
+ industry: string | null;
358
+ core_pages: Array<{
359
+ url: string;
360
+ title?: string;
361
+ }>;
362
+ extracted: {
363
+ colors?: Array<{
364
+ hex: string;
365
+ label?: string;
366
+ }>;
367
+ logo_urls?: Array<string>;
368
+ background_urls?: Array<string>;
369
+ fonts?: Array<string>;
370
+ };
371
+ memory_facts: Array<{
372
+ key: string;
373
+ content: string;
374
+ }>;
375
+ } | null;
376
+ warnings: Array<string>;
377
+ error: string | null;
378
+ created_at: string;
379
+ updated_at: string;
380
+ completed_at: string | null;
381
+ /** The profile as the accept left it. */
382
+ brand_kit: {
383
+ object: "brand_kit";
384
+ id: string;
385
+ name: string;
386
+ is_default: boolean;
387
+ website_url: string | null;
388
+ description: string | null;
389
+ tone: "NEUTRAL" | "FORMAL" | "FRIENDLY" | "PLAYFUL" | null;
390
+ voice_notes: string | null;
391
+ industry: string | null;
392
+ core_pages: Array<{
393
+ url: string;
394
+ title?: string;
395
+ }>;
396
+ extracted: {
397
+ colors?: Array<{
398
+ hex: string;
399
+ label?: string;
400
+ }>;
401
+ logo_urls?: Array<string>;
402
+ background_urls?: Array<string>;
403
+ fonts?: Array<string>;
404
+ };
405
+ graphics: Array<{
406
+ /** The image's bare id (kept for compatibility); `image_id` is its library id. */
407
+ library_image_id: string;
408
+ /** The library image (`img_…`, GET /library-images/{id}). */
409
+ image_id: string;
410
+ /** Put this in a template's `<Image src>`. */
411
+ path: string;
412
+ role: "logo" | "logo_light" | "logo_dark" | "mark" | "background" | "other";
413
+ label?: string;
414
+ }>;
415
+ source: string | null;
416
+ updated_at: string | null;
417
+ };
418
+ /** What the accept couldn't bring in (a logo that wouldn't fetch, the graphics cap, a renamed profile). */
419
+ apply_warnings: Array<string>;
420
+ };
421
+ type BrandImportCreate = {
422
+ /** The site to read: an https URL or a bare domain (`acme.com`). */
423
+ url?: string;
424
+ /** Or paste the brand's own words (an about page, a style guide). */
425
+ text?: string;
426
+ /** With `text`: the brand's site, for the profile. */
427
+ website_url?: string | null;
428
+ /** The profile to fill (`bk_…`). Default: the default profile, or a new one when it already has content. */
429
+ brand_kit_id?: string;
430
+ /** `true` stops at the proposal for you to accept (POST …/accept); default `false` applies it when ready. */
431
+ review?: boolean;
432
+ /** Also set the email branding's accent from the imported colors (the default profile only). */
433
+ sync_visual?: boolean;
434
+ };
435
+ type Branding$1 = {
436
+ object: "branding";
437
+ /** The name the footer shows; the workspace's name unless one was set. */
438
+ company_name: string | null;
439
+ company_address: string | null;
440
+ /** The logo emails and the unsubscribe page show: the brand logo, else the workspace image, else none. */
441
+ logo_url: string | null;
442
+ has_brand_logo: boolean;
443
+ colors: {
444
+ background: string | null;
445
+ footer_background: string | null;
446
+ text: string | null;
447
+ accent: string | null;
448
+ button_text: string | null;
449
+ };
450
+ font: string | null;
451
+ /** The stored choice. */
452
+ hide_unitpost_branding: boolean;
453
+ /** Whether recipients see no mark now: the choice, the plan and the account together. */
454
+ unitpost_branding_hidden: boolean;
455
+ /** Whether the plan allows hiding the mark. */
456
+ can_hide_unitpost_branding: boolean;
457
+ unsubscribe_page: {
458
+ title: string | null;
459
+ description: string | null;
460
+ confirm: boolean;
461
+ collect_reason: boolean;
462
+ show_address: boolean;
463
+ show_topics: boolean;
464
+ save_label: string | null;
465
+ global_label: string | null;
466
+ global_note: string | null;
467
+ topics_heading: string | null;
468
+ };
469
+ footer: {
470
+ intro_text: string | null;
471
+ unsubscribe_label: string | null;
472
+ };
473
+ };
474
+ type BrandingUpdate = {
475
+ /** Shown in the footer (`{{company_name}}`). */
476
+ company_name?: string | null;
477
+ /** The postal address every marketing email carries (`{{company_address}}`). */
478
+ company_address?: string | null;
479
+ colors?: {
480
+ /** The page and footer background. */
481
+ background?: string | null;
482
+ /** The footer band, when it differs from the background. */
483
+ footer_background?: string | null;
484
+ text?: string | null;
485
+ /** Links and buttons. */
486
+ accent?: string | null;
487
+ /** Text on accent buttons (default white). */
488
+ button_text?: string | null;
489
+ };
490
+ /** One of: System default, Arial, Helvetica, Verdana, Tahoma, Trebuchet MS, Georgia, Times New Roman, Courier New. */
491
+ font?: "System default" | "Arial" | "Helvetica" | "Verdana" | "Tahoma" | "Trebuchet MS" | "Georgia" | "Times New Roman" | "Courier New" | null;
492
+ /** Hide the "Sent with Unitpost" mark. Paid plans only (403 `limit_reached`). */
493
+ hide_unitpost_branding?: boolean;
494
+ unsubscribe_page?: {
495
+ /** The page heading. */
496
+ title?: string | null;
497
+ /** The intro under the heading. */
498
+ description?: string | null;
499
+ /** Ask before unsubscribing from everything. */
500
+ confirm?: boolean;
501
+ /** Offer an optional "why are you leaving?". */
502
+ collect_reason?: boolean;
503
+ /** Show the postal address on the page (the footer always shows it). */
504
+ show_address?: boolean;
505
+ /** Let recipients choose topics on the page. */
506
+ show_topics?: boolean;
507
+ /** The topic-preferences save button. */
508
+ save_label?: string | null;
509
+ /** The unsubscribe-from-everything control. */
510
+ global_label?: string | null;
511
+ /** The note under it. */
512
+ global_note?: string | null;
513
+ /** The heading over the topics. */
514
+ topics_heading?: string | null;
515
+ };
516
+ footer?: {
517
+ /** The line before the unsubscribe link. */
518
+ intro_text?: string | null;
519
+ /** The unsubscribe link's text. */
520
+ unsubscribe_label?: string | null;
521
+ };
522
+ };
220
523
  type BrandKit = {
221
524
  object: "brand_kit";
222
525
  id: string;
@@ -241,13 +544,88 @@ type BrandKit = {
241
544
  fonts?: Array<string>;
242
545
  };
243
546
  graphics: Array<{
547
+ /** The image's bare id (kept for compatibility); `image_id` is its library id. */
244
548
  library_image_id: string;
549
+ /** The library image (`img_…`, GET /library-images/{id}). */
550
+ image_id?: string;
551
+ /** Put this in a template's `<Image src>`. */
552
+ path?: string;
245
553
  role: "logo" | "logo_light" | "logo_dark" | "mark" | "background" | "other";
246
554
  label?: string;
247
555
  }>;
248
556
  source: string | null;
249
557
  updated_at: string | null;
250
558
  };
559
+ type BrandKitCreate = {
560
+ /** Unique in the workspace. */
561
+ name: string;
562
+ /** Make it the default profile (the first profile always is). */
563
+ make_default?: boolean;
564
+ };
565
+ type BrandKitGraphicAdd = {
566
+ /** A public https PNG, JPEG, GIF or WebP (fetched once, no redirects; up to 5 MB). */
567
+ url: string;
568
+ /** Default `logo`. */
569
+ role?: "logo" | "logo_light" | "logo_dark" | "mark" | "background" | "other";
570
+ label?: string;
571
+ };
572
+ type BrandKitGraphicAdded = {
573
+ object: "brand_kit_graphic";
574
+ brand_kit: {
575
+ object: "brand_kit";
576
+ id: string;
577
+ name: string;
578
+ is_default: boolean;
579
+ website_url: string | null;
580
+ description: string | null;
581
+ tone: "NEUTRAL" | "FORMAL" | "FRIENDLY" | "PLAYFUL" | null;
582
+ voice_notes: string | null;
583
+ industry: string | null;
584
+ core_pages: Array<{
585
+ url: string;
586
+ title?: string;
587
+ }>;
588
+ extracted: {
589
+ colors?: Array<{
590
+ hex: string;
591
+ label?: string;
592
+ }>;
593
+ logo_urls?: Array<string>;
594
+ background_urls?: Array<string>;
595
+ fonts?: Array<string>;
596
+ };
597
+ graphics: Array<{
598
+ /** The image's bare id (kept for compatibility); `image_id` is its library id. */
599
+ library_image_id: string;
600
+ /** The library image (`img_…`, GET /library-images/{id}). */
601
+ image_id: string;
602
+ /** Put this in a template's `<Image src>`. */
603
+ path: string;
604
+ role: "logo" | "logo_light" | "logo_dark" | "mark" | "background" | "other";
605
+ label?: string;
606
+ }>;
607
+ source: string | null;
608
+ updated_at: string | null;
609
+ };
610
+ image: {
611
+ object: "library_image";
612
+ id: string;
613
+ /** Put this in a template or design: `<Image src="/img/…">` or `<img src="/img/…">`. Template and design sends resolve it to the image host; a raw `html` send doesn't, so use `url` there. */
614
+ path: string;
615
+ /** The image's public address on our asset CDN: use it in raw `html` sends and anywhere outside Unitpost. */
616
+ url: string;
617
+ filename: string;
618
+ content_type: string;
619
+ /** Bytes. */
620
+ size: number;
621
+ width: number | null;
622
+ height: number | null;
623
+ /** The alt text suggested when the image is inserted. */
624
+ alt: string | null;
625
+ created_at: string;
626
+ updated_at: string;
627
+ };
628
+ };
251
629
  type BrandKitList = {
252
630
  object: "list";
253
631
  data: Array<{
@@ -274,7 +652,12 @@ type BrandKitList = {
274
652
  fonts?: Array<string>;
275
653
  };
276
654
  graphics: Array<{
655
+ /** The image's bare id (kept for compatibility); `image_id` is its library id. */
277
656
  library_image_id: string;
657
+ /** The library image (`img_…`, GET /library-images/{id}). */
658
+ image_id?: string;
659
+ /** Put this in a template's `<Image src>`. */
660
+ path?: string;
278
661
  role: "logo" | "logo_light" | "logo_dark" | "mark" | "background" | "other";
279
662
  label?: string;
280
663
  }>;
@@ -283,6 +666,41 @@ type BrandKitList = {
283
666
  }>;
284
667
  default_id: string | null;
285
668
  };
669
+ type BrandKitUpdate = {
670
+ name?: string;
671
+ /** An https URL; `null` or `""` clears it. */
672
+ website_url?: string | null;
673
+ /** What the brand does. */
674
+ description?: string | null;
675
+ tone?: "NEUTRAL" | "FORMAL" | "FRIENDLY" | "PLAYFUL" | null;
676
+ /** Dos and don'ts for writing in this voice. */
677
+ voice_notes?: string | null;
678
+ /** The brand's industry. */
679
+ industry?: string | null;
680
+ /** Replaces the list. */
681
+ core_pages?: Array<{
682
+ url: string;
683
+ title?: string;
684
+ }>;
685
+ /** The palette, logo and background candidates, fonts. Replaces the set. */
686
+ extracted?: {
687
+ colors?: Array<{
688
+ hex: string;
689
+ label?: string;
690
+ }>;
691
+ logo_urls?: Array<string>;
692
+ background_urls?: Array<string>;
693
+ fonts?: Array<string>;
694
+ };
695
+ /** The pinned library images (`img_…`). Replaces the list. */
696
+ graphics?: Array<{
697
+ image_id: string;
698
+ role: "logo" | "logo_light" | "logo_dark" | "mark" | "background" | "other";
699
+ label?: string;
700
+ }>;
701
+ /** On the default profile, also set the email branding's accent from these colors (no change on another profile, or without a usable accent). */
702
+ sync_visual?: boolean;
703
+ };
286
704
  type Campaign = {
287
705
  object: "campaign";
288
706
  id: string;
@@ -310,7 +728,7 @@ type Campaign = {
310
728
  sent_count: number;
311
729
  failed_count: number;
312
730
  pause_reason: {
313
- code: "user" | "hard_bounce_rate" | "complaint_rate" | "quality_review" | "provider_limit" | "failure_streak" | "sender_unavailable" | "template_unavailable" | "billing" | "not_drained" | "sending_restricted" | "workspace_suspended";
731
+ code: "user" | "hard_bounce_rate" | "complaint_rate" | "quality_review" | "provider_limit" | "failure_streak" | "sender_unavailable" | "template_unavailable" | "billing" | "not_drained" | "sending_restricted" | "workspace_suspended" | "sending_paused";
314
732
  message: string | null;
315
733
  metric: "hard_bounce_rate" | "complaint_rate" | null;
316
734
  value: number | null;
@@ -329,6 +747,13 @@ type Campaign = {
329
747
  created_at: string;
330
748
  updated_at: string;
331
749
  };
750
+ type CampaignAffectedRecipient = {
751
+ object: "campaign_affected_recipient";
752
+ email: string;
753
+ contact_id: string | null;
754
+ /** The address doesn't exist (`hard_bounce`), or the person marked it as spam. */
755
+ reason: "hard_bounce" | "complaint";
756
+ };
332
757
  type CampaignCreate = {
333
758
  name: string;
334
759
  template_id: string;
@@ -345,15 +770,83 @@ type CampaignCreate = {
345
770
  variable_fallbacks?: Record<string, string>;
346
771
  excluded_contact_ids?: Array<string>;
347
772
  };
773
+ type CampaignDuplicate = {
774
+ /** Name of the copy. Defaults to the source's name with " (copy)". */
775
+ name?: string;
776
+ };
777
+ type CampaignQualityRemoval = {
778
+ object: "campaign_quality_removal";
779
+ removed: number;
780
+ };
781
+ type CampaignRecipient = {
782
+ object: "campaign_recipient";
783
+ contact_id: string;
784
+ email: string | null;
785
+ name: string | null;
786
+ /** What a send now would do for this member, by the send's own rule. */
787
+ status: "sendable" | "missing_data" | "suppressed" | "excluded";
788
+ /** Why, in plain words; null when sendable. */
789
+ reason: string | null;
790
+ reason_code: "unsubscribed" | "no_email" | "suppression_list" | "topic_unsubscribed" | "excluded" | "missing_data" | null;
791
+ };
348
792
  type CampaignReschedule = {
349
793
  /** ISO 8601 with `Z` or a `±hh:mm` offset; returned in UTC. A time without a timezone is read as UTC (deprecated: include the zone). */
350
794
  scheduled_at: string;
351
795
  };
796
+ type CampaignReviewRequest = {
797
+ object: "campaign_review_request";
798
+ requested: boolean;
799
+ already_requested: boolean;
800
+ };
352
801
  type CampaignSend = {
353
802
  scheduled_at?: string | null;
354
803
  };
804
+ type CampaignStats = {
805
+ object: "campaign_stats";
806
+ campaign_id: string;
807
+ /** Contacts the campaign was sent to (suppressed addresses never became recipients). */
808
+ recipients: number;
809
+ /** Recipients that didn't receive it, including ones that failed before a message existed. */
810
+ failed_recipients: number;
811
+ /** Contacts left out at send because their address is suppressed; null for campaigns sent before this was counted. */
812
+ suppressed: number | null;
813
+ counts: {
814
+ sent: number;
815
+ delivered: number;
816
+ /** Unique opens. */
817
+ opened: number;
818
+ /** Unique clicks. */
819
+ clicked: number;
820
+ unsubscribed: number;
821
+ bounced: number;
822
+ complained: number;
823
+ failed: number;
824
+ };
825
+ /** Percentages with one decimal (12.3 = 12.3%). null when there is nothing to measure yet, or when that tracking was off. */
826
+ rates: {
827
+ delivery: number | null;
828
+ open: number | null;
829
+ click: number | null;
830
+ unsubscribe: number | null;
831
+ bounce: number | null;
832
+ complaint: number | null;
833
+ };
834
+ tracking: {
835
+ open: boolean | null;
836
+ click: boolean | null;
837
+ };
838
+ /** Live rows, the counts frozen when old messages were cleaned up, or both. */
839
+ source: "live" | "snapshot" | "combined";
840
+ snapshotted_at: string | null;
841
+ };
355
842
  type CampaignUpdate = {
356
843
  archived?: boolean;
844
+ name?: string;
845
+ template_id?: string;
846
+ segment_id?: string;
847
+ from?: string;
848
+ subject?: string | null;
849
+ preview_text?: string | null;
357
850
  topic_id?: string | null;
358
851
  open_tracking?: boolean | null;
359
852
  click_tracking?: boolean | null;
@@ -365,6 +858,7 @@ type Contact = {
365
858
  object: "contact";
366
859
  id: string;
367
860
  email: string | null;
861
+ phone?: string | null;
368
862
  first_name: string | null;
369
863
  last_name: string | null;
370
864
  unsubscribed: boolean;
@@ -374,12 +868,54 @@ type Contact = {
374
868
  created_at: string;
375
869
  updated_at: string;
376
870
  };
871
+ type ContactActivity = {
872
+ object: "contact_activity";
873
+ /** An email (`email_…`) or text (`sms_…`) id; read it with its own get operation. */
874
+ message_id: string;
875
+ /** `email` or `sms`. */
876
+ channel: string;
877
+ direction: "outbound" | "inbound";
878
+ /** An email's subject, or the start of a text. */
879
+ subject: string | null;
880
+ /** The message's `status` as its own object reports it (`GET /email/{id}`, `GET /sms/{id}`). */
881
+ status: string;
882
+ campaign_id: string | null;
883
+ created_at: string;
884
+ sent_at: string | null;
885
+ /** Texts only: why it wasn't delivered, in plain words. */
886
+ error: string | null;
887
+ error_code: string | null;
888
+ };
889
+ type ContactAddress = {
890
+ object: "contact_address";
891
+ /** `email` for an email address, `sms` for a phone number. */
892
+ channel: string;
893
+ /** The email address, or the phone number in E.164. */
894
+ address: string;
895
+ /** The address sends use for this channel. */
896
+ primary: boolean;
897
+ /** `active`, or why it can't be used (e.g. `opted_out`, `bounced`). */
898
+ status: string;
899
+ /** ISO country of a phone number. */
900
+ country: string | null;
901
+ verified_at: string | null;
902
+ /** When SMS consent was recorded (see `/contacts/{id}/sms-consent`). */
903
+ consented_at: string | null;
904
+ consent_source: string | null;
905
+ consent_purpose: string | null;
906
+ /** When the carrier last refused a text to this number because it opted out at the carrier. Not a consent record. */
907
+ carrier_opt_out_at: string | null;
908
+ created_at: string;
909
+ };
377
910
  type ContactCreate = {
378
911
  email: string;
912
+ phone?: string | null;
379
913
  first_name?: string;
380
914
  last_name?: string;
381
915
  unsubscribed?: boolean;
382
916
  custom_fields?: Record<string, string | number | boolean | null>;
917
+ /** `true` updates the contact that already has this email instead of answering `409`: the fields you send are merged onto it (what you leave out is untouched, and `custom_fields` merges key by key), and the response is `200` rather than the `201` of a real create. Default `false`: a duplicate email is a `409`. It is not a way around an opt-out — `unsubscribed: false` on a suppressed address is still refused. */
918
+ update_if_exists?: boolean;
383
919
  };
384
920
  type ContactField = {
385
921
  object: "contact_field";
@@ -436,6 +972,26 @@ type ContactImportCreate = {
436
972
  unsubscribed?: boolean | string;
437
973
  }>;
438
974
  };
975
+ type ContactSegment = {
976
+ object: "contact_segment";
977
+ segment_id: string;
978
+ name: string;
979
+ /** A dynamic segment's members come from its filter; they can't be added or removed by hand. */
980
+ type: "static" | "dynamic";
981
+ /** Whether this segment's sends reach the contact (a static segment can be opted out of on its own). */
982
+ subscribed: boolean;
983
+ unsubscribed_at: string | null;
984
+ };
985
+ type ContactsExport = {
986
+ /** Free text: email, first and last name, and with 3+ digits the SMS number. */
987
+ q?: string;
988
+ status?: "subscribed" | "unsubscribed";
989
+ phone?: "has" | "none";
990
+ /** Members of this segment. Also needs `segments:read`. */
991
+ segment_id?: string;
992
+ /** With a static `segment_id`: its per-segment opt-out. */
993
+ segment_subscription?: "subscribed" | "opted_out";
994
+ };
439
995
  type ContactTopic = {
440
996
  object: "contact_topic";
441
997
  topic_id: string;
@@ -445,12 +1001,27 @@ type ContactTopic = {
445
1001
  status: "subscribed" | "unsubscribed";
446
1002
  source: "user" | "manual" | "import" | "api";
447
1003
  };
1004
+ type ContactTopicList = {
1005
+ object: "list";
1006
+ has_more: false;
1007
+ data: Array<ContactTopic>;
1008
+ };
448
1009
  type ContactTopicSet = {
449
1010
  topic_id?: string;
450
1011
  topic?: string;
451
1012
  subscribed: boolean;
452
1013
  };
1014
+ type ContactTopicsUpdate = {
1015
+ /** The preferences to change, up to 50, each topic once. Topics left out keep theirs. */
1016
+ topics: Array<{
1017
+ /** The topic (`top_…`). */
1018
+ topic_id: string;
1019
+ /** `true` to subscribe the contact, `false` to unsubscribe. */
1020
+ subscribed: boolean;
1021
+ }>;
1022
+ };
453
1023
  type ContactUpdate = {
1024
+ phone?: string | null;
454
1025
  first_name?: string | null;
455
1026
  last_name?: string | null;
456
1027
  unsubscribed?: boolean;
@@ -474,6 +1045,35 @@ type Domain = {
474
1045
  tracking_subdomain: string | null;
475
1046
  /** When tracked links and open pixels started using the custom tracking host (`tracking_subdomain`). Non-null only while sends actually use it: the domain is verified (or degraded) and the host's last check proved it answers over HTTPS. Otherwise null, and links use the default tracking host. A host that stops answering, or a domain that's no longer verified, goes back to null. */
476
1047
  tracking_verified_at: string | null;
1048
+ capabilities: {
1049
+ /** Always `enabled`: a domain can't be switched to receive-only. `status` says whether it can send now. */
1050
+ sending: "enabled";
1051
+ /** Whether mail sent to any address at this domain is received (catch-all). Turn it on with `PATCH /email/domains/{id}` once the domain is `verified`; `receiving` says how far setup is. */
1052
+ receiving: "enabled" | "disabled";
1053
+ };
1054
+ /** Receiving setup: the MX record to publish and the last check of it. */
1055
+ receiving: {
1056
+ /** `disabled`: receiving is off. `not_started`: on, but the MX record hasn't been checked yet (call `POST /email/domains/{id}/verify`). `pending`: checked, and either the MX record isn't published, another MX record has an equal or lower priority number, or mail isn't accepted yet. `verified`: mail to any address at the domain is received here. `held_elsewhere`: on, but another workspace has this domain verified, so its mail doesn't come to this one. */
1057
+ status: "disabled" | "not_started" | "pending" | "verified" | "held_elsewhere";
1058
+ /** The MX record to publish for receiving, at the domain's own name. Not part of `records`: publishing it routes ALL mail for the name to Unitpost, so if `checks.other_mx_found` is true the name already gets mail somewhere else (e.g. a mailbox provider). Use a subdomain for receiving instead. */
1059
+ record: {
1060
+ type: string;
1061
+ name: string;
1062
+ value: string;
1063
+ priority?: number;
1064
+ };
1065
+ /** The last MX check, or null before the first one. */
1066
+ checks: {
1067
+ /** Our MX record is published at the name. */
1068
+ mx_found: boolean;
1069
+ /** Our MX record has the lowest priority number at the name, so mail reaches Unitpost. */
1070
+ mx_lowest_priority: boolean;
1071
+ /** Another MX record (another mail provider) is published at the name. */
1072
+ other_mx_found: boolean;
1073
+ } | null;
1074
+ /** When the MX record was last checked. */
1075
+ checked_at: string | null;
1076
+ };
477
1077
  verified_at: string | null;
478
1078
  created_at: string;
479
1079
  updated_at: string;
@@ -522,6 +1122,13 @@ type DomainUpdate = {
522
1122
  click_tracking?: boolean | null;
523
1123
  tls?: "opportunistic" | "enforced";
524
1124
  tracking_subdomain?: string | null;
1125
+ /** Turn receiving on or off: `{ "receiving": "enabled" }` or `{ "receiving": "disabled" }`. */
1126
+ capabilities?: {
1127
+ /** Only `enabled` is accepted: sending can't be turned off for a domain. */
1128
+ sending?: "enabled";
1129
+ /** `enabled` receives mail sent to any address at the domain (it must be `verified`, else 409); `disabled` stops receiving (always allowed). Then publish `receiving.record` and call verify. */
1130
+ receiving?: "enabled" | "disabled";
1131
+ };
525
1132
  };
526
1133
  type Email$1 = {
527
1134
  object: "email";
@@ -541,15 +1148,36 @@ type Email$1 = {
541
1148
  canceled_at: string | null;
542
1149
  last_error: string | null;
543
1150
  created_at: string;
1151
+ /** Cc recipients, as sent. Empty when none. Only on `GET /email/{id}`. */
1152
+ cc?: Array<string>;
1153
+ /** Bcc recipients, as sent. Empty when none. Only on `GET /email/{id}`. */
1154
+ bcc?: Array<string>;
1155
+ /** Reply-To addresses, as sent. Empty when none. Only on `GET /email/{id}`. */
1156
+ reply_to?: Array<string>;
1157
+ /** The send's tags. Empty when none. Only on `GET /email/{id}`. */
1158
+ tags?: Array<{
1159
+ name: string;
1160
+ value: string;
1161
+ }>;
1162
+ };
1163
+ type EmailEvent = {
1164
+ object: "email_event";
1165
+ id: string;
1166
+ /** The event, as webhooks name it (`email.delivered`, `email.bounced`, ...). */
1167
+ type: string;
1168
+ /** When it happened. */
1169
+ created_at: string;
1170
+ /** The event's own detail, under the webhook's field names: `bounce` { type, sub_type, category, diagnostic_code[] } (`category`: hard_bounce, soft_bounce, provider_policy_reject or already_suppressed; only hard_bounce means the address can't receive mail), `complaint` { feedback_type }, `open` { user_agent }, `click` { link, user_agent }, `failed` { reason }, `suppressed` { recipients[], reasons[] { email, reason }, full }, `unsubscribe` { scope, source }. Empty for the rest. */
1171
+ data: Record<string, unknown>;
544
1172
  };
545
1173
  type EmailPatch = {
546
1174
  cancel?: true;
547
1175
  scheduled_at?: string;
548
1176
  };
549
1177
  type EmailStats = {
550
- /** The rolling window, in days. */
1178
+ /** The window, in days (a period's length, rounded up). */
551
1179
  windowDays: number;
552
- /** Non-null when the requested window exceeded the plan's log retention and was clamped to this many days (data past the retention horizon is purged). */
1180
+ /** Non-null when the window reached past the plan's log retention: counting starts this many days back (data past the retention horizon is purged). */
553
1181
  clampedToRetentionDays?: number | null;
554
1182
  totals: {
555
1183
  sent: number;
@@ -559,32 +1187,262 @@ type EmailStats = {
559
1187
  bounced: number;
560
1188
  complained: number;
561
1189
  failed: number;
1190
+ /** Hard (permanent) bounces: the address doesn't exist or never accepts mail. Counted as the hard-bounce rate that can pause a campaign counts them. */
1191
+ bounced_permanent?: number;
1192
+ /** Soft bounces: everything else in `bounced` (a full mailbox, a message too large, an undetermined bounce). */
1193
+ bounced_transient?: number;
1194
+ /** Sends that skipped a suppressed recipient (`email.suppressed`). */
1195
+ suppressed?: number;
1196
+ /** Unsubscribes from a sent email (`email.unsubscribed`). */
1197
+ unsubscribed?: number;
562
1198
  };
563
- /** Percentages (one decimal). delivery/bounce/complaint are vs sent; open/click are vs delivered. */
1199
+ /** Percentages (one decimal). delivery/bounce/complaint are vs sent; open/click are vs delivered with that tracking on; unsubscribe vs delivered. */
564
1200
  rates: {
565
1201
  delivery: number;
566
1202
  open: number;
567
1203
  click: number;
568
1204
  bounce: number;
569
1205
  complaint: number;
1206
+ /** Unsubscribes vs delivered (vs sent when nothing was delivered), at most 100. */
1207
+ unsubscribe?: number;
570
1208
  };
1209
+ /** The sending domain counted (`domain_id`), or null for every domain. */
1210
+ domain_id?: string | null;
1211
+ /** Start of the window counted (UTC). */
1212
+ from?: string;
1213
+ /** End of the window counted, exclusive (UTC). */
1214
+ to?: string;
1215
+ /** The send volume per `grain` bucket over `from`–`to`, as the dashboard home charts it; null without `grain`. */
1216
+ series?: {
1217
+ grain: "5m" | "1h" | "1d";
1218
+ time_zone: string;
1219
+ /** Buckets with sends, oldest first; a bucket with none is left out. */
1220
+ buckets: Array<{
1221
+ /** The bucket's start in `time_zone` wall time: `YYYY-MM-DD` for `1d`, `YYYY-MM-DDTHH:MM` for `1h` and `5m`. */
1222
+ bucket: string;
1223
+ /** Emails created in the bucket (sent or attempted). */
1224
+ sends: number;
1225
+ }>;
1226
+ } | null;
571
1227
  };
572
- type Error$1 = {
573
- error: {
574
- /** Stable machine-readable error code (branch on this, not the message). */
575
- code: string;
576
- /** Human-readable summary. For validation errors it's path-prefixed (e.g. "template.variables.first_name: …"). */
577
- message: string;
578
- /** Present on errors that carry per-field reasons: validation errors (422), a blocked campaign send (409), and a plan that doesn't include a feature (403 `limit_reached` with one entry whose `code` is `feature_not_in_plan` and whose `field` names the feature, e.g. `smsChannel`). One entry per offending field/blocker. */
579
- details?: Array<{
580
- /** Dotted path to the field, e.g. "template.variables.first_name" (empty for a whole-body problem). */
581
- field: string;
1228
+ type EmailThread = {
1229
+ object: "email_thread";
1230
+ id: string;
1231
+ subject: string | null;
1232
+ last_message_at: string;
1233
+ last_direction: "inbound" | "outbound";
1234
+ /** The newest received message's opening words; null when the newest message is one you sent. */
1235
+ snippet: string | null;
1236
+ /** The other party: the newest received message's sender. */
1237
+ from: string | null;
1238
+ from_name: string | null;
1239
+ /** Your address it came in on (the newest received message's To). */
1240
+ inbox_address: string | null;
1241
+ message_count: number;
1242
+ has_attachments: boolean;
1243
+ /** A received message was flagged spam or virus, or failed SPF, DKIM or DMARC. */
1244
+ flagged: boolean;
1245
+ /** A reply or forward was sent from this conversation. */
1246
+ replied: boolean;
1247
+ };
1248
+ type EmailThreadDeleted = {
1249
+ object: "email_thread";
1250
+ id: string;
1251
+ deleted: true;
1252
+ /** Received messages erased. */
1253
+ deleted_messages: number;
1254
+ };
1255
+ type EmailThreadDetail = {
1256
+ object: "email_thread";
1257
+ id: string;
1258
+ subject: string | null;
1259
+ last_message_at: string;
1260
+ /** The other party; null when the conversation has no received mail. */
1261
+ sender: {
1262
+ address: string;
1263
+ } | null;
1264
+ /** Older messages exist than the ones in `messages`; read them with `before` = `older_cursor`. */
1265
+ older_hidden: boolean;
1266
+ /** Pass as `before` to read the messages before these (the next page back). Null when nothing older remains. */
1267
+ older_cursor: string | null;
1268
+ /** A reply from here carries the "Sent with Unitpost" line (your plan decides). */
1269
+ sent_with_unitpost: boolean;
1270
+ /** Oldest first. What you sent is metadata only: no body. */
1271
+ messages: Array<{
1272
+ object: "received_email";
1273
+ direction: "inbound";
1274
+ id: string;
1275
+ received_at: string;
1276
+ from: string;
1277
+ from_name: string | null;
1278
+ to: Array<string>;
1279
+ cc: Array<string>;
1280
+ /** Reply-To addresses; answer these before `from` when present. */
1281
+ reply_to: Array<string>;
1282
+ subject: string | null;
1283
+ message_id: string | null;
1284
+ /** Null on a copy of one of your own sends (`sent_by_us`): sent bodies aren't on the API. */
1285
+ text: string | null;
1286
+ /** Inline (`cid:`) images point to short-lived links. Null on a copy of your own send. */
1287
+ html: string | null;
1288
+ verdicts: {
1289
+ spam: string | null;
1290
+ virus: string | null;
1291
+ spf: string | null;
1292
+ dkim: string | null;
1293
+ dmarc: string | null;
1294
+ };
1295
+ size: number;
1296
+ attachments: Array<{
1297
+ object: "received_attachment";
1298
+ id: string;
1299
+ filename: string | null;
1300
+ content_type: string | null;
1301
+ content_disposition: string | null;
1302
+ content_id: string | null;
1303
+ size: number;
1304
+ }>;
1305
+ /** A copy of one of your own sends that came back in to your receiving domain. */
1306
+ sent_by_us: boolean;
1307
+ /** It repeats a message the conversation already shows; the dashboard folds it away. */
1308
+ duplicate: boolean;
1309
+ } | {
1310
+ object: "email";
1311
+ direction: "outbound";
1312
+ id: string;
1313
+ created_at: string;
1314
+ from: string;
1315
+ to: Array<string>;
1316
+ cc: Array<string>;
1317
+ bcc: Array<string>;
1318
+ subject: string;
1319
+ status: "scheduled" | "queued" | "sent" | "delivered" | "bounced" | "complained" | "canceled" | "failed";
1320
+ /** Sent from this conversation; null for an earlier send a reply pulled in. */
1321
+ kind: "reply" | "forward" | null;
1322
+ sent_at: string | null;
1323
+ delivered_at: string | null;
1324
+ opened_at: string | null;
1325
+ clicked_at: string | null;
1326
+ attachments: Array<{
1327
+ filename: string;
1328
+ content_type: string | null;
1329
+ size: number;
1330
+ }>;
1331
+ }>;
1332
+ };
1333
+ type EmailThreadReplyRequest = {
1334
+ /** The received message (`inb_…`) in this conversation to answer or forward. */
1335
+ received_email_id: string;
1336
+ /** `reply` (the sender), `reply_all` (everyone on it), or `forward` (to someone new, with the original's attachments you pick). */
1337
+ mode: "reply" | "reply_all" | "forward";
1338
+ /** One of your sending addresses, e.g. the address the message came in on. */
1339
+ from: string;
1340
+ /** For a reply: the message's `reply_to`, else its `from`. Up to 50. */
1341
+ to: string | Array<string>;
1342
+ /** Copy recipients, up to 50. */
1343
+ cc?: string | Array<string>;
1344
+ /** Blind-copy recipients, up to 50. */
1345
+ bcc?: string | Array<string>;
1346
+ /** Usually `Re: <their subject>` (or `Fwd:`). */
1347
+ subject: string;
1348
+ /** Your words, plain text. The original is quoted under them. */
1349
+ text?: string;
1350
+ /** Your words, HTML. The original is quoted under them. */
1351
+ html?: string;
1352
+ /** Quote the original under a reply (default true; a forward always carries it). A copy of one of your own sends (`sent_by_us`) is never quoted: left out, it defaults to false there, and `true` is a `403`. */
1353
+ include_quote?: boolean;
1354
+ /** Forward only: the original's attachments to carry over (their `id`s). */
1355
+ forward_attachment_ids?: Array<string>;
1356
+ /** Files to attach: `content` (base64) or `path` (an https URL), up to 20 with the carried-over ones. */
1357
+ attachments?: Array<{
1358
+ filename: string;
1359
+ content?: string;
1360
+ path?: string;
1361
+ content_type?: string;
1362
+ content_id?: string;
1363
+ }>;
1364
+ /** Open and click tracking for this message; omitted = the sending domain's default. */
1365
+ tracking?: boolean;
1366
+ };
1367
+ type EmailThreadReplyResult = {
1368
+ object: "email";
1369
+ /** The sent email (`email_…`); read it with `GET /email/{id}`. */
1370
+ id: string;
1371
+ status: "queued" | "scheduled";
1372
+ thread_id: string | null;
1373
+ };
1374
+ type Error$1 = {
1375
+ error: {
1376
+ /** Stable machine-readable error code (branch on this, not the message). */
1377
+ code: string;
1378
+ /** Human-readable summary. For validation errors it's path-prefixed (e.g. "template.variables.first_name: …"). */
1379
+ message: string;
1380
+ /** Present on errors that carry per-field reasons: validation errors (422), a blocked campaign send (409), and a plan that doesn't include a feature (403 `limit_reached` with one entry whose `code` is `feature_not_in_plan` and whose `field` names the feature, e.g. `smsChannel`). One entry per offending field/blocker. */
1381
+ details?: Array<{
1382
+ /** Dotted path to the field, e.g. "template.variables.first_name" (empty for a whole-body problem). */
1383
+ field: string;
582
1384
  /** Machine-readable reason for this entry, when there is one (e.g. `template_not_published` on `template_id` for a blocked SMS campaign send, or `feature_not_in_plan` on `smsChannel` when the plan has no SMS). Absent on plain validation errors. */
583
1385
  code?: string;
584
1386
  message: string;
585
1387
  }>;
1388
+ /** A page that explains this error and what to do, when there is one (today: `sending_paused`). Additive; absent otherwise. */
1389
+ doc_url?: string;
586
1390
  };
587
1391
  };
1392
+ type File = {
1393
+ object: "file";
1394
+ id: string;
1395
+ /** What the file is for: `sms_opt_in_evidence` (PNG, up to 400 KB), `sms_document` (PDF, PNG or JPEG, up to 3 MB), `image` (PNG, JPEG, GIF or WebP, up to 5 MB). */
1396
+ purpose: "sms_opt_in_evidence" | "sms_document" | "image";
1397
+ /** `ready`: checked and usable by `file_id`. `awaiting_upload`: an upload session whose bytes haven't been PUT yet (reading the file checks again). `failed`: the uploaded bytes were refused (`failure_reason` says why). */
1398
+ status: "awaiting_upload" | "ready" | "failed";
1399
+ filename: string;
1400
+ /** The type the file's bytes carry (checked by their contents), or, before an upload session's bytes arrive, the type declared. */
1401
+ content_type: string;
1402
+ size_bytes: number;
1403
+ /** The hex SHA-256 of the bytes once `ready`. */
1404
+ sha256: string | null;
1405
+ failure_reason: string | null;
1406
+ /** An upload session's PUT, in the create response only (null otherwise). */
1407
+ upload: {
1408
+ /** PUT the bytes here, with exactly `headers`, before `expires_at`: `curl -T <file> -H "Content-Type: …" "<url>"`. The URL is a credential for this one file: don't share or log it. */
1409
+ url: string;
1410
+ method: "PUT";
1411
+ /** Send these headers with the PUT. The length and type are signed: any other size or type is refused by storage. */
1412
+ headers: Record<string, string>;
1413
+ /** The URL stops working at this time (15 minutes after the file is created). */
1414
+ expires_at: string;
1415
+ } | null;
1416
+ created_at: string;
1417
+ /** The file is deleted at this time, 24 hours after it was created, whether or not it was used. An operation that used it keeps its own copy. */
1418
+ expires_at: string;
1419
+ };
1420
+ type FileCreate = {
1421
+ /** What the file is for, which sets what it may be: `sms_opt_in_evidence` (PNG, up to 400 KB), `sms_document` (PDF, PNG or JPEG, up to 3 MB), `image` (PNG, JPEG, GIF or WebP, up to 5 MB). The bytes decide the type, never the name or the label. */
1422
+ purpose: "sms_opt_in_evidence" | "sms_document" | "image";
1423
+ /** A public https address to fetch the file from (no redirects, no private addresses, 12 seconds). One of `url`, `data`, or neither (an upload session). */
1424
+ url?: string;
1425
+ /** The bytes, base64 (no `data:` prefix), with `content_type`. A request over ~6 MB is refused before it arrives, so this fits about 4 MB; agents should prefer `url` or an upload session for anything but small files. */
1426
+ data?: string;
1427
+ /** Required with `data` and for an upload session (it is signed into the PUT); refused with `url`. */
1428
+ content_type?: "image/png" | "application/pdf" | "image/jpeg" | "image/gif" | "image/webp";
1429
+ /** An upload session only: the exact size of the file you'll PUT, in bytes (signed into the PUT). Within the purpose's maximum. */
1430
+ size_bytes?: number;
1431
+ /** A name for the file (shown on what uses it). Defaults to the URL's last path part, or `file.<ext>`. */
1432
+ filename?: string;
1433
+ };
1434
+ type ImageUpload = {
1435
+ /** A public https image to fetch (no redirects, no private addresses). PNG, JPEG, GIF or WebP, up to 5 MB and 16,384 px a side (50 megapixels at most); anything else is a 422 naming `url`. */
1436
+ url?: string;
1437
+ /** The image bytes, base64 (no `data:` prefix). Base64 adds a third, and a request over ~6 MB is refused before it arrives, so this fits about 4 MB of image; send larger images (up to 5 MB) by `url`. At most 16,384 px a side and 50 megapixels; anything else is a 422 naming `data`. */
1438
+ data?: string;
1439
+ /** A file made with `POST /files` and purpose `image` (`file_…`): how an agent hands over a local image without base64 (an upload session), or an image up to 5 MB. Checked by its bytes when it was made, and again here. */
1440
+ file_id?: string;
1441
+ /** Required with `data`; refused with `url` and `file_id` (the server reads the type from the bytes). */
1442
+ content_type?: "image/png" | "image/jpeg" | "image/gif" | "image/webp";
1443
+ /** Shown in the library. Defaults to the URL's file name, or `image`. */
1444
+ filename?: string;
1445
+ };
588
1446
  type Job = {
589
1447
  object: "job";
590
1448
  id: string;
@@ -597,6 +1455,285 @@ type Job = {
597
1455
  created_at: string;
598
1456
  completed_at: string | null;
599
1457
  };
1458
+ type JobDownload = {
1459
+ object: "job_download";
1460
+ job_id: string;
1461
+ /** A signed URL to the file; it expires in 5 minutes. */
1462
+ url: string;
1463
+ filename: string;
1464
+ expires_at: string;
1465
+ };
1466
+ type LibraryImage = {
1467
+ object: "library_image";
1468
+ id: string;
1469
+ /** Put this in a template or design: `<Image src="/img/…">` or `<img src="/img/…">`. Template and design sends resolve it to the image host; a raw `html` send doesn't, so use `url` there. */
1470
+ path: string;
1471
+ /** The image's public address on our asset CDN: use it in raw `html` sends and anywhere outside Unitpost. */
1472
+ url: string;
1473
+ filename: string;
1474
+ content_type: string;
1475
+ /** Bytes. */
1476
+ size: number;
1477
+ width: number | null;
1478
+ height: number | null;
1479
+ /** The alt text suggested when the image is inserted. */
1480
+ alt: string | null;
1481
+ created_at: string;
1482
+ updated_at: string;
1483
+ };
1484
+ type LibraryImageCreate = {
1485
+ /** A public https image to fetch (no redirects, no private addresses). PNG, JPEG, GIF or WebP, up to 5 MB and 16,384 px a side (50 megapixels at most); anything else is a 422 naming `url`. */
1486
+ url?: string;
1487
+ /** The image bytes, base64 (no `data:` prefix). Base64 adds a third, and a request over ~6 MB is refused before it arrives, so this fits about 4 MB of image; send larger images (up to 5 MB) by `url`. At most 16,384 px a side and 50 megapixels; anything else is a 422 naming `data`. */
1488
+ data?: string;
1489
+ /** A file made with `POST /files` and purpose `image` (`file_…`): how an agent hands over a local image without base64 (an upload session), or an image up to 5 MB. Checked by its bytes when it was made, and again here. */
1490
+ file_id?: string;
1491
+ /** Required with `data`; refused with `url` and `file_id` (the server reads the type from the bytes). */
1492
+ content_type?: "image/png" | "image/jpeg" | "image/gif" | "image/webp";
1493
+ /** Shown in the library. Defaults to the URL's file name, or `image`. */
1494
+ filename?: string;
1495
+ /** Alt text suggested when the image is inserted. */
1496
+ alt?: string | null;
1497
+ };
1498
+ type LibraryImageUpdate = {
1499
+ /** The new alt text; `null` or `""` clears it. */
1500
+ alt: string | null;
1501
+ };
1502
+ type MintedWorkspaceKey = {
1503
+ object: "api_key";
1504
+ /** `key_…` */
1505
+ id: string;
1506
+ /** The secret, shown once. */
1507
+ key: string;
1508
+ prefix: string;
1509
+ scope: "full" | "sending" | "read_only";
1510
+ capabilities: Array<string>;
1511
+ workspace_id: string;
1512
+ };
1513
+ type OrganizationPlanQuote = {
1514
+ object: "plan_quote";
1515
+ /** `pq_…` */
1516
+ id: string;
1517
+ /** `ws_…` */
1518
+ workspace_id: string;
1519
+ /** The workspace's `external_id` when quoted. */
1520
+ external_id: string | null;
1521
+ /** `open` until confirmed or 10 minutes pass; `confirmed` once a confirm used it. */
1522
+ status: "open" | "confirmed" | "expired";
1523
+ /** `upgrade`: now, charged in full, the period restarts, unused allowance carries over. `downgrade`: at the period end. `lateral`: now. `start`: from free, now. `cancel`: to free, at the period end. `noop`: the plan stays as it is; with a `pending_change`, the confirm cancels it (nothing charged). */
1524
+ kind: "upgrade" | "downgrade" | "lateral" | "start" | "cancel" | "noop";
1525
+ current: OrganizationPlanStop;
1526
+ target: OrganizationPlanStop;
1527
+ /** Charged to the organization's card on confirm: the new monthly price on an upgrade or a start, else 0 (before any discount). An upgrade restarts the billing period, so usage beyond the old plan's allowance this period, if any, is billed on the same invoice and is not in this number. */
1528
+ due_now_cents: number;
1529
+ /** Unused allowance carried into the new period (an upgrade only). */
1530
+ carryover_cents: number;
1531
+ effective: "now" | "period_end";
1532
+ /** When the change takes effect (once confirmed, when it did or will). Null for a `noop`, except one on a plan already set to end, where it is when the plan ends. */
1533
+ effective_at: string | null;
1534
+ expires_at: string;
1535
+ created_at: string;
1536
+ confirmed_at: string | null;
1537
+ /** After a confirm from free (`start`): the organization's card was declined or asked for authentication. The plan starts when this invoice is paid; unpaid, it lapses after about 23 hours, nothing is charged and the workspace stays on Free. Null otherwise. */
1538
+ hosted_invoice_url: string | null;
1539
+ /** A free workspace that pays for itself, started on a paid plan billed to the organization: the confirm moves it onto the organization's billing first. */
1540
+ moves_to_organization: boolean;
1541
+ /** A downgrade already scheduled for the end of the period when the quote was made: the plan and stop it moves to, and when. Null when none is scheduled. With one, a quote for the current plan and tier is a `noop` whose confirm cancels it, so the workspace keeps its plan; an upgrade or a lateral move replaces it, another downgrade replaces it, and a cancel to free ends the plan instead. */
1542
+ pending_change: {
1543
+ plan: string;
1544
+ tier_index: number;
1545
+ effective_at: string | null;
1546
+ } | null;
1547
+ /** On create only: the single-use token the confirm takes (`pqct_…`). Stored hashed; never shown again. */
1548
+ confirm_token?: string;
1549
+ };
1550
+ type OrganizationPlanQuoteConfirm = {
1551
+ /** The quote's `confirm_token` (`pqct_…`) from its create response. Single use. */
1552
+ confirm_token: string;
1553
+ };
1554
+ type OrganizationPlanQuoteCreate = {
1555
+ /** `free`, or a paid plan the Owner's API rules allow. */
1556
+ plan: string;
1557
+ /** The stop on the paid plan's price ladder (default 0, its lowest price). Ignored for `free`. */
1558
+ tier_index?: number;
1559
+ };
1560
+ type OrganizationPlanStop = {
1561
+ /** `free` or the paid plan's key. */
1562
+ plan: string;
1563
+ /** The stop on the plan's ladder; null for free or a custom plan. */
1564
+ tier_index: number | null;
1565
+ /** The monthly price; 0 for free, null for a custom plan. */
1566
+ price_monthly_cents: number | null;
1567
+ };
1568
+ type OrganizationSharedPlan$1 = {
1569
+ object: "shared_plan";
1570
+ /** Unitpost's team turned the shared plan on for the organization; it is never on by default. */
1571
+ approved: boolean;
1572
+ /** When an Owner or Billing member asked for it (Organization → Billing); null if nobody has. */
1573
+ requested_at: string | null;
1574
+ /** `none` until a plan is bought; then the plan's status. `past_due` keeps its workspaces but takes no new ones; `canceled` once it ended (its workspaces left it). */
1575
+ status: "none" | "active" | "trialing" | "past_due" | "paused" | "canceled";
1576
+ /** The plan's key (`pro` is Starter, `scale` is Growth); null with none. */
1577
+ plan: string | null;
1578
+ /** The stop on the plan's price ladder. */
1579
+ tier_index: number | null;
1580
+ /** The stop's list price a month, before any discount or promotion code. */
1581
+ price_monthly_cents: number | null;
1582
+ period_start: string | null;
1583
+ period_end: string | null;
1584
+ /** Set to end then (the period end); null while it renews. */
1585
+ cancel_at: string | null;
1586
+ /** The allowance its workspaces share each period, in cents of sending (email, SMS, WhatsApp). */
1587
+ allowance_cents: number | null;
1588
+ /** What its workspaces drew this period, including workspaces that left during it. 0 with no plan. */
1589
+ used_cents: number;
1590
+ /** The part of `used_cents` beyond the allowance, billed at the plan's overage rate. */
1591
+ overage_cents: number;
1592
+ /** The overage band: how far past the allowance its workspaces may send in a period. Null: no band. */
1593
+ overage_cap_cents: number | null;
1594
+ /** The allowance and the band are used up (only the allowance while `overage_frozen`): every workspace on the plan stops sending until the period renews or the plan is upgraded. */
1595
+ paused: boolean;
1596
+ /** Unitpost's team paused overage on the plan (a disputed charge): sending stops at the allowance. */
1597
+ overage_frozen: boolean;
1598
+ /** How many workspaces the plan covers (Starter 3, Growth 10, unless Unitpost's team set another number). Before a plan is bought, the number set for the organization, or null for the plan's own. */
1599
+ workspace_limit: number | null;
1600
+ /** How many workspaces are on it now. */
1601
+ workspaces: number;
1602
+ };
1603
+ type OrganizationSharedPlanRemoval = {
1604
+ object: "shared_plan_removal";
1605
+ /** `ws_…` */
1606
+ workspace_id: string;
1607
+ external_id: string | null;
1608
+ /** False when it wasn't on the shared plan: nothing changed. */
1609
+ left: boolean;
1610
+ /** `free`: it is on Free (its Owner's one free workspace). `needs_plan`: it sends again once a plan is bought for it. Null when `left` is false. */
1611
+ drops_to: "free" | "needs_plan" | null;
1612
+ };
1613
+ type OrganizationSharedPlanWorkspace = {
1614
+ object: "shared_plan_workspace";
1615
+ /** `ws_…` */
1616
+ workspace_id: string;
1617
+ /** Your own id for it, if you gave one. */
1618
+ external_id: string | null;
1619
+ name: string;
1620
+ /** What it may draw from the shared plan each period, allowance and overage together. Null: no cap. */
1621
+ cap_cents: number | null;
1622
+ joined_at: string;
1623
+ /** What it drew this period, counted against its cap. */
1624
+ used_cents: number;
1625
+ };
1626
+ type OrganizationSharedPlanWorkspaceAdd = {
1627
+ /** Its cap, in cents a period (0 stops it drawing, null: none). Left out: none on a join, unchanged when it is already on the plan. */
1628
+ cap_cents?: number | null;
1629
+ };
1630
+ type OrganizationSharedPlanWorkspaceUpdate = {
1631
+ /** Its cap, in cents a period: 0 stops it drawing, null removes the cap. */
1632
+ cap_cents: number | null;
1633
+ };
1634
+ type OrganizationWebhookDelivery = WebhookDelivery & {
1635
+ /** The workspace the event happened in (`ws_…`). */
1636
+ workspace_id: string;
1637
+ /** That workspace's `external_id` now (the delivered envelope carried the one at delivery time); null when it has none. */
1638
+ external_id: string | null;
1639
+ };
1640
+ type OrganizationWorkspace = {
1641
+ object: "workspace";
1642
+ /** `ws_…` */
1643
+ id: string;
1644
+ name: string;
1645
+ slug: string;
1646
+ /** Your own id for it, unique in the organization. */
1647
+ external_id: string | null;
1648
+ /** `free`, or the paid plan's key. */
1649
+ plan: string;
1650
+ paid_by: "workspace" | "organization";
1651
+ /** No free allowance: the Owner already has a free workspace, so it sends once a plan is bought. */
1652
+ requires_paid_plan: boolean;
1653
+ /** The workspace's monthly cap on SMS purchases by API, in cents (ADR-0114). Null: none, so every API purchase is refused with `api_spend_cap_not_set`. */
1654
+ sms_purchases_cap_cents?: number | null;
1655
+ closed_at: string | null;
1656
+ /** Once closed: the last moment it can be restored, 30 days after `closed_at`. Null while open. */
1657
+ restorable_until: string | null;
1658
+ /** Once closed: when it is deleted unless restored, the later of `restorable_until` and 7 days after the end of the billing period it closed in (so that period's usage stays readable). Its SMS numbers are released then. Null while open. */
1659
+ deletes_at?: string | null;
1660
+ /** On the organization's shared plan: its cap on what it draws each period (`cap_cents`, null: none) and when it joined. Null when it isn't on it. Its usage is on `GET /organizations/{id}/shared-plan/workspaces`. */
1661
+ shared_plan?: {
1662
+ cap_cents: number | null;
1663
+ joined_at: string;
1664
+ } | null;
1665
+ created_at: string;
1666
+ /** On create only: the card asked for authentication; paying here starts the plan. */
1667
+ hosted_invoice_url?: string | null;
1668
+ };
1669
+ type OrganizationWorkspaceCreate = {
1670
+ name: string;
1671
+ external_id?: string;
1672
+ /** Default: the Owner's default plan, else `free`. A paid plan is billed to the organization's card at once. */
1673
+ plan?: string;
1674
+ /** The paid plan's tier (default 0). Its price must be within the Owner's largest plan price (Organization → API); with none set, only tier 0. */
1675
+ tier_index?: number;
1676
+ /** The monthly SMS purchases cap, in cents, at most the Owner's largest. Above 0 only on a paid plan or the shared plan (billed to the organization). Left out: the Owner's default there, else none; null: none. */
1677
+ sms_purchases_cap_cents?: number | null;
1678
+ /** Make it straight onto the organization's shared plan: it draws on the shared allowance, has no plan of its own and is paid by the organization's card. Needs `organizations:billing`; not with `plan` or `tier_index`. Set a cap afterwards with `PATCH /organizations/{id}/shared-plan/workspaces/{workspace_id}`. */
1679
+ shared_plan?: boolean;
1680
+ };
1681
+ type OrganizationWorkspaceUpdate = {
1682
+ name?: string;
1683
+ external_id?: string | null;
1684
+ /** The monthly SMS purchases cap, in cents; null clears it. Above 0 only on a workspace the organization pays for, and at most the Owner's largest. */
1685
+ sms_purchases_cap_cents?: number | null;
1686
+ };
1687
+ type OrganizationWorkspaceUsage = {
1688
+ object: "workspace_usage";
1689
+ workspace_id: string;
1690
+ external_id: string | null;
1691
+ name: string;
1692
+ closed_at: string | null;
1693
+ plan: string;
1694
+ period_start: string | null;
1695
+ period_end: string | null;
1696
+ emails: {
1697
+ sent: number;
1698
+ };
1699
+ spend: {
1700
+ total_cents: number;
1701
+ email_cents: number;
1702
+ sms_cents: number;
1703
+ sms_carrier_fees_cents: number;
1704
+ other_cents: number;
1705
+ refunds_cents: number;
1706
+ included_cents: number;
1707
+ purchased_credit_cents: number;
1708
+ overage_cents: number;
1709
+ credits_added_cents: number;
1710
+ };
1711
+ sms: {
1712
+ messages: number;
1713
+ segments: number;
1714
+ send_cents: number;
1715
+ received: number;
1716
+ received_cents: number;
1717
+ monthly_fees_cents: number;
1718
+ one_time_fees_cents: number;
1719
+ refunds_cents: number;
1720
+ countries: Array<{
1721
+ country: string;
1722
+ messages: number;
1723
+ segments: number;
1724
+ price_per_segment_cents: number | null;
1725
+ price_per_segment_cents_decimal: string | null;
1726
+ cost_cents: number;
1727
+ }>;
1728
+ received_countries: Array<{
1729
+ country: string;
1730
+ received: number;
1731
+ segments: number;
1732
+ cost_cents: number;
1733
+ }>;
1734
+ };
1735
+ on_shared_plan?: boolean;
1736
+ };
600
1737
  type ReceivedAttachmentUrl = {
601
1738
  object: "received_attachment_url";
602
1739
  /** A signed, expiring URL to download the attachment bytes. */
@@ -633,6 +1770,23 @@ type ReceivedEmail = {
633
1770
  }>;
634
1771
  received_at: string;
635
1772
  created_at: string;
1773
+ /** The conversation (`thr_…`); null until the message is threaded. */
1774
+ thread_id?: string | null;
1775
+ /** Reply-To addresses: answer these before `from` when present. */
1776
+ reply_to?: Array<string>;
1777
+ /** The headers we keep, by lower-case name: `date`, `in-reply-to`, `references`, `reply-to`, `return-path`, `list-unsubscribe` (when present). */
1778
+ headers?: Record<string, string>;
1779
+ /** A copy of one of your own sends that came back to your receiving domain. Its `text` and `html` are null: sent bodies aren't on the API (they can carry a sign-in or reset link). */
1780
+ sent_by_us?: boolean;
1781
+ };
1782
+ type ReceivedEmailRaw = {
1783
+ object: "received_email_raw";
1784
+ /** A signed, expiring URL to download the original message (.eml, RFC 5322). */
1785
+ url: string;
1786
+ /** ISO 8601 expiry of the signed URL (~5 minutes out). */
1787
+ expires_at: string;
1788
+ /** The message's size in bytes. */
1789
+ size_bytes: number;
636
1790
  };
637
1791
  type ReceivedEmailSummary = {
638
1792
  object: "received_email";
@@ -652,8 +1806,30 @@ type ReceivedEmailSummary = {
652
1806
  size: number;
653
1807
  received_at: string;
654
1808
  created_at: string;
1809
+ /** The conversation (`thr_…`); null until the message is threaded. */
1810
+ thread_id?: string | null;
1811
+ /** Reply-To addresses: answer these before `from` when present. */
1812
+ reply_to?: Array<string>;
655
1813
  attachment_count: number;
656
1814
  };
1815
+ type RequestLog = {
1816
+ object: "request_log";
1817
+ /** The log row (`rlog_…`); page with it as `after` / `before`. */
1818
+ id: string;
1819
+ /** The `x-request-id` the response carried: quote it to support. */
1820
+ request_id: string | null;
1821
+ method: string;
1822
+ /** The path called, without the host and `/api/v1` (e.g. `/email/email_…`); no query string. An email address or phone number in it reads `{email}` / `{phone}`. */
1823
+ path: string;
1824
+ /** The HTTP status answered. */
1825
+ status: number;
1826
+ /** How long the request took to answer. */
1827
+ duration_ms: number | null;
1828
+ /** The API key that called (`key_…`); null for an MCP or CLI sign-in, or a key since deleted. */
1829
+ api_key_id: string | null;
1830
+ user_agent: string | null;
1831
+ created_at: string;
1832
+ };
657
1833
  type Segment = {
658
1834
  object: "segment";
659
1835
  id: string;
@@ -682,6 +1858,32 @@ type SegmentMemberAdd = {
682
1858
  contact: string;
683
1859
  subscribed?: boolean;
684
1860
  };
1861
+ type SegmentMemberUpdate = {
1862
+ /** `false` opts the contact out of this segment's sends without removing it; `true` opts it back in. */
1863
+ subscribed: boolean;
1864
+ };
1865
+ type SegmentPreview = {
1866
+ object: "segment_preview";
1867
+ /** The saved segment, or null for an unsaved filter. */
1868
+ segment_id: string | null;
1869
+ /** Whether the saved segment is archived (a campaign can't target it); null for an unsaved filter. */
1870
+ archived: boolean | null;
1871
+ /** Contacts that match (or are members). */
1872
+ member_count: number;
1873
+ /** Of those, the ones a campaign would mail: not unsubscribed. 0 means an empty send. */
1874
+ subscribed_count: number;
1875
+ /** Up to 3 of the subscribed set. Empty without `contacts:read`. */
1876
+ sample: Array<{
1877
+ id: string;
1878
+ email: string | null;
1879
+ first_name: string | null;
1880
+ last_name: string | null;
1881
+ }>;
1882
+ };
1883
+ type SegmentPreviewRequest = {
1884
+ /** The filter to count, as a dynamic segment's `filter`. Dynamic segments only: the saved filter, evaluated live. A condition on a custom field uses the field's default_value for any contact with no value (key missing or null), the same value merge tags use; defaults are never written onto contacts. is_set / is_not_set check whether the contact itself has a value. */
1885
+ filter: unknown;
1886
+ };
685
1887
  type SegmentUpdate = {
686
1888
  name?: string;
687
1889
  description?: string | null;
@@ -725,6 +1927,30 @@ type SendEmail = {
725
1927
  /** Future send time: ISO 8601 with `Z` or a `±hh:mm` offset, normalized to UTC (reads return UTC). Up to 90 days ahead, fewer on some plans. A time in the past or under 30 seconds ahead sends immediately, so check the response `status`. */
726
1928
  scheduled_at?: string;
727
1929
  };
1930
+ type Sender = {
1931
+ object: "sender";
1932
+ id: string;
1933
+ domain_id: string;
1934
+ /** `local_part@domain`. */
1935
+ address: string;
1936
+ display_name: string | null;
1937
+ /** The From value to send with: `Display Name <address>`, or the address alone. */
1938
+ from: string;
1939
+ /** `manual` (saved by someone) or `api` (seen on a send through the API). */
1940
+ source: "manual" | "api";
1941
+ created_at: string;
1942
+ updated_at: string;
1943
+ };
1944
+ type SenderCreate = {
1945
+ /** The mailbox to save, on one of your domains (e.g. `hello@mail.acme.com`). Its domain may still be verifying. */
1946
+ address: string;
1947
+ /** Shown as the sender's name (`Acme Support <hello@…>`). */
1948
+ display_name?: string | null;
1949
+ };
1950
+ type SenderUpdate = {
1951
+ /** The new display name; `null` or `""` clears it. */
1952
+ display_name: string | null;
1953
+ };
728
1954
  type SendResult = {
729
1955
  id: string;
730
1956
  status: "queued" | "scheduled";
@@ -739,7 +1965,7 @@ type Sms$1 = {
739
1965
  status: "queued" | "scheduled" | "sending" | "sent" | "delivered" | "failed" | "suppressed" | "canceled" | "received";
740
1966
  type: "transactional" | "marketing";
741
1967
  body: string | null;
742
- /** Billed units. Outbound: segments. Inbound: 1 when the received text was charged (1¢ in the US and Canada), else 0. */
1968
+ /** Billed units. Outbound: segments. Inbound: the received text's segments when it was charged ($0.008 a segment in the US and $0.004 in Canada; a text charged before per-segment pricing was 1¢ flat and shows 1), else 0. */
743
1969
  segments: number;
744
1970
  /** Inbound only: your text this reply answers (`sms_…`), when the carrier says which. Null otherwise. */
745
1971
  in_reply_to: string | null;
@@ -747,9 +1973,10 @@ type Sms$1 = {
747
1973
  received_at: string | null;
748
1974
  /** Inbound only: the text reads like a request to stop texting ("please stop texting me") but was not an opt-out keyword, so no opt-out was recorded. Decide whether to record one (POST /v1/contacts/{id}/sms-consent, action opt_out). False for an exact keyword such as STOP (already recorded) and on outbound. */
749
1975
  looks_like_opt_out: boolean;
1976
+ /** The other party's country (ISO 3166-1 alpha-2): the recipient's on a send, the sender's on a received text. Null when the number's country isn't known. */
750
1977
  country: string | null;
751
1978
  scheduled_at: string | null;
752
- /** Legacy free-text error. Prefer `error.code`. */
1979
+ /** The sentence for why the text failed or was skipped. Match on `failure_code` (failed) or `error.code` (suppressed), not on this text. */
753
1980
  last_error: string | null;
754
1981
  /** Set on `suppressed` messages: the stable skip reason and its sentence. Null otherwise. */
755
1982
  error: {
@@ -758,6 +1985,36 @@ type Sms$1 = {
758
1985
  /** Human-readable sentence for `code`. */
759
1986
  message: string;
760
1987
  } | null;
1988
+ /** Set on `failed` messages: why it failed, as a stable code (the sentence is `last_error`). Null otherwise. Only `carrier_undelivered` (the carrier accepted the text, then could not deliver it) is billed; every other failure is not charged. Billing when a scheduled text was due: `quota_exceeded`, `overage_cap_exceeded`, `subscription_inactive`, `sms_not_in_plan` (the paid plan ended and its grace is over, or it is 100% discounted); `unsupported_country`: SMS to the country was paused; workspace holds: `workspace_suspended`, `sms_brand_blocked`; the sender: `sender_not_active`, `sender_registration_incomplete`, `sender_action_required`, `sender_use_case_mismatch`; `quiet_hours_unsatisfiable`: marketing that could not go out inside the recipient's window; ours: `channel_unavailable`, `delivery_exhausted`; `provider_rejected`: refused before any carrier; `suspected_pumping`: stopped before the carrier as suspected SMS pumping. The same code is `failed.code` on the `sms.failed` webhook. */
1989
+ failure_code?: "quota_exceeded" | "overage_cap_exceeded" | "subscription_inactive" | "sms_not_in_plan" | "unsupported_country" | "workspace_suspended" | "sms_brand_blocked" | "sender_not_active" | "sender_registration_incomplete" | "sender_action_required" | "sender_use_case_mismatch" | "quiet_hours_unsatisfiable" | "channel_unavailable" | "delivery_exhausted" | "provider_rejected" | "carrier_undelivered" | "suspected_pumping" | null;
1990
+ created_at: string;
1991
+ /** The contact this text is filed under (`con_…`), or null: an inbound text from a number that isn't a contact. Make one with POST /sms/{id}/contact. */
1992
+ contact_id?: string | null;
1993
+ /** The other party (the sender of an inbound text, the recipient of an outbound one) can't be texted by this workspace now: they texted STOP or the number is suppressed. A reply to them is refused (`opted_out`) until they text START or UNSTOP. As of this read. */
1994
+ participant_opted_out?: boolean;
1995
+ /** The tags the text was sent with (`tags` on `POST /sms`), in the order given. Empty for a text sent without tags and for received texts. */
1996
+ tags?: Array<{
1997
+ name: string;
1998
+ value: string;
1999
+ }>;
2000
+ };
2001
+ type SmsAddContact = Record<string, unknown>;
2002
+ type SmsBillableResource = {
2003
+ object: "sms_billable_resource";
2004
+ id: string;
2005
+ /** What the charge is for (a local number, a 10DLC campaign, …). */
2006
+ label: string;
2007
+ resource_type: string;
2008
+ /** For a number, which one. */
2009
+ phone_number: string | null;
2010
+ country: string | null;
2011
+ monthly_price_cents: number;
2012
+ status: string;
2013
+ billing_started_at: string | null;
2014
+ next_charge_at: string | null;
2015
+ /** A past-due number is released after this. */
2016
+ grace_until: string | null;
2017
+ billable_to_customer: boolean;
761
2018
  created_at: string;
762
2019
  };
763
2020
  type SmsBrand = {
@@ -784,8 +2041,165 @@ type SmsBrand = {
784
2041
  number_count: number;
785
2042
  /** False once the brand is locked: carriers approved or are reviewing its 10DLC registration, or senders are registered with its details. Locked brands are corrected only when carriers ask. */
786
2043
  editable: boolean;
2044
+ /** The name the business trades under, when it isn't the legal name. */
2045
+ dba_name?: string | null;
2046
+ /** The one Sender ID the brand sends under abroad (1–11 characters). */
2047
+ sender_id_name?: string | null;
2048
+ /** The brand's industry, in the carriers' words (e.g. `RETAIL`). */
2049
+ vertical?: string | null;
2050
+ /** `PRIVATE_PROFIT`, `PUBLIC_PROFIT`, `NON_PROFIT`, `GOVERNMENT`, … */
2051
+ legal_organization_type?: string | null;
2052
+ registration_number_type?: string | null;
2053
+ tax_country?: string | null;
2054
+ stock_symbol?: string | null;
2055
+ stock_exchange?: string | null;
2056
+ /** Who carriers reach about the brand (the email is `contact_email`). */
2057
+ contact?: {
2058
+ first_name: string | null;
2059
+ last_name: string | null;
2060
+ phone: string | null;
2061
+ };
2062
+ /** The registered business address. */
2063
+ address?: {
2064
+ address1: string | null;
2065
+ address2: string | null;
2066
+ city: string | null;
2067
+ state: string | null;
2068
+ zip_code: string | null;
2069
+ iso_country_code: string | null;
2070
+ };
2071
+ /** Moves on every material change; a registration keeps the revision it was submitted with. */
2072
+ revision?: number;
2073
+ archived_at?: string | null;
2074
+ created_at: string;
2075
+ };
2076
+ type SmsBrandCreate = {
2077
+ /** The brand name recipients see. */
2078
+ name: string;
2079
+ /** The brand's website; a bare host gets https://. */
2080
+ website?: string | null;
2081
+ /** An address on the website's domain (carriers check). */
2082
+ contact_email?: string | null;
2083
+ /** The one Sender ID the brand sends under abroad: 1–11 letters, digits or hyphens, with a letter. */
2084
+ sender_id_name?: string | null;
2085
+ /** The industry, in the carriers' words (e.g. `RETAIL`). */
2086
+ vertical?: string | null;
2087
+ /** The exact registered legal name. */
2088
+ legal_name?: string | null;
2089
+ dba_name?: string | null;
2090
+ /** `PRIVATE_PROFIT`, `PUBLIC_PROFIT`, `NON_PROFIT`, `GOVERNMENT`, … */
2091
+ legal_organization_type?: string | null;
2092
+ /** The company tax id (EIN in the US). Write-only: stored encrypted, read back as `tax_id_on_file`; it can be replaced, not removed. */
2093
+ tax_id?: string;
2094
+ registration_number_type?: string | null;
2095
+ /** Two-letter ISO country code. */
2096
+ tax_country?: string | null;
2097
+ stock_symbol?: string | null;
2098
+ stock_exchange?: string | null;
2099
+ contact?: {
2100
+ first_name?: string | null;
2101
+ last_name?: string | null;
2102
+ /** E.164, e.g. +12065550142. */
2103
+ phone?: string | null;
2104
+ };
2105
+ address?: {
2106
+ address1?: string | null;
2107
+ address2?: string | null;
2108
+ city?: string | null;
2109
+ /** The state or region code carriers expect (e.g. `WA`). */
2110
+ state?: string | null;
2111
+ zip_code?: string | null;
2112
+ /** Two-letter ISO country code. */
2113
+ iso_country_code?: string | null;
2114
+ };
2115
+ };
2116
+ type SmsBrandDocument = {
2117
+ object: "sms_brand_document";
2118
+ id: string;
2119
+ brand_id: string;
2120
+ kind: "registration_certificate" | "letter_of_authorization" | "proof_of_sender_id_connection" | "signatory_id" | "emirates_id" | "signatory_passport" | "establishment_card" | "power_of_attorney" | "business_license" | "tax_document" | "regulatory_license" | "carrier_registration_form" | "opt_in_screenshot" | "business_number";
2121
+ /** The slot's variant: which carrier or form a letter is addressed to (e.g. `ooredoo`), or null. */
2122
+ carrier: string | null;
2123
+ /** Set when this is one country's own version of a shared document (ADR-0115): it goes to that country only, in place of the shared file. Null for the shared file. */
2124
+ country: string | null;
2125
+ /** What the document is, in words: "Letter of authorization — Ooredoo (Qatar)". */
2126
+ label: string;
2127
+ input: "file" | "text";
2128
+ filename: string | null;
2129
+ content_type: string | null;
2130
+ size_bytes: number | null;
2131
+ /** `business_number` only. */
2132
+ text_value: string | null;
787
2133
  created_at: string;
788
2134
  };
2135
+ type SmsBrandDocumentCreate = {
2136
+ /** The document slot. File kinds: `registration_certificate`, `letter_of_authorization`, `proof_of_sender_id_connection`, `signatory_id`, `emirates_id`, `signatory_passport`, `establishment_card`, `power_of_attorney`, `business_license`, `tax_document`, `regulatory_license`, `carrier_registration_form`, `opt_in_screenshot`. Text kinds: `business_number`. A document in an occupied slot replaces the current one (the old one is kept only while a registration under review pinned it). */
2137
+ kind: "registration_certificate" | "letter_of_authorization" | "proof_of_sender_id_connection" | "signatory_id" | "emirates_id" | "signatory_passport" | "establishment_card" | "power_of_attorney" | "business_license" | "tax_document" | "regulatory_license" | "carrier_registration_form" | "opt_in_screenshot" | "business_number";
2138
+ /** The slot's variant, for documents addressed to one carrier (a letter of authorization for `ooredoo`). A Sender ID refusal names it. */
2139
+ carrier?: string;
2140
+ /** Make this one country's own version of a shared document (ADR-0115): it goes to that country only. Refused for a slot only one country reads. */
2141
+ country?: string;
2142
+ /** A file kind: a file made with `POST /files`, purpose `sms_document` (PDF, PNG or JPEG, up to 3 MB; a slot can take less, e.g. Singapore's letter is a PNG up to 400 KB) or `sms_opt_in_evidence` for `opt_in_screenshot`. */
2143
+ file_id?: string;
2144
+ /** A text kind (`business_number`). */
2145
+ text?: string;
2146
+ };
2147
+ type SmsBrandDocumentDeleted = {
2148
+ object: "sms_brand_document";
2149
+ id: string;
2150
+ deleted: true;
2151
+ /** A registration sent this file to a regulator, so it is kept as the record of what they received (not on the brand any more). */
2152
+ file_kept: boolean;
2153
+ };
2154
+ type SmsBrandDocumentUrl = {
2155
+ object: "sms_brand_document_url";
2156
+ /** A signed link to the file. It is a credential: fetch it now, don't share or log it. */
2157
+ url: string;
2158
+ /** The link stops working at this time (5 minutes). */
2159
+ expires_at: string;
2160
+ };
2161
+ type SmsBrandPatch = {
2162
+ /** The brand name recipients see. */
2163
+ name?: string | null;
2164
+ /** The brand's website; a bare host gets https://. */
2165
+ website?: string | null;
2166
+ /** An address on the website's domain (carriers check). */
2167
+ contact_email?: string | null;
2168
+ /** The one Sender ID the brand sends under abroad: 1–11 letters, digits or hyphens, with a letter. */
2169
+ sender_id_name?: string | null;
2170
+ /** The industry, in the carriers' words (e.g. `RETAIL`). */
2171
+ vertical?: string | null;
2172
+ /** The exact registered legal name. */
2173
+ legal_name?: string | null;
2174
+ dba_name?: string | null;
2175
+ /** `PRIVATE_PROFIT`, `PUBLIC_PROFIT`, `NON_PROFIT`, `GOVERNMENT`, … */
2176
+ legal_organization_type?: string | null;
2177
+ /** The company tax id (EIN in the US). Write-only: stored encrypted, read back as `tax_id_on_file`; it can be replaced, not removed. */
2178
+ tax_id?: string;
2179
+ registration_number_type?: string | null;
2180
+ /** Two-letter ISO country code. */
2181
+ tax_country?: string | null;
2182
+ stock_symbol?: string | null;
2183
+ stock_exchange?: string | null;
2184
+ contact?: {
2185
+ first_name?: string | null;
2186
+ last_name?: string | null;
2187
+ /** E.164, e.g. +12065550142. */
2188
+ phone?: string | null;
2189
+ };
2190
+ address?: {
2191
+ address1?: string | null;
2192
+ address2?: string | null;
2193
+ city?: string | null;
2194
+ /** The state or region code carriers expect (e.g. `WA`). */
2195
+ state?: string | null;
2196
+ zip_code?: string | null;
2197
+ /** Two-letter ISO country code. */
2198
+ iso_country_code?: string | null;
2199
+ };
2200
+ /** Archive (`true`) or restore (`false`) the brand; send it alone. */
2201
+ archived?: boolean;
2202
+ };
789
2203
  type SmsCampaign = {
790
2204
  object: "sms_campaign";
791
2205
  id: string;
@@ -803,7 +2217,7 @@ type SmsCampaign = {
803
2217
  until: string | null;
804
2218
  } | null;
805
2219
  pause_reason: {
806
- code: "user" | "budget_exhausted" | "plan_lapsed" | "sender_not_active" | "template_unavailable" | "workspace_suspended" | "sending_restricted" | "risk_throttled" | "sms_brand_blocked" | "subscription_inactive" | "not_drained";
2220
+ code: "user" | "budget_exhausted" | "plan_lapsed" | "sender_not_active" | "template_unavailable" | "workspace_suspended" | "sending_restricted" | "risk_throttled" | "sms_brand_blocked" | "subscription_inactive" | "not_drained" | "failure_streak";
807
2221
  message: string | null;
808
2222
  paused_at: string | null;
809
2223
  } | null;
@@ -831,10 +2245,38 @@ type SmsCampaignCreate = {
831
2245
  variable_fallbacks?: Record<string, string>;
832
2246
  scheduled_at?: string | null;
833
2247
  };
2248
+ type SmsCampaignRecipient = {
2249
+ object: "sms_campaign_recipient";
2250
+ /** This recipient row (`rcpt_…`); pass the last one as `after` for the next page. */
2251
+ id: string;
2252
+ contact_id: string | null;
2253
+ /** The number in E.164. */
2254
+ to: string | null;
2255
+ name: string | null;
2256
+ /** The carrier's answer when a text exists, else why none was sent (`skipped`). */
2257
+ status: "delivered" | "sent" | "failed" | "suppressed" | "canceled" | "deferred" | "pending" | "skipped";
2258
+ /** Why it failed or was skipped, in plain words. */
2259
+ reason: string | null;
2260
+ /** The SMS skip reason (`opted_out`, `no_marketing_consent`, …) when there is one. */
2261
+ reason_code: string | null;
2262
+ /** The text (`sms_…`); read it with `GET /sms/{id}`. */
2263
+ message_id: string | null;
2264
+ /** Segments billed. */
2265
+ segments: number | null;
2266
+ created_at: string;
2267
+ };
834
2268
  type SmsCampaignReschedule = {
835
2269
  /** ISO 8601 with `Z` or a `±hh:mm` offset; normalized to UTC (reads return the UTC time). A time without a timezone, a bare date, or natural language is a `422`. */
836
2270
  scheduled_at: string;
837
2271
  };
2272
+ type SmsCampaignResubmit = {
2273
+ /** The messaging program (`prog_…`) holding the corrected use case: fix what carriers flagged there first (PATCH /sms/messaging-programs/{id}), then resubmit from it. Its fee tier must match the campaign's (a low-volume campaign stays low-volume). */
2274
+ messaging_program_id: string;
2275
+ /** A new opt-in screenshot (POST /files, purpose `sms_opt_in_evidence`). Without one, the screenshot carriers already have is sent again. */
2276
+ opt_in_screenshot_file_id?: string;
2277
+ /** Resubmit although nothing changed since carriers sent it back, because the cause was fixed outside Unitpost (the privacy page now loads). Without it an identical resubmission is refused (`registration_unchanged`). */
2278
+ acknowledge_unchanged?: true;
2279
+ };
838
2280
  type SmsCampaignSend = {
839
2281
  scheduled_at?: string | null;
840
2282
  };
@@ -922,6 +2364,190 @@ type SmsConsentRecorded = {
922
2364
  occurred_at: string;
923
2365
  } | null;
924
2366
  };
2367
+ type SmsConsentSetup = {
2368
+ object: "sms_consent_setup";
2369
+ id: string;
2370
+ name: string;
2371
+ /** How people opt in, in the carriers' words (`DIGITAL_FORM`, `TEXT`, …): the values a program's `opt_in_type` takes. */
2372
+ type: string;
2373
+ source_url: string | null;
2374
+ is_public: boolean;
2375
+ requires_authentication: boolean;
2376
+ brand_name: string | null;
2377
+ message_purpose: string | null;
2378
+ frequency_disclosure: string | null;
2379
+ status: string;
2380
+ updated_at: string;
2381
+ };
2382
+ type SmsJoinKeyword = {
2383
+ object: "sms_join_keyword";
2384
+ /** `sjk_…`. */
2385
+ id: string;
2386
+ /** The number (`snum_…`) people text the keyword to. */
2387
+ number_id: string;
2388
+ /** As you wrote it. A text matches it whatever the case and surrounding punctuation. */
2389
+ keyword: string;
2390
+ /** The static segment (`seg_…`) a confirmed texter joins, or null. */
2391
+ segment_id: string | null;
2392
+ /** The SMS topic a confirmed texter is subscribed to, or null. */
2393
+ topic_id: string | null;
2394
+ created_at: string;
2395
+ };
2396
+ type SmsJoinKeywordCreate = {
2397
+ /** One word of 2–20 letters or digits, such as JOIN. STOP, HELP, START, YES and their variants are refused. */
2398
+ keyword: string;
2399
+ /** A static segment (`seg_…`) to add confirmed texters to. */
2400
+ segment_id?: string;
2401
+ /** An SMS topic to subscribe confirmed texters to. */
2402
+ topic_id?: string;
2403
+ };
2404
+ type SmsJoinKeywordCreated = {
2405
+ object: "sms_join_keyword";
2406
+ /** `sjk_…`. */
2407
+ id: string;
2408
+ /** The number (`snum_…`) people text the keyword to. */
2409
+ number_id: string;
2410
+ /** As you wrote it. A text matches it whatever the case and surrounding punctuation. */
2411
+ keyword: string;
2412
+ /** The static segment (`seg_…`) a confirmed texter joins, or null. */
2413
+ segment_id: string | null;
2414
+ /** The SMS topic a confirmed texter is subscribed to, or null. */
2415
+ topic_id: string | null;
2416
+ created_at: string;
2417
+ /** Set when the number's carrier registration doesn't list texting a keyword as a way to opt in: carriers can flag sign-ups its registration didn't declare, so add keyword opt-in to its use case and resubmit. Null otherwise. */
2418
+ registration_warning: string | null;
2419
+ };
2420
+ type SmsJoinKeywordList = {
2421
+ object: "list";
2422
+ data: Array<{
2423
+ object: "sms_join_keyword";
2424
+ /** `sjk_…`. */
2425
+ id: string;
2426
+ /** The number (`snum_…`) people text the keyword to. */
2427
+ number_id: string;
2428
+ /** As you wrote it. A text matches it whatever the case and surrounding punctuation. */
2429
+ keyword: string;
2430
+ /** The static segment (`seg_…`) a confirmed texter joins, or null. */
2431
+ segment_id: string | null;
2432
+ /** The SMS topic a confirmed texter is subscribed to, or null. */
2433
+ topic_id: string | null;
2434
+ created_at: string;
2435
+ }>;
2436
+ has_more: boolean;
2437
+ /** Set when the number's carrier registration doesn't list texting a keyword as a way to opt in: carriers can flag sign-ups its registration didn't declare, so add keyword opt-in to its use case and resubmit. Null otherwise. */
2438
+ registration_warning: string | null;
2439
+ };
2440
+ type SmsMessagingProgram = {
2441
+ name: string;
2442
+ description?: string | null;
2443
+ message_type: "transactional" | "marketing";
2444
+ canonical_purpose?: string | null;
2445
+ frequency_disclosure?: string | null;
2446
+ opt_in_type?: string | null;
2447
+ opt_in_workflow?: string | null;
2448
+ opt_in_confirmation?: string | null;
2449
+ help_message?: string | null;
2450
+ stop_message?: string | null;
2451
+ terms_url?: string | null;
2452
+ privacy_url?: string | null;
2453
+ monthly_volume?: string | null;
2454
+ sample_messages: Array<string>;
2455
+ embedded_links: boolean;
2456
+ embedded_link_sample?: string | null;
2457
+ embedded_phones: boolean;
2458
+ age_gated: boolean;
2459
+ provider_overrides?: {
2460
+ toll_free?: {
2461
+ use_case_category?: string;
2462
+ };
2463
+ ten_dlc?: {
2464
+ use_case?: string;
2465
+ sub_use_cases?: Array<string>;
2466
+ };
2467
+ } | null;
2468
+ recipe_id: string | null;
2469
+ /** A consent setup (`cset_…`) this workspace has. */
2470
+ consent_setup_id?: string | null;
2471
+ object: "sms_messaging_program";
2472
+ id: string;
2473
+ recipe_version: number | null;
2474
+ /** Moves on a material change; registrations keep the revision they copied. */
2475
+ revision: number;
2476
+ /** Whether the program has what a registration needs; `missing` names the fields still to fill (the wizard's own check). */
2477
+ readiness: {
2478
+ ready: boolean;
2479
+ missing: Array<string>;
2480
+ };
2481
+ archived_at: string | null;
2482
+ created_at: string;
2483
+ updated_at: string;
2484
+ };
2485
+ type SmsMessagingProgramCreate = {
2486
+ name: string;
2487
+ description?: string | null;
2488
+ message_type?: "transactional" | "marketing";
2489
+ canonical_purpose?: string | null;
2490
+ frequency_disclosure?: string | null;
2491
+ opt_in_type?: string | null;
2492
+ opt_in_workflow?: string | null;
2493
+ opt_in_confirmation?: string | null;
2494
+ help_message?: string | null;
2495
+ stop_message?: string | null;
2496
+ terms_url?: string | null;
2497
+ privacy_url?: string | null;
2498
+ monthly_volume?: string | null;
2499
+ sample_messages?: Array<string>;
2500
+ embedded_links?: boolean;
2501
+ embedded_link_sample?: string | null;
2502
+ embedded_phones?: boolean;
2503
+ age_gated?: boolean;
2504
+ provider_overrides?: {
2505
+ toll_free?: {
2506
+ use_case_category?: string;
2507
+ };
2508
+ ten_dlc?: {
2509
+ use_case?: string;
2510
+ sub_use_cases?: Array<string>;
2511
+ };
2512
+ } | null;
2513
+ /** The compliance recipe the program follows; its version is the recipe's current one. Left out, it's derived from `canonical_purpose`. */
2514
+ recipe_id?: "ACCOUNT_NOTIFICATIONS" | "SECURITY_ALERTS" | "ONE_TIME_PASSCODES" | "ORDER_UPDATES" | "APPOINTMENT_REMINDERS" | "CUSTOMER_SUPPORT" | "MARKETING_PROMOTIONS" | "OTHER_CUSTOM";
2515
+ /** A consent setup (`cset_…`) this workspace has. */
2516
+ consent_setup_id?: string | null;
2517
+ };
2518
+ type SmsMessagingProgramUpdate = {
2519
+ name?: string;
2520
+ description?: string | null;
2521
+ message_type?: "transactional" | "marketing";
2522
+ canonical_purpose?: string | null;
2523
+ frequency_disclosure?: string | null;
2524
+ opt_in_type?: string | null;
2525
+ opt_in_workflow?: string | null;
2526
+ opt_in_confirmation?: string | null;
2527
+ help_message?: string | null;
2528
+ stop_message?: string | null;
2529
+ terms_url?: string | null;
2530
+ privacy_url?: string | null;
2531
+ monthly_volume?: string | null;
2532
+ sample_messages?: Array<string>;
2533
+ embedded_links?: boolean;
2534
+ embedded_link_sample?: string | null;
2535
+ embedded_phones?: boolean;
2536
+ age_gated?: boolean;
2537
+ provider_overrides?: {
2538
+ toll_free?: {
2539
+ use_case_category?: string;
2540
+ };
2541
+ ten_dlc?: {
2542
+ use_case?: string;
2543
+ sub_use_cases?: Array<string>;
2544
+ };
2545
+ } | null;
2546
+ /** The compliance recipe the program follows; its version is the recipe's current one. Left out, it's derived from `canonical_purpose`. */
2547
+ recipe_id?: "ACCOUNT_NOTIFICATIONS" | "SECURITY_ALERTS" | "ONE_TIME_PASSCODES" | "ORDER_UPDATES" | "APPOINTMENT_REMINDERS" | "CUSTOMER_SUPPORT" | "MARKETING_PROMOTIONS" | "OTHER_CUSTOM";
2548
+ /** A consent setup (`cset_…`) this workspace has. */
2549
+ consent_setup_id?: string | null;
2550
+ };
925
2551
  type SmsNumber = {
926
2552
  object: "sms_number";
927
2553
  /** Prefixed number id, e.g. `snum_…`. */
@@ -936,7 +2562,7 @@ type SmsNumber = {
936
2562
  is_default: boolean;
937
2563
  /** ISO-3166 alpha-2 country the number was issued in (`US` for toll-free and 10DLC, `CA` for a Canadian long code). Null until recorded. */
938
2564
  country: string | null;
939
- /** Whether people can text this number: once it is active, a text to it fires the `sms.received` webhook and costs 1¢. True for US toll-free and 10DLC numbers and Canadian long codes (two-way is offered in the US and Canada only); false for Sender IDs, which are one-way, and for the simulator. */
2565
+ /** Whether people can text this number: once it is active, a text to it fires the `sms.received` webhook and costs $0.008 a segment in the US and $0.004 in Canada. True for US toll-free and 10DLC numbers and Canadian long codes (two-way is offered in the US and Canada only); false for Sender IDs, which are one-way, and for the simulator. */
940
2566
  two_way: boolean;
941
2567
  /** ISO-3166 alpha-2 countries this number can deliver to. US toll-free and 10DLC numbers reach `["US"]` only; a Canadian long code reaches `["CA"]` only. A recipient outside this list is skipped before send (status `suppressed`, not billed) rather than forwarded best-effort from a shared identity. Empty while the country is unknown. */
942
2568
  reach: Array<string>;
@@ -949,6 +2575,15 @@ type SmsNumber = {
949
2575
  } | null;
950
2576
  /** Set when status is `action_required` (what to fix: carrier feedback, why a submission failed, or a request that never reached the registry) or `rejected`. */
951
2577
  action_required_reason: string | null;
2578
+ /** What carriers sent back, item by item, when a toll-free verification needs changes (`action_required`); null otherwise. Fix it on the brand or the messaging program, then POST /sms/numbers/{id}/resubmit (ADR-0159). */
2579
+ feedback?: Array<{
2580
+ /** The carrier's reason code. */
2581
+ reason: string;
2582
+ /** What to fix, in the carrier's words (redacted). */
2583
+ description: string;
2584
+ /** A carrier help page about it, when they gave one. */
2585
+ link: string | null;
2586
+ }> | null;
952
2587
  /** Present on `sender_id` entries only. A Sender ID is ONE identity per brand enabled per country: the list still returns one entry per (Sender ID, country) so existing integrations keep working, and every entry of the same identity carries the same `sender_id_group` describing the whole set. */
953
2588
  sender_id_group: {
954
2589
  /** The Sender ID string recipients see. */
@@ -964,11 +2599,154 @@ type SmsNumber = {
964
2599
  } | null;
965
2600
  created_at: string;
966
2601
  };
967
- type SmsPatch = {
968
- /** Cancel a `queued` or `scheduled` text. Its reserved credit is refunded. */
969
- cancel?: true;
970
- /** Move a `scheduled` text to this future time: ISO 8601 with `Z` or a `±hh:mm` offset, normalized to UTC. */
971
- scheduled_at?: string;
2602
+ type SmsNumberRelease = {
2603
+ /** Release although campaigns are scheduled on this number or texts are queued through it (the 409 `sender_release_blocked` lists them): those sends fail as "sender not active". An automation that uses the number still blocks the release (`resource_in_use`). */
2604
+ force?: boolean;
2605
+ };
2606
+ type SmsNumberRequest = {
2607
+ object: "sms_number_request";
2608
+ /** The 10DLC campaign (`sreg_…`). */
2609
+ registration_id: string;
2610
+ /** The number (`snum_…`): read its state on GET /sms/numbers. It leases within minutes. */
2611
+ number_id: string;
2612
+ /** False when the campaign's number was already live: nothing was requested. */
2613
+ created: boolean;
2614
+ /** A failed number was brought back (the same row, the same committed fee). */
2615
+ retried: boolean;
2616
+ };
2617
+ type SmsNumberResubmission = {
2618
+ object: "sms_number_resubmission";
2619
+ number_id: string;
2620
+ /** The verification went back to carriers; the number reads `pending` on GET /sms/numbers until they answer. */
2621
+ status: "resubmitted";
2622
+ resubmitted: true;
2623
+ };
2624
+ type SmsNumberRetry = Record<string, unknown>;
2625
+ type SmsOptInRequest = {
2626
+ /** Which of the contact's numbers to text (E.164). Default: its primary number. */
2627
+ phone?: string;
2628
+ };
2629
+ type SmsPatch = {
2630
+ /** Cancel a `queued` or `scheduled` text. Its reserved credit is refunded (a text due in a later billing period has not been charged yet). */
2631
+ cancel?: true;
2632
+ /** Move a `scheduled` text to this future time: ISO 8601 with `Z` or a `±hh:mm` offset, normalized to UTC. A text moved into a later billing period is refunded now and paid when it sends; a text is never charged twice. */
2633
+ scheduled_at?: string;
2634
+ };
2635
+ type SmsQuote = {
2636
+ object: "sms_quote";
2637
+ /** The quote (`squote_…`). */
2638
+ id: string;
2639
+ product: "ten_dlc_brand_registration" | "ten_dlc_brand_vetting" | "ten_dlc_campaign" | "ten_dlc_number" | "long_code_number" | "toll_free_number";
2640
+ /** `open` until confirmed or `expires_at`; `ordered` once placed; `pending` while the outcome is unknown (the carrier didn't answer: a fee due now is held, monthly fees are committed, and it settles to `ordered` or `failed` from the billing ledger, so read it again; don't buy the same thing meanwhile); `failed` when the confirm bought nothing (nothing was charged; quote again). */
2641
+ status: "open" | "expired" | "confirming" | "ordered" | "pending" | "failed";
2642
+ /** What is bought, as the dashboard names it. */
2643
+ label: string;
2644
+ brand_id: string | null;
2645
+ /** The registration the order is for (a brand registration, or the campaign whose number it is). */
2646
+ registration_id: string | null;
2647
+ messaging_program_id: string | null;
2648
+ country: string | null;
2649
+ /** Charged at the confirm, from the plan's allowance (one-time fees). */
2650
+ due_now_cents: number;
2651
+ /** Charged when the number leases or carriers approve the campaign, then every month. */
2652
+ monthly_cents: number;
2653
+ currency: "usd";
2654
+ line_items: Array<{
2655
+ fee_code: string;
2656
+ label: string;
2657
+ amount_cents: number;
2658
+ cadence: "one_time" | "monthly";
2659
+ /** When the fee starts: at the confirm, when the number leases, or when carriers approve the campaign. */
2660
+ starts_when: "on_confirmation" | "number_leased" | "campaign_approved";
2661
+ }>;
2662
+ /** This workspace's carrier fees are covered by Unitpost: nothing is charged. */
2663
+ covered_by_unitpost: boolean;
2664
+ /** Confirm before this (quotes last 10 minutes). */
2665
+ expires_at: string;
2666
+ created_at: string;
2667
+ confirmed_at: string | null;
2668
+ /** What the confirmed order made; null until then. */
2669
+ order: {
2670
+ /** The carrier registration the order made (`sreg_…`). */
2671
+ registration_id: string | null;
2672
+ /** The number it ordered (`snum_…`); it leases shortly after. */
2673
+ number_id: string | null;
2674
+ /** The registration's or the number request's status as the order left it. */
2675
+ status: string | null;
2676
+ } | null;
2677
+ /** Only in the create response, once: pass it to the confirm. Stored only as a hash; a lost token means a new quote. */
2678
+ confirm_token?: string;
2679
+ };
2680
+ type SmsQuoteConfirm = {
2681
+ /** The quote's confirm token (`sqct_…`), from its create response. Single use. */
2682
+ confirm_token: string;
2683
+ };
2684
+ type SmsQuoteCreate = {
2685
+ /** What to buy. `ten_dlc_brand_registration` registers a brand with US carriers (or resubmits one they sent back; the fee is the resubmission's). `ten_dlc_brand_vetting` vets an approved brand for higher throughput. `ten_dlc_campaign` registers a 10DLC campaign from a messaging program, with its local number, which leases once carriers approve it. `ten_dlc_number` orders the number of an approved campaign that has none (a failed number whose fee is already committed is retried for free: POST /sms/registrations/{id}/number). `long_code_number` orders a local number that needs no registration (`country: "CA"`). `toll_free_number` orders a US toll-free number and files its carrier verification from the brand and a messaging program, with the opt-in evidence as a file (`opt_in_evidence_file_id`). */
2686
+ product: "ten_dlc_brand_registration" | "ten_dlc_brand_vetting" | "ten_dlc_campaign" | "ten_dlc_number" | "long_code_number" | "toll_free_number";
2687
+ /** The SMS brand (`sbrand_…`). */
2688
+ brand_id?: string;
2689
+ /** `ten_dlc_number`: the approved 10DLC campaign registration (`sreg_…`). */
2690
+ registration_id?: string;
2691
+ /** `ten_dlc_campaign`: the messaging program (`prog_…`) the campaign is registered from. */
2692
+ messaging_program_id?: string;
2693
+ /** `long_code_number`: the two-letter country (`CA`). */
2694
+ country?: string;
2695
+ /** `long_code_number`: the number's name in the dashboard. */
2696
+ display_name?: string;
2697
+ /** `ten_dlc_brand_registration`: who at the company follows the registry's email link, on the brand website's domain. Required for a public company, or when carriers ask for it; else the brand's saved one. */
2698
+ brand_verification_email?: string;
2699
+ /** `ten_dlc_brand_registration`, a resubmission: send it anyway although nothing carriers flagged changed, because the cause was fixed outside Unitpost (the website now loads, the registry was updated). Without it, an identical resubmission is refused (`registration_unchanged`, nothing charged). */
2700
+ acknowledge_unchanged?: true;
2701
+ /** `ten_dlc_campaign`: a screenshot of the opt-in (POST /files, purpose `sms_opt_in_evidence`: PNG up to 400 KB). Carriers require one for verbal or printed opt-in, or when the opt-in workflow links to no public page. */
2702
+ opt_in_screenshot_file_id?: string;
2703
+ /** `toll_free_number`: the opt-in evidence carriers review (POST /files, purpose `sms_opt_in_evidence`: a PNG up to 400 KB of the form, page or flow where people agree to receive these texts). */
2704
+ opt_in_evidence_file_id?: string;
2705
+ /** `toll_free_number`: an IRS letter (CP 575, 147C or SS-4) or registry extract showing the legal name and company ID (POST /files, purpose `sms_document`, up to 2 MB). Required when the brand is a government agency. */
2706
+ business_registration_document_file_id?: string;
2707
+ /** `toll_free_number`: the public https page where people opt in (your form or checkout). Goes into the opt-in description carriers read. */
2708
+ consent_source_url?: string;
2709
+ };
2710
+ type SmsRegistration = {
2711
+ object: "sms_registration";
2712
+ id: string;
2713
+ /** `us_ten_dlc_brand`, `us_ten_dlc_campaign`, or a toll-free verification. */
2714
+ type: string;
2715
+ brand_id: string | null;
2716
+ /** The carrier review state: `draft`, `submitted`, `reviewing`, `requires_updates`, `complete`, `closed`, … */
2717
+ status: string;
2718
+ /** The customer must act (the carrier asked for changes). */
2719
+ requires_action: boolean;
2720
+ /** The carrier's reasons when it asks for changes or closes it (`reason`, `description`, `field_path`, `link`). */
2721
+ feedback: Array<Record<string, unknown>> | null;
2722
+ use_case: string | null;
2723
+ message_type: string | null;
2724
+ parent_registration_id: string | null;
2725
+ /** 10DLC campaigns: a number is leased when carriers approve. */
2726
+ auto_provision_number: boolean | null;
2727
+ /** 10DLC campaigns: the number it backs, once one exists. */
2728
+ sender: {
2729
+ id: string;
2730
+ status: string;
2731
+ phone_number: string | null;
2732
+ } | null;
2733
+ /** 10DLC campaigns: one customer-facing state over the campaign and its number. */
2734
+ setup_state: string | null;
2735
+ /** Why an approved campaign's number isn't being leased (e.g. the plan has no carrier resources). */
2736
+ number_withheld_reason: string | null;
2737
+ archived_at: string | null;
2738
+ submitted_at: string | null;
2739
+ completed_at: string | null;
2740
+ created_at: string;
2741
+ };
2742
+ type SmsRegistrationRemove = Record<string, unknown>;
2743
+ type SmsRegistrationReplace = Record<string, unknown>;
2744
+ type SmsRegistrationResubmission = {
2745
+ object: "sms_registration_resubmission";
2746
+ registration_id: string;
2747
+ /** The registration's state after the resubmission (`submitted`, `reviewing`, …); follow it on GET /sms/registrations. */
2748
+ status: string | null;
2749
+ resubmitted: true;
972
2750
  };
973
2751
  type SmsSend = {
974
2752
  /** Recipient phone number in E.164 format, e.g. `+15551234567`. */
@@ -979,10 +2757,15 @@ type SmsSend = {
979
2757
  body: string;
980
2758
  /** Defaults to `transactional`. Use `marketing` for anything promotional (offers, sales, newsletters): marketing sends require the recipient's prior express consent on record and honor recipient-local quiet hours. Sending promotional text as `transactional` skips both checks and breaks carrier rules. */
981
2759
  type?: "transactional" | "marketing";
982
- /** Time to send at: ISO 8601 with `Z` or a `±hh:mm` offset (e.g. `2026-10-24T02:00:00Z` or `2026-10-24T09:00:00+07:00`), normalized to UTC. Omit to send immediately. A time in the past is not refused: the text goes out right away. */
2760
+ /** Time to send at: ISO 8601 with `Z` or a `±hh:mm` offset (e.g. `2026-10-24T02:00:00Z` or `2026-10-24T09:00:00+07:00`), normalized to UTC. Omit to send immediately. A time in the past is not refused: the text goes out right away. A time in a later billing period is checked now (plan, price, country) but paid when it sends, from that period's allowance, so this period's balance does not refuse it. If the plan can't cover it then, the text ends `failed` with `failure_code` set (e.g. `quota_exceeded`), and `sms.failed` fires with the same code. */
983
2761
  scheduled_at?: string;
984
2762
  /** Create a contact for this recipient if one doesn't exist yet. Defaults to false. Sends don't modify your contact list. When the recipient is already a contact, the message is attached to them either way. A contact created this way records no consent, so it can't be used for marketing sends. */
985
2763
  create_contact?: boolean;
2764
+ /** Labels to tell your texts apart later (which customer, feature or agent a text was for): up to 10 `{ name, value }` pairs, each half 1–256 ASCII letters, digits, `_` or `-`, the same rule as email tags. More than 10, or a character outside the rule, is `422 validation_error` and nothing is sent; keep anything more in your own records under the text's `id`. Returned as `tags` on the SMS object and in outbound `sms.*` webhooks; filter the list with `GET /sms?tag=name:value`. */
2765
+ tags?: Array<{
2766
+ name: string;
2767
+ value: string;
2768
+ }>;
986
2769
  };
987
2770
  type SmsStats = {
988
2771
  object: "sms_stats";
@@ -1027,11 +2810,98 @@ type SmsTemplateCreate = {
1027
2810
  name: string;
1028
2811
  body?: string;
1029
2812
  };
2813
+ type SmsTemplateTestSend = {
2814
+ /** A simulator number (`+14254147755` delivers, `+14254147167` fails) or one of GET /sms/test-destinations' verified numbers (E.164). */
2815
+ to: string;
2816
+ /** Values for the template's `{{variables}}`; every one must be filled. */
2817
+ variables?: Record<string, string>;
2818
+ /** Send from this live sender (`snum_…`); default: routed like any text. */
2819
+ sender_id?: string;
2820
+ };
2821
+ type SmsTemplateTestSendResult = {
2822
+ object: "sms_template_test_send";
2823
+ /** The test text (`sms_…`); read it with GET /sms/{id}. */
2824
+ sms_id: string;
2825
+ };
1030
2826
  type SmsTemplateUpdate = {
1031
2827
  name?: string;
1032
2828
  body?: string;
1033
2829
  status?: "draft" | "published";
1034
2830
  };
2831
+ type SmsTemplateUsage = {
2832
+ object: "sms_template_usage";
2833
+ template_id: string;
2834
+ live_campaigns: Array<{
2835
+ id: string;
2836
+ name: string;
2837
+ status: string;
2838
+ }>;
2839
+ live_automations: Array<{
2840
+ id: string;
2841
+ name: string;
2842
+ status: string;
2843
+ }>;
2844
+ pending_sends: number;
2845
+ system_locked: boolean;
2846
+ can_edit_content: boolean;
2847
+ content_blocked_reason: string | null;
2848
+ can_unpublish: boolean;
2849
+ unpublish_blocked_reason: string | null;
2850
+ };
2851
+ type SmsTestDestination = {
2852
+ object: "sms_test_destination";
2853
+ id: string;
2854
+ phone_number: string;
2855
+ /** `pending` until the code texted to it is entered in the dashboard, then `verified`. */
2856
+ status: string;
2857
+ created_at: string;
2858
+ };
2859
+ type SmsTollFreeResubmit = {
2860
+ /** The messaging program (`prog_…`) the corrected use case, samples and opt-in come from; fix what carriers flagged there (or on the brand) first. Defaults to the program the number was registered from. */
2861
+ messaging_program_id?: string;
2862
+ /** New opt-in evidence (POST /files, purpose `sms_opt_in_evidence`). Required when carriers flagged the evidence, unless `reuse_opt_in_evidence`. */
2863
+ opt_in_evidence_file_id?: string;
2864
+ /** Send the evidence on file again although carriers flagged it (it was fixed where it lives, e.g. the page it shows changed). */
2865
+ reuse_opt_in_evidence?: true;
2866
+ /** A new business registration document (POST /files, purpose `sms_document`, up to 2 MB): required when carriers flagged it. */
2867
+ business_registration_document_file_id?: string;
2868
+ /** The public https page where people opt in. */
2869
+ consent_source_url?: string;
2870
+ /** Resubmit fields carriers flagged unchanged, because the cause was fixed outside Unitpost. Without it they're refused (`flagged_fields_unchanged`). */
2871
+ acknowledge_unchanged?: true;
2872
+ };
2873
+ type SpendCaps$1 = {
2874
+ object: "spend_caps";
2875
+ /** SMS purchases by API (`POST /sms/quotes/{id}/confirm`). Purchases made in the dashboard never count. */
2876
+ sms_purchases: {
2877
+ /** The monthly cap on SMS purchases made with an API key or an app, as set. Null: none, so every API purchase is refused. 0: API purchases off. The cap that applies is the lower of this and `max_cents`. */
2878
+ cap_cents: number | null;
2879
+ /** The most a cap may be set to, and the most any cap counts as (Unitpost's limit, which staff can change). */
2880
+ max_cents: number;
2881
+ /** Counted this period: each API purchase's fee due now plus the first month of a monthly fee, for orders placed, confirming or waiting on the carrier. Failed orders count nothing. */
2882
+ spent_cents: number;
2883
+ /** The start of the UTC calendar month being counted (inclusive). */
2884
+ period_start: string;
2885
+ /** The start of the next UTC month (exclusive). */
2886
+ period_end: string;
2887
+ };
2888
+ /** The workspace's cap on its organization's shared plan, read-only: its organization sets it (`PATCH /organizations/{id}/shared-plan/workspaces/{workspace_id}`). Null when the workspace isn't on a shared plan. */
2889
+ shared_plan?: {
2890
+ /** What this workspace may draw from the shared plan each period (allowance and overage together), set by its organization. Null: no cap. */
2891
+ cap_cents: number | null;
2892
+ /** What this workspace drew this period (its own sending and SMS, never the other workspaces'). */
2893
+ spent_cents: number;
2894
+ /** The shared plan's current billing period start (inclusive). */
2895
+ period_start: string | null;
2896
+ /** The period end (exclusive). */
2897
+ period_end: string | null;
2898
+ } | null;
2899
+ };
2900
+ type SpendCapsUpdate = {
2901
+ sms_purchases?: {
2902
+ cap_cents: number | null;
2903
+ };
2904
+ };
1035
2905
  type Suppression = {
1036
2906
  object: "suppression";
1037
2907
  id: string;
@@ -1070,9 +2940,13 @@ type Template = {
1070
2940
  kind: "simple" | "designed";
1071
2941
  /** Inbox preview text: the snippet most inboxes show after the subject. Empty when unset. */
1072
2942
  preview_text?: string;
2943
+ /** `marketing` (a campaign can send it; it gets the unsubscribe footer at send) or `transactional` (receipts, sign-in codes, notifications: no footer, and campaigns refuse it). Change it with `category` on an update. */
2944
+ category?: "transactional" | "marketing";
1073
2945
  html?: string | null;
1074
2946
  /** A `design` template's body as @unitpost/email component TSX, wrapped in the `<Email …>` element that carries its theme, preview text and category — edit it and send it back as `tsx`. Null for `simple` and `code` templates. Present on single reads; omitted from list rows. */
1075
2947
  tsx?: string | null;
2948
+ /** A `simple` template's body in the Simple `text` format: edit it and send it back as `text`. Null for `design` and `code` templates, and for a Simple email the format can't carry whole (an indented line): change that one in the dashboard, or send a whole new `text`. Present on single reads; omitted from list rows. */
2949
+ text?: string | null;
1076
2950
  /** Create or update only: what changed that you didn't write, in plain words — markup the Simple format removed from `text`, `<Email>` attributes or theme values that were ignored, what an `editor` conversion flattened or couldn't keep, a `tsx` write that switched the template's editor. Absent when nothing did. Tell the user. */
1077
2951
  warnings?: Array<string>;
1078
2952
  created_at: string;
@@ -1082,7 +2956,7 @@ type Template = {
1082
2956
  type TemplateCreate = {
1083
2957
  name: string;
1084
2958
  subject?: string;
1085
- /** A Design email body (editor `design`) — the DEFAULT for anything branded: newsletters, announcements, promos, welcome and product emails, receipts. @unitpost/email component TSX: <Section>, <Row>/<Column>, <Heading>, <Text>, <Button href>, <Image src alt>, <List>, <Divider>, <Spacer>, <Link>, <Code> (props and ready-made layout bands: the `design_library` MCP tool or unitpost.com/components). Wrap the blocks in ONE <Email …> element to set the page in the same call: background-color, body-color, content-width, body-padding, body-radius, body-border-width/-style/-color, font-family, text-color, link-color, preview-text, category. <Section> holds leaf blocks and nested <Section>s (never a <Row>); <Row> holds only <Column>s. Inline <strong>/<em>/<a href> inside <Text>; no Markdown; no <html>/<body>. Images: hosted https URLs or `/img/{id}` library images only. Don't write the unsubscribe / postal-address footer — marketing templates get it at send. `{{variables}}` fill at send. Pass exactly one of `tsx`, `html` or `text`. */
2959
+ /** A Design email body (editor `design`) — the DEFAULT for anything branded: newsletters, announcements, promos, welcome and product emails, receipts. @unitpost/email component TSX: <Section>, <Row>/<Column>, <Heading>, <Text>, <Button href>, <Image src alt>, <List>, <Divider>, <Spacer>, <Link>, <Code> (props and ready-made layout bands: the `design_library` MCP tool or unitpost.com/components). Wrap the blocks in ONE <Email …> element to set the page in the same call: background-color, body-color, content-width, body-padding, body-radius, body-border-width/-style/-color, font-family, text-color, link-color, preview-text, category. <Section> holds leaf blocks and nested <Section>s (never a <Row>); <Row> holds only <Column>s. Inline <strong>/<em>/<a href> inside <Text>, and <br /> for a line break (a new line in the markup is only a space); no Markdown; no <html>/<body>. Images: hosted https URLs or `/img/{id}` library images only. Don't write the unsubscribe / postal-address footer — marketing templates get it at send. `{{variables}}` fill at send. Pass exactly one of `tsx`, `html` or `text`. */
1086
2960
  tsx?: string;
1087
2961
  /** A Code email body (editor `code`): raw HTML kept as-is in one HTML block — the Design editor can show it but not edit it piece by piece. Use it only when the user asks for HTML or brings their own; for a branded email send `tsx` instead. Write simple, email-safe HTML: tables for layout, inline styles, hosted https images. `{{variables}}` fill at send. Pass exactly one of `tsx`, `html` or `text`. */
1088
2962
  html?: string;
@@ -1117,6 +2991,33 @@ type TemplateCreate = {
1117
2991
  preview_text?: string;
1118
2992
  category?: "transactional" | "marketing";
1119
2993
  };
2994
+ type TemplateDuplicate = {
2995
+ /** The copy's name. Default: the original's with " (copy)". */
2996
+ name?: string;
2997
+ };
2998
+ type TemplateFromLibrary = {
2999
+ /** The gallery email to add (unitpost.com/templates): `welcome`, `email-verification`, `one-time-code`, `magic-link`, `password-reset`, `password-changed`, `security-alert`, `team-invite`, `receipt`, `invoice`, `payment-failed`, `subscription-renewal`, `trial-ending`, `usage-alert`, `subscription-cancelled`, `order-confirmation`, `shipping-confirmation`, `delivery-update`, `booking-confirmation`, `appointment-reminder`, `review-request`, `comment-mention`, `support-reply`, `weekly-report`, `document-to-sign`, `export-ready`, `newsletter`, `daily-brief`, `link-roundup`, `content-digest`, `essay-letter`, `founder-letter`, `community-update`, `monthly-product-update`, `july-newsletter`, `product-announcement`, `product-launch-dark`, `app-release`, `pricing-update`, `waitlist-invite`, `flash-sale`, `discount-offer`, `new-collection`, `back-in-stock`, `abandoned-cart`, `birthday-reward`, `holiday-greeting`, `new-listings`, `seasonal-menu`, `rewards-poster`, `travel-guide`, `event-invite`, `conference-invite`, `webinar-recap`, `webinar-invite`, `onboarding-tips`, `re-engagement`, `feedback-survey`, `referral`, `case-study`, `nonprofit-impact`. */
3000
+ slug: string;
3001
+ /** The template's name. Default: the gallery email's. */
3002
+ name?: string;
3003
+ };
3004
+ type TemplateRender = {
3005
+ object: "template_render";
3006
+ subject: string;
3007
+ /** The HTML a send would carry, footer and branding included. `{{unsubscribe_url}}` is a preview link. */
3008
+ html: string;
3009
+ text: string;
3010
+ /** Variables with no value: they render as a literal {{token}}, and a real send would refuse them. */
3011
+ missing_variables: Array<string>;
3012
+ };
3013
+ type TemplateRenderInput = {
3014
+ /** Values for the template's {{variables}}, as a send's `template.variables`. One with no value stays a literal {{token}} and is listed in `missing_variables`. */
3015
+ variables?: Record<string, string | number>;
3016
+ /** Render this subject instead of the template's. */
3017
+ subject?: string;
3018
+ /** Fill contact fields ({{first_name}}, custom fields) from this contact (`con_…`), as a send to them would. */
3019
+ contact_id?: string;
3020
+ };
1120
3021
  type TemplateTestSend = {
1121
3022
  to: string;
1122
3023
  subject?: string;
@@ -1138,7 +3039,7 @@ type TemplateUpdate = {
1138
3039
  name?: string;
1139
3040
  subject?: string | null;
1140
3041
  status?: "draft" | "published";
1141
- /** A Design email body (editor `design`) — the DEFAULT for anything branded: newsletters, announcements, promos, welcome and product emails, receipts. @unitpost/email component TSX: <Section>, <Row>/<Column>, <Heading>, <Text>, <Button href>, <Image src alt>, <List>, <Divider>, <Spacer>, <Link>, <Code> (props and ready-made layout bands: the `design_library` MCP tool or unitpost.com/components). Wrap the blocks in ONE <Email …> element to set the page in the same call: background-color, body-color, content-width, body-padding, body-radius, body-border-width/-style/-color, font-family, text-color, link-color, preview-text, category. <Section> holds leaf blocks and nested <Section>s (never a <Row>); <Row> holds only <Column>s. Inline <strong>/<em>/<a href> inside <Text>; no Markdown; no <html>/<body>. Images: hosted https URLs or `/img/{id}` library images only. Don't write the unsubscribe / postal-address footer — marketing templates get it at send. `{{variables}}` fill at send. Pass exactly one of `tsx`, `html` or `text`. */
3042
+ /** A Design email body (editor `design`) — the DEFAULT for anything branded: newsletters, announcements, promos, welcome and product emails, receipts. @unitpost/email component TSX: <Section>, <Row>/<Column>, <Heading>, <Text>, <Button href>, <Image src alt>, <List>, <Divider>, <Spacer>, <Link>, <Code> (props and ready-made layout bands: the `design_library` MCP tool or unitpost.com/components). Wrap the blocks in ONE <Email …> element to set the page in the same call: background-color, body-color, content-width, body-padding, body-radius, body-border-width/-style/-color, font-family, text-color, link-color, preview-text, category. <Section> holds leaf blocks and nested <Section>s (never a <Row>); <Row> holds only <Column>s. Inline <strong>/<em>/<a href> inside <Text>, and <br /> for a line break (a new line in the markup is only a space); no Markdown; no <html>/<body>. Images: hosted https URLs or `/img/{id}` library images only. Don't write the unsubscribe / postal-address footer — marketing templates get it at send. `{{variables}}` fill at send. Pass exactly one of `tsx`, `html` or `text`. */
1142
3043
  tsx?: string;
1143
3044
  /** A Code email body (editor `code`): raw HTML kept as-is in one HTML block — the Design editor can show it but not edit it piece by piece. Use it only when the user asks for HTML or brings their own; for a branded email send `tsx` instead. Write simple, email-safe HTML: tables for layout, inline styles, hosted https images. `{{variables}}` fill at send. Pass exactly one of `tsx`, `html` or `text`. */
1144
3045
  html?: string;
@@ -1171,9 +3072,55 @@ type TemplateUpdate = {
1171
3072
  };
1172
3073
  /** Inbox preview text: the snippet shown after the subject. A short line that complements the subject. Wins over a `preview-text` on <Email>. */
1173
3074
  preview_text?: string;
3075
+ /** `marketing` or `transactional`, on any editor. A campaign sends only a `marketing` template; a change is a content edit, so it is refused while a live campaign uses the template. With `tsx` it wins over `<Email category>`. */
3076
+ category?: "transactional" | "marketing";
1174
3077
  /** Convert the template to this editor. Alone (no body field) it converts the CURRENT body: simple → design keeps every line; design → code renders it to HTML (looks the same, no longer editable block by block); code → design rebuilds components where the HTML maps and keeps the rest as HTML; design or code → simple flattens to plain lines. What a conversion changes comes back in `warnings`. With a body field it must name that field's editor (`tsx` = design, `html` = code, `text` = simple). Only when the user asked to switch. */
1175
3078
  editor?: "simple" | "design" | "code";
1176
3079
  };
3080
+ type TemplateUsage = {
3081
+ object: "template_usage";
3082
+ template_id: string;
3083
+ /** The campaigns that use it, any status, newest first: the newest 25 (`campaign_count` says how many in all). */
3084
+ campaigns: Array<{
3085
+ id: string;
3086
+ name: string;
3087
+ status: "draft" | "scheduled" | "sending" | "paused" | "sent" | "canceled" | "failed";
3088
+ created_at: string;
3089
+ }>;
3090
+ /** How many campaigns use it in all. */
3091
+ campaign_count: number;
3092
+ /** Emails sent from it, all time. */
3093
+ sent_count: number;
3094
+ /** Scheduled, sending or paused campaigns: they render its current content when they send, so its content is locked. */
3095
+ live_campaigns: Array<{
3096
+ id: string;
3097
+ name: string;
3098
+ status: "draft" | "scheduled" | "sending" | "paused" | "sent" | "canceled" | "failed";
3099
+ }>;
3100
+ /** Active or paused automations whose published version sends it: it can't be unpublished or deleted. */
3101
+ live_automations: Array<{
3102
+ id: string;
3103
+ name: string;
3104
+ status: "active" | "paused";
3105
+ }>;
3106
+ /** Queued or scheduled single sends that render it when they go out. */
3107
+ pending_sends: number;
3108
+ /** A template behind Unitpost's own emails: read-only. */
3109
+ system_locked: boolean;
3110
+ /** Whether an update to its body, subject or category would be accepted now. */
3111
+ can_edit_content: boolean;
3112
+ content_blocked_reason: string | null;
3113
+ /** Whether `status: "draft"` would be accepted now. */
3114
+ can_unpublish: boolean;
3115
+ unpublish_blocked_reason: string | null;
3116
+ };
3117
+ type TemplateVersion = {
3118
+ object: "template_version";
3119
+ /** 1 is the first publish; every publish, and every content save while published, adds one. */
3120
+ version: number;
3121
+ subject: string | null;
3122
+ created_at: string;
3123
+ };
1177
3124
  type Topic = {
1178
3125
  object: "topic";
1179
3126
  id: string;
@@ -1182,6 +3129,10 @@ type Topic = {
1182
3129
  /** Which channel the topic belongs to. Email topics are managed under `/email/topics`, SMS topics under `/sms/topics`. */
1183
3130
  channel: "email" | "sms";
1184
3131
  default_opt_in: boolean;
3132
+ /** Contacts subscribed to this topic, among those the channel can reach (an email address, or an SMS number): for an opt-out topic everyone but those who opted out of it, for an opt-in topic those who opted in. A send also skips contacts unsubscribed from everything and suppressed addresses. The dashboard's count. */
3133
+ subscriber_count?: number;
3134
+ /** Reachable contacts who opted out of this topic. */
3135
+ unsubscribed_count?: number;
1185
3136
  created_at: string;
1186
3137
  updated_at: string;
1187
3138
  };
@@ -1190,6 +3141,15 @@ type TopicCreate = {
1190
3141
  description?: string;
1191
3142
  default_opt_in?: boolean;
1192
3143
  };
3144
+ /** Who to opt out: exactly one of `contact_ids`, `emails` or `segment_id`. */
3145
+ type TopicOptOut = {
3146
+ /** Contacts of this workspace (`con_…`), up to 1,000. */
3147
+ contact_ids?: Array<string>;
3148
+ /** Contacts of this workspace by email address, up to 1,000. */
3149
+ emails?: Array<string>;
3150
+ /** Every member of this segment (`seg_…`), however many. Also needs `segments:read`. */
3151
+ segment_id?: string;
3152
+ };
1193
3153
  type TopicUpdate = {
1194
3154
  name?: string;
1195
3155
  description?: string | null;
@@ -1209,11 +3169,19 @@ type Usage$1 = {
1209
3169
  wallet: {
1210
3170
  allowance_cents: number | null;
1211
3171
  used_cents: number;
3172
+ reserved_cents: number;
3173
+ fee_deficit_cents: number;
3174
+ fee_deficit_settled_cents: number;
1212
3175
  carryover_cents: number;
1213
3176
  purchased_credit_cents: number;
1214
3177
  overage_cents: number;
1215
3178
  overage_cap_cents: number | null;
1216
3179
  email_rate_per_1k_cents: number | null;
3180
+ shared_plan?: {
3181
+ allowance_cents: number | null;
3182
+ cap_cents: number | null;
3183
+ paused: boolean;
3184
+ } | null;
1217
3185
  } | null;
1218
3186
  spend: {
1219
3187
  total_cents: number;
@@ -1241,8 +3209,55 @@ type Usage$1 = {
1241
3209
  messages: number;
1242
3210
  segments: number;
1243
3211
  price_per_segment_cents: number | null;
3212
+ price_per_segment_cents_decimal?: string | null;
1244
3213
  cost_cents: number;
1245
3214
  }>;
3215
+ received_countries?: Array<{
3216
+ country: string;
3217
+ received: number;
3218
+ segments: number;
3219
+ cost_cents: number;
3220
+ }>;
3221
+ };
3222
+ limits?: {
3223
+ /** Days sent and received email, events and activity stay readable; null when unlimited or custom. */
3224
+ log_retention_days: number | null;
3225
+ /** Sending domains; null when unlimited or custom. */
3226
+ domains: number | null;
3227
+ /** Team members (seats); null when unlimited or custom. */
3228
+ team_members: number | null;
3229
+ /** Live API keys; null when unlimited or custom. */
3230
+ api_keys: number | null;
3231
+ /** Webhook endpoints; null when unlimited or custom. */
3232
+ webhook_endpoints: number | null;
3233
+ /** Hosted image storage, in MB; null when unlimited or custom. */
3234
+ image_storage_mb: number | null;
3235
+ /** Stored contacts; null when unlimited or custom. */
3236
+ contacts: number | null;
3237
+ /** How far ahead a send or campaign may be scheduled, in days; null means the platform's maximum, 90. */
3238
+ advance_scheduling_days: number | null;
3239
+ /** Automation runs included per period; null when unlimited or custom. */
3240
+ automation_runs_included: number | null;
3241
+ /** Ask Unit credits per period; null when unlimited or custom. */
3242
+ ai_credits: number | null;
3243
+ /** Toll-free numbers held at once; null when unlimited or custom. */
3244
+ sms_toll_free_numbers: number | null;
3245
+ /** Instant local numbers held per country; null when unlimited or custom. */
3246
+ sms_local_numbers_per_country: number | null;
3247
+ };
3248
+ features?: {
3249
+ /** The SMS channel: brands, senders and sends. */
3250
+ sms: boolean;
3251
+ /** Phone numbers and carrier registrations billed from the wallet. */
3252
+ sms_carrier_resources: boolean;
3253
+ /** Receiving email on your domains. */
3254
+ inbound_email: boolean;
3255
+ /** Subscription topics. */
3256
+ topics: boolean;
3257
+ /** Read-only and custom API keys, fine-tuned teammate permissions. */
3258
+ granular_permissions: boolean;
3259
+ /** Removing the Unitpost mark from the footer and unsubscribe page. */
3260
+ remove_branding: boolean;
1246
3261
  };
1247
3262
  };
1248
3263
  type Webhook = {
@@ -1252,13 +3267,24 @@ type Webhook = {
1252
3267
  url: string;
1253
3268
  events: Array<"email.sent" | "email.delivered" | "email.delivery_delayed" | "email.bounced" | "email.complained" | "email.opened" | "email.clicked" | "email.failed" | "email.scheduled" | "email.suppressed" | "email.received" | "email.*" | "sms.sent" | "sms.delivered" | "sms.failed" | "sms.scheduled" | "sms.suppressed" | "sms.received" | "sms.*" | "domain.created" | "domain.updated" | "domain.deleted" | "domain.*" | "contact.created" | "contact.updated" | "contact.deleted" | "contact.*" | "segment.joined" | "segment.left" | "segment.*" | "topic.subscribed" | "topic.unsubscribed" | "topic.*" | "campaign.paused" | "campaign.resumed" | "campaign.*" | "sms_campaign.paused" | "sms_campaign.resumed" | "sms_campaign.*" | (string & {})>;
1254
3269
  status: "enabled" | "disabled" | "suspended";
3270
+ /** `email.received` deliveries to this endpoint also carry the message's plain-text body as `text`, at most 64 KB (`text_truncated` says it was cut). Null for a copy of one of your own sends (`sent_by_us`), a message deleted since, or one with no plain-text part. Default false: metadata only. The text is read when each delivery is sent and is never kept with the event, so the deliveries log doesn't show it. */
3271
+ include_text?: boolean;
1255
3272
  created_at: string;
1256
3273
  updated_at: string;
3274
+ /** The deliveries a flush would send. Each count stops at 10,001, which means more than 10,000. Only on `GET /webhooks/{id}`. */
3275
+ backlog?: {
3276
+ /** Deliveries held while the endpoint was paused or disabled. */
3277
+ queued: number;
3278
+ /** Deliveries that failed or ran out of retries. */
3279
+ failed: number;
3280
+ };
1257
3281
  };
1258
3282
  type WebhookCreate = {
1259
3283
  url: string;
1260
3284
  events: Array<"email.sent" | "email.delivered" | "email.delivery_delayed" | "email.bounced" | "email.complained" | "email.opened" | "email.clicked" | "email.failed" | "email.scheduled" | "email.suppressed" | "email.received" | "email.*" | "sms.sent" | "sms.delivered" | "sms.failed" | "sms.scheduled" | "sms.suppressed" | "sms.received" | "sms.*" | "domain.created" | "domain.updated" | "domain.deleted" | "domain.*" | "contact.created" | "contact.updated" | "contact.deleted" | "contact.*" | "segment.joined" | "segment.left" | "segment.*" | "topic.subscribed" | "topic.unsubscribed" | "topic.*" | "campaign.paused" | "campaign.resumed" | "campaign.*" | "sms_campaign.paused" | "sms_campaign.resumed" | "sms_campaign.*" | (string & {})>;
1261
3285
  name?: string;
3286
+ /** `email.received` deliveries to this endpoint also carry the message's plain-text body as `text`, at most 64 KB (`text_truncated` says it was cut). Null for a copy of one of your own sends (`sent_by_us`), a message deleted since, or one with no plain-text part. Default false: metadata only. The text is read when each delivery is sent and is never kept with the event, so the deliveries log doesn't show it. */
3287
+ include_text?: boolean;
1262
3288
  };
1263
3289
  type WebhookCreated = Webhook & {
1264
3290
  /** The HMAC signing secret. Shown exactly once — store it now; it can never be retrieved again. Use it to verify the signature on every delivery to this endpoint. */
@@ -1288,6 +3314,22 @@ type WebhookDelivery = {
1288
3314
  /** The event's `data`, as delivered. */
1289
3315
  data: Record<string, unknown>;
1290
3316
  };
3317
+ type WebhookDeliveryReplay = {
3318
+ object: "webhook_delivery_replay";
3319
+ webhook_id: string;
3320
+ delivery_id: string;
3321
+ replayed: true;
3322
+ };
3323
+ type WebhookFlush = {
3324
+ /** Also deliver the `failed` and `exhausted` deliveries again. Default false: only the `queued` ones (held while the webhook was suspended). */
3325
+ include_failed?: boolean;
3326
+ };
3327
+ type WebhookFlushResult = {
3328
+ object: "webhook_flush";
3329
+ webhook_id: string;
3330
+ /** How many deliveries were handed back for delivery (0 when the backlog was empty). */
3331
+ flushed: number;
3332
+ };
1291
3333
  type WebhookSecretRotated = WebhookCreated & {
1292
3334
  /** Until this time deliveries are signed with the new AND the old secret, so switch your receiver to the new one before then. */
1293
3335
  previous_secret_expires_at: string;
@@ -1308,22 +3350,104 @@ type WebhookUpdate = {
1308
3350
  events?: Array<"email.sent" | "email.delivered" | "email.delivery_delayed" | "email.bounced" | "email.complained" | "email.opened" | "email.clicked" | "email.failed" | "email.scheduled" | "email.suppressed" | "email.received" | "email.*" | "sms.sent" | "sms.delivered" | "sms.failed" | "sms.scheduled" | "sms.suppressed" | "sms.received" | "sms.*" | "domain.created" | "domain.updated" | "domain.deleted" | "domain.*" | "contact.created" | "contact.updated" | "contact.deleted" | "contact.*" | "segment.joined" | "segment.left" | "segment.*" | "topic.subscribed" | "topic.unsubscribed" | "topic.*" | "campaign.paused" | "campaign.resumed" | "campaign.*" | "sms_campaign.paused" | "sms_campaign.resumed" | "sms_campaign.*" | (string & {})>;
1309
3351
  name?: string;
1310
3352
  status?: "enabled" | "disabled";
3353
+ /** `email.received` deliveries to this endpoint also carry the message's plain-text body as `text`, at most 64 KB (`text_truncated` says it was cut). Null for a copy of one of your own sends (`sent_by_us`), a message deleted since, or one with no plain-text part. Default false: metadata only. The text is read when each delivery is sent and is never kept with the event, so the deliveries log doesn't show it. */
3354
+ include_text?: boolean;
3355
+ };
3356
+ type Whoami = {
3357
+ object: "whoami";
3358
+ workspace: {
3359
+ /** The workspace's id (`ws_…`). */
3360
+ id: string;
3361
+ name: string;
3362
+ slug: string;
3363
+ };
3364
+ /** The organization the workspace belongs to. A key still reaches only its own workspace. */
3365
+ organization?: {
3366
+ /** The organization's id (`org_…`). */
3367
+ id: string;
3368
+ name: string;
3369
+ };
3370
+ /** Never the secret. */
3371
+ credential: {
3372
+ /** An API key, or a sign-in through OAuth (the CLI, an MCP client). */
3373
+ type: "api_key" | "oauth";
3374
+ /** The API key's id (`key_…`); null for a sign-in. */
3375
+ id: string | null;
3376
+ /** The API key's name; null for a sign-in. */
3377
+ name: string | null;
3378
+ /** The key's non-secret display prefix (e.g. `pk_live_a1b2`); null for a sign-in. */
3379
+ prefix: string | null;
3380
+ /** The preset the key was made with; `capabilities` is what it may do. Null for a sign-in. */
3381
+ scope: "full" | "sending" | "read_only" | null;
3382
+ created_at: string | null;
3383
+ last_used_at: string | null;
3384
+ /** The OAuth app a sign-in came from; null for a key. */
3385
+ client_id: string | null;
3386
+ client_name: string | null;
3387
+ /** The member a sign-in acts for (name, or email); null for a key. */
3388
+ user: string | null;
3389
+ };
3390
+ /** What this credential may do, after every clamp: a call that needs another one answers 403 `insufficient_scope`. */
3391
+ capabilities: Array<string>;
3392
+ rate_limit: {
3393
+ /** Requests per window, shared by every credential of the workspace. */
3394
+ limit: number;
3395
+ /** The window's length, in seconds. */
3396
+ window_seconds: number;
3397
+ };
3398
+ };
3399
+ type Workspace$1 = {
3400
+ object: "workspace";
3401
+ id: string;
3402
+ name: string;
3403
+ slug: string;
3404
+ /** The workspace image (its avatar in the dashboard). */
3405
+ image_url: string | null;
3406
+ };
3407
+ type WorkspaceKeyMint = {
3408
+ name: string;
3409
+ scope?: "full" | "sending" | "read_only";
3410
+ /** Capabilities no scope grants, added to the scope's. `sms:purchase` only on a workspace the organization pays for that has an SMS purchases cap. */
3411
+ opt_in_capabilities?: Array<"sms:purchase">;
3412
+ };
3413
+ type WorkspaceUpdate = {
3414
+ /** The workspace's new name. */
3415
+ name: string;
1311
3416
  };
1312
3417
 
3418
+ type models_Activity = Activity;
1313
3419
  type models_ApiKey = ApiKey;
1314
3420
  type models_ApiKeyCreate = ApiKeyCreate;
1315
3421
  type models_ApiKeyCreated = ApiKeyCreated;
3422
+ type models_ApiKeyUsage = ApiKeyUsage;
1316
3423
  type models_Batch = Batch;
1317
3424
  type models_BatchSend = BatchSend;
1318
3425
  type models_BatchSendResult = BatchSendResult;
3426
+ type models_BrandImport = BrandImport;
3427
+ type models_BrandImportAccept = BrandImportAccept;
3428
+ type models_BrandImportAccepted = BrandImportAccepted;
3429
+ type models_BrandImportCreate = BrandImportCreate;
1319
3430
  type models_BrandKit = BrandKit;
3431
+ type models_BrandKitCreate = BrandKitCreate;
3432
+ type models_BrandKitGraphicAdd = BrandKitGraphicAdd;
3433
+ type models_BrandKitGraphicAdded = BrandKitGraphicAdded;
1320
3434
  type models_BrandKitList = BrandKitList;
3435
+ type models_BrandKitUpdate = BrandKitUpdate;
3436
+ type models_BrandingUpdate = BrandingUpdate;
1321
3437
  type models_Campaign = Campaign;
3438
+ type models_CampaignAffectedRecipient = CampaignAffectedRecipient;
1322
3439
  type models_CampaignCreate = CampaignCreate;
3440
+ type models_CampaignDuplicate = CampaignDuplicate;
3441
+ type models_CampaignQualityRemoval = CampaignQualityRemoval;
3442
+ type models_CampaignRecipient = CampaignRecipient;
1323
3443
  type models_CampaignReschedule = CampaignReschedule;
3444
+ type models_CampaignReviewRequest = CampaignReviewRequest;
1324
3445
  type models_CampaignSend = CampaignSend;
3446
+ type models_CampaignStats = CampaignStats;
1325
3447
  type models_CampaignUpdate = CampaignUpdate;
1326
3448
  type models_Contact = Contact;
3449
+ type models_ContactActivity = ContactActivity;
3450
+ type models_ContactAddress = ContactAddress;
1327
3451
  type models_ContactCreate = ContactCreate;
1328
3452
  type models_ContactField = ContactField;
1329
3453
  type models_ContactFieldCreate = ContactFieldCreate;
@@ -1331,66 +3455,158 @@ type models_ContactFieldRename = ContactFieldRename;
1331
3455
  type models_ContactFieldUpdate = ContactFieldUpdate;
1332
3456
  type models_ContactImport = ContactImport;
1333
3457
  type models_ContactImportCreate = ContactImportCreate;
3458
+ type models_ContactSegment = ContactSegment;
1334
3459
  type models_ContactTopic = ContactTopic;
3460
+ type models_ContactTopicList = ContactTopicList;
1335
3461
  type models_ContactTopicSet = ContactTopicSet;
3462
+ type models_ContactTopicsUpdate = ContactTopicsUpdate;
1336
3463
  type models_ContactUpdate = ContactUpdate;
3464
+ type models_ContactsExport = ContactsExport;
1337
3465
  type models_Domain = Domain;
1338
3466
  type models_DomainCreate = DomainCreate;
1339
3467
  type models_DomainDiagnosis = DomainDiagnosis;
1340
3468
  type models_DomainUpdate = DomainUpdate;
3469
+ type models_EmailEvent = EmailEvent;
1341
3470
  type models_EmailPatch = EmailPatch;
1342
3471
  type models_EmailStats = EmailStats;
3472
+ type models_EmailThread = EmailThread;
3473
+ type models_EmailThreadDeleted = EmailThreadDeleted;
3474
+ type models_EmailThreadDetail = EmailThreadDetail;
3475
+ type models_EmailThreadReplyRequest = EmailThreadReplyRequest;
3476
+ type models_EmailThreadReplyResult = EmailThreadReplyResult;
3477
+ type models_File = File;
3478
+ type models_FileCreate = FileCreate;
3479
+ type models_ImageUpload = ImageUpload;
1343
3480
  type models_Job = Job;
3481
+ type models_JobDownload = JobDownload;
3482
+ type models_LibraryImage = LibraryImage;
3483
+ type models_LibraryImageCreate = LibraryImageCreate;
3484
+ type models_LibraryImageUpdate = LibraryImageUpdate;
3485
+ type models_MintedWorkspaceKey = MintedWorkspaceKey;
3486
+ type models_OrganizationPlanQuote = OrganizationPlanQuote;
3487
+ type models_OrganizationPlanQuoteConfirm = OrganizationPlanQuoteConfirm;
3488
+ type models_OrganizationPlanQuoteCreate = OrganizationPlanQuoteCreate;
3489
+ type models_OrganizationPlanStop = OrganizationPlanStop;
3490
+ type models_OrganizationSharedPlanRemoval = OrganizationSharedPlanRemoval;
3491
+ type models_OrganizationSharedPlanWorkspace = OrganizationSharedPlanWorkspace;
3492
+ type models_OrganizationSharedPlanWorkspaceAdd = OrganizationSharedPlanWorkspaceAdd;
3493
+ type models_OrganizationSharedPlanWorkspaceUpdate = OrganizationSharedPlanWorkspaceUpdate;
3494
+ type models_OrganizationWebhookDelivery = OrganizationWebhookDelivery;
3495
+ type models_OrganizationWorkspace = OrganizationWorkspace;
3496
+ type models_OrganizationWorkspaceCreate = OrganizationWorkspaceCreate;
3497
+ type models_OrganizationWorkspaceUpdate = OrganizationWorkspaceUpdate;
3498
+ type models_OrganizationWorkspaceUsage = OrganizationWorkspaceUsage;
1344
3499
  type models_ReceivedAttachmentUrl = ReceivedAttachmentUrl;
1345
3500
  type models_ReceivedEmail = ReceivedEmail;
3501
+ type models_ReceivedEmailRaw = ReceivedEmailRaw;
1346
3502
  type models_ReceivedEmailSummary = ReceivedEmailSummary;
3503
+ type models_RequestLog = RequestLog;
1347
3504
  type models_Segment = Segment;
1348
3505
  type models_SegmentCreate = SegmentCreate;
1349
3506
  type models_SegmentMember = SegmentMember;
1350
3507
  type models_SegmentMemberAdd = SegmentMemberAdd;
3508
+ type models_SegmentMemberUpdate = SegmentMemberUpdate;
3509
+ type models_SegmentPreview = SegmentPreview;
3510
+ type models_SegmentPreviewRequest = SegmentPreviewRequest;
1351
3511
  type models_SegmentUpdate = SegmentUpdate;
1352
3512
  type models_SendEmail = SendEmail;
1353
3513
  type models_SendResult = SendResult;
3514
+ type models_Sender = Sender;
3515
+ type models_SenderCreate = SenderCreate;
3516
+ type models_SenderUpdate = SenderUpdate;
3517
+ type models_SmsAddContact = SmsAddContact;
3518
+ type models_SmsBillableResource = SmsBillableResource;
1354
3519
  type models_SmsBrand = SmsBrand;
3520
+ type models_SmsBrandCreate = SmsBrandCreate;
3521
+ type models_SmsBrandDocument = SmsBrandDocument;
3522
+ type models_SmsBrandDocumentCreate = SmsBrandDocumentCreate;
3523
+ type models_SmsBrandDocumentDeleted = SmsBrandDocumentDeleted;
3524
+ type models_SmsBrandDocumentUrl = SmsBrandDocumentUrl;
3525
+ type models_SmsBrandPatch = SmsBrandPatch;
1355
3526
  type models_SmsCampaign = SmsCampaign;
1356
3527
  type models_SmsCampaignCreate = SmsCampaignCreate;
3528
+ type models_SmsCampaignRecipient = SmsCampaignRecipient;
1357
3529
  type models_SmsCampaignReschedule = SmsCampaignReschedule;
3530
+ type models_SmsCampaignResubmit = SmsCampaignResubmit;
1358
3531
  type models_SmsCampaignSend = SmsCampaignSend;
1359
3532
  type models_SmsCampaignUpdate = SmsCampaignUpdate;
1360
3533
  type models_SmsCampaignValidation = SmsCampaignValidation;
1361
3534
  type models_SmsConsent = SmsConsent;
1362
3535
  type models_SmsConsentRecord = SmsConsentRecord;
1363
3536
  type models_SmsConsentRecorded = SmsConsentRecorded;
3537
+ type models_SmsConsentSetup = SmsConsentSetup;
3538
+ type models_SmsJoinKeyword = SmsJoinKeyword;
3539
+ type models_SmsJoinKeywordCreate = SmsJoinKeywordCreate;
3540
+ type models_SmsJoinKeywordCreated = SmsJoinKeywordCreated;
3541
+ type models_SmsJoinKeywordList = SmsJoinKeywordList;
3542
+ type models_SmsMessagingProgram = SmsMessagingProgram;
3543
+ type models_SmsMessagingProgramCreate = SmsMessagingProgramCreate;
3544
+ type models_SmsMessagingProgramUpdate = SmsMessagingProgramUpdate;
1364
3545
  type models_SmsNumber = SmsNumber;
3546
+ type models_SmsNumberRelease = SmsNumberRelease;
3547
+ type models_SmsNumberRequest = SmsNumberRequest;
3548
+ type models_SmsNumberResubmission = SmsNumberResubmission;
3549
+ type models_SmsNumberRetry = SmsNumberRetry;
3550
+ type models_SmsOptInRequest = SmsOptInRequest;
1365
3551
  type models_SmsPatch = SmsPatch;
3552
+ type models_SmsQuote = SmsQuote;
3553
+ type models_SmsQuoteConfirm = SmsQuoteConfirm;
3554
+ type models_SmsQuoteCreate = SmsQuoteCreate;
3555
+ type models_SmsRegistration = SmsRegistration;
3556
+ type models_SmsRegistrationRemove = SmsRegistrationRemove;
3557
+ type models_SmsRegistrationReplace = SmsRegistrationReplace;
3558
+ type models_SmsRegistrationResubmission = SmsRegistrationResubmission;
1366
3559
  type models_SmsSend = SmsSend;
1367
3560
  type models_SmsStats = SmsStats;
1368
3561
  type models_SmsTemplate = SmsTemplate;
1369
3562
  type models_SmsTemplateCreate = SmsTemplateCreate;
3563
+ type models_SmsTemplateTestSend = SmsTemplateTestSend;
3564
+ type models_SmsTemplateTestSendResult = SmsTemplateTestSendResult;
1370
3565
  type models_SmsTemplateUpdate = SmsTemplateUpdate;
3566
+ type models_SmsTemplateUsage = SmsTemplateUsage;
3567
+ type models_SmsTestDestination = SmsTestDestination;
3568
+ type models_SmsTollFreeResubmit = SmsTollFreeResubmit;
3569
+ type models_SpendCapsUpdate = SpendCapsUpdate;
1371
3570
  type models_Suppression = Suppression;
1372
3571
  type models_SuppressionBulkResult = SuppressionBulkResult;
1373
3572
  type models_SuppressionCreate = SuppressionCreate;
1374
3573
  type models_Template = Template;
1375
3574
  type models_TemplateCreate = TemplateCreate;
3575
+ type models_TemplateDuplicate = TemplateDuplicate;
3576
+ type models_TemplateFromLibrary = TemplateFromLibrary;
3577
+ type models_TemplateRender = TemplateRender;
3578
+ type models_TemplateRenderInput = TemplateRenderInput;
1376
3579
  type models_TemplateTestSend = TemplateTestSend;
1377
3580
  type models_TemplateTestSendResult = TemplateTestSendResult;
1378
3581
  type models_TemplateUpdate = TemplateUpdate;
3582
+ type models_TemplateUsage = TemplateUsage;
3583
+ type models_TemplateVersion = TemplateVersion;
1379
3584
  type models_Topic = Topic;
1380
3585
  type models_TopicCreate = TopicCreate;
3586
+ type models_TopicOptOut = TopicOptOut;
1381
3587
  type models_TopicUpdate = TopicUpdate;
1382
3588
  type models_Webhook = Webhook;
1383
3589
  type models_WebhookCreate = WebhookCreate;
1384
3590
  type models_WebhookCreated = WebhookCreated;
1385
3591
  type models_WebhookDelivery = WebhookDelivery;
3592
+ type models_WebhookDeliveryReplay = WebhookDeliveryReplay;
3593
+ type models_WebhookFlush = WebhookFlush;
3594
+ type models_WebhookFlushResult = WebhookFlushResult;
1386
3595
  type models_WebhookSecretRotated = WebhookSecretRotated;
1387
3596
  type models_WebhookTestResult = WebhookTestResult;
1388
3597
  type models_WebhookUpdate = WebhookUpdate;
3598
+ type models_Whoami = Whoami;
3599
+ type models_WorkspaceKeyMint = WorkspaceKeyMint;
3600
+ type models_WorkspaceUpdate = WorkspaceUpdate;
1389
3601
  declare namespace models {
1390
- 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_CampaignSend as CampaignSend, 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_DomainDiagnosis as DomainDiagnosis, models_DomainUpdate as DomainUpdate, Email$1 as Email, models_EmailPatch as EmailPatch, models_EmailStats as EmailStats, Error$1 as Error, models_Job as Job, 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, Sms$1 as Sms, models_SmsBrand as SmsBrand, models_SmsCampaign as SmsCampaign, models_SmsCampaignCreate as SmsCampaignCreate, models_SmsCampaignReschedule as SmsCampaignReschedule, models_SmsCampaignSend as SmsCampaignSend, models_SmsCampaignUpdate as SmsCampaignUpdate, models_SmsCampaignValidation as SmsCampaignValidation, models_SmsConsent as SmsConsent, models_SmsConsentRecord as SmsConsentRecord, models_SmsConsentRecorded as SmsConsentRecorded, models_SmsNumber as SmsNumber, models_SmsPatch as SmsPatch, models_SmsSend as SmsSend, models_SmsStats as SmsStats, models_SmsTemplate as SmsTemplate, models_SmsTemplateCreate as SmsTemplateCreate, models_SmsTemplateUpdate as SmsTemplateUpdate, models_Suppression as Suppression, models_SuppressionBulkResult as SuppressionBulkResult, models_SuppressionCreate as SuppressionCreate, models_Template as Template, models_TemplateCreate as TemplateCreate, models_TemplateTestSend as TemplateTestSend, models_TemplateTestSendResult as TemplateTestSendResult, 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_WebhookDelivery as WebhookDelivery, models_WebhookSecretRotated as WebhookSecretRotated, models_WebhookTestResult as WebhookTestResult, models_WebhookUpdate as WebhookUpdate };
3602
+ export type { models_Activity as Activity, models_ApiKey as ApiKey, models_ApiKeyCreate as ApiKeyCreate, models_ApiKeyCreated as ApiKeyCreated, models_ApiKeyUsage as ApiKeyUsage, models_Batch as Batch, models_BatchSend as BatchSend, models_BatchSendResult as BatchSendResult, models_BrandImport as BrandImport, models_BrandImportAccept as BrandImportAccept, models_BrandImportAccepted as BrandImportAccepted, models_BrandImportCreate as BrandImportCreate, models_BrandKit as BrandKit, models_BrandKitCreate as BrandKitCreate, models_BrandKitGraphicAdd as BrandKitGraphicAdd, models_BrandKitGraphicAdded as BrandKitGraphicAdded, models_BrandKitList as BrandKitList, models_BrandKitUpdate as BrandKitUpdate, Branding$1 as Branding, models_BrandingUpdate as BrandingUpdate, models_Campaign as Campaign, models_CampaignAffectedRecipient as CampaignAffectedRecipient, models_CampaignCreate as CampaignCreate, models_CampaignDuplicate as CampaignDuplicate, models_CampaignQualityRemoval as CampaignQualityRemoval, models_CampaignRecipient as CampaignRecipient, models_CampaignReschedule as CampaignReschedule, models_CampaignReviewRequest as CampaignReviewRequest, models_CampaignSend as CampaignSend, models_CampaignStats as CampaignStats, models_CampaignUpdate as CampaignUpdate, models_Contact as Contact, models_ContactActivity as ContactActivity, models_ContactAddress as ContactAddress, 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_ContactSegment as ContactSegment, models_ContactTopic as ContactTopic, models_ContactTopicList as ContactTopicList, models_ContactTopicSet as ContactTopicSet, models_ContactTopicsUpdate as ContactTopicsUpdate, models_ContactUpdate as ContactUpdate, models_ContactsExport as ContactsExport, models_Domain as Domain, models_DomainCreate as DomainCreate, models_DomainDiagnosis as DomainDiagnosis, models_DomainUpdate as DomainUpdate, Email$1 as Email, models_EmailEvent as EmailEvent, models_EmailPatch as EmailPatch, models_EmailStats as EmailStats, models_EmailThread as EmailThread, models_EmailThreadDeleted as EmailThreadDeleted, models_EmailThreadDetail as EmailThreadDetail, models_EmailThreadReplyRequest as EmailThreadReplyRequest, models_EmailThreadReplyResult as EmailThreadReplyResult, Error$1 as Error, models_File as File, models_FileCreate as FileCreate, models_ImageUpload as ImageUpload, models_Job as Job, models_JobDownload as JobDownload, models_LibraryImage as LibraryImage, models_LibraryImageCreate as LibraryImageCreate, models_LibraryImageUpdate as LibraryImageUpdate, models_MintedWorkspaceKey as MintedWorkspaceKey, models_OrganizationPlanQuote as OrganizationPlanQuote, models_OrganizationPlanQuoteConfirm as OrganizationPlanQuoteConfirm, models_OrganizationPlanQuoteCreate as OrganizationPlanQuoteCreate, models_OrganizationPlanStop as OrganizationPlanStop, OrganizationSharedPlan$1 as OrganizationSharedPlan, models_OrganizationSharedPlanRemoval as OrganizationSharedPlanRemoval, models_OrganizationSharedPlanWorkspace as OrganizationSharedPlanWorkspace, models_OrganizationSharedPlanWorkspaceAdd as OrganizationSharedPlanWorkspaceAdd, models_OrganizationSharedPlanWorkspaceUpdate as OrganizationSharedPlanWorkspaceUpdate, models_OrganizationWebhookDelivery as OrganizationWebhookDelivery, models_OrganizationWorkspace as OrganizationWorkspace, models_OrganizationWorkspaceCreate as OrganizationWorkspaceCreate, models_OrganizationWorkspaceUpdate as OrganizationWorkspaceUpdate, models_OrganizationWorkspaceUsage as OrganizationWorkspaceUsage, models_ReceivedAttachmentUrl as ReceivedAttachmentUrl, models_ReceivedEmail as ReceivedEmail, models_ReceivedEmailRaw as ReceivedEmailRaw, models_ReceivedEmailSummary as ReceivedEmailSummary, models_RequestLog as RequestLog, models_Segment as Segment, models_SegmentCreate as SegmentCreate, models_SegmentMember as SegmentMember, models_SegmentMemberAdd as SegmentMemberAdd, models_SegmentMemberUpdate as SegmentMemberUpdate, models_SegmentPreview as SegmentPreview, models_SegmentPreviewRequest as SegmentPreviewRequest, models_SegmentUpdate as SegmentUpdate, models_SendEmail as SendEmail, models_SendResult as SendResult, models_Sender as Sender, models_SenderCreate as SenderCreate, models_SenderUpdate as SenderUpdate, Sms$1 as Sms, models_SmsAddContact as SmsAddContact, models_SmsBillableResource as SmsBillableResource, models_SmsBrand as SmsBrand, models_SmsBrandCreate as SmsBrandCreate, models_SmsBrandDocument as SmsBrandDocument, models_SmsBrandDocumentCreate as SmsBrandDocumentCreate, models_SmsBrandDocumentDeleted as SmsBrandDocumentDeleted, models_SmsBrandDocumentUrl as SmsBrandDocumentUrl, models_SmsBrandPatch as SmsBrandPatch, models_SmsCampaign as SmsCampaign, models_SmsCampaignCreate as SmsCampaignCreate, models_SmsCampaignRecipient as SmsCampaignRecipient, models_SmsCampaignReschedule as SmsCampaignReschedule, models_SmsCampaignResubmit as SmsCampaignResubmit, models_SmsCampaignSend as SmsCampaignSend, models_SmsCampaignUpdate as SmsCampaignUpdate, models_SmsCampaignValidation as SmsCampaignValidation, models_SmsConsent as SmsConsent, models_SmsConsentRecord as SmsConsentRecord, models_SmsConsentRecorded as SmsConsentRecorded, models_SmsConsentSetup as SmsConsentSetup, models_SmsJoinKeyword as SmsJoinKeyword, models_SmsJoinKeywordCreate as SmsJoinKeywordCreate, models_SmsJoinKeywordCreated as SmsJoinKeywordCreated, models_SmsJoinKeywordList as SmsJoinKeywordList, models_SmsMessagingProgram as SmsMessagingProgram, models_SmsMessagingProgramCreate as SmsMessagingProgramCreate, models_SmsMessagingProgramUpdate as SmsMessagingProgramUpdate, models_SmsNumber as SmsNumber, models_SmsNumberRelease as SmsNumberRelease, models_SmsNumberRequest as SmsNumberRequest, models_SmsNumberResubmission as SmsNumberResubmission, models_SmsNumberRetry as SmsNumberRetry, models_SmsOptInRequest as SmsOptInRequest, models_SmsPatch as SmsPatch, models_SmsQuote as SmsQuote, models_SmsQuoteConfirm as SmsQuoteConfirm, models_SmsQuoteCreate as SmsQuoteCreate, models_SmsRegistration as SmsRegistration, models_SmsRegistrationRemove as SmsRegistrationRemove, models_SmsRegistrationReplace as SmsRegistrationReplace, models_SmsRegistrationResubmission as SmsRegistrationResubmission, models_SmsSend as SmsSend, models_SmsStats as SmsStats, models_SmsTemplate as SmsTemplate, models_SmsTemplateCreate as SmsTemplateCreate, models_SmsTemplateTestSend as SmsTemplateTestSend, models_SmsTemplateTestSendResult as SmsTemplateTestSendResult, models_SmsTemplateUpdate as SmsTemplateUpdate, models_SmsTemplateUsage as SmsTemplateUsage, models_SmsTestDestination as SmsTestDestination, models_SmsTollFreeResubmit as SmsTollFreeResubmit, SpendCaps$1 as SpendCaps, models_SpendCapsUpdate as SpendCapsUpdate, models_Suppression as Suppression, models_SuppressionBulkResult as SuppressionBulkResult, models_SuppressionCreate as SuppressionCreate, models_Template as Template, models_TemplateCreate as TemplateCreate, models_TemplateDuplicate as TemplateDuplicate, models_TemplateFromLibrary as TemplateFromLibrary, models_TemplateRender as TemplateRender, models_TemplateRenderInput as TemplateRenderInput, models_TemplateTestSend as TemplateTestSend, models_TemplateTestSendResult as TemplateTestSendResult, models_TemplateUpdate as TemplateUpdate, models_TemplateUsage as TemplateUsage, models_TemplateVersion as TemplateVersion, models_Topic as Topic, models_TopicCreate as TopicCreate, models_TopicOptOut as TopicOptOut, models_TopicUpdate as TopicUpdate, Usage$1 as Usage, models_Webhook as Webhook, models_WebhookCreate as WebhookCreate, models_WebhookCreated as WebhookCreated, models_WebhookDelivery as WebhookDelivery, models_WebhookDeliveryReplay as WebhookDeliveryReplay, models_WebhookFlush as WebhookFlush, models_WebhookFlushResult as WebhookFlushResult, models_WebhookSecretRotated as WebhookSecretRotated, models_WebhookTestResult as WebhookTestResult, models_WebhookUpdate as WebhookUpdate, models_Whoami as Whoami, Workspace$1 as Workspace, models_WorkspaceKeyMint as WorkspaceKeyMint, models_WorkspaceUpdate as WorkspaceUpdate };
1391
3603
  }
1392
3604
 
1393
- /** Filters for `sms.list` / `sms.listAll`. */
3605
+ /**
3606
+ * Filters for `sms.list` / `sms.listAll`. A `q`, `type` or `sender_id` value
3607
+ * the list can't apply is ignored and named in the `Unitpost-Warning`
3608
+ * response header; `Unitpost-Strict: true` refuses it instead.
3609
+ */
1394
3610
  type SmsListParams = ListParams & {
1395
3611
  direction?: "inbound" | "outbound";
1396
3612
  status?: string;
@@ -1402,11 +3618,175 @@ type SmsListParams = ListParams & {
1402
3618
  campaign_id?: string;
1403
3619
  created_after?: string;
1404
3620
  created_before?: string;
3621
+ /**
3622
+ * Search the message text; 3 or more digits also match either number, as
3623
+ * the dashboard's Messages log searches. At most 200 characters.
3624
+ */
3625
+ q?: string;
3626
+ type?: "transactional" | "marketing";
3627
+ /** A number's `snum_…` id (from `sms.numbers()`): its texts, both directions. */
3628
+ sender_id?: string;
3629
+ /**
3630
+ * Only texts sent with these tags, `name:value`: a comma-separated string
3631
+ * (`"customer:acme,flow:reminders"`) or an array, all of which must match.
3632
+ * Received texts have none.
3633
+ */
3634
+ tag?: string | string[];
1405
3635
  };
1406
- type Result<T> = Promise<{
1407
- data: T | null;
1408
- error: UnitpostError | null;
1409
- }>;
3636
+ /**
3637
+ * Filters for `email.list` / `email.listAll`. A `q`, `source` or `outcome`
3638
+ * value the list can't apply is ignored and named in the `Unitpost-Warning`
3639
+ * response header; `Unitpost-Strict: true` refuses it instead.
3640
+ */
3641
+ type EmailListParams = ListParams & {
3642
+ status?: string;
3643
+ /** Only emails to this recipient address. */
3644
+ to?: string;
3645
+ /** Only emails to this contact (`con_…`). */
3646
+ contact_id?: string;
3647
+ campaign_id?: string;
3648
+ batch_id?: string;
3649
+ created_after?: string;
3650
+ created_before?: string;
3651
+ /**
3652
+ * An exact recipient address, or part of the subject or the sender
3653
+ * (case-insensitive), as the dashboard's Sent table searches. At most 200
3654
+ * characters.
3655
+ */
3656
+ q?: string;
3657
+ /** How the email was sent (`test`: a test send; `reply`: from the inbox). */
3658
+ source?: "api" | "smtp" | "test" | "batch" | "campaign" | "reply";
3659
+ /**
3660
+ * What happened, as a campaign's Emails tab filters (engagement overlaps
3661
+ * delivery; `failed` includes suppressed and canceled). With `campaign_id`:
3662
+ * who opened or clicked that campaign.
3663
+ */
3664
+ outcome?: "delivered" | "opened" | "clicked" | "unsubscribed" | "bounced" | "complained" | "failed" | "pending";
3665
+ };
3666
+ /**
3667
+ * Filters for `workspace.listActivity` / `workspace.listAllActivity`. An
3668
+ * unknown key is a `422`.
3669
+ */
3670
+ type ActivityListParams = ListParams & {
3671
+ /** Only changes to this kind of record. */
3672
+ subject?: Activity["subject"];
3673
+ /** With `subject`: one record's changes (its id, e.g. `dom_…`). */
3674
+ subject_id?: string;
3675
+ /** One contact's timeline (`con_…`). */
3676
+ contact_id?: string;
3677
+ /** A campaign's changes and what it led to, e.g. unsubscribes through it (`cmp_…`). */
3678
+ campaign_id?: string;
3679
+ /** Part of the record's name or the actor's (case-insensitive), at most 200 characters. */
3680
+ q?: string;
3681
+ /** `email`: without the SMS rows. */
3682
+ channel?: "email";
3683
+ };
3684
+ /**
3685
+ * Filters for `logs.list`. An unknown key, or one given twice, is a `422`.
3686
+ */
3687
+ type LogListParams = ListParams & {
3688
+ /** A status code (e.g. `429`) or a class: `2xx`, `3xx`, `4xx` or `5xx`. */
3689
+ status?: number | `${number}` | "2xx" | "3xx" | "4xx" | "5xx";
3690
+ /** Only one API key's calls (`key_…`). */
3691
+ api_key_id?: string;
3692
+ /** Only one HTTP method. */
3693
+ method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
3694
+ /** Only paths starting with this, as in the API reference (e.g. `/email/campaigns`), at most 200 characters. */
3695
+ path_prefix?: string;
3696
+ /** One call, by the `x-request-id` its response carried. */
3697
+ request_id?: string;
3698
+ /** Calls at or after this time (ISO 8601 with `Z` or an offset). */
3699
+ created_after?: string;
3700
+ /** Calls before this time (ISO 8601 with `Z` or an offset). */
3701
+ created_before?: string;
3702
+ };
3703
+ /**
3704
+ * Filters for `suppressions.list` / `suppressions.listAll`. The list ignored
3705
+ * them before, so a value it can't apply is ignored and named in the
3706
+ * `Unitpost-Warning` response header (the list answers as without it);
3707
+ * `Unitpost-Strict: true` refuses it instead.
3708
+ */
3709
+ type SuppressionListParams = ListParams & {
3710
+ /** Part of the email address (case-insensitive), at most 200 characters. */
3711
+ q?: string;
3712
+ /** Only suppressions with this reason. */
3713
+ reason?: "bounce" | "complaint" | "unsubscribe" | "manual" | "import" | "api";
3714
+ /** Only suppressions created at or after this time (ISO 8601 with `Z` or an offset). */
3715
+ created_after?: string;
3716
+ /** Only suppressions created before this time (ISO 8601 with `Z` or an offset). */
3717
+ created_before?: string;
3718
+ /** @deprecated Ignored since 2026-10-13: the list is always your own suppressions. */
3719
+ scope?: "workspace" | "platform";
3720
+ };
3721
+ /**
3722
+ * Filters for `webhooks.listDeliveries` / `webhooks.listAllDeliveries`. The
3723
+ * log ignored them before, so a value it can't apply is ignored and named in
3724
+ * the `Unitpost-Warning` response header (the list answers as without it);
3725
+ * `Unitpost-Strict: true` refuses it instead.
3726
+ */
3727
+ type WebhookDeliveryListParams = ListParams & {
3728
+ /**
3729
+ * One or more delivery statuses, comma-separated: `pending`, `queued`,
3730
+ * `retrying`, `succeeded`, `failed`, `exhausted` (e.g. `"failed,exhausted"`).
3731
+ */
3732
+ status?: string;
3733
+ /** Only deliveries of this event type, e.g. `email.bounced`. */
3734
+ event_type?: string;
3735
+ };
3736
+ /**
3737
+ * The window for `email.stats`: the last `days`, or a period (`from` / `to`).
3738
+ * A value the API can't apply is ignored and named in the `Unitpost-Warning`
3739
+ * response header; `Unitpost-Strict: true` refuses it instead.
3740
+ */
3741
+ type EmailStatsParams = {
3742
+ /** Window size in days (1–365); defaults to 30 server-side. */
3743
+ days?: number;
3744
+ /** Start of a period, with `to`, instead of `days` (ISO 8601 with `Z` or an offset; not in the future). */
3745
+ from?: string;
3746
+ /**
3747
+ * End of the period, exclusive: at most 365 days after `from`; with
3748
+ * `grain`, at most 6 hours (`5m`), 3 days (`1h`) or 93 days (`1d`).
3749
+ */
3750
+ to?: string;
3751
+ /** With `from` and `to`: also return `series`, the send volume per bucket. */
3752
+ grain?: "5m" | "1h" | "1d";
3753
+ /** With `grain`: the IANA time zone the buckets are keyed in (default `UTC`). */
3754
+ tz?: string;
3755
+ /** Count only emails sent from this sending domain (`dom_…`). */
3756
+ domain_id?: string;
3757
+ };
3758
+ /** Filters for `contacts.list` / `contacts.listAll`. */
3759
+ type ContactListParams = ListParams & {
3760
+ /** Search email, first and last name; 3 or more digits also match the SMS number. */
3761
+ q?: string;
3762
+ /** The contact-level marketing opt-out. */
3763
+ status?: "subscribed" | "unsubscribed";
3764
+ /** `has`: contacts with an SMS number; `none`: without one. */
3765
+ phone?: "has" | "none";
3766
+ /** Only members of this segment. */
3767
+ segment_id?: string;
3768
+ /** With a static `segment_id`: subscribed to, or opted out of, that segment's sends. */
3769
+ segment_subscription?: "subscribed" | "opted_out";
3770
+ };
3771
+ /** `files.list` filters. */
3772
+ type FileListParams = ListParams & {
3773
+ /** Only the files made for this purpose. */
3774
+ purpose?: File["purpose"];
3775
+ };
3776
+ /** What `files.upload` sends: a local `path` or the bytes in `data`. */
3777
+ interface FileUploadInput {
3778
+ /** A local file to read (Node's `fs`). Give this or `data`. */
3779
+ path?: string;
3780
+ /** The bytes, when you already hold them (a `Buffer` works). Give this or `path`. */
3781
+ data?: Uint8Array;
3782
+ /** What the file is for, which sets what it may be and how big. */
3783
+ purpose: FileCreate["purpose"];
3784
+ /** The file's type. The API checks it against the bytes. */
3785
+ contentType: NonNullable<FileCreate["content_type"]>;
3786
+ /** A name for the file. Defaults to `path`'s base name. */
3787
+ filename?: string;
3788
+ }
3789
+ type Result<T> = Promise<ApiResult<T>>;
1410
3790
  interface SendOptions {
1411
3791
  idempotencyKey?: string;
1412
3792
  }
@@ -1421,6 +3801,18 @@ declare class Sms extends Resource {
1421
3801
  readonly campaigns: SmsCampaigns;
1422
3802
  /** SMS subscription topics (independent from email topics). */
1423
3803
  readonly topics: SmsTopics;
3804
+ /** Messaging programs: what a sender registration says your texts are for. */
3805
+ readonly messagingPrograms: SmsMessagingPrograms;
3806
+ /** The verified numbers a template test may text. */
3807
+ readonly testDestinations: SmsTestDestinations;
3808
+ /** Where and how people opt in to your texts. */
3809
+ readonly consentSetups: SmsConsentSetups;
3810
+ /** What the workspace pays for SMS every month. */
3811
+ readonly billing: SmsBilling;
3812
+ /** Carrier registrations, their review state, and fixing what carriers sent back. */
3813
+ readonly registrations: SmsRegistrations;
3814
+ /** Buy carrier resources: price an order, then confirm it. */
3815
+ readonly quotes: SmsQuotes;
1424
3816
  constructor(http: HttpClient);
1425
3817
  /**
1426
3818
  * Send or schedule an SMS message.
@@ -1433,6 +3825,18 @@ declare class Sms extends Resource {
1433
3825
  send(body: SmsSend, opts?: SendOptions): Result<Sms$1>;
1434
3826
  /** Retrieve one SMS message's status and delivery state. */
1435
3827
  get(id: string): Result<Sms$1>;
3828
+ /**
3829
+ * Make the sender of a received text a contact, or file the text under the
3830
+ * contact that already has the number. Phone only: no name and no consent
3831
+ * (texting a number isn't consent to marketing). Every earlier text with
3832
+ * that number that no contact holds is filed under the contact too, so
3833
+ * `contact_id` reads it from then on. Answers the contact: `201` when it is
3834
+ * new, `200` when it existed, so a retry is safe. It counts against the
3835
+ * plan's contacts (`403 limit_reached` when full), and a number that texted
3836
+ * STOP stays opted out. A text you sent is refused (`409`). Needs
3837
+ * `contacts:write` and `sms:read`.
3838
+ */
3839
+ addContact(id: string): Result<Contact>;
1436
3840
  /**
1437
3841
  * Cancel a queued/scheduled SMS (`{ cancel: true }` — its reserved credit is
1438
3842
  * refunded) or move a scheduled one (`{ scheduled_at }`).
@@ -1454,10 +3858,58 @@ declare class Sms extends Resource {
1454
3858
  * `status` says whether you or the carrier is the blocker, and `missing`
1455
3859
  * lists exactly what is still required.
1456
3860
  *
1457
- * Read-only — creating a brand is a paid carrier submission and is only
1458
- * available in the dashboard.
3861
+ * Create and edit a brand with `createBrand` / `updateBrand` (free).
3862
+ * Registering it with carriers is a paid order: `sms.quotes.create` prices
3863
+ * it, `sms.quotes.confirm` places it. Needs `sms:read`.
1459
3864
  */
1460
3865
  brands(params?: ListParams): Result<ListResponse<SmsBrand>>;
3866
+ /**
3867
+ * Create a brand (201): the business identity carriers register before
3868
+ * they approve a number. A draft may be partial (only `name` is required);
3869
+ * `missing` says what is still needed. Free, with no carrier call; one brand
3870
+ * per website domain (`409`). The tax id is write-only: stored encrypted,
3871
+ * read back as `tax_id_on_file`. Registering the brand with carriers is a
3872
+ * paid order through `sms.quotes`. Needs `sms:manage`. Pass an
3873
+ * `idempotencyKey` so a retry never makes a second brand; one is generated
3874
+ * when you don't.
3875
+ */
3876
+ createBrand(body: SmsBrandCreate, opts?: SendOptions): Result<SmsBrand>;
3877
+ /** One brand with every field you can edit, its `status` and `missing` list. Needs `sms:read`. */
3878
+ getBrand(id: string): Result<SmsBrand>;
3879
+ /**
3880
+ * Edit a brand: only the fields you send change, `null` clears an optional
3881
+ * one; send `{ archived }` alone to archive or restore it. The tax id is
3882
+ * write-only. A locked brand (`editable: false`: carriers are reviewing or
3883
+ * approved it, or it has numbers) refuses carrier-field edits with
3884
+ * `409 brand_locked`, `details` naming each field, except those a
3885
+ * correction request opened. Needs `sms:manage`.
3886
+ */
3887
+ updateBrand(id: string, body: SmsBrandPatch): Result<SmsBrand>;
3888
+ /**
3889
+ * A brand's documents (`sdoc_` ids): the files and numbers a country's
3890
+ * carriers ask for, one per slot (`kind`, plus `carrier` / `country` for a
3891
+ * variant). Needs `sms:read`.
3892
+ */
3893
+ listBrandDocuments(brandId: string): Result<ListResponse<SmsBrandDocument>>;
3894
+ /**
3895
+ * Add a document to a brand's slot (201): a file kind takes `file_id` (a
3896
+ * file from `files.create` / `files.upload`, purpose `sms_document`, or
3897
+ * `sms_opt_in_evidence` for `opt_in_screenshot`), a text kind takes `text`.
3898
+ * A document in an occupied slot replaces the current one. Needs
3899
+ * `sms:manage`. Pass an `idempotencyKey` so a retry adds one document; one
3900
+ * is generated when you don't.
3901
+ */
3902
+ addBrandDocument(brandId: string, body: SmsBrandDocumentCreate, opts?: SendOptions): Result<SmsBrandDocument>;
3903
+ /** One brand document. Needs `sms:read`. */
3904
+ getBrandDocument(brandId: string, documentId: string): Result<SmsBrandDocument>;
3905
+ /** Remove a brand document from its slot. Needs `sms:manage`. */
3906
+ removeBrandDocument(brandId: string, documentId: string): Result<SmsBrandDocumentDeleted>;
3907
+ /**
3908
+ * A 5-minute signed link to a file document's bytes. The link is a bearer
3909
+ * credential: fetch it yourself, don't log or share it. An identity
3910
+ * document needs `sms:manage`; the rest `sms:read`.
3911
+ */
3912
+ brandDocumentUrl(brandId: string, documentId: string): Result<SmsBrandDocumentUrl>;
1461
3913
  /**
1462
3914
  * List SMS phone numbers.
1463
3915
  *
@@ -1465,10 +3917,62 @@ declare class Sms extends Resource {
1465
3917
  * `phone_number` until carriers approve it, and a `simulator` number only
1466
3918
  * reaches verified test destinations.
1467
3919
  *
1468
- * Read-only — requesting or releasing a number is only available in the
1469
- * dashboard.
3920
+ * Order a number through `sms.quotes`; release one with `releaseNumber`.
1470
3921
  */
1471
3922
  numbers(params?: ListParams): Result<ListResponse<SmsNumber>>;
3923
+ /**
3924
+ * One number, or one country of a Sender ID (`snum_…`), as `numbers()`
3925
+ * reads it: its status, what carriers sent back (`feedback`) and its use
3926
+ * case. Read a resubmit, a retry or a release back with it. Needs
3927
+ * `sms:read`.
3928
+ */
3929
+ getNumber(numberId: string): Result<SmsNumber>;
3930
+ /**
3931
+ * Release a number, or one country of a Sender ID, back to the carrier.
3932
+ * PERMANENT: it stops sending at once, reads `released` from then on and
3933
+ * can't be had back; its monthly fee ends with it (no proration), and a
3934
+ * 10DLC number's campaign registration goes with it. Refused while an
3935
+ * automation uses it (`409 resource_in_use`) and, unless `force: true`,
3936
+ * while campaigns are scheduled on it or texts are queued through it
3937
+ * (`409 sender_release_blocked`, counts in `error.blockers`). Releasing a
3938
+ * released number answers it. Needs `sms:manage`. Pass an `idempotencyKey`
3939
+ * so a retry releases once; one is generated when you don't.
3940
+ */
3941
+ releaseNumber(numberId: string, body?: SmsNumberRelease, opts?: SendOptions): Result<SmsNumber>;
3942
+ /**
3943
+ * Resubmit a toll-free verification carriers sent back (free): fix what
3944
+ * the number's `feedback` names, then send the new evidence
3945
+ * (`opt_in_evidence_file_id`, or `reuse_opt_in_evidence`), a
3946
+ * `business_registration_document_file_id`, `consent_source_url`, or
3947
+ * `acknowledge_unchanged`. Needs `sms:manage`. Pass an `idempotencyKey` so
3948
+ * a retry resubmits once; one is generated when you don't.
3949
+ */
3950
+ resubmitNumber(numberId: string, body: SmsTollFreeResubmit, opts?: SendOptions): Result<SmsNumberResubmission>;
3951
+ /**
3952
+ * Text-to-join: the words people can text this number (`snum_…`) to sign
3953
+ * up. `registration_warning` is set when the number's carrier registration
3954
+ * doesn't list keyword opt-in, so carriers could flag the sign-ups. Needs
3955
+ * `sms:read`.
3956
+ */
3957
+ listJoinKeywords(numberId: string): Result<SmsJoinKeywordList>;
3958
+ /**
3959
+ * Add a join keyword to a number. A text that is exactly this word (any
3960
+ * case) gets the double opt-in request ("Reply YES to get … texts"); the
3961
+ * YES records marketing consent, makes the texter a contact if they aren't
3962
+ * one, and adds them to `segment_id` (a static segment) and/or `topic_id`
3963
+ * (an SMS topic). A keyword is never consent by itself and never lifts a
3964
+ * STOP. STOP, HELP, START, YES and their variants are refused; at most 10
3965
+ * per number, and only on numbers people can text back. Answers the keyword
3966
+ * with `registration_warning`: `201` when added, `200` when the same keyword
3967
+ * with the same settings is already there, so a retry is safe (the same
3968
+ * word with other settings is `409`). Needs `sms:manage`.
3969
+ */
3970
+ addJoinKeyword(numberId: string, body: SmsJoinKeywordCreate): Result<SmsJoinKeywordCreated>;
3971
+ /**
3972
+ * Remove a join keyword (`sjk_…`): it stops answering. People who already
3973
+ * joined keep their consent, contact and memberships. Needs `sms:manage`.
3974
+ */
3975
+ removeJoinKeyword(numberId: string, keywordId: string): Result<null>;
1472
3976
  /**
1473
3977
  * SMS delivery stats over a rolling window: queued, sent, delivered,
1474
3978
  * failed, suppressed, canceled, inbound and segments billed, with delivery,
@@ -1483,6 +3987,12 @@ declare class Sms extends Resource {
1483
3987
  smsConsent(contactId: string): Result<SmsConsent>;
1484
3988
  /** Record an SMS consent change (opt-in or opt-out) for a contact. */
1485
3989
  recordSmsConsent(contactId: string, body: SmsConsentRecord): Result<SmsConsentRecorded>;
3990
+ /**
3991
+ * Text the contact a request to reply YES to confirm marketing texts. It
3992
+ * sends a real text, so pass an `idempotencyKey` to make a retry safe; one is
3993
+ * generated when you don't.
3994
+ */
3995
+ requestSmsOptIn(contactIdOrEmail: string, body?: SmsOptInRequest, opts?: SendOptions): Result<Sms$1>;
1486
3996
  }
1487
3997
  /**
1488
3998
  * SMS templates (`/sms/templates`). Draft → published like email templates;
@@ -1495,6 +4005,23 @@ declare class SmsTemplates extends Resource {
1495
4005
  get(id: string): Result<SmsTemplate>;
1496
4006
  update(id: string, body: SmsTemplateUpdate): Result<SmsTemplate>;
1497
4007
  delete(id: string): Result<null>;
4008
+ /**
4009
+ * What uses the template, and whether a change would be accepted now: its
4010
+ * live campaigns and automations, queued texts, and `can_edit_content` /
4011
+ * `can_unpublish` with the reason when not. Read it before an edit or a
4012
+ * delete. Needs `templates:read`.
4013
+ */
4014
+ usage(id: string): Result<SmsTemplateUsage>;
4015
+ /**
4016
+ * Send ONE test text of the template to `to`, which must be a simulator
4017
+ * number (`+14254147755` delivers, `+14254147167` fails) or a verified
4018
+ * number from `sms.testDestinations.list()` (any other is a `403`). Every `{{variable}}`
4019
+ * needs a value in `variables` (`422`). It goes from `sender_id`, or is
4020
+ * routed by the destination's country. It is a real text, billed like any.
4021
+ * Needs `sms:send`. Pass an `idempotencyKey` so a retry never texts twice;
4022
+ * one is generated when you don't.
4023
+ */
4024
+ testSend(id: string, body: SmsTemplateTestSend, opts?: SendOptions): Result<SmsTemplateTestSendResult>;
1498
4025
  }
1499
4026
  /** SMS subscription topics (`/sms/topics`); `delete` archives. */
1500
4027
  declare class SmsCampaigns extends Resource {
@@ -1520,6 +4047,15 @@ declare class SmsCampaigns extends Resource {
1520
4047
  cancel(id: string): Result<SmsCampaign>;
1521
4048
  pause(id: string): Result<SmsCampaign>;
1522
4049
  resume(id: string): Result<SmsCampaign>;
4050
+ /** Move a scheduled campaign back to draft so it can be edited; clears its send time. */
4051
+ unschedule(id: string): Result<SmsCampaign>;
4052
+ /**
4053
+ * Copy a campaign into a new draft (201). Pass an `idempotencyKey` so a
4054
+ * retry returns the same copy; one is generated when you don't.
4055
+ */
4056
+ duplicate(id: string, body?: {
4057
+ name?: string;
4058
+ }, opts?: SendOptions): Result<SmsCampaign>;
1523
4059
  reschedule(id: string, body: SmsCampaignReschedule): Result<SmsCampaign>;
1524
4060
  /**
1525
4061
  * Who the campaign would reach if sent now (non-mutating). A large audience
@@ -1528,6 +4064,21 @@ declare class SmsCampaigns extends Resource {
1528
4064
  * (`"job"`).
1529
4065
  */
1530
4066
  validate(id: string): Result<SmsCampaignValidation | Job>;
4067
+ /**
4068
+ * How each recipient fared: the carrier's answer for a text that went out
4069
+ * (`delivered`, `sent`, `failed`, …), or why none was sent (`skipped`, with
4070
+ * `reason_code`). Newest first, cursor-paginated on `id`; `q` matches digits
4071
+ * of the number. `skipped_by_reason` counts skipped recipients over the
4072
+ * whole campaign.
4073
+ */
4074
+ listRecipients(id: string, params?: ListParams & {
4075
+ q?: string;
4076
+ }): Result<ListResponse<SmsCampaignRecipient> & {
4077
+ skipped_by_reason?: {
4078
+ reason: string;
4079
+ count: number;
4080
+ }[];
4081
+ }>;
1531
4082
  }
1532
4083
  declare class SmsTopics extends Resource {
1533
4084
  list(params?: ListParams): Result<ListResponse<Topic>>;
@@ -1536,12 +4087,186 @@ declare class SmsTopics extends Resource {
1536
4087
  get(id: string): Result<Topic>;
1537
4088
  update(id: string, body: TopicUpdate): Result<Topic>;
1538
4089
  delete(id: string): Result<null>;
4090
+ /**
4091
+ * Opt many contacts out of this SMS topic as a background job (202, the
4092
+ * `Job`): `{ contact_ids }` or `{ emails }` (up to 1,000) or
4093
+ * `{ segment_id }` (every member). Follow it with `jobs.get(id)`. Pass an
4094
+ * `idempotencyKey` so a retry answers the same job; one is generated when
4095
+ * you don't. There is no bulk opt-in.
4096
+ */
4097
+ optOut(id: string, body: TopicOptOut, opts?: SendOptions): Result<Job>;
4098
+ }
4099
+ /**
4100
+ * Messaging programs (`/sms/messaging-programs`): what a sender registration
4101
+ * says your texts are for, how people opt in, the help and stop replies and
4102
+ * sample messages. A registration copies the program when it is submitted, so
4103
+ * a later edit never changes one. Reads need `sms:read`; the writes need
4104
+ * `sms:manage`, which FULL keys have and SENDING keys don't. Submitting a
4105
+ * registration is a paid order through `sms.quotes`.
4106
+ */
4107
+ declare class SmsMessagingPrograms extends Resource {
4108
+ /**
4109
+ * Your programs, newest first, cursor-paginated (`limit`, `after`,
4110
+ * `before`); `{ archived: true }` includes archived ones.
4111
+ */
4112
+ list(params?: ListParams & {
4113
+ archived?: boolean;
4114
+ }): Result<ListResponse<SmsMessagingProgram>>;
4115
+ /**
4116
+ * Create a program (201; `name` is required). Each field is checked by the
4117
+ * carriers' rules: lengths, help and stop replies that are a sentence and
4118
+ * not just a keyword, links to a real web address. Pass an
4119
+ * `idempotencyKey` so a retry never makes a second one; one is generated
4120
+ * when you don't.
4121
+ */
4122
+ create(body: SmsMessagingProgramCreate, opts?: SendOptions): Result<SmsMessagingProgram>;
4123
+ /** One program, archived ones too. */
4124
+ get(id: string): Result<SmsMessagingProgram>;
4125
+ /**
4126
+ * Edit a program: only the fields you send change, `null` clears one, and
4127
+ * the result must still pass the carriers' rules. `revision` moves on a
4128
+ * material change. An archived program is a `409`: `duplicate` it to keep
4129
+ * editing.
4130
+ */
4131
+ update(id: string, body: SmsMessagingProgramUpdate): Result<SmsMessagingProgram>;
4132
+ /** Archive a program. Registrations that copied it keep their copy. */
4133
+ delete(id: string): Result<null>;
4134
+ /**
4135
+ * Copy a program (an archived one too) into a new editable one named
4136
+ * "… (copy)" at revision 1 (201). It sends no body. Pass an
4137
+ * `idempotencyKey` so a retry returns the same copy; one is generated when
4138
+ * you don't.
4139
+ */
4140
+ duplicate(id: string, opts?: SendOptions): Result<SmsMessagingProgram>;
4141
+ }
4142
+ /**
4143
+ * Test numbers (`/sms/test-destinations`): the numbers a template test may
4144
+ * text besides the simulator, `pending` until the code texted to one is
4145
+ * entered, then `verified`. Adding and verifying one stays in the dashboard
4146
+ * (Phone numbers → Testing), because it proves the phone is yours. `list`
4147
+ * needs `sms:read`; `delete` needs `sms:manage`.
4148
+ */
4149
+ declare class SmsTestDestinations extends Resource {
4150
+ /** Your test numbers, newest first, cursor-paginated (`limit`, `after`, `before`). */
4151
+ list(params?: ListParams): Result<ListResponse<SmsTestDestination>>;
4152
+ /** Remove a test number; template tests can no longer text it. */
4153
+ delete(id: string): Result<null>;
4154
+ }
4155
+ /**
4156
+ * Consent setups (`/sms/consent-setups`): where and how people opt in to your
4157
+ * texts, the form or page and the brand and purpose it discloses. A messaging
4158
+ * program points at one with `consent_setup_id`. Needs `sms:read`.
4159
+ */
4160
+ declare class SmsConsentSetups extends Resource {
4161
+ /**
4162
+ * Your consent setups except archived ones, newest first, cursor-paginated
4163
+ * (`limit`, `after`, `before`).
4164
+ */
4165
+ list(params?: ListParams): Result<ListResponse<SmsConsentSetup>>;
4166
+ }
4167
+ /** SMS billing (`/sms/billing`). Needs `sms:read`; buying goes through `sms.quotes`. */
4168
+ declare class SmsBilling extends Resource {
4169
+ /**
4170
+ * What the workspace pays for SMS every month: each number and 10DLC
4171
+ * campaign, its monthly price, status and next charge, and for a past-due
4172
+ * number the date it is released (`grace_until`). Newest first,
4173
+ * cursor-paginated (`limit`, `after`, `before`).
4174
+ */
4175
+ listResources(params?: ListParams): Result<ListResponse<SmsBillableResource>>;
4176
+ }
4177
+ /**
4178
+ * Carrier purchases (`/sms/quotes`): register a 10DLC brand, vet it, register
4179
+ * a campaign, order a number. Each is two calls: `create` prices the order
4180
+ * and binds what it buys, `confirm` places it at the price you showed.
4181
+ */
4182
+ declare class SmsQuotes extends Resource {
4183
+ /**
4184
+ * Price an order (201). The quote binds the action and what it buys, and
4185
+ * returns `due_now_cents`, `monthly_cents`, `line_items` and a single-use
4186
+ * `confirm_token` (only in this response). It lasts 10 minutes and charges
4187
+ * nothing. Needs `sms:manage`.
4188
+ */
4189
+ create(body: SmsQuoteCreate): Result<SmsQuote>;
4190
+ /** One quote: its price, status and, once confirmed, what the order made. Needs `sms:read`. */
4191
+ get(id: string): Result<SmsQuote>;
4192
+ /**
4193
+ * Place the quoted order and charge it. Show the person the quote's price
4194
+ * and get their yes first. Needs `sms:purchase`, which a key or app has
4195
+ * only when a member who holds it ticked it, and the owner's monthly cap for
4196
+ * SMS purchases by API. A changed price or content answers `409`: quote
4197
+ * again. If you don't pass `idempotencyKey`, one is generated so a retry
4198
+ * can't buy twice; pass your own to replay the same answer later.
4199
+ */
4200
+ confirm(id: string, body: SmsQuoteConfirm, opts?: SendOptions): Result<SmsQuote>;
4201
+ }
4202
+ /**
4203
+ * Carrier registrations (`/sms/registrations`): 10DLC brand and campaign
4204
+ * registrations and toll-free verifications, with their review state and the
4205
+ * carrier's feedback. Submitting one is a purchase through `sms.quotes`;
4206
+ * fixing a campaign carriers sent back is `resubmit`, a failed number whose
4207
+ * fee is paid is `requestNumber`, taking down a 10DLC setup is `remove`, and
4208
+ * archiving an approved brand registration to register it again is
4209
+ * `replace`. Reads need `sms:read`, the writes `sms:manage`.
4210
+ */
4211
+ declare class SmsRegistrations extends Resource {
4212
+ /**
4213
+ * Your registrations, newest first, cursor-paginated (`limit`, `after`,
4214
+ * `before`). A 10DLC campaign also carries the number it backs (`sender`)
4215
+ * and one `setup_state`.
4216
+ */
4217
+ list(params?: ListParams): Result<ListResponse<SmsRegistration>>;
4218
+ /**
4219
+ * One registration (`sreg_…`), as `list()` reads it. Read a resubmit, a
4220
+ * removal or a replacement back with it.
4221
+ */
4222
+ get(registrationId: string): Result<SmsRegistration>;
4223
+ /**
4224
+ * Remove a 10DLC setup: take down a campaign registration
4225
+ * (`us_ten_dlc_campaign`) that has no active number. The carrier
4226
+ * registration is deleted, the campaign's monthly fee ends (no proration)
4227
+ * and the registration reads `archived_at` from then on. A campaign with a
4228
+ * number answers `409 resource_in_use` (release the number first with
4229
+ * `sms.releaseNumber`); one under carrier review answers `409 conflict`.
4230
+ * Pass an `idempotencyKey` so a retry removes once; one is generated when
4231
+ * you don't.
4232
+ */
4233
+ remove(registrationId: string, body?: SmsRegistrationRemove, opts?: SendOptions): Result<SmsRegistration>;
4234
+ /**
4235
+ * Replace an approved 10DLC brand registration (`us_ten_dlc_brand`):
4236
+ * archive it so the brand can be registered again (corrected legal
4237
+ * details, a new owner of the EIN). The brand unlocks for
4238
+ * `sms.updateBrand`, and the new registration is a quote and its confirm
4239
+ * (`ten_dlc_brand_registration`). Nothing changes at the carrier and
4240
+ * nothing is charged here. Refused while a number on the brand isn't
4241
+ * released or a 10DLC setup on it isn't removed (`409 resource_in_use`,
4242
+ * with `dependents`). Pass an `idempotencyKey` so a retry replaces once;
4243
+ * one is generated when you don't.
4244
+ */
4245
+ replace(registrationId: string, body?: SmsRegistrationReplace, opts?: SendOptions): Result<SmsRegistration>;
4246
+ /**
4247
+ * Resubmit a 10DLC campaign carriers sent back (free), after fixing what
4248
+ * its feedback names: an optional `opt_in_screenshot_file_id`, or
4249
+ * `acknowledge_unchanged` when the fix was made outside Unitpost. Pass an
4250
+ * `idempotencyKey` so a retry resubmits once; one is generated when you
4251
+ * don't.
4252
+ */
4253
+ resubmit(registrationId: string, body: SmsCampaignResubmit, opts?: SendOptions): Result<SmsRegistrationResubmission>;
4254
+ /**
4255
+ * Request a campaign's number again after it failed, when its fee is
4256
+ * already committed (free). A number the fee doesn't cover answers `409
4257
+ * quote_required`: order it through `sms.quotes` (`ten_dlc_number`). Pass
4258
+ * an `idempotencyKey` so a retry requests one number; one is generated when
4259
+ * you don't.
4260
+ */
4261
+ requestNumber(registrationId: string, body?: SmsNumberRetry, opts?: SendOptions): Result<SmsNumberRequest>;
1539
4262
  }
1540
4263
  declare class Email extends Resource {
1541
4264
  readonly topics: Topics;
1542
4265
  readonly campaigns: Campaigns;
1543
4266
  readonly templates: Templates;
1544
4267
  readonly domains: Domains;
4268
+ /** Inbox conversations: list, read, delete and reply. */
4269
+ readonly threads: EmailThreads;
1545
4270
  constructor(http: HttpClient);
1546
4271
  /**
1547
4272
  * Send or schedule a transactional email.
@@ -1564,33 +4289,67 @@ declare class Email extends Resource {
1564
4289
  getBatch(id: string): Result<Batch>;
1565
4290
  /** Cancel every still-cancelable message in a batch. */
1566
4291
  cancelBatch(id: string): Result<Batch>;
4292
+ /**
4293
+ * Your batch sends, newest first (cursor-paginated), as the dashboard's
4294
+ * Batches tab lists them. Each row is the same live rollup `getBatch`
4295
+ * returns: how many emails it holds, when it's scheduled, a count per
4296
+ * delivery status and how many are still cancelable.
4297
+ */
4298
+ listBatches(params?: ListParams): Result<ListResponse<Batch>>;
1567
4299
  /** List sent/scheduled emails (cursor-paginated). */
1568
- list(params?: ListParams & {
1569
- status?: string;
1570
- campaign_id?: string;
1571
- batch_id?: string;
1572
- }): Result<ListResponse<Email$1>>;
1573
- /** Async-iterate every sent/scheduled email. */
1574
- listAll(params?: ListParams): AsyncGenerator<Email$1, void, void>;
1575
- /** Retrieve a sent or scheduled email. */
4300
+ list(params?: EmailListParams): Result<ListResponse<Email$1>>;
4301
+ /** Async-iterate every sent/scheduled email (same filters as `list`). */
4302
+ listAll(params?: EmailListParams): AsyncGenerator<Email$1, void, void>;
4303
+ /** Retrieve a sent or scheduled email, with its `cc`, `bcc`, `reply_to` and `tags`. */
1576
4304
  get(id: string): Result<Email$1>;
4305
+ /**
4306
+ * One sent email's delivery events, oldest first, as the dashboard's email
4307
+ * detail shows the timeline. Each event carries its detail in `data` under
4308
+ * the webhook's names (`data.bounce.diagnostic_code`, `data.click.link`,
4309
+ * `data.complaint.feedback_type`, ...). Cursor-paginated: `after` /
4310
+ * `before` take an `emev_` id. Needs `emails:read`.
4311
+ */
4312
+ listEvents(id: string, params?: ListParams): Result<ListResponse<EmailEvent>>;
1577
4313
  /** Cancel or reschedule a scheduled/queued email. */
1578
4314
  update(id: string, body: EmailPatch): Result<Email$1>;
1579
4315
  /**
1580
- * Deliverability / engagement stats over a rolling window.
4316
+ * Send a `failed` email again on the same `id`, as the dashboard's Retry
4317
+ * does. Only a one-off send whose failure was temporary is retried: a
4318
+ * campaign recipient, a template test, a suppressed or rejected send, or a
4319
+ * content error is a `409` saying why (send a new email instead). It passes
4320
+ * the same checks as a new send: the sending domain, your plan and quota.
4321
+ * It sends no body; follow the email with `get`.
1581
4322
  *
1582
- * `days` is the window size (1–365); defaults to 30 server-side.
4323
+ * It sends real email, so if you don't pass `idempotencyKey` the SDK
4324
+ * generates one, which makes an auto-retry safe. Pass your own to dedupe
4325
+ * across separate `retry()` calls.
1583
4326
  */
1584
- stats(params?: {
1585
- days?: number;
1586
- }): Result<EmailStats>;
4327
+ retry(id: string, opts?: SendOptions): Result<Email$1>;
4328
+ /**
4329
+ * Deliverability / engagement stats over a rolling window or a period.
4330
+ *
4331
+ * `days` is the window size (1–365); defaults to 30 server-side. Or count a
4332
+ * period with `from` and `to`; add `grain` (and `tz`) for `series`, the send
4333
+ * volume per bucket. `domain_id` counts one sending domain. A value the API
4334
+ * can't apply is ignored and named in the `Unitpost-Warning` response
4335
+ * header; `Unitpost-Strict: true` refuses it instead.
4336
+ */
4337
+ stats(params?: EmailStatsParams): Result<EmailStats>;
1587
4338
  receivedList(params?: ListParams): Result<ListResponse<ReceivedEmailSummary>>;
1588
4339
  receivedGet(id: string): Result<ReceivedEmail>;
1589
4340
  receivedAttachmentUrl(id: string, attachmentId: string): Result<ReceivedAttachmentUrl>;
4341
+ /**
4342
+ * A signed URL to download the received message's original MIME (`.eml`),
4343
+ * valid for about 5 minutes (`expires_at`), with its `size_bytes`. A body
4344
+ * over 256 KB isn't inlined on `receivedGet` (its `text` and `html` are
4345
+ * `null`), so this is how to read it. A copy of one of your own sends
4346
+ * (`sent_by_us`) is a `403`. Needs `emails:read`.
4347
+ */
4348
+ receivedRaw(id: string): Result<ReceivedEmailRaw>;
1590
4349
  }
1591
4350
  declare class Contacts extends Resource {
1592
- list(params?: ListParams): Result<ListResponse<Contact>>;
1593
- listAll(params?: ListParams): AsyncGenerator<Contact, void, void>;
4351
+ list(params?: ContactListParams): Result<ListResponse<Contact>>;
4352
+ listAll(params?: ContactListParams): AsyncGenerator<Contact, void, void>;
1594
4353
  create(body: ContactCreate): Result<Contact>;
1595
4354
  /** Retrieve by contact id or email. */
1596
4355
  get(idOrEmail: string): Result<Contact>;
@@ -1601,6 +4360,29 @@ declare class Contacts extends Resource {
1601
4360
  listImports(params?: ListParams): Result<ListResponse<ContactImport>>;
1602
4361
  getImport(id: string): Result<ContactImport>;
1603
4362
  cancelImport(id: string): Result<ContactImport>;
4363
+ /** Re-run a failed import from its stored rows (202); rows already added are skipped. */
4364
+ retryImport(id: string): Result<ContactImport>;
4365
+ /** The contact's email addresses and phone numbers, with each one's status (one page, never `has_more`). */
4366
+ addresses(idOrEmail: string): Result<ListResponse<ContactAddress>>;
4367
+ /** The contact's most recent emails and texts, newest first (`limit` 1–100, default 25; no cursor). */
4368
+ activity(idOrEmail: string, params?: {
4369
+ limit?: number;
4370
+ }): Result<ListResponse<ContactActivity>>;
4371
+ /**
4372
+ * The segments the contact is in, with its per-segment opt-out (not
4373
+ * paginated). To add the contact to a static segment or remove it, use
4374
+ * `segments.addMember` / `segments.removeMember`.
4375
+ */
4376
+ listSegments(idOrEmail: string): Result<ListResponse<ContactSegment>>;
4377
+ /**
4378
+ * Export contacts to a CSV file (202), as the Contacts page's Export does:
4379
+ * every contact, or the ones the filters match (`q`, `status`, `phone`,
4380
+ * `segment_id`, `segment_subscription`, as on `list`). It runs as a
4381
+ * background job: follow it with `jobs.get(job.id)`, then fetch the file
4382
+ * with `jobs.download(job.id)`. One export runs at a time: another while it
4383
+ * runs is a `409` `job_in_progress`. `segment_id` also needs `segments:read`.
4384
+ */
4385
+ export(body?: ContactsExport): Result<Job>;
1604
4386
  }
1605
4387
  declare class ContactFields extends Resource {
1606
4388
  list(params?: ListParams): Result<ListResponse<ContactField>>;
@@ -1623,11 +4405,38 @@ declare class ContactFields extends Resource {
1623
4405
  rename(id: string, body: ContactFieldRename): Result<ContactField | Job>;
1624
4406
  }
1625
4407
  declare class Jobs extends Resource {
4408
+ /**
4409
+ * Your background jobs, newest first (cursor-paginated), as Settings → Bulk
4410
+ * operations lists them: the kinds an API operation starts that your key
4411
+ * may read. Filter with `status` or `kind` (`"contacts.export"`,
4412
+ * `"contact_field.delete"`, …).
4413
+ */
4414
+ list(params?: ListParams & {
4415
+ status?: Job["status"];
4416
+ kind?: string;
4417
+ }): Result<ListResponse<Job>>;
1626
4418
  /**
1627
4419
  * Retrieve a background job — the `202` answer of an operation too large for
1628
4420
  * one request. Poll until `status` is `COMPLETED`, `FAILED` or `CANCELED`.
1629
4421
  */
1630
4422
  get(id: string): Result<Job>;
4423
+ /**
4424
+ * Stop a queued or running job. A running job stops after the part in
4425
+ * flight; the work already done stays. A kind that can't stop half-way (a
4426
+ * custom-field rename) is a `409` saying why. It sends no body.
4427
+ */
4428
+ cancel(id: string): Result<Job>;
4429
+ /**
4430
+ * Resume a `FAILED` job from where it stopped (202): nothing it already
4431
+ * processed runs again. Any other status is a `409`. It sends no body.
4432
+ */
4433
+ retry(id: string): Result<Job>;
4434
+ /**
4435
+ * A finished job's file (a contacts export's CSV) as a signed `url` that
4436
+ * expires in 5 minutes: fetch it right away, and call `download` again for a
4437
+ * fresh one. A job that isn't `COMPLETED`, or a kind with no file, is a `409`.
4438
+ */
4439
+ download(id: string): Result<JobDownload>;
1631
4440
  }
1632
4441
  declare class Segments extends Resource {
1633
4442
  list(params?: ListParams): Result<ListResponse<Segment>>;
@@ -1641,6 +4450,32 @@ declare class Segments extends Resource {
1641
4450
  addMember(id: string, body: SegmentMemberAdd): Result<SegmentMember>;
1642
4451
  /** Remove a contact (by id or email) from the segment. */
1643
4452
  removeMember(id: string, contact: string): Result<null>;
4453
+ /**
4454
+ * Opt a member (by id or email) out of this segment's sends without
4455
+ * removing it (`{ subscribed: false }`), or back in, as the members table's
4456
+ * toggle does. It stays a member. A dynamic segment has no per-segment
4457
+ * opt-out (`422`).
4458
+ */
4459
+ updateMember(id: string, contact: string, body: SegmentMemberUpdate): Result<SegmentMember>;
4460
+ /**
4461
+ * How many contacts a saved segment reaches: its members, the subscribed
4462
+ * set a campaign would mail (`0` means a campaign would send nothing), and a
4463
+ * sample (which also needs `contacts:read`).
4464
+ */
4465
+ preview(id: string): Result<SegmentPreview>;
4466
+ /**
4467
+ * Count an unsaved dynamic filter before you create the segment, as the
4468
+ * segment dialog's live count does: how many contacts match, how many of
4469
+ * them a campaign would mail, and a sample (which also needs
4470
+ * `contacts:read`). Nothing is saved.
4471
+ */
4472
+ previewFilter(body: SegmentPreviewRequest): Result<SegmentPreview>;
4473
+ /**
4474
+ * The workspace's managed "All subscribed contacts" segment, the
4475
+ * dashboard's "Everyone subscribed" campaign target: made the first time you
4476
+ * ask (201), the same segment after that (200). It sends no body.
4477
+ */
4478
+ allContacts(): Result<Segment>;
1644
4479
  }
1645
4480
  declare class Topics extends Resource {
1646
4481
  list(params?: ListParams): Result<ListResponse<Topic>>;
@@ -1649,10 +4484,29 @@ declare class Topics extends Resource {
1649
4484
  get(id: string): Result<Topic>;
1650
4485
  update(id: string, body: TopicUpdate): Result<Topic>;
1651
4486
  delete(id: string): Result<null>;
4487
+ /**
4488
+ * Opt many contacts out of this topic as a background job (202, the `Job`):
4489
+ * `{ contact_ids }` or `{ emails }` (up to 1,000, each a contact of this
4490
+ * workspace) or `{ segment_id }` (every member, however many). Each is
4491
+ * opted out as `setTopic` would, with its webhook only when it was
4492
+ * subscribed. Follow it with `jobs.get(id)`. Pass an `idempotencyKey` so a
4493
+ * retry answers the same job; one is generated when you don't. There is no
4494
+ * bulk opt-in.
4495
+ */
4496
+ optOut(id: string, body: TopicOptOut, opts?: SendOptions): Result<Job>;
1652
4497
  /** List a contact's effective topic subscriptions. */
1653
4498
  listTopics(contactId: string, params?: ListParams): Result<ListResponse<ContactTopic>>;
1654
4499
  /** Set a contact's preference for one topic. */
1655
4500
  setTopic(contactId: string, body: ContactTopicSet): Result<ContactTopic>;
4501
+ /**
4502
+ * Change a contact's preferences for several topics in one call
4503
+ * (`{ topics: [{ topic_id, subscribed }] }`, up to 50, each topic once);
4504
+ * topics left out keep theirs. Every topic is checked before any is set (an
4505
+ * unknown one is a 404 and nothing changes). Answers the resolved
4506
+ * preferences in the order sent (`{ object: "list", has_more: false, data }`).
4507
+ * Idempotent.
4508
+ */
4509
+ updateTopics(contactId: string, body: ContactTopicsUpdate): Result<ContactTopicList>;
1656
4510
  }
1657
4511
  declare class Campaigns extends Resource {
1658
4512
  list(params?: ListParams): Result<ListResponse<Campaign>>;
@@ -1672,6 +4526,15 @@ declare class Campaigns extends Resource {
1672
4526
  pause(id: string): Result<Campaign>;
1673
4527
  /** Resume a paused campaign; sending continues with the remaining recipients. */
1674
4528
  resume(id: string): Result<Campaign>;
4529
+ /** Move a scheduled campaign back to draft so it can be edited; clears its send time. */
4530
+ unschedule(id: string): Result<Campaign>;
4531
+ /**
4532
+ * Copy a campaign into a new draft (201). Pass an `idempotencyKey` so a
4533
+ * retry returns the same copy; one is generated when you don't.
4534
+ */
4535
+ duplicate(id: string, body?: {
4536
+ name?: string;
4537
+ }, opts?: SendOptions): Result<Campaign>;
1675
4538
  reschedule(id: string, body: CampaignReschedule): Result<Campaign>;
1676
4539
  /**
1677
4540
  * Non-mutating pre-send validation report. A large audience is counted in
@@ -1679,6 +4542,51 @@ declare class Campaigns extends Resource {
1679
4542
  * it returns the report.
1680
4543
  */
1681
4544
  validate(id: string): Result<unknown>;
4545
+ /**
4546
+ * The campaign's results: delivered, unique opens and clicks, unsubscribes,
4547
+ * bounces, complaints and their rates. Every rate is `null` until something
4548
+ * was sent; open and click rates are `null` when that tracking was off.
4549
+ */
4550
+ stats(id: string): Result<CampaignStats>;
4551
+ /**
4552
+ * `stats` for up to 100 campaigns in one read (1–100 ids). An id that isn't
4553
+ * one of this workspace's email campaigns is left out of `data`, never an
4554
+ * error; `has_more` is always false.
4555
+ */
4556
+ listStats(ids: string[]): Result<ListResponse<CampaignStats>>;
4557
+ /**
4558
+ * Who the campaign would reach if sent now, member by member: `sendable`,
4559
+ * `missing_data`, `suppressed` or `excluded`, with the reason. Pass the
4560
+ * page's `next_cursor` as `after` for the next page (rows carry no `id`).
4561
+ * A page can hold fewer rows than `limit` while `has_more` is true.
4562
+ */
4563
+ listRecipients(id: string, params?: {
4564
+ status?: "all" | "sendable" | "missing_data" | "suppressed" | "excluded";
4565
+ /** Rows per page (1–100, default 50). */
4566
+ limit?: number;
4567
+ /** The previous page's `next_cursor`. */
4568
+ after?: string;
4569
+ }): Result<ListResponse<CampaignRecipient> & {
4570
+ next_cursor?: string | null;
4571
+ }>;
4572
+ /**
4573
+ * After an automatic quality pause: the recipients whose message
4574
+ * hard-bounced or drew a spam complaint. They're already suppressed; this is
4575
+ * for cleaning the source list. Up to 10,000; `has_more` says it was cut there.
4576
+ */
4577
+ listAffected(id: string): Result<ListResponse<CampaignAffectedRecipient>>;
4578
+ /**
4579
+ * After an automatic quality pause: take the flagged contacts out of the
4580
+ * campaign's static segment (needs `segments:write` too; a filter segment is
4581
+ * a `409`). A repeat removes nothing. It doesn't resume the campaign.
4582
+ */
4583
+ removeAffected(id: string): Result<CampaignQualityRemoval>;
4584
+ /**
4585
+ * Ask for the review a campaign needs before it can resume after a repeat
4586
+ * quality pause (`resume` answers `409 review_required` until then). A
4587
+ * repeat answers `already_requested: true` and notifies no one.
4588
+ */
4589
+ requestReview(id: string): Result<CampaignReviewRequest>;
1682
4590
  }
1683
4591
  declare class Templates extends Resource {
1684
4592
  list(params?: ListParams): Result<ListResponse<Template>>;
@@ -1689,12 +4597,113 @@ declare class Templates extends Resource {
1689
4597
  delete(id: string): Result<null>;
1690
4598
  /**
1691
4599
  * Send ONE test of the template to `to`, rendered with sample `variables`
1692
- * exactly as a recipient gets it. Without a verified domain only workspace
1693
- * members may receive it.
4600
+ * exactly as a recipient gets it. Once a sending domain is verified it may
4601
+ * go to anyone; until then only to a member of your workspace.
1694
4602
  */
1695
4603
  testSend(id: string, body: TemplateTestSend): Result<TemplateTestSendResult>;
4604
+ /**
4605
+ * The `subject`, `html` and `text` a send of this template would carry,
4606
+ * with your footer and branding, filled from `variables` (and from a
4607
+ * contact's fields with `contact_id`). It sends and stores nothing, so it
4608
+ * takes no idempotency key. `missing_variables` lists the variables left
4609
+ * without a value: they render as a literal `{{token}}`, and a real send
4610
+ * would refuse them. The body is optional: `{}` renders with no variables.
4611
+ * Needs `templates:read`, and has its own per-workspace rate limit.
4612
+ */
4613
+ render(id: string, body?: TemplateRenderInput): Result<TemplateRender>;
4614
+ /**
4615
+ * Copy a template into a new draft (201): its name (with " (copy)", or your
4616
+ * `name`), subject, editor and body carry over; its status, versions and
4617
+ * usage don't. Pass an `idempotencyKey` so a retry returns the same copy;
4618
+ * one is generated when you don't.
4619
+ */
4620
+ duplicate(id: string, body?: TemplateDuplicate, opts?: SendOptions): Result<Template>;
4621
+ /**
4622
+ * Add one of the gallery's ready-made emails (unitpost.com/templates) to
4623
+ * your workspace as a draft Design template (201). `slug` names it; the ones
4624
+ * marked for paid plans answer `403 limit_reached` on the free plan. Pass an
4625
+ * `idempotencyKey` so a retry returns the same template; one is generated
4626
+ * when you don't.
4627
+ */
4628
+ fromLibrary(body: TemplateFromLibrary, opts?: SendOptions): Result<Template>;
4629
+ /**
4630
+ * What uses the template, and whether a change would be accepted now: the
4631
+ * campaigns that reference it, its live campaigns and automations, queued
4632
+ * sends, and `can_edit_content` / `can_unpublish` with the reason when not.
4633
+ * Read it before an edit or a delete: a content edit is refused while a
4634
+ * live campaign renders the template, and a delete while any campaign uses
4635
+ * it.
4636
+ */
4637
+ usage(id: string): Result<TemplateUsage>;
4638
+ /**
4639
+ * The template's history, newest first: a version is added on every publish
4640
+ * and on every content save while it's published. It pages by version
4641
+ * number: pass the last row's `version` (an integer, not an id) as `after`.
4642
+ * There is no `before`.
4643
+ */
4644
+ listVersions(id: string, params?: {
4645
+ /** Rows per page (1–100, default 20). */
4646
+ limit?: number;
4647
+ /** The last `version` of the previous page. */
4648
+ after?: number;
4649
+ }): Result<ListResponse<TemplateVersion>>;
4650
+ /**
4651
+ * Put a version's subject and body back, as the editor's History → Restore
4652
+ * does. It is an update, so a system template, or one a live campaign
4653
+ * renders, is refused with a `409` naming why (`usage` says so up front).
4654
+ * On a published template the restore adds a new version; history is never
4655
+ * rewritten. It sends no body.
4656
+ */
4657
+ restoreVersion(id: string, version: number): Result<Template>;
4658
+ }
4659
+ /**
4660
+ * Inbox conversations (`/email/threads`, `thr_…`): each received message and
4661
+ * the replies and forwards sent from it are one conversation, as Emails →
4662
+ * Received shows them.
4663
+ */
4664
+ declare class EmailThreads extends Resource {
4665
+ /**
4666
+ * Every conversation (Spam included), newest activity first. `q` searches
4667
+ * the subject, the sender and the opening words. Pass the page's
4668
+ * `next_cursor` as `after` for the next page (not the last row's `id`).
4669
+ */
4670
+ list(params?: {
4671
+ q?: string;
4672
+ /** Rows per page (1–100, default 50). */
4673
+ limit?: number;
4674
+ /** The previous page's `next_cursor`. */
4675
+ after?: string;
4676
+ }): Result<ListResponse<EmailThread> & {
4677
+ next_cursor?: string | null;
4678
+ }>;
4679
+ /**
4680
+ * One conversation, oldest message first: what you received (with bodies)
4681
+ * and what you sent from it (status and recipients, no body).
4682
+ */
4683
+ get(id: string): Result<EmailThreadDetail>;
4684
+ /**
4685
+ * Delete a conversation for good: its received messages are erased; replies
4686
+ * and forwards sent from it stay on your sent emails. It can't be undone.
4687
+ */
4688
+ delete(id: string): Result<EmailThreadDeleted>;
4689
+ /**
4690
+ * Reply, reply all or forward one received message of the conversation
4691
+ * (`received_email_id`): your `text`/`html` go on top and the original is
4692
+ * quoted under them. It sends now and marks the conversation read.
4693
+ *
4694
+ * It sends real email, so if you don't pass `idempotencyKey` the SDK
4695
+ * generates one, which makes an auto-retry safe. Pass your own to dedupe
4696
+ * across separate `reply()` calls.
4697
+ */
4698
+ reply(id: string, body: EmailThreadReplyRequest, opts?: SendOptions): Result<EmailThreadReplyResult>;
1696
4699
  }
1697
- /** Read-only Brand Kit profiles (voice, colors, pinned `/img/{id}` graphics). */
4700
+ /**
4701
+ * Brand Kit profiles (voice, colors, pinned `/img/{id}` graphics), and the
4702
+ * imports that fill them from a website or the brand's own words. The reads
4703
+ * (`list`, `get`, `getImport`) need `templates:read`; the writes
4704
+ * and starting, accepting or canceling an import need `branding:write`, which
4705
+ * no key preset grants: tick it on the key.
4706
+ */
1698
4707
  declare class BrandKits extends Resource {
1699
4708
  /** List profiles (max 5). Optional `name` filters by display name. */
1700
4709
  list(params?: {
@@ -1702,6 +4711,61 @@ declare class BrandKits extends Resource {
1702
4711
  }): Result<BrandKitList>;
1703
4712
  /** Retrieve one profile by `bk_…` id. */
1704
4713
  get(id: string): Result<BrandKit>;
4714
+ /**
4715
+ * Create an empty profile (201); `name` is unique in the workspace. The
4716
+ * first profile, or one with `make_default`, becomes the default. At most
4717
+ * five profiles (`403 limit_reached`). Fill it with `update` or `import`.
4718
+ */
4719
+ create(body: BrandKitCreate): Result<BrandKit>;
4720
+ /**
4721
+ * Edit a profile: only the fields you send change, a list replaces the
4722
+ * list, and `null` or `""` clears a text field. `graphics` pins library
4723
+ * images by `image_id` (`img_…`). `sync_visual` on the default profile also
4724
+ * sets the email branding's accent from its colors.
4725
+ */
4726
+ update(id: string, body: BrandKitUpdate): Result<BrandKit>;
4727
+ /**
4728
+ * Delete a profile. When it was the default, the oldest remaining profile
4729
+ * becomes the default. The last profile can't be deleted (`409`): `reset`
4730
+ * it instead. Its pinned images stay in the library.
4731
+ */
4732
+ delete(id: string): Result<null>;
4733
+ /**
4734
+ * Clear a profile's content (voice, colors, graphics, pages), keeping its
4735
+ * name and whether it's the default. It sends no body.
4736
+ */
4737
+ reset(id: string): Result<BrandKit>;
4738
+ /** Make a profile the default: the one agents write with unless told otherwise. It sends no body. */
4739
+ setDefault(id: string): Result<BrandKit>;
4740
+ /**
4741
+ * Add a graphic (201) from a public https image `url` (fetched once, no
4742
+ * redirects): it goes into the image library, counted against its storage,
4743
+ * and is pinned with its `role` (default `logo`). To pin an image already in
4744
+ * the library, `update` the profile's `graphics`.
4745
+ */
4746
+ addGraphic(id: string, body: BrandKitGraphicAdd): Result<BrandKitGraphicAdded>;
4747
+ /**
4748
+ * Build a profile from a website (`url`, or a bare domain) or the brand's
4749
+ * own words (`text`). It runs in the background, usually under a minute
4750
+ * (202): follow it with `getImport`. By default the result is applied when
4751
+ * it lands, to `brand_kit_id`, else the default profile, or a new one when
4752
+ * the default already has content. With `review: true` it stops at a
4753
+ * proposal (`preview_ready`) for `acceptImport`; one review import is open
4754
+ * at a time, and a new one replaces it.
4755
+ */
4756
+ import(body: BrandImportCreate): Result<BrandImport>;
4757
+ /** One import: its status, the proposal once it's ready, warnings and any error. */
4758
+ getImport(id: string): Result<BrandImport>;
4759
+ /**
4760
+ * Apply a review import's proposal (`preview_ready`) to a profile: voice,
4761
+ * colors and pages, and its logos and backgrounds brought into the image
4762
+ * library and pinned. The body is optional: `brand_kit_id` applies it to
4763
+ * another profile, `name` names it. To change other fields, accept and then
4764
+ * `update`.
4765
+ */
4766
+ acceptImport(id: string, body?: BrandImportAccept): Result<BrandImportAccepted>;
4767
+ /** Discard a review import's proposal or stop its crawl. It sends no body. */
4768
+ cancelImport(id: string): Result<BrandImport>;
1705
4769
  }
1706
4770
  declare class Domains extends Resource {
1707
4771
  list(params?: ListParams): Result<ListResponse<Domain>>;
@@ -1716,12 +4780,43 @@ declare class Domains extends Resource {
1716
4780
  }>;
1717
4781
  /** Explain the domain's DNS: every nameserver's answer per record, and ranked findings with fixes. Read-only. */
1718
4782
  diagnose(id: string): Result<DomainDiagnosis>;
4783
+ /**
4784
+ * Your saved From addresses, as the domain page lists them and the
4785
+ * dashboard's From pickers offer them: each a mailbox on one of your
4786
+ * domains, with its display name and `from`, the value to send with.
4787
+ * `domain_id` keeps one domain's. A sender can send once its domain can.
4788
+ */
4789
+ listSenders(params?: ListParams & {
4790
+ domain_id?: string;
4791
+ }): Result<ListResponse<Sender>>;
4792
+ /**
4793
+ * Save a From address on one of your domains (201); the domain may still be
4794
+ * verifying. A mailbox already saved on that domain is a `409`, so a retry
4795
+ * never saves it twice.
4796
+ */
4797
+ createSender(body: SenderCreate): Result<Sender>;
4798
+ /** One saved From address. */
4799
+ getSender(id: string): Result<Sender>;
4800
+ /**
4801
+ * Change a sender's display name (`null` or `""` clears it), the only field
4802
+ * that changes: a different mailbox is a new sender.
4803
+ */
4804
+ updateSender(id: string, body: SenderUpdate): Result<Sender>;
4805
+ /**
4806
+ * Remove a saved From address from the pickers. Templates and campaigns that
4807
+ * send from it keep their From.
4808
+ */
4809
+ deleteSender(id: string): Result<null>;
1719
4810
  }
1720
4811
  declare class Webhooks extends Resource {
1721
4812
  list(params?: ListParams): Result<ListResponse<Webhook>>;
1722
4813
  listAll(params?: ListParams): AsyncGenerator<Webhook, void, void>;
1723
4814
  /** Create an endpoint. The response includes `signing_secret` exactly once. */
1724
4815
  create(body: WebhookCreate): Result<WebhookCreated>;
4816
+ /**
4817
+ * One endpoint, with its `backlog`: the deliveries `flush` would send
4818
+ * (`queued` while it was paused, and `failed`).
4819
+ */
1725
4820
  get(id: string): Result<Webhook>;
1726
4821
  update(id: string, body: WebhookUpdate): Result<Webhook>;
1727
4822
  delete(id: string): Result<null>;
@@ -1732,35 +4827,87 @@ declare class Webhooks extends Resource {
1732
4827
  * secret co-signs deliveries until `previous_secret_expires_at` (24 h).
1733
4828
  */
1734
4829
  rotateSecret(id: string): Result<WebhookSecretRotated>;
1735
- /** The endpoint's delivery log, newest first (cursor-paginated). */
1736
- listDeliveries(id: string, params?: ListParams): Result<ListResponse<WebhookDelivery>>;
1737
- /** Async-iterate every delivery of the endpoint. */
1738
- listAllDeliveries(id: string, params?: ListParams): AsyncGenerator<WebhookDelivery, void, void>;
4830
+ /**
4831
+ * The endpoint's delivery log, newest first (cursor-paginated). Narrow it
4832
+ * with `status` (comma-separated, e.g. `"failed,exhausted"`) and
4833
+ * `event_type` (e.g. `email.bounced`).
4834
+ */
4835
+ listDeliveries(id: string, params?: WebhookDeliveryListParams): Result<ListResponse<WebhookDelivery>>;
4836
+ /** Async-iterate every delivery of the endpoint (same filters as `listDeliveries`). */
4837
+ listAllDeliveries(id: string, params?: WebhookDeliveryListParams): AsyncGenerator<WebhookDelivery, void, void>;
4838
+ /**
4839
+ * Deliver one event to the endpoint again (202), as the dashboard's Replay
4840
+ * does. The same event goes out with the same id, so a receiver that
4841
+ * dedupes on it treats the replay as the delivery it already has. The
4842
+ * webhook must be enabled: a disabled or suspended one is a `409`
4843
+ * (re-enable it with `update` first). Find deliveries with
4844
+ * `listDeliveries`. It sends no body.
4845
+ */
4846
+ replayDelivery(id: string, deliveryId: string): Result<WebhookDeliveryReplay>;
4847
+ /**
4848
+ * Deliver the backlog (202): the deliveries held while the webhook was
4849
+ * suspended (`queued`), as the dashboard's "Retry queued" does. With
4850
+ * `include_failed: true`, also the ones that failed for good (`failed`,
4851
+ * `exhausted`). The webhook must be enabled: a disabled or suspended one is
4852
+ * a `409` (re-enable it with `update` first); re-enabling never delivers the
4853
+ * backlog on its own. `flushed` counts the deliveries handed back.
4854
+ */
4855
+ flush(id: string, body?: WebhookFlush): Result<WebhookFlushResult>;
1739
4856
  /**
1740
4857
  * Verify a webhook delivery's signature and return the parsed event. Throws
1741
4858
  * `WebhookVerificationError` on a missing/invalid/stale signature. Alias of the
1742
- * top-level `verifyWebhook` for a Resend-style `unitpost.webhooks.verify(...)`.
4859
+ * top-level `verifyWebhook`, callable as `unitpost.webhooks.verify(...)`.
1743
4860
  */
1744
4861
  verify<T = unknown>(args: VerifyWebhookArgs): T;
1745
4862
  }
1746
4863
  declare class ApiKeys extends Resource {
4864
+ /**
4865
+ * The workspace's API keys (prefix, scope, capabilities, last use; never
4866
+ * the secret). With an API key or an MCP sign-in it needs `apikeys:read`,
4867
+ * which no key preset includes.
4868
+ */
1747
4869
  list(params?: ListParams): Result<ListResponse<ApiKey>>;
1748
4870
  listAll(params?: ListParams): AsyncGenerator<ApiKey, void, void>;
1749
4871
  /** Create a key. The response includes the plaintext `key` exactly once. */
1750
4872
  create(body: ApiKeyCreate): Result<ApiKeyCreated>;
1751
4873
  delete(id: string): Result<null>;
4874
+ /**
4875
+ * One key's last 24 hours: how many requests it made, how many were
4876
+ * answered 4xx, 5xx or 429, and when it was last used. Check it before you
4877
+ * revoke a key (is anything still calling with it?) or when an
4878
+ * integration's calls fail. Needs `apikeys:read`, which no key preset
4879
+ * includes.
4880
+ */
4881
+ usage(id: string): Result<ApiKeyUsage>;
4882
+ }
4883
+ /**
4884
+ * The workspace's API request log: one row per call. Needs `apikeys:read`,
4885
+ * which no key preset includes.
4886
+ */
4887
+ declare class Logs extends Resource {
4888
+ /**
4889
+ * Your workspace's API request log, newest first (cursor-paginated, `rlog_`
4890
+ * ids): each call's `method`, `path`, `status`, time taken (`duration_ms`),
4891
+ * the API key that made it (`api_key_id`) and its `x-request-id`
4892
+ * (`request_id`: quote it to support). Never the caller's IP and never a
4893
+ * body. Narrow it with `status` (a code, or a class such as `4xx`),
4894
+ * `api_key_id`, `method`, `path_prefix` (e.g. `/email`), `request_id` and a
4895
+ * `created_after` / `created_before` range; an unknown filter is a `422`.
4896
+ * Rows are kept 30 days. Needs `apikeys:read`, which no key preset
4897
+ * includes, and has its own per-workspace rate limit.
4898
+ */
4899
+ list(params?: LogListParams): Result<ListResponse<RequestLog>>;
1752
4900
  }
1753
4901
  declare class Suppressions extends Resource {
1754
4902
  /**
1755
4903
  * List your workspace's suppressed addresses. Unitpost-wide (platform)
1756
4904
  * blocks are enforced at send time but not listed — `get(email)` explains one.
4905
+ * Narrow it with `q` (part of the address), `reason` and a `created_after`
4906
+ * / `created_before` range.
1757
4907
  */
1758
- list(params?: ListParams & {
1759
- /** @deprecated Ignored since 2026-10-13: the list is always your own suppressions. */
1760
- scope?: "workspace" | "platform";
1761
- }): Result<ListResponse<Suppression>>;
1762
- /** Async-iterate every suppressed address. */
1763
- listAll(params?: ListParams): AsyncGenerator<Suppression, void, void>;
4908
+ list(params?: SuppressionListParams): Result<ListResponse<Suppression>>;
4909
+ /** Async-iterate every suppressed address (same filters as `list`). */
4910
+ listAll(params?: SuppressionListParams): AsyncGenerator<Suppression, void, void>;
1764
4911
  /**
1765
4912
  * Suppress one address (`{ email }`) or many (`{ emails: [...] }`). Idempotent
1766
4913
  * — re-suppressing an existing address is a no-op. The bulk form resolves to a
@@ -1772,6 +4919,158 @@ declare class Suppressions extends Resource {
1772
4919
  /** Un-suppress an address by id or email. Idempotent on the email form. */
1773
4920
  delete(idOrEmail: string): Result<null>;
1774
4921
  }
4922
+ /**
4923
+ * Files (`/files`, `file_` ids): bytes handed to the API for one `purpose`,
4924
+ * which an operation then takes by `file_id` (a brand document, the SMS
4925
+ * opt-in evidence on a quote or resubmission, a library image, the logo).
4926
+ * A file is private, metadata-only on the API, and expires 24 hours after it
4927
+ * is created; what uses it keeps its own copy. `sms_*` purposes need
4928
+ * `sms:manage`, `image` needs `templates:write` or `branding:write` (ADR-0159).
4929
+ */
4930
+ declare class Files extends Resource {
4931
+ /** The workspace's unexpired files, newest first (cursor-paginated; `purpose` filters). */
4932
+ list(params?: FileListParams): Result<ListResponse<File>>;
4933
+ /**
4934
+ * Create a file (201) one of three ways: a public https `url` (fetched
4935
+ * once, no redirects, no private addresses), base64 `data` with its
4936
+ * `content_type` (up to about 4 MB), or neither, with `content_type` and
4937
+ * `size_bytes`: an upload session, whose `upload` says where to PUT the
4938
+ * bytes (`files.upload` does all of this for a local file). The bytes
4939
+ * decide the type. Pass an `idempotencyKey` so a retry makes one file; one
4940
+ * is generated when you don't.
4941
+ */
4942
+ create(body: FileCreate, opts?: SendOptions): Result<File>;
4943
+ /**
4944
+ * One file's metadata (never its bytes). Reading an `awaiting_upload` file
4945
+ * checks its upload, which makes it `ready` or `failed`.
4946
+ */
4947
+ get(id: string): Result<File>;
4948
+ /** Delete a file before it expires. What already used it keeps its copy. */
4949
+ delete(id: string): Result<null>;
4950
+ /**
4951
+ * Upload a local file or bytes and return the file, checked. Up to 3 MB it
4952
+ * is sent inline (base64 `data`); a larger one opens an upload session,
4953
+ * PUTs the bytes to its `upload.url` with exactly `upload.headers`, then
4954
+ * reads the file back, so the answer is `ready` or `failed`. The
4955
+ * `idempotencyKey` (generated when you don't pass one) is the create's.
4956
+ */
4957
+ upload(input: FileUploadInput, opts?: SendOptions): Result<File>;
4958
+ }
4959
+ /**
4960
+ * The workspace's image library: the images a template embeds. Each image's
4961
+ * `path` (`/img/…`) is what a template's `<Image src>` (or `<img src>`) takes;
4962
+ * `url` is its public address. Reads need `templates:read`, writes
4963
+ * `templates:write`.
4964
+ */
4965
+ declare class LibraryImages extends Resource {
4966
+ /** The library, newest first (cursor-paginated). */
4967
+ list(params?: ListParams): Result<ListResponse<LibraryImage>>;
4968
+ /** Async-iterate every image in the library. */
4969
+ listAll(params?: ListParams): AsyncGenerator<LibraryImage, void, void>;
4970
+ /**
4971
+ * Add an image (201) from a public https `url` (fetched once, no redirects,
4972
+ * no private addresses) or base64 `data` with its `content_type`: PNG,
4973
+ * JPEG, GIF or WebP up to 5 MB, counted against the plan's image storage
4974
+ * (`403 limit_reached`). Pass an `idempotencyKey` so a retried upload stores
4975
+ * one image; one is generated when you don't.
4976
+ */
4977
+ create(body: LibraryImageCreate, opts?: SendOptions): Result<LibraryImage>;
4978
+ get(id: string): Result<LibraryImage>;
4979
+ /** Change the alt text the image suggests when it's inserted (`null` or `""` clears it). */
4980
+ update(id: string, body: LibraryImageUpdate): Result<LibraryImage>;
4981
+ /**
4982
+ * Remove an image from the library. While a template, a campaign or sent
4983
+ * mail uses it, the answer is a `409` `resource_in_use` naming them
4984
+ * (`details`). `{ force: true }` (sent as `?force=true`) deletes it anyway:
4985
+ * those emails then show a broken image wherever it isn't cached yet.
4986
+ */
4987
+ delete(id: string, params?: {
4988
+ force?: boolean;
4989
+ }): Result<null>;
4990
+ }
4991
+ /**
4992
+ * The look marketing emails' footer and the hosted unsubscribe page share, as
4993
+ * Settings → Brand shows it. Reading it needs `templates:read`; the writes
4994
+ * need `branding:write`, which no key preset grants: tick it on the key.
4995
+ */
4996
+ declare class Branding extends Resource {
4997
+ /** Colors, font, company name and postal address, the unsubscribe page, the footer, the logo; `null` means the default. */
4998
+ get(): Result<Branding$1>;
4999
+ /**
5000
+ * Change branding: only the fields you send change, and `null` restores a
5001
+ * default. Hiding the "Sent with Unitpost" mark needs a paid plan
5002
+ * (`403 limit_reached`).
5003
+ */
5004
+ update(body: BrandingUpdate): Result<Branding$1>;
5005
+ /** Replace the logo, from a public https `url` or base64 `data` (PNG, JPEG, GIF or WebP, up to 5 MB). */
5006
+ setLogo(body: ImageUpload): Result<Branding$1>;
5007
+ /** Clear the brand logo (the workspace image shows instead, else none). It sends no body and answers the branding. */
5008
+ removeLogo(): Result<Branding$1>;
5009
+ }
5010
+ /**
5011
+ * The calling credential (`whoami`, which any valid credential may read), the
5012
+ * activity log (`listActivity`, which needs `activity:read`), and the
5013
+ * workspace's name and image. `update`, `setImage` and `removeImage` need
5014
+ * `branding:write`. No key preset grants either capability: tick it on the
5015
+ * key. Deleting the workspace stays in the dashboard.
5016
+ */
5017
+ declare class Workspace extends Resource {
5018
+ /**
5019
+ * Who is calling: the workspace, the credential (an API key or an OAuth
5020
+ * sign-in, never its secret), its `capabilities` and the workspace's rate
5021
+ * limit. Call it first to see what the credential may do: a call that needs
5022
+ * a capability it lacks answers `403 insufficient_scope`. It needs no
5023
+ * capability: any valid credential may read it.
5024
+ */
5025
+ whoami(): Result<Whoami>;
5026
+ /**
5027
+ * The workspace activity log, newest first (cursor-paginated, `act_` ids):
5028
+ * what changed, when, who changed it (`actor.name`: a teammate, `System`,
5029
+ * `Ask Unit`) and, for a change made over the API, MCP or Ask Unit, how
5030
+ * (`actor.via`, with the API key). The rows the dashboard's Activity page
5031
+ * and each record's timeline show. Narrow it with `subject` (and
5032
+ * `subject_id`), `contact_id`, `campaign_id`, `q` and `channel: "email"`;
5033
+ * an unknown filter is a `422`. Needs `activity:read`, which no key preset
5034
+ * includes: the log names your teammates.
5035
+ */
5036
+ listActivity(params?: ActivityListParams): Result<ListResponse<Activity>>;
5037
+ /** Async-iterate every activity row (same filters as `listActivity`). */
5038
+ listAllActivity(params?: ActivityListParams): AsyncGenerator<Activity, void, void>;
5039
+ /** Rename the workspace. */
5040
+ update(body: WorkspaceUpdate): Result<Workspace$1>;
5041
+ /**
5042
+ * Replace the workspace image (its avatar in the dashboard, and the email
5043
+ * logo when there's no brand logo), from a public https `url` or base64
5044
+ * `data` (PNG, JPEG, GIF or WebP, up to 5 MB).
5045
+ */
5046
+ setImage(body: ImageUpload): Result<Workspace$1>;
5047
+ /** Clear the workspace image. It sends no body and answers the workspace. */
5048
+ removeImage(): Result<Workspace$1>;
5049
+ }
5050
+ /**
5051
+ * The workspace's monthly spend caps and what each counted this UTC calendar
5052
+ * month. `sms_purchases` caps the SMS carrier purchases API keys and apps
5053
+ * confirm (`sms.quotes.confirm`). Reading needs `sms:read`, `sms:purchase` or
5054
+ * `spend_caps:write`; `update()` needs `spend_caps:write`, which no key preset
5055
+ * includes and only the workspace owner can give a key.
5056
+ */
5057
+ declare class SpendCaps extends Resource {
5058
+ /**
5059
+ * `{ object: "spend_caps", sms_purchases: { cap_cents, max_cents,
5060
+ * spent_cents, period_start, period_end } }`. A `cap_cents` of `null` means
5061
+ * none, so every API purchase is refused with `403 api_spend_cap_not_set`;
5062
+ * the cap that applies is the lower of `cap_cents` and `max_cents`.
5063
+ */
5064
+ get(): Result<SpendCaps$1>;
5065
+ /**
5066
+ * Set caps: `{ sms_purchases: { cap_cents } }` in whole cents (>= 0), or
5067
+ * `null` to clear it. Only the caps you send change. A workspace its
5068
+ * organization pays for answers `403 billed_by_organization`: its
5069
+ * organization sets the cap with `sms_purchases_cap_cents` on the
5070
+ * organization's workspace update.
5071
+ */
5072
+ update(body: SpendCapsUpdate): Result<SpendCaps$1>;
5073
+ }
1775
5074
  declare class Usage extends Resource {
1776
5075
  /**
1777
5076
  * Retrieve the current billing-period usage snapshot: plan, period window,
@@ -1793,11 +5092,201 @@ declare class Unitpost {
1793
5092
  readonly jobs: Jobs;
1794
5093
  readonly segments: Segments;
1795
5094
  readonly brandKits: BrandKits;
5095
+ /** The image library templates embed (`/img/…` paths). */
5096
+ readonly libraryImages: LibraryImages;
5097
+ /** Files handed to the API for one purpose, used by `file_id` (`upload()` sends a local file). */
5098
+ readonly files: Files;
5099
+ /** The email footer and unsubscribe page look. Writes need `branding:write` (on no key preset). */
5100
+ readonly branding: Branding;
5101
+ /** Who is calling (`whoami`, any credential), the activity log (`listActivity`, needs `activity:read`, on no key preset), and the workspace's name and image; the writes need `branding:write` (on no key preset). */
5102
+ readonly workspace: Workspace;
1796
5103
  readonly webhooks: Webhooks;
1797
5104
  readonly apiKeys: ApiKeys;
5105
+ /** The API request log (`list()`, needs `apikeys:read`, on no key preset). */
5106
+ readonly logs: Logs;
1798
5107
  readonly suppressions: Suppressions;
1799
5108
  readonly usage: Usage;
5109
+ /** Monthly spend caps (`get()`, `update()`); `update()` needs `spend_caps:write`, on no key preset. */
5110
+ readonly spendCaps: SpendCaps;
1800
5111
  constructor(apiKeyOrOptions?: string | UnitpostOptions);
1801
5112
  }
1802
5113
 
1803
- export { type ListParams, type ListResponse, models as Models, type Result, SDK_VERSION, type SendOptions, type SmsListParams, Unitpost, UnitpostError, type UnitpostOptions, type VerifyWebhookArgs, WebhookVerificationError, verifyWebhook };
5114
+ interface UnitpostOrganizationOptions extends Omit<UnitpostOptions, "apiKey"> {
5115
+ /** Organization key (`ok_live_…`). Defaults to `process.env.UNITPOST_ORG_KEY`. */
5116
+ apiKey?: string;
5117
+ /** The organization's id (`org_…`). Defaults to `process.env.UNITPOST_ORGANIZATION_ID`. */
5118
+ organizationId?: string;
5119
+ }
5120
+ /** Filters for `workspaces.list` / `workspaces.listAll`. */
5121
+ type OrganizationWorkspaceListParams = ListParams & {
5122
+ /** Only the workspace you gave this id (`external_id`). */
5123
+ external_id?: string;
5124
+ };
5125
+ /** Filters for `webhooks.listDeliveries` / `webhooks.listAllDeliveries`: the workspace endpoint's, plus which workspace. */
5126
+ type OrganizationWebhookDeliveryListParams = WebhookDeliveryListParams & {
5127
+ /** Only deliveries about this workspace (`ws_…`). */
5128
+ workspace_id?: string;
5129
+ /** Only deliveries about the workspace you gave this id. */
5130
+ external_id?: string;
5131
+ };
5132
+ /** Filters for `usage.list` / `usage.listAll`. */
5133
+ type OrganizationUsageListParams = {
5134
+ /** `current` (default), or an ISO 8601 instant: each workspace's billing period containing it. */
5135
+ period?: string;
5136
+ /** Only the workspace you gave this id. */
5137
+ external_id?: string;
5138
+ /** Workspaces per page, 1–25 (default 10). */
5139
+ limit?: number;
5140
+ /** Next page: the last row's `workspace_id`. */
5141
+ after?: string;
5142
+ /** Previous page: the first row's `workspace_id`. Not with `after`. */
5143
+ before?: string;
5144
+ };
5145
+ declare class UnitpostOrganization {
5146
+ /** The organization every call acts on (`org_…`). */
5147
+ readonly organizationId: string;
5148
+ /** The organization's workspaces: list, create, get, update, close, restore. */
5149
+ readonly workspaces: OrganizationWorkspaces;
5150
+ /** Keys for one of the organization's workspaces: `create` mints one (the secret is in that answer only). */
5151
+ readonly workspaceKeys: OrganizationWorkspaceKeys;
5152
+ /** The organization's webhook endpoints: events from every workspace it owns, each with `workspace_id` and `external_id`. */
5153
+ readonly webhooks: OrganizationWebhooks;
5154
+ /** Usage per workspace for a billing period (`list`). */
5155
+ readonly usage: OrganizationUsage;
5156
+ /** A plan change for one workspace the organization pays for: quote, read, confirm. */
5157
+ readonly planQuotes: OrganizationPlanQuotes;
5158
+ /** The organization's shared plan: read it, and add, cap or remove the workspaces on it. */
5159
+ readonly sharedPlan: OrganizationSharedPlan;
5160
+ constructor(options?: UnitpostOrganizationOptions);
5161
+ }
5162
+ declare class OrganizationResource {
5163
+ protected readonly http: HttpClient;
5164
+ protected readonly organizationId: string;
5165
+ constructor(http: HttpClient, organizationId: string);
5166
+ }
5167
+ declare class OrganizationWorkspaces extends OrganizationResource {
5168
+ /** The organization's workspaces, newest first (cursor-paginated). Needs `organizations:read`. */
5169
+ list(params?: OrganizationWorkspaceListParams): Result<ListResponse<OrganizationWorkspace>>;
5170
+ /** Async-iterate every workspace of the organization (same filters as `list`). */
5171
+ listAll(params?: OrganizationWorkspaceListParams): AsyncGenerator<OrganizationWorkspace, void, void>;
5172
+ /**
5173
+ * Create a workspace (201). Its Owner is the key's creator. An
5174
+ * Idempotency-Key is generated when you don't pass one, so a retry can't
5175
+ * make two. Needs `organizations:write`.
5176
+ */
5177
+ create(body: OrganizationWorkspaceCreate, opts?: SendOptions): Result<OrganizationWorkspace>;
5178
+ /** One workspace (`ws_…`). Needs `organizations:read`. */
5179
+ get(workspaceId: string): Result<OrganizationWorkspace>;
5180
+ /** Rename it, set its `external_id` or its SMS purchases cap. Needs `organizations:write`. */
5181
+ update(workspaceId: string, body: OrganizationWorkspaceUpdate): Result<OrganizationWorkspace>;
5182
+ /**
5183
+ * Close it: it stops sending at once. It can be restored for 30 days
5184
+ * (`restorable_until`); unless restored, it is deleted once those 30 days
5185
+ * are over and 7 days have passed since the end of the billing period it
5186
+ * closed in, whichever is later (`deletes_at`). Closing twice changes
5187
+ * nothing. Needs `organizations:write`.
5188
+ */
5189
+ close(workspaceId: string): Result<OrganizationWorkspace>;
5190
+ /** Restore a closed workspace within its 30 days. Needs `organizations:write`. */
5191
+ restore(workspaceId: string): Result<OrganizationWorkspace>;
5192
+ }
5193
+ declare class OrganizationWorkspaceKeys extends OrganizationResource {
5194
+ /**
5195
+ * Mint a workspace key (201) for one of the organization's workspaces. The
5196
+ * answer holds the secret (`key`) once; use it with `new Unitpost(key)`.
5197
+ * Needs `organizations:write`.
5198
+ */
5199
+ create(workspaceId: string, body: WorkspaceKeyMint): Result<MintedWorkspaceKey>;
5200
+ }
5201
+ declare class OrganizationWebhooks extends OrganizationResource {
5202
+ /** The organization's webhook endpoints. Needs `organizations:read`. */
5203
+ list(params?: ListParams): Result<ListResponse<Webhook>>;
5204
+ /** Async-iterate every webhook endpoint of the organization. Needs `organizations:read`. */
5205
+ listAll(params?: ListParams): AsyncGenerator<Webhook, void, void>;
5206
+ /** Create an endpoint. The answer has `signing_secret` exactly once. Needs `organizations:write`. */
5207
+ create(body: WebhookCreate): Result<WebhookCreated>;
5208
+ /** One endpoint (`wh_…`). Needs `organizations:read`. */
5209
+ get(webhookId: string): Result<Webhook>;
5210
+ update(webhookId: string, body: WebhookUpdate): Result<Webhook>;
5211
+ delete(webhookId: string): Result<null>;
5212
+ /** Mint a new signing secret; the answer carries it exactly once. */
5213
+ rotateSecret(webhookId: string): Result<WebhookSecretRotated>;
5214
+ /** Fire a sample event at the endpoint. */
5215
+ test(webhookId: string): Result<WebhookTestResult>;
5216
+ /**
5217
+ * The endpoint's delivery log, newest first; each row names its
5218
+ * `workspace_id` and `external_id`. Needs `organizations:write` (the rows
5219
+ * carry each event's data, so `organizations:read` alone is a 403).
5220
+ */
5221
+ listDeliveries(webhookId: string, params?: OrganizationWebhookDeliveryListParams): Result<ListResponse<OrganizationWebhookDelivery>>;
5222
+ /** Async-iterate the endpoint's whole delivery log (same filters as `listDeliveries`). Needs `organizations:write`. */
5223
+ listAllDeliveries(webhookId: string, params?: OrganizationWebhookDeliveryListParams): AsyncGenerator<OrganizationWebhookDelivery, void, void>;
5224
+ /** Deliver one event to the endpoint again (202). */
5225
+ replayDelivery(webhookId: string, deliveryId: string): Result<WebhookDeliveryReplay>;
5226
+ /** Deliver the backlog (202); `include_failed: true` adds the ones that failed for good. */
5227
+ flush(webhookId: string, body?: WebhookFlush): Result<WebhookFlushResult>;
5228
+ /** Verify a delivery's signature and return the parsed event (the top-level `verifyWebhook`). */
5229
+ verify<T = unknown>(args: VerifyWebhookArgs): T;
5230
+ }
5231
+ declare class OrganizationUsage extends OrganizationResource {
5232
+ /**
5233
+ * Usage per workspace (`workspace_usage` rows), each for that workspace's
5234
+ * own billing period containing `period`. Paged by workspace. Needs
5235
+ * `organizations:read`.
5236
+ */
5237
+ list(params?: OrganizationUsageListParams): Result<ListResponse<OrganizationWorkspaceUsage>>;
5238
+ /**
5239
+ * Async-iterate the usage row of every workspace (same filters as `list`),
5240
+ * paging by the last row's `workspace_id`. Needs `organizations:read`.
5241
+ */
5242
+ listAll(params?: OrganizationUsageListParams): AsyncGenerator<OrganizationWorkspaceUsage, void, void>;
5243
+ }
5244
+ declare class OrganizationPlanQuotes extends OrganizationResource {
5245
+ /**
5246
+ * Price a plan change for one workspace the organization pays for (201).
5247
+ * Charges nothing; the quote lasts 10 minutes and holds a single-use
5248
+ * `confirm_token` (only in this answer). Its `pending_change` is a
5249
+ * downgrade already scheduled for the period end, or null; with one, a
5250
+ * quote for the current plan and tier is a `noop` whose confirm cancels
5251
+ * it. Needs `organizations:billing`.
5252
+ */
5253
+ create(workspaceId: string, body: OrganizationPlanQuoteCreate): Result<OrganizationPlanQuote>;
5254
+ /** One quote (`pq_…`). Needs `organizations:read`. */
5255
+ get(workspaceId: string, quoteId: string): Result<OrganizationPlanQuote>;
5256
+ /**
5257
+ * Apply the quoted change and charge it. An Idempotency-Key is generated
5258
+ * when you don't pass one, so a retry can't charge twice. Needs
5259
+ * `organizations:billing`.
5260
+ */
5261
+ confirm(workspaceId: string, quoteId: string, body: OrganizationPlanQuoteConfirm, opts?: SendOptions): Result<OrganizationPlanQuote>;
5262
+ }
5263
+ declare class OrganizationSharedPlan extends OrganizationResource {
5264
+ /**
5265
+ * The organization's shared plan (one plan whose allowance its workspaces
5266
+ * share): whether it's turned on (`approved`), its `status` (`none` until
5267
+ * one is bought), plan, price and period, and this period's
5268
+ * `used_cents`, `overage_cents`, `paused`. Buying, upgrading and ending it
5269
+ * are done in the dashboard. Needs `organizations:read`.
5270
+ */
5271
+ get(): Result<OrganizationSharedPlan$1>;
5272
+ /** Every workspace on the shared plan, with its cap and what it drew this period (one page). Needs `organizations:read`. */
5273
+ listWorkspaces(): Result<ListResponse<OrganizationSharedPlanWorkspace>>;
5274
+ /**
5275
+ * Put a workspace on the shared plan (it moves onto the organization's
5276
+ * card), or set its cap when it's already on it. Refusals carry the reason
5277
+ * in `error.details[0].code` (`own_plan`, `limit_reached`, …). An
5278
+ * Idempotency-Key is generated when you don't pass one, so a retry answers
5279
+ * what the first call did. Needs `organizations:billing`.
5280
+ */
5281
+ addWorkspace(workspaceId: string, body?: OrganizationSharedPlanWorkspaceAdd, opts?: SendOptions): Result<OrganizationSharedPlanWorkspace>;
5282
+ /** Set a workspace's cap (`cap_cents`; null removes it). Needs `organizations:billing`. */
5283
+ updateWorkspace(workspaceId: string, body: OrganizationSharedPlanWorkspaceUpdate): Result<OrganizationSharedPlanWorkspace>;
5284
+ /**
5285
+ * Take a workspace off the shared plan: `drops_to` is `free` or
5286
+ * `needs_plan`; one not on it answers `left: false`. An Idempotency-Key is
5287
+ * generated when you don't pass one. Needs `organizations:billing`.
5288
+ */
5289
+ removeWorkspace(workspaceId: string, opts?: SendOptions): Result<OrganizationSharedPlanRemoval>;
5290
+ }
5291
+
5292
+ export { type ActivityListParams, type ApiFieldError, type ApiResult, type ContactListParams, type EmailListParams, type EmailStatsParams, type FileListParams, type FileUploadInput, type ListParams, type ListResponse, type LogListParams, models as Models, type OrganizationUsageListParams, type OrganizationWebhookDeliveryListParams, type OrganizationWorkspaceListParams, type Result, SDK_VERSION, type SendOptions, type SmsListParams, type SuppressionListParams, Unitpost, UnitpostError, type UnitpostOptions, UnitpostOrganization, type UnitpostOrganizationOptions, type VerifyWebhookArgs, type WebhookDeliveryListParams, WebhookVerificationError, verifyWebhook };