@vitrina/api 14.2.0 → 14.3.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
@@ -101712,7 +101712,8 @@ interface paths {
101712
101712
  * "presupuestado_clp": 4381028,
101713
101713
  * "presupuestos": 18,
101714
101714
  * "recaudado_clp": 3307992,
101715
- * "pagos": 21
101715
+ * "pagos": 21,
101716
+ * "citas": 52
101716
101717
  * },
101717
101718
  * "totals": {
101718
101719
  * "produccion": {
@@ -103551,17 +103552,32 @@ interface paths {
103551
103552
  * {
103552
103553
  * "hour": 9,
103553
103554
  * "total": 3,
103554
- * "primeras_visitas": 1
103555
+ * "primeras_visitas": 1,
103556
+ * "by_kind": {
103557
+ * "new": 1,
103558
+ * "new_rebooked": 0,
103559
+ * "in_treatment": 2
103560
+ * }
103555
103561
  * },
103556
103562
  * {
103557
103563
  * "hour": 11,
103558
103564
  * "total": 4,
103559
- * "primeras_visitas": 2
103565
+ * "primeras_visitas": 2,
103566
+ * "by_kind": {
103567
+ * "new": 1,
103568
+ * "new_rebooked": 1,
103569
+ * "in_treatment": 2
103570
+ * }
103560
103571
  * },
103561
103572
  * {
103562
103573
  * "hour": 14,
103563
103574
  * "total": 2,
103564
- * "primeras_visitas": 1
103575
+ * "primeras_visitas": 1,
103576
+ * "by_kind": {
103577
+ * "new": 1,
103578
+ * "new_rebooked": 0,
103579
+ * "in_treatment": 1
103580
+ * }
103565
103581
  * }
103566
103582
  * ],
103567
103583
  * "origin": {
@@ -103634,6 +103650,12 @@ interface paths {
103634
103650
  hour: number;
103635
103651
  total: number;
103636
103652
  primeras_visitas: number;
103653
+ /** @description The hour's citas by Tipo de agendamiento; a cita whose kind could not be judged counts in `total` only. */
103654
+ by_kind: {
103655
+ new: number;
103656
+ new_rebooked: number;
103657
+ in_treatment: number;
103658
+ };
103637
103659
  }[];
103638
103660
  origin: {
103639
103661
  meta: number;
@@ -142756,9 +142778,10 @@ interface paths {
142756
142778
  * @description WHICH count to list — each is read from the very read the count is folded from, so `count` equals the number the screen shows:
142757
142779
  * · `paid_patients` / `arrived_patients` / `returned_patients` — `patient_return.patients` / `.arrived_patients` / `.returned_patients` of `/ads/overview` (no scope), of a `/ads/campaigns` row (`campaign_id`), of an ad (`ad_id`), or «Anuncios aún sin campaña conocida» (`unplaced=1`).
142758
142780
  * · `funnel_<step>` — `/ads/funnel` `steps[<step>].ads` = `/ads/stages` M1 `m1.conversations` (`funnel_contacted`), M2 `m2.booked` / `m2.attended`, M3 `m3.quote_presented` / `m3.accepted` / `m3.paid`. No scope.
142781
+ * · `new_people[_booked|_paid]`, `returned_people[_booked]` — `/ads/stages` `m2.new_people` (D93): `people` / `booked` / `paid` and `returned.people` / `returned.booked`, over that block’s own `window` (the read’s `window`). No scope.
142759
142782
  * · `conversations[_replied|_booked|_attended|_closed]` — the conversations ads opened (one row per CONVERSATION), all ads, one campaign (`campaign_id`, through the ad → campaign map as `/ads/campaigns` counts them) or one ad (`ad_id`).
142760
142783
  */
142761
- metric: "paid_patients" | "arrived_patients" | "returned_patients" | "funnel_contacted" | "funnel_booked" | "funnel_attended" | "funnel_quote_presented" | "funnel_accepted" | "funnel_paid" | "conversations" | "conversations_replied" | "conversations_booked" | "conversations_attended" | "conversations_closed";
142784
+ metric: "paid_patients" | "arrived_patients" | "returned_patients" | "funnel_contacted" | "funnel_booked" | "funnel_attended" | "funnel_quote_presented" | "funnel_accepted" | "funnel_paid" | "new_people" | "new_people_booked" | "new_people_paid" | "returned_people" | "returned_people_booked" | "conversations" | "conversations_replied" | "conversations_booked" | "conversations_attended" | "conversations_closed";
142762
142785
  /** @description A campaign’s PLATFORM id (`/ads/campaigns` `campaign_external_id`). Patient-return and conversation metrics only. */
142763
142786
  campaign_id?: string;
142764
142787
  /** @description An ad’s PLATFORM id. Patient-return and conversation metrics only. */
@@ -143681,7 +143704,13 @@ interface paths {
143681
143704
  * "booked_conversations": 45,
143682
143705
  * "ai_bookings": 54,
143683
143706
  * "rate_pct": 7.7,
143684
- * "team_helped": 60
143707
+ * "team_helped": 60,
143708
+ * "existing": {
143709
+ * "conversations": 214,
143710
+ * "booked_conversations": 38,
143711
+ * "ai_bookings": 41
143712
+ * },
143713
+ * "cancelled": 6
143685
143714
  * },
143686
143715
  * "from_ads": {
143687
143716
  * "conversations": 461,
@@ -143767,11 +143796,11 @@ interface paths {
143767
143796
  first_ai_booked_on: string | null;
143768
143797
  timezone: string;
143769
143798
  min_conversations: number;
143770
- /** @description The same figure as `conversation_rate` on `GET /clinic/insights/resultados` for the same days. */
143799
+ /** @description The same figure as `conversation_rate` on `GET /clinic/insights/resultados` for the same days. NEW PEOPLE ONLY (D94): conversations of people who had written before the window are counted in `existing`, never in the rate — nor in `from_ads`, `without_ad`, `by_campaign`, `by_ad`, `by_hour`. */
143771
143800
  overall: {
143772
- /** @description Conversations Vitrina answered ALONE: the person wrote, the AI agent replied after that message, and no team member wrote before the AI booking (or in the whole window, with no booking). */
143801
+ /** @description Conversations Vitrina answered ALONE with NEW people (they had not written before the window): the person wrote, the AI agent replied after that message, and no team member wrote before the AI booking (or in the whole window, with no booking). */
143773
143802
  conversations: number;
143774
- /** @description Of `conversations`, those where the agent booked at least one cita inside the window. */
143803
+ /** @description Of `conversations`, those where the agent booked at least one cita inside the window (anuladas excluded). */
143775
143804
  booked_conversations: number;
143776
143805
  /** @description Citas the agent booked in those conversations (≥ `booked_conversations`). */
143777
143806
  ai_bookings: number;
@@ -143779,12 +143808,23 @@ interface paths {
143779
143808
  rate_pct: number | null;
143780
143809
  /** @description Conversations the AI answered where a team member wrote first — excluded. */
143781
143810
  team_helped: number;
143811
+ /** @description People who had written before the window (D94): OUTSIDE the rate — its headline counts new people only — and shown on their own line. */
143812
+ existing: {
143813
+ /** @description Conversations Vitrina answered alone with people who had written to the business BEFORE the window (patients’ follow-ups, changes of hour, earlier leads). */
143814
+ conversations: number;
143815
+ /** @description Of them, those where the agent booked at least one cita (anuladas excluded). */
143816
+ booked_conversations: number;
143817
+ /** @description Citas the agent booked in them. */
143818
+ ai_bookings: number;
143819
+ };
143820
+ /** @description Citas the agent booked for new people in the window that were then anuladas — never in `ai_bookings`. */
143821
+ cancelled: number;
143782
143822
  } | null;
143783
143823
  /** @description Conversations a Meta ad opened (its `ad_referral`). */
143784
143824
  from_ads: {
143785
- /** @description Conversations Vitrina answered ALONE: the person wrote, the AI agent replied after that message, and no team member wrote before the AI booking (or in the whole window, with no booking). */
143825
+ /** @description Conversations Vitrina answered ALONE with NEW people (they had not written before the window): the person wrote, the AI agent replied after that message, and no team member wrote before the AI booking (or in the whole window, with no booking). */
143786
143826
  conversations: number;
143787
- /** @description Of `conversations`, those where the agent booked at least one cita inside the window. */
143827
+ /** @description Of `conversations`, those where the agent booked at least one cita inside the window (anuladas excluded). */
143788
143828
  booked_conversations: number;
143789
143829
  /** @description Citas the agent booked in those conversations (≥ `booked_conversations`). */
143790
143830
  ai_bookings: number;
@@ -143792,9 +143832,9 @@ interface paths {
143792
143832
  rate_pct: number | null;
143793
143833
  } | null;
143794
143834
  without_ad: {
143795
- /** @description Conversations Vitrina answered ALONE: the person wrote, the AI agent replied after that message, and no team member wrote before the AI booking (or in the whole window, with no booking). */
143835
+ /** @description Conversations Vitrina answered ALONE with NEW people (they had not written before the window): the person wrote, the AI agent replied after that message, and no team member wrote before the AI booking (or in the whole window, with no booking). */
143796
143836
  conversations: number;
143797
- /** @description Of `conversations`, those where the agent booked at least one cita inside the window. */
143837
+ /** @description Of `conversations`, those where the agent booked at least one cita inside the window (anuladas excluded). */
143798
143838
  booked_conversations: number;
143799
143839
  /** @description Citas the agent booked in those conversations (≥ `booked_conversations`). */
143800
143840
  ai_bookings: number;
@@ -143811,9 +143851,9 @@ interface paths {
143811
143851
  /** @description Meta's campaign id (= `/ads/campaigns` rows). */
143812
143852
  campaign_external_id: string;
143813
143853
  campaign_name: string | null;
143814
- /** @description Conversations Vitrina answered ALONE: the person wrote, the AI agent replied after that message, and no team member wrote before the AI booking (or in the whole window, with no booking). */
143854
+ /** @description Conversations Vitrina answered ALONE with NEW people (they had not written before the window): the person wrote, the AI agent replied after that message, and no team member wrote before the AI booking (or in the whole window, with no booking). */
143815
143855
  conversations: number;
143816
- /** @description Of `conversations`, those where the agent booked at least one cita inside the window. */
143856
+ /** @description Of `conversations`, those where the agent booked at least one cita inside the window (anuladas excluded). */
143817
143857
  booked_conversations: number;
143818
143858
  /** @description Citas the agent booked in those conversations (≥ `booked_conversations`). */
143819
143859
  ai_bookings: number;
@@ -143828,9 +143868,9 @@ interface paths {
143828
143868
  /** @description Meta's ad id (= `/ads/creatives` rows). */
143829
143869
  ad_external_id: string;
143830
143870
  campaign_external_id: string | null;
143831
- /** @description Conversations Vitrina answered ALONE: the person wrote, the AI agent replied after that message, and no team member wrote before the AI booking (or in the whole window, with no booking). */
143871
+ /** @description Conversations Vitrina answered ALONE with NEW people (they had not written before the window): the person wrote, the AI agent replied after that message, and no team member wrote before the AI booking (or in the whole window, with no booking). */
143832
143872
  conversations: number;
143833
- /** @description Of `conversations`, those where the agent booked at least one cita inside the window. */
143873
+ /** @description Of `conversations`, those where the agent booked at least one cita inside the window (anuladas excluded). */
143834
143874
  booked_conversations: number;
143835
143875
  /** @description Citas the agent booked in those conversations (≥ `booked_conversations`). */
143836
143876
  ai_bookings: number;
@@ -143842,9 +143882,9 @@ interface paths {
143842
143882
  /** @description 24 rows, by the hour (in `timezone`) of the person's first message in the window. */
143843
143883
  by_hour: {
143844
143884
  hour: number;
143845
- /** @description Conversations Vitrina answered ALONE: the person wrote, the AI agent replied after that message, and no team member wrote before the AI booking (or in the whole window, with no booking). */
143885
+ /** @description Conversations Vitrina answered ALONE with NEW people (they had not written before the window): the person wrote, the AI agent replied after that message, and no team member wrote before the AI booking (or in the whole window, with no booking). */
143846
143886
  conversations: number;
143847
- /** @description Of `conversations`, those where the agent booked at least one cita inside the window. */
143887
+ /** @description Of `conversations`, those where the agent booked at least one cita inside the window (anuladas excluded). */
143848
143888
  booked_conversations: number;
143849
143889
  /** @description Citas the agent booked in those conversations (≥ `booked_conversations`). */
143850
143890
  ai_bookings: number;
@@ -144884,7 +144924,28 @@ interface paths {
144884
144924
  * "booked": 24,
144885
144925
  * "attended": 15,
144886
144926
  * "booked_rate": 0.112,
144887
- * "attended_rate": 0.625
144927
+ * "attended_rate": 0.625,
144928
+ * "new_people": {
144929
+ * "window": {
144930
+ * "from": "2026-09-21",
144931
+ * "to": "2026-09-30"
144932
+ * },
144933
+ * "booking_start": "2026-09-21",
144934
+ * "mature_days": 3,
144935
+ * "unmeasured": null,
144936
+ * "people": 162,
144937
+ * "booked": 9,
144938
+ * "booked_rate": 0.056,
144939
+ * "paid": 2,
144940
+ * "paid_rate": 0.222,
144941
+ * "replied": 118,
144942
+ * "replied_booked": 9,
144943
+ * "replied_rate": 0.076,
144944
+ * "returned": {
144945
+ * "people": 31,
144946
+ * "booked": 3
144947
+ * }
144948
+ * }
144888
144949
  * },
144889
144950
  * "m3": {
144890
144951
  * "quote_presented": 11,
@@ -171214,7 +171275,7 @@ interface paths {
171214
171275
  };
171215
171276
  /**
171216
171277
  * Get a clinic patient
171217
- * @description Also carries `origin`: the patient's Origen, Meta (with the ad, ad set and campaign) Orgánico (a linked contact with no ad touch) or Sin dato (`unknown`: no linked contact) — the attribution Vitrina Ads reports, through the patient's linked contact.
171278
+ * @description Also carries `origin`: the patient's Origen, Meta (with the ad, ad set and campaign) Orgánico (a linked contact with no ad touch) or Sin dato (`unknown`: no linked contact) — the attribution Vitrina Ads reports, through the patient's linked contact. `link` is the contact link (`contact_id`, `verified_method`, `verified_at`) plus `revoked_at` / `revoked_reason` / `revoked_method`: set while the automatic phone-link guard holds the link revoked (a minor, a number shared by several fichas, …) — it still books but no longer reveals the record, and `revoked_method` is what the link was before.
171218
171279
  *
171219
171280
  * **Connected apps:** refused with `403 CONNECTED_APP_SENSITIVE_DATA`, whatever scopes they hold — this operation carries a dato sensible (ADR 0106 §4). Only an API key or a personal token of the workspace that holds the scope reaches it.
171220
171281
  */
@@ -179031,6 +179092,8 @@ interface components {
179031
179092
  presupuestos: number;
179032
179093
  recaudado_clp: number | null;
179033
179094
  pagos: number | null;
179095
+ /** @description Citas on the agenda today, cancelled ones out. 0 = the clinic is not seeing patients today (closed, holiday), so three $0 figures are not a slow day. */
179096
+ citas: number;
179034
179097
  };
179035
179098
  totals: {
179036
179099
  produccion: {
@@ -179285,9 +179348,9 @@ interface components {
179285
179348
  to: string | null;
179286
179349
  /** @description True when `from` was moved forward to the first AI booking (conversations before it could not be booked by the AI). */
179287
179350
  starts_at_first_booking: boolean;
179288
- /** @description Denominator — conversations Vitrina answered ALONE in the window: the person wrote, the AI agent replied after that message, and no team member (`human_user`) wrote before the AI booking (or in the whole window, with no booking). Tool calls, reasoning and events are not replies; an AI follow-up nobody answered is not counted. Quarantined conversations, system senders and team accounts are out. Every sucursal (conversations carry no location). */
179351
+ /** @description Denominator — conversations Vitrina answered ALONE in the window with NEW people (they had not written before the window — D94; the others are in `existing`): the person wrote, the AI agent replied after that message, and no team member (`human_user`) wrote before the AI booking (or in the whole window, with no booking). Tool calls, reasoning and events are not replies; an AI follow-up nobody answered is not counted. Quarantined conversations, system senders and team accounts are out. Every sucursal (conversations carry no location). */
179289
179352
  conversations: number | null;
179290
- /** @description Numerator — of `conversations`, those where the agent booked at least one cita (`source=agent`, not a public booking page; blocks and holds out) BOOKED inside the window. */
179353
+ /** @description Numerator — of `conversations`, those where the agent booked at least one cita (`source=agent`, not a public booking page; blocks, holds and anuladas out) BOOKED inside the window. */
179291
179354
  booked_conversations: number | null;
179292
179355
  /** @description Citas the agent booked in those conversations (a conversation may book more than one). Counted by the day they were booked, unlike `bookings.ai` (by the day of the cita). */
179293
179356
  ai_bookings: number | null;
@@ -179295,6 +179358,17 @@ interface components {
179295
179358
  rate_pct: number | null;
179296
179359
  /** @description Conversations the AI answered where a team member wrote before the outcome — excluded from the rate. */
179297
179360
  team_helped: number | null;
179361
+ /** @description D94: conversations of people who had written to the business BEFORE the window (follow-ups, changes of hour) — outside the rate, said on their own line. `null` when not measured. */
179362
+ existing: {
179363
+ /** @description Conversations Vitrina answered alone with people who had written to the business BEFORE the window (patients’ follow-ups, changes of hour, earlier leads). */
179364
+ conversations: number;
179365
+ /** @description Of them, those where the agent booked at least one cita (anuladas excluded). */
179366
+ booked_conversations: number;
179367
+ /** @description Citas the agent booked in them. */
179368
+ ai_bookings: number;
179369
+ } | null;
179370
+ /** @description Citas the agent booked for new people in the window that were then anuladas — never in `ai_bookings`. `null` when not measured. */
179371
+ cancelled: number | null;
179298
179372
  /** @description The read hit its row cap: counts are a floor. */
179299
179373
  truncated: boolean;
179300
179374
  /** @description The equal-length window right before, only when the AI was already booking through all of it; `null` otherwise (no fair baseline). */
@@ -181854,7 +181928,7 @@ interface components {
181854
181928
  };
181855
181929
  AdsPeople: {
181856
181930
  /** @enum {string} */
181857
- metric: "paid_patients" | "arrived_patients" | "returned_patients" | "funnel_contacted" | "funnel_booked" | "funnel_attended" | "funnel_quote_presented" | "funnel_accepted" | "funnel_paid" | "conversations" | "conversations_replied" | "conversations_booked" | "conversations_attended" | "conversations_closed";
181931
+ metric: "paid_patients" | "arrived_patients" | "returned_patients" | "funnel_contacted" | "funnel_booked" | "funnel_attended" | "funnel_quote_presented" | "funnel_accepted" | "funnel_paid" | "new_people" | "new_people_booked" | "new_people_paid" | "returned_people" | "returned_people_booked" | "conversations" | "conversations_replied" | "conversations_booked" | "conversations_attended" | "conversations_closed";
181858
181932
  /** @description The days the population is counted over — the count’s own window (patient return: clipped to the first measured day, as `/ads/overview`; conversations: the `/ads/campaigns` conversational window). */
181859
181933
  window: {
181860
181934
  from: string;
@@ -182425,6 +182499,43 @@ interface components {
182425
182499
  * @enum {string|null}
182426
182500
  */
182427
182501
  rate_not_comparable: "conversations_late" | "booking_link" | null;
182502
+ /** @description D93 — M2’s own cohort, the one its verdict (`weakest`) is judged on. Unlike `booked` (the `/ads/funnel` cohort: every person from ads in the period, «volvieron» included, any step reached), it counts new people only, from the booking start, mature days only, real citas only. Absent when it could not be read. */
182503
+ new_people?: {
182504
+ /** @description The days counted: the period from `booking_start`, without the last `mature_days` days (a person who wrote yesterday has had no time to book). `null` = no such day (`unmeasured`). */
182505
+ window: {
182506
+ from: string;
182507
+ to: string;
182508
+ } | null;
182509
+ /** @description The first day the assistant answered people (at least 5 on one day), derived from the messages. `null` = it never answered anyone: the window then starts with the conversations Vitrina measures. */
182510
+ booking_start: string | null;
182511
+ mature_days: number;
182512
+ /**
182513
+ * @description `before_booking_start` = the period ends before the assistant started; `too_recent` = all its days since then are within the last `mature_days`. `null` = measured.
182514
+ * @enum {string|null}
182515
+ */
182516
+ unmeasured: "before_booking_start" | "too_recent" | null;
182517
+ /** @description NEW people whose first message came from an ad and fell in `window` (never «volvieron»). */
182518
+ people: number;
182519
+ /** @description Of `people`, with a REAL cita booked since their first message (D91: booked by Vitrina, by reception or mirrored from the clinic software; anuladas out). A quote or a payment with no cita is not «agendó». */
182520
+ booked: number;
182521
+ /** @description booked ÷ people — THE number held against the 10–15 % band. */
182522
+ booked_rate: number | null;
182523
+ /** @description Of `booked`, those who paid. */
182524
+ paid: number;
182525
+ /** @description paid ÷ booked. */
182526
+ paid_rate: number | null;
182527
+ /** @description «Respondieron»: of `people`, who wrote again after the first answer they saw (within 7 days of their first message). */
182528
+ replied: number;
182529
+ /** @description Of `replied`, with a real cita. */
182530
+ replied_booked: number;
182531
+ /** @description replied_booked ÷ replied. */
182532
+ replied_rate: number | null;
182533
+ /** @description «Volvieron»: people an ad brought BACK in `window` (they had written before) and, of them, with a real cita since — their own line, never in the rate. */
182534
+ returned: {
182535
+ people: number;
182536
+ booked: number;
182537
+ };
182538
+ };
182428
182539
  };
182429
182540
  /** @description M3 · Venta en clínica (the professional). The same people as `/ads/funnel`. */
182430
182541
  m3: {
@@ -182483,7 +182594,7 @@ interface components {
182483
182594
  };
182484
182595
  };
182485
182596
  /**
182486
- * @description Where it leaks, deterministically and only where a benchmark exists: `m1` = spend and nobody wrote (no credited person from ads AND no ad-opened conversation in `m2.ad_conversations`); `m2` = writing → booking under the program reference low (10 %) while `m2.booked_measured`; `null` = neither, and always when Vitrina does not measure conversations from the window’s first day. M3 is never judged: there is no program benchmark for quotes → payment, so `m3.paid_rate` is shown without a verdict.
182597
+ * @description Where it leaks, deterministically and only where a benchmark exists: `m1` = spend and nobody wrote (no credited person from ads AND no ad-opened conversation in `m2.ad_conversations`); `m2` = writing → booking (`m2.new_people.booked_rate` when present) under the program reference low (10 %) while `m2.booked_measured`; `null` = neither, and always when Vitrina does not measure conversations from the window’s first day. M3 is never judged: there is no program benchmark for quotes → payment, so `m3.paid_rate` is shown without a verdict.
182487
182598
  * @enum {string|null}
182488
182599
  */
182489
182600
  weakest: "m1" | "m2" | null;
package/dist/index.d.ts CHANGED
@@ -101712,7 +101712,8 @@ interface paths {
101712
101712
  * "presupuestado_clp": 4381028,
101713
101713
  * "presupuestos": 18,
101714
101714
  * "recaudado_clp": 3307992,
101715
- * "pagos": 21
101715
+ * "pagos": 21,
101716
+ * "citas": 52
101716
101717
  * },
101717
101718
  * "totals": {
101718
101719
  * "produccion": {
@@ -103551,17 +103552,32 @@ interface paths {
103551
103552
  * {
103552
103553
  * "hour": 9,
103553
103554
  * "total": 3,
103554
- * "primeras_visitas": 1
103555
+ * "primeras_visitas": 1,
103556
+ * "by_kind": {
103557
+ * "new": 1,
103558
+ * "new_rebooked": 0,
103559
+ * "in_treatment": 2
103560
+ * }
103555
103561
  * },
103556
103562
  * {
103557
103563
  * "hour": 11,
103558
103564
  * "total": 4,
103559
- * "primeras_visitas": 2
103565
+ * "primeras_visitas": 2,
103566
+ * "by_kind": {
103567
+ * "new": 1,
103568
+ * "new_rebooked": 1,
103569
+ * "in_treatment": 2
103570
+ * }
103560
103571
  * },
103561
103572
  * {
103562
103573
  * "hour": 14,
103563
103574
  * "total": 2,
103564
- * "primeras_visitas": 1
103575
+ * "primeras_visitas": 1,
103576
+ * "by_kind": {
103577
+ * "new": 1,
103578
+ * "new_rebooked": 0,
103579
+ * "in_treatment": 1
103580
+ * }
103565
103581
  * }
103566
103582
  * ],
103567
103583
  * "origin": {
@@ -103634,6 +103650,12 @@ interface paths {
103634
103650
  hour: number;
103635
103651
  total: number;
103636
103652
  primeras_visitas: number;
103653
+ /** @description The hour's citas by Tipo de agendamiento; a cita whose kind could not be judged counts in `total` only. */
103654
+ by_kind: {
103655
+ new: number;
103656
+ new_rebooked: number;
103657
+ in_treatment: number;
103658
+ };
103637
103659
  }[];
103638
103660
  origin: {
103639
103661
  meta: number;
@@ -142756,9 +142778,10 @@ interface paths {
142756
142778
  * @description WHICH count to list — each is read from the very read the count is folded from, so `count` equals the number the screen shows:
142757
142779
  * · `paid_patients` / `arrived_patients` / `returned_patients` — `patient_return.patients` / `.arrived_patients` / `.returned_patients` of `/ads/overview` (no scope), of a `/ads/campaigns` row (`campaign_id`), of an ad (`ad_id`), or «Anuncios aún sin campaña conocida» (`unplaced=1`).
142758
142780
  * · `funnel_<step>` — `/ads/funnel` `steps[<step>].ads` = `/ads/stages` M1 `m1.conversations` (`funnel_contacted`), M2 `m2.booked` / `m2.attended`, M3 `m3.quote_presented` / `m3.accepted` / `m3.paid`. No scope.
142781
+ * · `new_people[_booked|_paid]`, `returned_people[_booked]` — `/ads/stages` `m2.new_people` (D93): `people` / `booked` / `paid` and `returned.people` / `returned.booked`, over that block’s own `window` (the read’s `window`). No scope.
142759
142782
  * · `conversations[_replied|_booked|_attended|_closed]` — the conversations ads opened (one row per CONVERSATION), all ads, one campaign (`campaign_id`, through the ad → campaign map as `/ads/campaigns` counts them) or one ad (`ad_id`).
142760
142783
  */
142761
- metric: "paid_patients" | "arrived_patients" | "returned_patients" | "funnel_contacted" | "funnel_booked" | "funnel_attended" | "funnel_quote_presented" | "funnel_accepted" | "funnel_paid" | "conversations" | "conversations_replied" | "conversations_booked" | "conversations_attended" | "conversations_closed";
142784
+ metric: "paid_patients" | "arrived_patients" | "returned_patients" | "funnel_contacted" | "funnel_booked" | "funnel_attended" | "funnel_quote_presented" | "funnel_accepted" | "funnel_paid" | "new_people" | "new_people_booked" | "new_people_paid" | "returned_people" | "returned_people_booked" | "conversations" | "conversations_replied" | "conversations_booked" | "conversations_attended" | "conversations_closed";
142762
142785
  /** @description A campaign’s PLATFORM id (`/ads/campaigns` `campaign_external_id`). Patient-return and conversation metrics only. */
142763
142786
  campaign_id?: string;
142764
142787
  /** @description An ad’s PLATFORM id. Patient-return and conversation metrics only. */
@@ -143681,7 +143704,13 @@ interface paths {
143681
143704
  * "booked_conversations": 45,
143682
143705
  * "ai_bookings": 54,
143683
143706
  * "rate_pct": 7.7,
143684
- * "team_helped": 60
143707
+ * "team_helped": 60,
143708
+ * "existing": {
143709
+ * "conversations": 214,
143710
+ * "booked_conversations": 38,
143711
+ * "ai_bookings": 41
143712
+ * },
143713
+ * "cancelled": 6
143685
143714
  * },
143686
143715
  * "from_ads": {
143687
143716
  * "conversations": 461,
@@ -143767,11 +143796,11 @@ interface paths {
143767
143796
  first_ai_booked_on: string | null;
143768
143797
  timezone: string;
143769
143798
  min_conversations: number;
143770
- /** @description The same figure as `conversation_rate` on `GET /clinic/insights/resultados` for the same days. */
143799
+ /** @description The same figure as `conversation_rate` on `GET /clinic/insights/resultados` for the same days. NEW PEOPLE ONLY (D94): conversations of people who had written before the window are counted in `existing`, never in the rate — nor in `from_ads`, `without_ad`, `by_campaign`, `by_ad`, `by_hour`. */
143771
143800
  overall: {
143772
- /** @description Conversations Vitrina answered ALONE: the person wrote, the AI agent replied after that message, and no team member wrote before the AI booking (or in the whole window, with no booking). */
143801
+ /** @description Conversations Vitrina answered ALONE with NEW people (they had not written before the window): the person wrote, the AI agent replied after that message, and no team member wrote before the AI booking (or in the whole window, with no booking). */
143773
143802
  conversations: number;
143774
- /** @description Of `conversations`, those where the agent booked at least one cita inside the window. */
143803
+ /** @description Of `conversations`, those where the agent booked at least one cita inside the window (anuladas excluded). */
143775
143804
  booked_conversations: number;
143776
143805
  /** @description Citas the agent booked in those conversations (≥ `booked_conversations`). */
143777
143806
  ai_bookings: number;
@@ -143779,12 +143808,23 @@ interface paths {
143779
143808
  rate_pct: number | null;
143780
143809
  /** @description Conversations the AI answered where a team member wrote first — excluded. */
143781
143810
  team_helped: number;
143811
+ /** @description People who had written before the window (D94): OUTSIDE the rate — its headline counts new people only — and shown on their own line. */
143812
+ existing: {
143813
+ /** @description Conversations Vitrina answered alone with people who had written to the business BEFORE the window (patients’ follow-ups, changes of hour, earlier leads). */
143814
+ conversations: number;
143815
+ /** @description Of them, those where the agent booked at least one cita (anuladas excluded). */
143816
+ booked_conversations: number;
143817
+ /** @description Citas the agent booked in them. */
143818
+ ai_bookings: number;
143819
+ };
143820
+ /** @description Citas the agent booked for new people in the window that were then anuladas — never in `ai_bookings`. */
143821
+ cancelled: number;
143782
143822
  } | null;
143783
143823
  /** @description Conversations a Meta ad opened (its `ad_referral`). */
143784
143824
  from_ads: {
143785
- /** @description Conversations Vitrina answered ALONE: the person wrote, the AI agent replied after that message, and no team member wrote before the AI booking (or in the whole window, with no booking). */
143825
+ /** @description Conversations Vitrina answered ALONE with NEW people (they had not written before the window): the person wrote, the AI agent replied after that message, and no team member wrote before the AI booking (or in the whole window, with no booking). */
143786
143826
  conversations: number;
143787
- /** @description Of `conversations`, those where the agent booked at least one cita inside the window. */
143827
+ /** @description Of `conversations`, those where the agent booked at least one cita inside the window (anuladas excluded). */
143788
143828
  booked_conversations: number;
143789
143829
  /** @description Citas the agent booked in those conversations (≥ `booked_conversations`). */
143790
143830
  ai_bookings: number;
@@ -143792,9 +143832,9 @@ interface paths {
143792
143832
  rate_pct: number | null;
143793
143833
  } | null;
143794
143834
  without_ad: {
143795
- /** @description Conversations Vitrina answered ALONE: the person wrote, the AI agent replied after that message, and no team member wrote before the AI booking (or in the whole window, with no booking). */
143835
+ /** @description Conversations Vitrina answered ALONE with NEW people (they had not written before the window): the person wrote, the AI agent replied after that message, and no team member wrote before the AI booking (or in the whole window, with no booking). */
143796
143836
  conversations: number;
143797
- /** @description Of `conversations`, those where the agent booked at least one cita inside the window. */
143837
+ /** @description Of `conversations`, those where the agent booked at least one cita inside the window (anuladas excluded). */
143798
143838
  booked_conversations: number;
143799
143839
  /** @description Citas the agent booked in those conversations (≥ `booked_conversations`). */
143800
143840
  ai_bookings: number;
@@ -143811,9 +143851,9 @@ interface paths {
143811
143851
  /** @description Meta's campaign id (= `/ads/campaigns` rows). */
143812
143852
  campaign_external_id: string;
143813
143853
  campaign_name: string | null;
143814
- /** @description Conversations Vitrina answered ALONE: the person wrote, the AI agent replied after that message, and no team member wrote before the AI booking (or in the whole window, with no booking). */
143854
+ /** @description Conversations Vitrina answered ALONE with NEW people (they had not written before the window): the person wrote, the AI agent replied after that message, and no team member wrote before the AI booking (or in the whole window, with no booking). */
143815
143855
  conversations: number;
143816
- /** @description Of `conversations`, those where the agent booked at least one cita inside the window. */
143856
+ /** @description Of `conversations`, those where the agent booked at least one cita inside the window (anuladas excluded). */
143817
143857
  booked_conversations: number;
143818
143858
  /** @description Citas the agent booked in those conversations (≥ `booked_conversations`). */
143819
143859
  ai_bookings: number;
@@ -143828,9 +143868,9 @@ interface paths {
143828
143868
  /** @description Meta's ad id (= `/ads/creatives` rows). */
143829
143869
  ad_external_id: string;
143830
143870
  campaign_external_id: string | null;
143831
- /** @description Conversations Vitrina answered ALONE: the person wrote, the AI agent replied after that message, and no team member wrote before the AI booking (or in the whole window, with no booking). */
143871
+ /** @description Conversations Vitrina answered ALONE with NEW people (they had not written before the window): the person wrote, the AI agent replied after that message, and no team member wrote before the AI booking (or in the whole window, with no booking). */
143832
143872
  conversations: number;
143833
- /** @description Of `conversations`, those where the agent booked at least one cita inside the window. */
143873
+ /** @description Of `conversations`, those where the agent booked at least one cita inside the window (anuladas excluded). */
143834
143874
  booked_conversations: number;
143835
143875
  /** @description Citas the agent booked in those conversations (≥ `booked_conversations`). */
143836
143876
  ai_bookings: number;
@@ -143842,9 +143882,9 @@ interface paths {
143842
143882
  /** @description 24 rows, by the hour (in `timezone`) of the person's first message in the window. */
143843
143883
  by_hour: {
143844
143884
  hour: number;
143845
- /** @description Conversations Vitrina answered ALONE: the person wrote, the AI agent replied after that message, and no team member wrote before the AI booking (or in the whole window, with no booking). */
143885
+ /** @description Conversations Vitrina answered ALONE with NEW people (they had not written before the window): the person wrote, the AI agent replied after that message, and no team member wrote before the AI booking (or in the whole window, with no booking). */
143846
143886
  conversations: number;
143847
- /** @description Of `conversations`, those where the agent booked at least one cita inside the window. */
143887
+ /** @description Of `conversations`, those where the agent booked at least one cita inside the window (anuladas excluded). */
143848
143888
  booked_conversations: number;
143849
143889
  /** @description Citas the agent booked in those conversations (≥ `booked_conversations`). */
143850
143890
  ai_bookings: number;
@@ -144884,7 +144924,28 @@ interface paths {
144884
144924
  * "booked": 24,
144885
144925
  * "attended": 15,
144886
144926
  * "booked_rate": 0.112,
144887
- * "attended_rate": 0.625
144927
+ * "attended_rate": 0.625,
144928
+ * "new_people": {
144929
+ * "window": {
144930
+ * "from": "2026-09-21",
144931
+ * "to": "2026-09-30"
144932
+ * },
144933
+ * "booking_start": "2026-09-21",
144934
+ * "mature_days": 3,
144935
+ * "unmeasured": null,
144936
+ * "people": 162,
144937
+ * "booked": 9,
144938
+ * "booked_rate": 0.056,
144939
+ * "paid": 2,
144940
+ * "paid_rate": 0.222,
144941
+ * "replied": 118,
144942
+ * "replied_booked": 9,
144943
+ * "replied_rate": 0.076,
144944
+ * "returned": {
144945
+ * "people": 31,
144946
+ * "booked": 3
144947
+ * }
144948
+ * }
144888
144949
  * },
144889
144950
  * "m3": {
144890
144951
  * "quote_presented": 11,
@@ -171214,7 +171275,7 @@ interface paths {
171214
171275
  };
171215
171276
  /**
171216
171277
  * Get a clinic patient
171217
- * @description Also carries `origin`: the patient's Origen, Meta (with the ad, ad set and campaign) Orgánico (a linked contact with no ad touch) or Sin dato (`unknown`: no linked contact) — the attribution Vitrina Ads reports, through the patient's linked contact.
171278
+ * @description Also carries `origin`: the patient's Origen, Meta (with the ad, ad set and campaign) Orgánico (a linked contact with no ad touch) or Sin dato (`unknown`: no linked contact) — the attribution Vitrina Ads reports, through the patient's linked contact. `link` is the contact link (`contact_id`, `verified_method`, `verified_at`) plus `revoked_at` / `revoked_reason` / `revoked_method`: set while the automatic phone-link guard holds the link revoked (a minor, a number shared by several fichas, …) — it still books but no longer reveals the record, and `revoked_method` is what the link was before.
171218
171279
  *
171219
171280
  * **Connected apps:** refused with `403 CONNECTED_APP_SENSITIVE_DATA`, whatever scopes they hold — this operation carries a dato sensible (ADR 0106 §4). Only an API key or a personal token of the workspace that holds the scope reaches it.
171220
171281
  */
@@ -179031,6 +179092,8 @@ interface components {
179031
179092
  presupuestos: number;
179032
179093
  recaudado_clp: number | null;
179033
179094
  pagos: number | null;
179095
+ /** @description Citas on the agenda today, cancelled ones out. 0 = the clinic is not seeing patients today (closed, holiday), so three $0 figures are not a slow day. */
179096
+ citas: number;
179034
179097
  };
179035
179098
  totals: {
179036
179099
  produccion: {
@@ -179285,9 +179348,9 @@ interface components {
179285
179348
  to: string | null;
179286
179349
  /** @description True when `from` was moved forward to the first AI booking (conversations before it could not be booked by the AI). */
179287
179350
  starts_at_first_booking: boolean;
179288
- /** @description Denominator — conversations Vitrina answered ALONE in the window: the person wrote, the AI agent replied after that message, and no team member (`human_user`) wrote before the AI booking (or in the whole window, with no booking). Tool calls, reasoning and events are not replies; an AI follow-up nobody answered is not counted. Quarantined conversations, system senders and team accounts are out. Every sucursal (conversations carry no location). */
179351
+ /** @description Denominator — conversations Vitrina answered ALONE in the window with NEW people (they had not written before the window — D94; the others are in `existing`): the person wrote, the AI agent replied after that message, and no team member (`human_user`) wrote before the AI booking (or in the whole window, with no booking). Tool calls, reasoning and events are not replies; an AI follow-up nobody answered is not counted. Quarantined conversations, system senders and team accounts are out. Every sucursal (conversations carry no location). */
179289
179352
  conversations: number | null;
179290
- /** @description Numerator — of `conversations`, those where the agent booked at least one cita (`source=agent`, not a public booking page; blocks and holds out) BOOKED inside the window. */
179353
+ /** @description Numerator — of `conversations`, those where the agent booked at least one cita (`source=agent`, not a public booking page; blocks, holds and anuladas out) BOOKED inside the window. */
179291
179354
  booked_conversations: number | null;
179292
179355
  /** @description Citas the agent booked in those conversations (a conversation may book more than one). Counted by the day they were booked, unlike `bookings.ai` (by the day of the cita). */
179293
179356
  ai_bookings: number | null;
@@ -179295,6 +179358,17 @@ interface components {
179295
179358
  rate_pct: number | null;
179296
179359
  /** @description Conversations the AI answered where a team member wrote before the outcome — excluded from the rate. */
179297
179360
  team_helped: number | null;
179361
+ /** @description D94: conversations of people who had written to the business BEFORE the window (follow-ups, changes of hour) — outside the rate, said on their own line. `null` when not measured. */
179362
+ existing: {
179363
+ /** @description Conversations Vitrina answered alone with people who had written to the business BEFORE the window (patients’ follow-ups, changes of hour, earlier leads). */
179364
+ conversations: number;
179365
+ /** @description Of them, those where the agent booked at least one cita (anuladas excluded). */
179366
+ booked_conversations: number;
179367
+ /** @description Citas the agent booked in them. */
179368
+ ai_bookings: number;
179369
+ } | null;
179370
+ /** @description Citas the agent booked for new people in the window that were then anuladas — never in `ai_bookings`. `null` when not measured. */
179371
+ cancelled: number | null;
179298
179372
  /** @description The read hit its row cap: counts are a floor. */
179299
179373
  truncated: boolean;
179300
179374
  /** @description The equal-length window right before, only when the AI was already booking through all of it; `null` otherwise (no fair baseline). */
@@ -181854,7 +181928,7 @@ interface components {
181854
181928
  };
181855
181929
  AdsPeople: {
181856
181930
  /** @enum {string} */
181857
- metric: "paid_patients" | "arrived_patients" | "returned_patients" | "funnel_contacted" | "funnel_booked" | "funnel_attended" | "funnel_quote_presented" | "funnel_accepted" | "funnel_paid" | "conversations" | "conversations_replied" | "conversations_booked" | "conversations_attended" | "conversations_closed";
181931
+ metric: "paid_patients" | "arrived_patients" | "returned_patients" | "funnel_contacted" | "funnel_booked" | "funnel_attended" | "funnel_quote_presented" | "funnel_accepted" | "funnel_paid" | "new_people" | "new_people_booked" | "new_people_paid" | "returned_people" | "returned_people_booked" | "conversations" | "conversations_replied" | "conversations_booked" | "conversations_attended" | "conversations_closed";
181858
181932
  /** @description The days the population is counted over — the count’s own window (patient return: clipped to the first measured day, as `/ads/overview`; conversations: the `/ads/campaigns` conversational window). */
181859
181933
  window: {
181860
181934
  from: string;
@@ -182425,6 +182499,43 @@ interface components {
182425
182499
  * @enum {string|null}
182426
182500
  */
182427
182501
  rate_not_comparable: "conversations_late" | "booking_link" | null;
182502
+ /** @description D93 — M2’s own cohort, the one its verdict (`weakest`) is judged on. Unlike `booked` (the `/ads/funnel` cohort: every person from ads in the period, «volvieron» included, any step reached), it counts new people only, from the booking start, mature days only, real citas only. Absent when it could not be read. */
182503
+ new_people?: {
182504
+ /** @description The days counted: the period from `booking_start`, without the last `mature_days` days (a person who wrote yesterday has had no time to book). `null` = no such day (`unmeasured`). */
182505
+ window: {
182506
+ from: string;
182507
+ to: string;
182508
+ } | null;
182509
+ /** @description The first day the assistant answered people (at least 5 on one day), derived from the messages. `null` = it never answered anyone: the window then starts with the conversations Vitrina measures. */
182510
+ booking_start: string | null;
182511
+ mature_days: number;
182512
+ /**
182513
+ * @description `before_booking_start` = the period ends before the assistant started; `too_recent` = all its days since then are within the last `mature_days`. `null` = measured.
182514
+ * @enum {string|null}
182515
+ */
182516
+ unmeasured: "before_booking_start" | "too_recent" | null;
182517
+ /** @description NEW people whose first message came from an ad and fell in `window` (never «volvieron»). */
182518
+ people: number;
182519
+ /** @description Of `people`, with a REAL cita booked since their first message (D91: booked by Vitrina, by reception or mirrored from the clinic software; anuladas out). A quote or a payment with no cita is not «agendó». */
182520
+ booked: number;
182521
+ /** @description booked ÷ people — THE number held against the 10–15 % band. */
182522
+ booked_rate: number | null;
182523
+ /** @description Of `booked`, those who paid. */
182524
+ paid: number;
182525
+ /** @description paid ÷ booked. */
182526
+ paid_rate: number | null;
182527
+ /** @description «Respondieron»: of `people`, who wrote again after the first answer they saw (within 7 days of their first message). */
182528
+ replied: number;
182529
+ /** @description Of `replied`, with a real cita. */
182530
+ replied_booked: number;
182531
+ /** @description replied_booked ÷ replied. */
182532
+ replied_rate: number | null;
182533
+ /** @description «Volvieron»: people an ad brought BACK in `window` (they had written before) and, of them, with a real cita since — their own line, never in the rate. */
182534
+ returned: {
182535
+ people: number;
182536
+ booked: number;
182537
+ };
182538
+ };
182428
182539
  };
182429
182540
  /** @description M3 · Venta en clínica (the professional). The same people as `/ads/funnel`. */
182430
182541
  m3: {
@@ -182483,7 +182594,7 @@ interface components {
182483
182594
  };
182484
182595
  };
182485
182596
  /**
182486
- * @description Where it leaks, deterministically and only where a benchmark exists: `m1` = spend and nobody wrote (no credited person from ads AND no ad-opened conversation in `m2.ad_conversations`); `m2` = writing → booking under the program reference low (10 %) while `m2.booked_measured`; `null` = neither, and always when Vitrina does not measure conversations from the window’s first day. M3 is never judged: there is no program benchmark for quotes → payment, so `m3.paid_rate` is shown without a verdict.
182597
+ * @description Where it leaks, deterministically and only where a benchmark exists: `m1` = spend and nobody wrote (no credited person from ads AND no ad-opened conversation in `m2.ad_conversations`); `m2` = writing → booking (`m2.new_people.booked_rate` when present) under the program reference low (10 %) while `m2.booked_measured`; `null` = neither, and always when Vitrina does not measure conversations from the window’s first day. M3 is never judged: there is no program benchmark for quotes → payment, so `m3.paid_rate` is shown without a verdict.
182487
182598
  * @enum {string|null}
182488
182599
  */
182489
182600
  weakest: "m1" | "m2" | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitrina/api",
3
- "version": "14.2.0",
3
+ "version": "14.3.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",