@vitrina/api 14.14.1 → 14.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -27349,7 +27349,7 @@ interface paths {
27349
27349
  * First-touch status for one lead source
27350
27350
  * @description Health and recent outcomes of the proactive first message for one lead source (`chileautos`, `yapo`, `mercadolibre`, `website`, …): which rail it uses, whether its account is usable, sends today, and the latest outcomes with the reason a lead was skipped.
27351
27351
  *
27352
- * `website` is ON by default for every workspace. With no `website` block of its own it borrows the account and template chain of the first enabled source (`config_origin: inherited`, named in `inherited_from`), or uses the partner WhatsApp account and Vitrina's own website templates (`platform_default`). `templates` lists the WhatsApp ladder in send order with each template's state on that account: only `APPROVED` templates are ever sent; a `PENDING` or `REJECTED` one is shown so it is not silently skipped, and `status: null` means it is not on that account. When no template can be sent the first message goes by email, from the workspace mailbox.
27352
+ * `website` is ON by default for every workspace, and a portal (`chileautos`, `mercadolibre`, `yapo`) is ON by default once the workspace has an enabled marketplace account for it. With no block of its own such a source borrows the account and template chain of the first enabled source (`config_origin: inherited`, named in `inherited_from`), or uses the partner WhatsApp account and Vitrina's own templates — for a portal, the workspace's own first-contact templates first, then Vitrina's fallback ones (`platform_default`). An explicit block, `enabled: false` included, always wins. `templates` lists the WhatsApp ladder in send order with each template's state on that account: only `APPROVED` templates are ever sent; a `PENDING` or `REJECTED` one is shown so it is not silently skipped, and `status: null` means it is not on that account. When no template can be sent the first message goes by email, from the workspace mailbox.
27353
27353
  */
27354
27354
  get: {
27355
27355
  parameters: {
@@ -86942,6 +86942,7 @@ interface paths {
86942
86942
  /** @description Pilot: send this many random recipients first, then pause (paused_reason "pilot") until resumed. Null = no pilot. */
86943
86943
  pilot_size?: number | null;
86944
86944
  send_window?: components["schemas"]["CampaignSendWindow"] & unknown;
86945
+ send_schedule?: components["schemas"]["CampaignSendSchedule"] & unknown;
86945
86946
  };
86946
86947
  };
86947
86948
  };
@@ -87078,6 +87079,8 @@ interface paths {
87078
87079
  * With `recipients`, `plan` says how a campaign to that many people would go: `sendable_now` (its fair share of the headroom, shared with the other campaigns sending on the number), `windows` (sending days), `estimated_completion_at` (continuations move into the workspace’s marketing hours) and the `recommended_send_mode`. `campaign_id` makes a saved campaign’s own recent sends count as its. 404 for a number that is not this workspace’s, 400 for one that is not WhatsApp.
87079
87080
  *
87080
87081
  * `send_window` (JSON-encoded, optional) plans against that window — `null` = the workspace default; absent = the saved campaign’s effective window (with `campaign_id`), else the workspace default. The plan then answers `send_window` (resolved), `window_label` («lun–vie 10:00–18:00 (America/Santiago)») and, when it is outside the window now, `next_window_opens_at` — the first batch, `next_batch_at` and `estimated_completion_at` start there, and every continuation lands inside the window. An invalid window is a 400 with `field_errors` (`send_window.start`, …).
87082
+ *
87083
+ * `send_schedule` (JSON-encoded `CampaignSendSchedule`, optional; `null` = none; absent = the saved campaign’s) plans against explicit instants instead (ADR 0139): `plan.schedule` simulates it batch by batch against the rolling 24 h — `planned` per slot, per-slot `warnings` (`budget_not_freed`, `partial_budget`, `outside_contact_hours` — only when the team answers the replies, see `reply_mode` —, `in_the_past`), `covers_all`, `completes_at` and `issues` (`slot_in_past`, `duplicate_slot`, `too_close` with a `suggested_at`, `uncovered`, `asap_not_allowed`). The window fields are then null: a schedule replaces the window.
87081
87084
  */
87082
87085
  get: {
87083
87086
  parameters: {
@@ -87087,6 +87090,10 @@ interface paths {
87087
87090
  campaign_id?: string;
87088
87091
  /** @description JSON-encoded CampaignSendWindow to plan with (e.g. {"timezone":"America/Santiago","days":[1,2,3,4,5],"start":"10:00","end":"18:00"}), or `null` for the workspace default. Absent = the campaign's effective window (with campaign_id), else the workspace default. */
87089
87092
  send_window?: string;
87093
+ /** @description JSON-encoded CampaignSendSchedule to plan with (e.g. {"kind":"daily","timezone":"America/Santiago","start_date":"2026-10-14","time":"20:00"}), or `null` for none. Absent = the saved campaign's schedule (with campaign_id), else none. With a schedule, `plan.schedule` carries the simulation. */
87094
+ send_schedule?: string;
87095
+ /** @description Who answers the replies, to plan with. `account_default` resolves the number's routing (an AI agent answers → slots outside the contact hours are not warned about). Absent = the saved campaign's (with campaign_id), else unknown (the warning stays). */
87096
+ reply_mode?: "account_default" | "human";
87090
87097
  };
87091
87098
  header?: never;
87092
87099
  path?: never;
@@ -87221,7 +87228,7 @@ interface paths {
87221
87228
  };
87222
87229
  /**
87223
87230
  * Fetch one campaign with its stats
87224
- * @description The campaign plus its delivery counters — this is the read to poll while a send is in progress. A WhatsApp campaign that is not finished also carries `pacing` (ADR 0129): its number’s tier and `limit_per_24h`, `sent_last_24h`, `pending`, `waiting` (a paced campaign waiting for the window) with `next_batch_at`, `estimated_completion_at` and `windows_remaining`, plus the effective `send_window` (`send_window_source`: campaign | workspace), its `window_label` and `next_window_opens_at` (outside the window now); null when the budget cannot be read.
87231
+ * @description The campaign plus its delivery counters — this is the read to poll while a send is in progress. A WhatsApp campaign that is not finished also carries `pacing` (ADR 0129): its number’s tier and `limit_per_24h`, `sent_last_24h`, `pending`, `waiting` (a paced campaign waiting for the window) with `next_batch_at`, `estimated_completion_at` and `windows_remaining`, plus the effective `send_window` (`send_window_source`: campaign | workspace), its `window_label` and `next_window_opens_at` (outside the window now); null when the budget cannot be read. With a `send_schedule` (ADR 0139) it also carries `schedule_label`, `next_slot_at`, `batches` (what each slot did: planned / sent / failed / skipped_reason, oldest first) and `schedule` — the pending part simulated slot by slot.
87225
87232
  */
87226
87233
  get: {
87227
87234
  parameters: {
@@ -87455,7 +87462,7 @@ interface paths {
87455
87462
  head?: never;
87456
87463
  /**
87457
87464
  * Edit a campaign
87458
- * @description Legal only while the campaign is `draft` or `scheduled`; from any other status this is a **409** — except a body carrying ONLY `send_window`, which is also legal while `paused` or `sending` and takes effect at the next batch (a campaign waiting for the old window re-plans at once). At least one field is required. `channel` is absent from the body on purpose — a campaign’s channel is fixed at creation, since the content shape depends on it.
87465
+ * @description Legal only while the campaign is `draft` or `scheduled`; from any other status this is a **409** — except a body carrying ONLY `send_window` and/or `send_schedule`, which is also legal while `paused` or `sending` and takes effect at the next batch (a campaign waiting for the old window or slot re-plans at once). At least one field is required. A `send_schedule` with `send_mode: asap` (set or stored) is a 400 `schedule_requires_paced`; a slot in the past or two slots at once a 400 `schedule_invalid`. `channel` is absent from the body on purpose — a campaign’s channel is fixed at creation, since the content shape depends on it.
87459
87466
  */
87460
87467
  patch: {
87461
87468
  parameters: {
@@ -87512,6 +87519,7 @@ interface paths {
87512
87519
  /** @description Pilot: send this many random recipients first, then pause (paused_reason "pilot") until resumed. Null = no pilot. */
87513
87520
  pilot_size?: number | null;
87514
87521
  send_window?: components["schemas"]["CampaignSendWindow"] & unknown;
87522
+ send_schedule?: components["schemas"]["CampaignSendSchedule"] & unknown;
87515
87523
  };
87516
87524
  };
87517
87525
  };
@@ -87825,7 +87833,9 @@ interface paths {
87825
87833
  *
87826
87834
  * Legal from `draft` and `scheduled`; a 409 from anywhere else. Sending is not undoable once recipients start receiving — `/pause` stops the remainder, it does not recall what went out.
87827
87835
  *
87828
- * The response is the campaign plus `started: true` and `waiting_for_window_until`: a paced campaign (or a pilot) sent outside its send window sends nothing yet and waits for the window — this is when it opens; null = the first batch leaves now.
87836
+ * The response is the campaign plus `started: true` and `waiting_for_window_until`: a paced campaign (or a pilot) sent outside its send window sends nothing yet and waits for the window — this is when it opens; null = the first batch leaves now. With a `send_schedule` it is the first slot.
87837
+ *
87838
+ * Optional body `{ send_schedule }` (ADR 0139): sets the schedule and sends in one step. The «¿Lista para enviar?» checks (`GET /campaigns/{id}/preflight`) run again here: while any is `block` the answer is a **409 `preflight_blocked`** with the checks in `error.details.checks`, and nothing changes.
87829
87839
  */
87830
87840
  post: {
87831
87841
  parameters: {
@@ -87839,7 +87849,21 @@ interface paths {
87839
87849
  };
87840
87850
  cookie?: never;
87841
87851
  };
87842
- requestBody?: never;
87852
+ requestBody?: {
87853
+ content: {
87854
+ /**
87855
+ * @example {
87856
+ * "send_schedule": {
87857
+ * "kind": "daily",
87858
+ * "timezone": "America/Santiago",
87859
+ * "start_date": "2026-10-01",
87860
+ * "time": "20:00"
87861
+ * }
87862
+ * }
87863
+ */
87864
+ "application/json": components["schemas"]["CampaignSendNowBody"];
87865
+ };
87866
+ };
87843
87867
  responses: {
87844
87868
  /** @description The campaign, now scheduled, and whether it waits for its window */
87845
87869
  200: {
@@ -87968,6 +87992,165 @@ interface paths {
87968
87992
  patch?: never;
87969
87993
  trace?: never;
87970
87994
  };
87995
+ "/campaigns/{id}/preflight": {
87996
+ parameters: {
87997
+ query?: never;
87998
+ header?: never;
87999
+ path?: never;
88000
+ cookie?: never;
88001
+ };
88002
+ /**
88003
+ * «¿Lista para enviar?» — the checks before a send
88004
+ * @description Everything worth knowing before pressing send, as a check list (ADR 0139): each `{ key, status: ok | warn | block, title_es/_en, detail_es/_en?, href? }`. WhatsApp: `template_approved`, `recipients` (reachable vs not), `header_media`, `test_sent` (a test in the last 7 days), `messaging_tier`, `number_quality`, `schedule` (the simulation’s issues), `replies` (who answers the replies: the AI agent the number routes to, or the team — `warn` when the team answers and some sends fall outside the contact hours), `opt_out` (a quick-reply button to say no), `recent_campaign_overlap` (people who got a campaign in the last 7 days). Email: `template`, `recipients`, `unsubscribe`, `test_sent`, `sender_domain`. `ready` = no `block`; `/send` refuses with 409 `preflight_blocked` otherwise. `summary` says how it will go (recipients, schedule label, first batch, completion, batches) and `plan` is the schedule simulated («Ver plan»). Reads only.
88005
+ */
88006
+ get: {
88007
+ parameters: {
88008
+ query?: never;
88009
+ header?: never;
88010
+ path: {
88011
+ id: string;
88012
+ };
88013
+ cookie?: never;
88014
+ };
88015
+ requestBody?: never;
88016
+ responses: {
88017
+ /** @description The checks, the summary and the plan */
88018
+ 200: {
88019
+ headers: {
88020
+ [name: string]: unknown;
88021
+ };
88022
+ content: {
88023
+ /**
88024
+ * @example {
88025
+ * "data": {
88026
+ * "ready": true,
88027
+ * "checks": [
88028
+ * {
88029
+ * "key": "template_approved",
88030
+ * "status": "ok",
88031
+ * "title_es": "Plantilla aprobada por Meta",
88032
+ * "title_en": "Template approved by Meta",
88033
+ * "detail_es": "promo_octubre",
88034
+ * "detail_en": "promo_octubre"
88035
+ * },
88036
+ * {
88037
+ * "key": "recipients",
88038
+ * "status": "warn",
88039
+ * "title_es": "Se enviará a 801 personas",
88040
+ * "title_en": "It will go to 801 people",
88041
+ * "detail_es": "50 no la recibirán: sin número válido, duplicadas o pidieron no recibir mensajes.",
88042
+ * "detail_en": "50 will not get it: no valid number, duplicates or opted out.",
88043
+ * "href": "/campaigns/audiences/7a7a7a7a-0000-4000-8000-0000000000a1"
88044
+ * },
88045
+ * {
88046
+ * "key": "messaging_tier",
88047
+ * "status": "ok",
88048
+ * "title_es": "Tu número puede iniciar 250 conversaciones cada 24 h",
88049
+ * "title_en": "Your number can start 250 conversations every 24 h",
88050
+ * "detail_es": "Las campañas dejan 50 libres para recordatorios y otros mensajes.",
88051
+ * "detail_en": "Campaigns leave 50 free for reminders and other messages."
88052
+ * }
88053
+ * ],
88054
+ * "summary": {
88055
+ * "recipients": 801,
88056
+ * "channel": "whatsapp",
88057
+ * "template_name": "promo_octubre",
88058
+ * "schedule_label_es": "Todos los días a las 20:00 (America/Santiago) desde hoy",
88059
+ * "schedule_label_en": "Every day at 20:00 (America/Santiago) from today",
88060
+ * "first_batch_at": "2026-10-01T23:00:00.000Z",
88061
+ * "completes_at": "2026-10-05T23:00:00.000Z",
88062
+ * "batches_count": 5,
88063
+ * "limit_per_24h": 250,
88064
+ * "reserve": 50
88065
+ * },
88066
+ * "plan": {
88067
+ * "batches": [
88068
+ * {
88069
+ * "at": "2026-10-01T23:00:00.000Z",
88070
+ * "local": "jue 1 oct, 20:00",
88071
+ * "planned": 200,
88072
+ * "slot_index": null,
88073
+ * "warnings": []
88074
+ * }
88075
+ * ],
88076
+ * "covers_all": true,
88077
+ * "remaining_after_last": 0,
88078
+ * "completes_at": "2026-10-05T23:00:00.000Z",
88079
+ * "issues": [],
88080
+ * "tier_unknown": false
88081
+ * }
88082
+ * }
88083
+ * }
88084
+ */
88085
+ "application/json": {
88086
+ data: components["schemas"]["CampaignPreflight"];
88087
+ };
88088
+ };
88089
+ };
88090
+ /** @description Validation error */
88091
+ 400: {
88092
+ headers: {
88093
+ [name: string]: unknown;
88094
+ };
88095
+ content: {
88096
+ "application/json": components["schemas"]["Error"];
88097
+ };
88098
+ };
88099
+ /** @description Unauthorized */
88100
+ 401: {
88101
+ headers: {
88102
+ [name: string]: unknown;
88103
+ };
88104
+ content: {
88105
+ "application/json": components["schemas"]["Error"];
88106
+ };
88107
+ };
88108
+ /** @description Forbidden */
88109
+ 403: {
88110
+ headers: {
88111
+ [name: string]: unknown;
88112
+ };
88113
+ content: {
88114
+ "application/json": components["schemas"]["Error"];
88115
+ };
88116
+ };
88117
+ /** @description Not found */
88118
+ 404: {
88119
+ headers: {
88120
+ [name: string]: unknown;
88121
+ };
88122
+ content: {
88123
+ "application/json": components["schemas"]["Error"];
88124
+ };
88125
+ };
88126
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
88127
+ 409: {
88128
+ headers: {
88129
+ [name: string]: unknown;
88130
+ };
88131
+ content: {
88132
+ "application/json": components["schemas"]["Error"];
88133
+ };
88134
+ };
88135
+ /** @description Rate limited */
88136
+ 429: {
88137
+ headers: {
88138
+ [name: string]: unknown;
88139
+ };
88140
+ content: {
88141
+ "application/json": components["schemas"]["Error"];
88142
+ };
88143
+ };
88144
+ };
88145
+ };
88146
+ put?: never;
88147
+ post?: never;
88148
+ delete?: never;
88149
+ options?: never;
88150
+ head?: never;
88151
+ patch?: never;
88152
+ trace?: never;
88153
+ };
87971
88154
  "/campaigns/{id}/pause": {
87972
88155
  parameters: {
87973
88156
  query?: never;
@@ -180456,6 +180639,70 @@ interface components {
180456
180639
  /** @description Local closing time, HH:MM (exclusive); later than start. */
180457
180640
  end: string;
180458
180641
  } | null;
180642
+ /** @description The schedule this plan used (ADR 0139); null = none. */
180643
+ CampaignSendSchedule: {
180644
+ /** @enum {string} */
180645
+ kind: "daily";
180646
+ /** @description IANA zone, e.g. America/Santiago. */
180647
+ timezone: string;
180648
+ /** @description First day (local), YYYY-MM-DD. */
180649
+ start_date: string;
180650
+ /** @description Local time of every batch, HH:MM. */
180651
+ time: string;
180652
+ } | {
180653
+ /** @enum {string} */
180654
+ kind: "slots";
180655
+ /** @description IANA zone, e.g. America/Santiago. */
180656
+ timezone: string;
180657
+ /** @description The batches, one per instant (stored sorted ascending). */
180658
+ slots: {
180659
+ /** @description Local date, YYYY-MM-DD. */
180660
+ date: string;
180661
+ /** @description Local time, HH:MM. */
180662
+ time: string;
180663
+ }[];
180664
+ /**
180665
+ * @description Recipients left after the last slot: continue every day at the last slot’s time, or pause (schedule_exhausted).
180666
+ * @enum {string}
180667
+ */
180668
+ after_last: "continue_daily" | "pause";
180669
+ } | null;
180670
+ /** @description With a schedule: batch by batch, against the budget (ADR 0139). Null without one. */
180671
+ CampaignScheduleSimulation: {
180672
+ batches: {
180673
+ /** @description The slot instant (ISO). */
180674
+ at: string;
180675
+ /** @description The slot on the schedule’s clock, e.g. «jue 15 oct, 20:00». */
180676
+ local: string;
180677
+ /** @description People this batch would send to. */
180678
+ planned: number;
180679
+ /** @description Index into the sorted `slots`; null for a daily batch. */
180680
+ slot_index: number | null;
180681
+ warnings: ("budget_not_freed" | "partial_budget" | "outside_contact_hours" | "in_the_past")[];
180682
+ }[];
180683
+ covers_all: boolean;
180684
+ remaining_after_last: number;
180685
+ /** @description The slot that sends the last person; null when it never does. */
180686
+ completes_at: string | null;
180687
+ issues: {
180688
+ /** @enum {string} */
180689
+ code: "slot_in_past" | "duplicate_slot" | "too_close" | "uncovered" | "asap_not_allowed";
180690
+ slot_index?: number;
180691
+ message_es: string;
180692
+ message_en: string;
180693
+ /** @description The earliest instant that would work (ISO). */
180694
+ suggested_at?: string;
180695
+ }[];
180696
+ /** @description No tier known for the number: no cap applied (all at the first slot). */
180697
+ tier_unknown: boolean;
180698
+ /**
180699
+ * @description Who answers the replies: `ai` = the AI agent the number routes to (slots outside the contact hours carry no `outside_contact_hours` warning); `human` = the team; null = unknown (warned as for the team).
180700
+ * @enum {string|null}
180701
+ */
180702
+ replies_handled_by: "ai" | "human" | null;
180703
+ /** @description The batches (`local`) outside the workspace’s contact hours, whoever answers. */
180704
+ outside_contact_hours: string[];
180705
+ } | null;
180459
180706
  CampaignSendPlan: {
180460
180707
  recipients: number;
180461
180708
  sendable_now: number | null;
@@ -180475,6 +180722,10 @@ interface components {
180475
180722
  window_label: string | null;
180476
180723
  /** @description Set when it is outside the window now: the first batch waits until then. */
180477
180724
  next_window_opens_at: string | null;
180725
+ send_schedule?: components["schemas"]["CampaignSendSchedule"];
180726
+ /** @description e.g. «Todos los días a las 20:00 (America/Santiago) desde hoy». */
180727
+ schedule_label?: string | null;
180728
+ schedule?: components["schemas"]["CampaignScheduleSimulation"];
180478
180729
  } | null;
180479
180730
  CampaignMessagingBudget: {
180480
180731
  budget: components["schemas"]["MessagingBudget"];
@@ -180486,6 +180737,46 @@ interface components {
180486
180737
  /** @description Outside the send window: nothing leaves until this instant (the window opening). Null = sends now. */
180487
180738
  waiting_for_window_until: string | null;
180488
180739
  };
180740
+ CampaignSendNowBody: {
180741
+ send_schedule?: components["schemas"]["CampaignSendSchedule"] & unknown;
180742
+ };
180743
+ CampaignPreflight: {
180744
+ /** @description No check is `block`. */
180745
+ ready: boolean;
180746
+ checks: {
180747
+ /** @description template_approved | recipients | header_media | test_sent | messaging_tier | number_quality | schedule | replies | opt_out | recent_campaign_overlap (WhatsApp); template | recipients | unsubscribe | test_sent | sender_domain (email). */
180748
+ key: string;
180749
+ /** @enum {string} */
180750
+ status: "ok" | "warn" | "block";
180751
+ title_es: string;
180752
+ title_en: string;
180753
+ detail_es?: string;
180754
+ detail_en?: string;
180755
+ /** @description App-relative link to fix it, e.g. the template or the audience. */
180756
+ href?: string;
180757
+ }[];
180758
+ summary: {
180759
+ recipients: number;
180760
+ /** @enum {string} */
180761
+ channel: "whatsapp" | "email";
180762
+ template_name?: string;
180763
+ schedule_label_es: string;
180764
+ schedule_label_en: string;
180765
+ first_batch_at: string | null;
180766
+ completes_at: string | null;
180767
+ batches_count: number | null;
180768
+ /** @description The number’s Meta limit (WhatsApp); null = no cap known. */
180769
+ limit_per_24h?: number | null;
180770
+ /** @description Kept free for reminders and other senders (WhatsApp). */
180771
+ reserve?: number;
180772
+ /**
180773
+ * @description Who answers the replies (WhatsApp): the AI agent the number routes to, or the team (`reply_mode = human`, or no agent on the number).
180774
+ * @enum {string}
180775
+ */
180776
+ replies_handled_by?: "ai" | "human";
180777
+ };
180778
+ plan: components["schemas"]["CampaignScheduleSimulation"] & unknown;
180779
+ };
180489
180780
  CampaignResumeBody: {
180490
180781
  /**
180491
180782
  * @description paced: continue automatically across the rolling 24 h windows; asap: send what fits now and pause (ADR 0129).
package/dist/index.d.ts CHANGED
@@ -27349,7 +27349,7 @@ interface paths {
27349
27349
  * First-touch status for one lead source
27350
27350
  * @description Health and recent outcomes of the proactive first message for one lead source (`chileautos`, `yapo`, `mercadolibre`, `website`, …): which rail it uses, whether its account is usable, sends today, and the latest outcomes with the reason a lead was skipped.
27351
27351
  *
27352
- * `website` is ON by default for every workspace. With no `website` block of its own it borrows the account and template chain of the first enabled source (`config_origin: inherited`, named in `inherited_from`), or uses the partner WhatsApp account and Vitrina's own website templates (`platform_default`). `templates` lists the WhatsApp ladder in send order with each template's state on that account: only `APPROVED` templates are ever sent; a `PENDING` or `REJECTED` one is shown so it is not silently skipped, and `status: null` means it is not on that account. When no template can be sent the first message goes by email, from the workspace mailbox.
27352
+ * `website` is ON by default for every workspace, and a portal (`chileautos`, `mercadolibre`, `yapo`) is ON by default once the workspace has an enabled marketplace account for it. With no block of its own such a source borrows the account and template chain of the first enabled source (`config_origin: inherited`, named in `inherited_from`), or uses the partner WhatsApp account and Vitrina's own templates — for a portal, the workspace's own first-contact templates first, then Vitrina's fallback ones (`platform_default`). An explicit block, `enabled: false` included, always wins. `templates` lists the WhatsApp ladder in send order with each template's state on that account: only `APPROVED` templates are ever sent; a `PENDING` or `REJECTED` one is shown so it is not silently skipped, and `status: null` means it is not on that account. When no template can be sent the first message goes by email, from the workspace mailbox.
27353
27353
  */
27354
27354
  get: {
27355
27355
  parameters: {
@@ -86942,6 +86942,7 @@ interface paths {
86942
86942
  /** @description Pilot: send this many random recipients first, then pause (paused_reason "pilot") until resumed. Null = no pilot. */
86943
86943
  pilot_size?: number | null;
86944
86944
  send_window?: components["schemas"]["CampaignSendWindow"] & unknown;
86945
+ send_schedule?: components["schemas"]["CampaignSendSchedule"] & unknown;
86945
86946
  };
86946
86947
  };
86947
86948
  };
@@ -87078,6 +87079,8 @@ interface paths {
87078
87079
  * With `recipients`, `plan` says how a campaign to that many people would go: `sendable_now` (its fair share of the headroom, shared with the other campaigns sending on the number), `windows` (sending days), `estimated_completion_at` (continuations move into the workspace’s marketing hours) and the `recommended_send_mode`. `campaign_id` makes a saved campaign’s own recent sends count as its. 404 for a number that is not this workspace’s, 400 for one that is not WhatsApp.
87079
87080
  *
87080
87081
  * `send_window` (JSON-encoded, optional) plans against that window — `null` = the workspace default; absent = the saved campaign’s effective window (with `campaign_id`), else the workspace default. The plan then answers `send_window` (resolved), `window_label` («lun–vie 10:00–18:00 (America/Santiago)») and, when it is outside the window now, `next_window_opens_at` — the first batch, `next_batch_at` and `estimated_completion_at` start there, and every continuation lands inside the window. An invalid window is a 400 with `field_errors` (`send_window.start`, …).
87082
+ *
87083
+ * `send_schedule` (JSON-encoded `CampaignSendSchedule`, optional; `null` = none; absent = the saved campaign’s) plans against explicit instants instead (ADR 0139): `plan.schedule` simulates it batch by batch against the rolling 24 h — `planned` per slot, per-slot `warnings` (`budget_not_freed`, `partial_budget`, `outside_contact_hours` — only when the team answers the replies, see `reply_mode` —, `in_the_past`), `covers_all`, `completes_at` and `issues` (`slot_in_past`, `duplicate_slot`, `too_close` with a `suggested_at`, `uncovered`, `asap_not_allowed`). The window fields are then null: a schedule replaces the window.
87081
87084
  */
87082
87085
  get: {
87083
87086
  parameters: {
@@ -87087,6 +87090,10 @@ interface paths {
87087
87090
  campaign_id?: string;
87088
87091
  /** @description JSON-encoded CampaignSendWindow to plan with (e.g. {"timezone":"America/Santiago","days":[1,2,3,4,5],"start":"10:00","end":"18:00"}), or `null` for the workspace default. Absent = the campaign's effective window (with campaign_id), else the workspace default. */
87089
87092
  send_window?: string;
87093
+ /** @description JSON-encoded CampaignSendSchedule to plan with (e.g. {"kind":"daily","timezone":"America/Santiago","start_date":"2026-10-14","time":"20:00"}), or `null` for none. Absent = the saved campaign's schedule (with campaign_id), else none. With a schedule, `plan.schedule` carries the simulation. */
87094
+ send_schedule?: string;
87095
+ /** @description Who answers the replies, to plan with. `account_default` resolves the number's routing (an AI agent answers → slots outside the contact hours are not warned about). Absent = the saved campaign's (with campaign_id), else unknown (the warning stays). */
87096
+ reply_mode?: "account_default" | "human";
87090
87097
  };
87091
87098
  header?: never;
87092
87099
  path?: never;
@@ -87221,7 +87228,7 @@ interface paths {
87221
87228
  };
87222
87229
  /**
87223
87230
  * Fetch one campaign with its stats
87224
- * @description The campaign plus its delivery counters — this is the read to poll while a send is in progress. A WhatsApp campaign that is not finished also carries `pacing` (ADR 0129): its number’s tier and `limit_per_24h`, `sent_last_24h`, `pending`, `waiting` (a paced campaign waiting for the window) with `next_batch_at`, `estimated_completion_at` and `windows_remaining`, plus the effective `send_window` (`send_window_source`: campaign | workspace), its `window_label` and `next_window_opens_at` (outside the window now); null when the budget cannot be read.
87231
+ * @description The campaign plus its delivery counters — this is the read to poll while a send is in progress. A WhatsApp campaign that is not finished also carries `pacing` (ADR 0129): its number’s tier and `limit_per_24h`, `sent_last_24h`, `pending`, `waiting` (a paced campaign waiting for the window) with `next_batch_at`, `estimated_completion_at` and `windows_remaining`, plus the effective `send_window` (`send_window_source`: campaign | workspace), its `window_label` and `next_window_opens_at` (outside the window now); null when the budget cannot be read. With a `send_schedule` (ADR 0139) it also carries `schedule_label`, `next_slot_at`, `batches` (what each slot did: planned / sent / failed / skipped_reason, oldest first) and `schedule` — the pending part simulated slot by slot.
87225
87232
  */
87226
87233
  get: {
87227
87234
  parameters: {
@@ -87455,7 +87462,7 @@ interface paths {
87455
87462
  head?: never;
87456
87463
  /**
87457
87464
  * Edit a campaign
87458
- * @description Legal only while the campaign is `draft` or `scheduled`; from any other status this is a **409** — except a body carrying ONLY `send_window`, which is also legal while `paused` or `sending` and takes effect at the next batch (a campaign waiting for the old window re-plans at once). At least one field is required. `channel` is absent from the body on purpose — a campaign’s channel is fixed at creation, since the content shape depends on it.
87465
+ * @description Legal only while the campaign is `draft` or `scheduled`; from any other status this is a **409** — except a body carrying ONLY `send_window` and/or `send_schedule`, which is also legal while `paused` or `sending` and takes effect at the next batch (a campaign waiting for the old window or slot re-plans at once). At least one field is required. A `send_schedule` with `send_mode: asap` (set or stored) is a 400 `schedule_requires_paced`; a slot in the past or two slots at once a 400 `schedule_invalid`. `channel` is absent from the body on purpose — a campaign’s channel is fixed at creation, since the content shape depends on it.
87459
87466
  */
87460
87467
  patch: {
87461
87468
  parameters: {
@@ -87512,6 +87519,7 @@ interface paths {
87512
87519
  /** @description Pilot: send this many random recipients first, then pause (paused_reason "pilot") until resumed. Null = no pilot. */
87513
87520
  pilot_size?: number | null;
87514
87521
  send_window?: components["schemas"]["CampaignSendWindow"] & unknown;
87522
+ send_schedule?: components["schemas"]["CampaignSendSchedule"] & unknown;
87515
87523
  };
87516
87524
  };
87517
87525
  };
@@ -87825,7 +87833,9 @@ interface paths {
87825
87833
  *
87826
87834
  * Legal from `draft` and `scheduled`; a 409 from anywhere else. Sending is not undoable once recipients start receiving — `/pause` stops the remainder, it does not recall what went out.
87827
87835
  *
87828
- * The response is the campaign plus `started: true` and `waiting_for_window_until`: a paced campaign (or a pilot) sent outside its send window sends nothing yet and waits for the window — this is when it opens; null = the first batch leaves now.
87836
+ * The response is the campaign plus `started: true` and `waiting_for_window_until`: a paced campaign (or a pilot) sent outside its send window sends nothing yet and waits for the window — this is when it opens; null = the first batch leaves now. With a `send_schedule` it is the first slot.
87837
+ *
87838
+ * Optional body `{ send_schedule }` (ADR 0139): sets the schedule and sends in one step. The «¿Lista para enviar?» checks (`GET /campaigns/{id}/preflight`) run again here: while any is `block` the answer is a **409 `preflight_blocked`** with the checks in `error.details.checks`, and nothing changes.
87829
87839
  */
87830
87840
  post: {
87831
87841
  parameters: {
@@ -87839,7 +87849,21 @@ interface paths {
87839
87849
  };
87840
87850
  cookie?: never;
87841
87851
  };
87842
- requestBody?: never;
87852
+ requestBody?: {
87853
+ content: {
87854
+ /**
87855
+ * @example {
87856
+ * "send_schedule": {
87857
+ * "kind": "daily",
87858
+ * "timezone": "America/Santiago",
87859
+ * "start_date": "2026-10-01",
87860
+ * "time": "20:00"
87861
+ * }
87862
+ * }
87863
+ */
87864
+ "application/json": components["schemas"]["CampaignSendNowBody"];
87865
+ };
87866
+ };
87843
87867
  responses: {
87844
87868
  /** @description The campaign, now scheduled, and whether it waits for its window */
87845
87869
  200: {
@@ -87968,6 +87992,165 @@ interface paths {
87968
87992
  patch?: never;
87969
87993
  trace?: never;
87970
87994
  };
87995
+ "/campaigns/{id}/preflight": {
87996
+ parameters: {
87997
+ query?: never;
87998
+ header?: never;
87999
+ path?: never;
88000
+ cookie?: never;
88001
+ };
88002
+ /**
88003
+ * «¿Lista para enviar?» — the checks before a send
88004
+ * @description Everything worth knowing before pressing send, as a check list (ADR 0139): each `{ key, status: ok | warn | block, title_es/_en, detail_es/_en?, href? }`. WhatsApp: `template_approved`, `recipients` (reachable vs not), `header_media`, `test_sent` (a test in the last 7 days), `messaging_tier`, `number_quality`, `schedule` (the simulation’s issues), `replies` (who answers the replies: the AI agent the number routes to, or the team — `warn` when the team answers and some sends fall outside the contact hours), `opt_out` (a quick-reply button to say no), `recent_campaign_overlap` (people who got a campaign in the last 7 days). Email: `template`, `recipients`, `unsubscribe`, `test_sent`, `sender_domain`. `ready` = no `block`; `/send` refuses with 409 `preflight_blocked` otherwise. `summary` says how it will go (recipients, schedule label, first batch, completion, batches) and `plan` is the schedule simulated («Ver plan»). Reads only.
88005
+ */
88006
+ get: {
88007
+ parameters: {
88008
+ query?: never;
88009
+ header?: never;
88010
+ path: {
88011
+ id: string;
88012
+ };
88013
+ cookie?: never;
88014
+ };
88015
+ requestBody?: never;
88016
+ responses: {
88017
+ /** @description The checks, the summary and the plan */
88018
+ 200: {
88019
+ headers: {
88020
+ [name: string]: unknown;
88021
+ };
88022
+ content: {
88023
+ /**
88024
+ * @example {
88025
+ * "data": {
88026
+ * "ready": true,
88027
+ * "checks": [
88028
+ * {
88029
+ * "key": "template_approved",
88030
+ * "status": "ok",
88031
+ * "title_es": "Plantilla aprobada por Meta",
88032
+ * "title_en": "Template approved by Meta",
88033
+ * "detail_es": "promo_octubre",
88034
+ * "detail_en": "promo_octubre"
88035
+ * },
88036
+ * {
88037
+ * "key": "recipients",
88038
+ * "status": "warn",
88039
+ * "title_es": "Se enviará a 801 personas",
88040
+ * "title_en": "It will go to 801 people",
88041
+ * "detail_es": "50 no la recibirán: sin número válido, duplicadas o pidieron no recibir mensajes.",
88042
+ * "detail_en": "50 will not get it: no valid number, duplicates or opted out.",
88043
+ * "href": "/campaigns/audiences/7a7a7a7a-0000-4000-8000-0000000000a1"
88044
+ * },
88045
+ * {
88046
+ * "key": "messaging_tier",
88047
+ * "status": "ok",
88048
+ * "title_es": "Tu número puede iniciar 250 conversaciones cada 24 h",
88049
+ * "title_en": "Your number can start 250 conversations every 24 h",
88050
+ * "detail_es": "Las campañas dejan 50 libres para recordatorios y otros mensajes.",
88051
+ * "detail_en": "Campaigns leave 50 free for reminders and other messages."
88052
+ * }
88053
+ * ],
88054
+ * "summary": {
88055
+ * "recipients": 801,
88056
+ * "channel": "whatsapp",
88057
+ * "template_name": "promo_octubre",
88058
+ * "schedule_label_es": "Todos los días a las 20:00 (America/Santiago) desde hoy",
88059
+ * "schedule_label_en": "Every day at 20:00 (America/Santiago) from today",
88060
+ * "first_batch_at": "2026-10-01T23:00:00.000Z",
88061
+ * "completes_at": "2026-10-05T23:00:00.000Z",
88062
+ * "batches_count": 5,
88063
+ * "limit_per_24h": 250,
88064
+ * "reserve": 50
88065
+ * },
88066
+ * "plan": {
88067
+ * "batches": [
88068
+ * {
88069
+ * "at": "2026-10-01T23:00:00.000Z",
88070
+ * "local": "jue 1 oct, 20:00",
88071
+ * "planned": 200,
88072
+ * "slot_index": null,
88073
+ * "warnings": []
88074
+ * }
88075
+ * ],
88076
+ * "covers_all": true,
88077
+ * "remaining_after_last": 0,
88078
+ * "completes_at": "2026-10-05T23:00:00.000Z",
88079
+ * "issues": [],
88080
+ * "tier_unknown": false
88081
+ * }
88082
+ * }
88083
+ * }
88084
+ */
88085
+ "application/json": {
88086
+ data: components["schemas"]["CampaignPreflight"];
88087
+ };
88088
+ };
88089
+ };
88090
+ /** @description Validation error */
88091
+ 400: {
88092
+ headers: {
88093
+ [name: string]: unknown;
88094
+ };
88095
+ content: {
88096
+ "application/json": components["schemas"]["Error"];
88097
+ };
88098
+ };
88099
+ /** @description Unauthorized */
88100
+ 401: {
88101
+ headers: {
88102
+ [name: string]: unknown;
88103
+ };
88104
+ content: {
88105
+ "application/json": components["schemas"]["Error"];
88106
+ };
88107
+ };
88108
+ /** @description Forbidden */
88109
+ 403: {
88110
+ headers: {
88111
+ [name: string]: unknown;
88112
+ };
88113
+ content: {
88114
+ "application/json": components["schemas"]["Error"];
88115
+ };
88116
+ };
88117
+ /** @description Not found */
88118
+ 404: {
88119
+ headers: {
88120
+ [name: string]: unknown;
88121
+ };
88122
+ content: {
88123
+ "application/json": components["schemas"]["Error"];
88124
+ };
88125
+ };
88126
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
88127
+ 409: {
88128
+ headers: {
88129
+ [name: string]: unknown;
88130
+ };
88131
+ content: {
88132
+ "application/json": components["schemas"]["Error"];
88133
+ };
88134
+ };
88135
+ /** @description Rate limited */
88136
+ 429: {
88137
+ headers: {
88138
+ [name: string]: unknown;
88139
+ };
88140
+ content: {
88141
+ "application/json": components["schemas"]["Error"];
88142
+ };
88143
+ };
88144
+ };
88145
+ };
88146
+ put?: never;
88147
+ post?: never;
88148
+ delete?: never;
88149
+ options?: never;
88150
+ head?: never;
88151
+ patch?: never;
88152
+ trace?: never;
88153
+ };
87971
88154
  "/campaigns/{id}/pause": {
87972
88155
  parameters: {
87973
88156
  query?: never;
@@ -180456,6 +180639,70 @@ interface components {
180456
180639
  /** @description Local closing time, HH:MM (exclusive); later than start. */
180457
180640
  end: string;
180458
180641
  } | null;
180642
+ /** @description The schedule this plan used (ADR 0139); null = none. */
180643
+ CampaignSendSchedule: {
180644
+ /** @enum {string} */
180645
+ kind: "daily";
180646
+ /** @description IANA zone, e.g. America/Santiago. */
180647
+ timezone: string;
180648
+ /** @description First day (local), YYYY-MM-DD. */
180649
+ start_date: string;
180650
+ /** @description Local time of every batch, HH:MM. */
180651
+ time: string;
180652
+ } | {
180653
+ /** @enum {string} */
180654
+ kind: "slots";
180655
+ /** @description IANA zone, e.g. America/Santiago. */
180656
+ timezone: string;
180657
+ /** @description The batches, one per instant (stored sorted ascending). */
180658
+ slots: {
180659
+ /** @description Local date, YYYY-MM-DD. */
180660
+ date: string;
180661
+ /** @description Local time, HH:MM. */
180662
+ time: string;
180663
+ }[];
180664
+ /**
180665
+ * @description Recipients left after the last slot: continue every day at the last slot’s time, or pause (schedule_exhausted).
180666
+ * @enum {string}
180667
+ */
180668
+ after_last: "continue_daily" | "pause";
180669
+ } | null;
180670
+ /** @description With a schedule: batch by batch, against the budget (ADR 0139). Null without one. */
180671
+ CampaignScheduleSimulation: {
180672
+ batches: {
180673
+ /** @description The slot instant (ISO). */
180674
+ at: string;
180675
+ /** @description The slot on the schedule’s clock, e.g. «jue 15 oct, 20:00». */
180676
+ local: string;
180677
+ /** @description People this batch would send to. */
180678
+ planned: number;
180679
+ /** @description Index into the sorted `slots`; null for a daily batch. */
180680
+ slot_index: number | null;
180681
+ warnings: ("budget_not_freed" | "partial_budget" | "outside_contact_hours" | "in_the_past")[];
180682
+ }[];
180683
+ covers_all: boolean;
180684
+ remaining_after_last: number;
180685
+ /** @description The slot that sends the last person; null when it never does. */
180686
+ completes_at: string | null;
180687
+ issues: {
180688
+ /** @enum {string} */
180689
+ code: "slot_in_past" | "duplicate_slot" | "too_close" | "uncovered" | "asap_not_allowed";
180690
+ slot_index?: number;
180691
+ message_es: string;
180692
+ message_en: string;
180693
+ /** @description The earliest instant that would work (ISO). */
180694
+ suggested_at?: string;
180695
+ }[];
180696
+ /** @description No tier known for the number: no cap applied (all at the first slot). */
180697
+ tier_unknown: boolean;
180698
+ /**
180699
+ * @description Who answers the replies: `ai` = the AI agent the number routes to (slots outside the contact hours carry no `outside_contact_hours` warning); `human` = the team; null = unknown (warned as for the team).
180700
+ * @enum {string|null}
180701
+ */
180702
+ replies_handled_by: "ai" | "human" | null;
180703
+ /** @description The batches (`local`) outside the workspace’s contact hours, whoever answers. */
180704
+ outside_contact_hours: string[];
180705
+ } | null;
180459
180706
  CampaignSendPlan: {
180460
180707
  recipients: number;
180461
180708
  sendable_now: number | null;
@@ -180475,6 +180722,10 @@ interface components {
180475
180722
  window_label: string | null;
180476
180723
  /** @description Set when it is outside the window now: the first batch waits until then. */
180477
180724
  next_window_opens_at: string | null;
180725
+ send_schedule?: components["schemas"]["CampaignSendSchedule"];
180726
+ /** @description e.g. «Todos los días a las 20:00 (America/Santiago) desde hoy». */
180727
+ schedule_label?: string | null;
180728
+ schedule?: components["schemas"]["CampaignScheduleSimulation"];
180478
180729
  } | null;
180479
180730
  CampaignMessagingBudget: {
180480
180731
  budget: components["schemas"]["MessagingBudget"];
@@ -180486,6 +180737,46 @@ interface components {
180486
180737
  /** @description Outside the send window: nothing leaves until this instant (the window opening). Null = sends now. */
180487
180738
  waiting_for_window_until: string | null;
180488
180739
  };
180740
+ CampaignSendNowBody: {
180741
+ send_schedule?: components["schemas"]["CampaignSendSchedule"] & unknown;
180742
+ };
180743
+ CampaignPreflight: {
180744
+ /** @description No check is `block`. */
180745
+ ready: boolean;
180746
+ checks: {
180747
+ /** @description template_approved | recipients | header_media | test_sent | messaging_tier | number_quality | schedule | replies | opt_out | recent_campaign_overlap (WhatsApp); template | recipients | unsubscribe | test_sent | sender_domain (email). */
180748
+ key: string;
180749
+ /** @enum {string} */
180750
+ status: "ok" | "warn" | "block";
180751
+ title_es: string;
180752
+ title_en: string;
180753
+ detail_es?: string;
180754
+ detail_en?: string;
180755
+ /** @description App-relative link to fix it, e.g. the template or the audience. */
180756
+ href?: string;
180757
+ }[];
180758
+ summary: {
180759
+ recipients: number;
180760
+ /** @enum {string} */
180761
+ channel: "whatsapp" | "email";
180762
+ template_name?: string;
180763
+ schedule_label_es: string;
180764
+ schedule_label_en: string;
180765
+ first_batch_at: string | null;
180766
+ completes_at: string | null;
180767
+ batches_count: number | null;
180768
+ /** @description The number’s Meta limit (WhatsApp); null = no cap known. */
180769
+ limit_per_24h?: number | null;
180770
+ /** @description Kept free for reminders and other senders (WhatsApp). */
180771
+ reserve?: number;
180772
+ /**
180773
+ * @description Who answers the replies (WhatsApp): the AI agent the number routes to, or the team (`reply_mode = human`, or no agent on the number).
180774
+ * @enum {string}
180775
+ */
180776
+ replies_handled_by?: "ai" | "human";
180777
+ };
180778
+ plan: components["schemas"]["CampaignScheduleSimulation"] & unknown;
180779
+ };
180489
180780
  CampaignResumeBody: {
180490
180781
  /**
180491
180782
  * @description paced: continue automatically across the rolling 24 h windows; asap: send what fits now and pause (ADR 0129).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitrina/api",
3
- "version": "14.14.1",
3
+ "version": "14.15.1",
4
4
  "description": "Typed TypeScript SDK for the Vitrina API pública — generated from the committed openapi.public.json (ADR 0106).",
5
5
  "type": "module",
6
6
  "license": "MIT",