@vitrina/api 11.2.0 → 11.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -11124,7 +11124,7 @@ interface paths {
11124
11124
  "application/json": {
11125
11125
  /** Format: uri */
11126
11126
  url?: string;
11127
- events?: ("*" | "ai_agent.publish" | "ai_agent_graph.publish" | "agent_scenario_run.completed" | "agent_scenario_suite.completed" | "conversation.created" | "conversation.assigned" | "conversation.resolved" | "message.received" | "message.sent" | "ticket.opened" | "ticket.reopened" | "ticket.resolved" | "ticket.closed" | "sla.breached" | "kb.source.create" | "kb.source.embed" | "kb.source.update" | "kb.source.delete" | "kb_file.uploaded" | "kb_file.deleted" | "skill.created" | "skill.updated" | "skill.deleted" | "custom_tool.created" | "custom_tool.updated" | "custom_tool.deleted" | "macro.applied" | "cost.budget_alert" | "runtime.budget_exceeded" | "lead.created" | "lead.stage_changed" | "lead.pipeline_changed" | "lead.assigned" | "lead.won" | "lead.lost" | "lead.unqualified" | "stock.synced" | "stock.source_retired" | "vehicle.published" | "vehicle.unpublished" | "vehicle.publish_failed" | "vehicle.created" | "vehicle.attachment.created" | "mercadolibre.order" | "mercadolibre.vis_lead" | "chileautos.lead" | "yapo.lead" | "website.lead" | "consignment.candidate.created" | "quote.issued" | "quote.voided" | "quote.extended" | "quote.archived" | "reservation.created" | "reservation.voided" | "reservation.abono_disposed" | "reservation.converted" | "sale_note.issued" | "sale_note.approved" | "sale_note.voided" | "purchase_note.issued" | "purchase_note.corrected" | "purchase_note.voided" | "payment.recorded" | "consignment.created" | "consignment.returned" | "consignment.sold" | "credit_application.recorded" | "credit_application.submitted" | "credit_application.decided" | "credit_application.withdrawn" | "price_approval.requested" | "price_approval.decided" | "contact.created" | "contact.updated" | "contact.merged" | "appointment.booked" | "appointment.rescheduled" | "appointment.cancelled" | "appointment.completed" | "appointment.no_show" | "appointment.reminded" | "appointment.imported" | "campaign.sent" | "campaign.paused" | "sending_domain.verified" | "coach.proposals_ready" | "coach.finding_ready" | "voice.autonomous_call" | "safety_hold.placed" | "safety_hold.ack_overdue" | "safety_hold.first_response_overdue" | "team.created" | "team.updated" | "team.deleted" | "custom_role.created" | "custom_role.updated" | "custom_role.deleted" | "macro.created" | "macro.updated" | "macro.deleted" | "assignment_rule.created" | "assignment_rule.updated" | "assignment_rule.deleted" | "sla_policy.created" | "sla_policy.updated" | "sla_policy.deleted" | "automation_trigger.created" | "automation_trigger.updated" | "automation_trigger.deleted" | "sending_domain.created" | "sending_domain.deleted" | "whatsapp_template.created" | "whatsapp_template.status_changed" | "whatsapp_template.deleted" | "whatsapp_flow.created" | "whatsapp_flow.published" | "whatsapp_flow.deprecated" | "whatsapp_flow.deleted" | "channel.connected" | "channel.updated" | "channel.disconnected" | "membership.created" | "membership.updated" | "membership.removed" | "clinic_professional.created" | "clinic_professional.updated" | "clinic_professional.deleted" | "clinic_service.created" | "clinic_service.updated" | "clinic_service.deleted" | "clinic_price_list.updated" | "clinic_pack_purchase.created" | "clinic_pack_purchase.session_consumed" | "clinic_pack_purchase.cancelled" | "clinic_budget.created" | "clinic_budget.sent" | "clinic_budget.accepted" | "clinic_budget.rejected" | "clinic_budget.voided" | "clinic_cash_session.opened" | "clinic_cash_session.closed" | "clinic_patient.created" | "clinic_patient.updated" | "clinic_patient.deleted" | "clinic_patient.merged" | "clinic_encounter.opened" | "clinic_encounter.closed" | "clinic_note.signed" | "clinic_note.amended" | "clinic_consent.signed" | "clinic_consent.revoked" | "clinic_document.uploaded" | "clinic_document.deleted" | "clinic_privacy_request.completed")[];
11127
+ events?: ("*" | "ai_agent.publish" | "ai_agent_graph.publish" | "agent_scenario_run.completed" | "agent_scenario_suite.completed" | "conversation.created" | "conversation.assigned" | "conversation.resolved" | "message.received" | "message.sent" | "ticket.opened" | "ticket.reopened" | "ticket.resolved" | "ticket.closed" | "sla.breached" | "kb.source.create" | "kb.source.embed" | "kb.source.update" | "kb.source.delete" | "kb_file.uploaded" | "kb_file.deleted" | "skill.created" | "skill.updated" | "skill.deleted" | "custom_tool.created" | "custom_tool.updated" | "custom_tool.deleted" | "macro.applied" | "cost.budget_alert" | "runtime.budget_exceeded" | "lead.created" | "lead.stage_changed" | "lead.pipeline_changed" | "lead.assigned" | "lead.won" | "lead.lost" | "lead.unqualified" | "stock.synced" | "stock.source_retired" | "vehicle.published" | "vehicle.unpublished" | "vehicle.publish_failed" | "vehicle.created" | "vehicle.attachment.created" | "mercadolibre.order" | "mercadolibre.vis_lead" | "chileautos.lead" | "yapo.lead" | "website.lead" | "consignment.candidate.created" | "quote.issued" | "quote.voided" | "quote.extended" | "quote.archived" | "reservation.created" | "reservation.voided" | "reservation.abono_disposed" | "reservation.converted" | "sale_note.issued" | "sale_note.approved" | "sale_note.voided" | "purchase_note.issued" | "purchase_note.corrected" | "purchase_note.voided" | "payment.recorded" | "consignment.created" | "consignment.returned" | "consignment.sold" | "credit_application.recorded" | "credit_application.submitted" | "credit_application.decided" | "credit_application.withdrawn" | "price_approval.requested" | "price_approval.decided" | "contact.created" | "contact.updated" | "contact.merged" | "appointment.booked" | "appointment.rescheduled" | "appointment.cancelled" | "appointment.completed" | "appointment.no_show" | "appointment.reminded" | "appointment.imported" | "campaign.sent" | "campaign.paused" | "sending_domain.verified" | "coach.proposals_ready" | "coach.finding_ready" | "voice.autonomous_call" | "safety_hold.placed" | "safety_hold.ack_overdue" | "safety_hold.first_response_overdue" | "team.created" | "team.updated" | "team.deleted" | "custom_role.created" | "custom_role.updated" | "custom_role.deleted" | "macro.created" | "macro.updated" | "macro.deleted" | "assignment_rule.created" | "assignment_rule.updated" | "assignment_rule.deleted" | "sla_policy.created" | "sla_policy.updated" | "sla_policy.deleted" | "automation_trigger.created" | "automation_trigger.updated" | "automation_trigger.deleted" | "sending_domain.created" | "sending_domain.deleted" | "whatsapp_template.created" | "whatsapp_template.status_changed" | "whatsapp_template.deleted" | "whatsapp_flow.created" | "whatsapp_flow.published" | "whatsapp_flow.deprecated" | "whatsapp_flow.deleted" | "channel.connected" | "channel.updated" | "channel.disconnected" | "membership.created" | "membership.updated" | "membership.removed" | "clinic_professional.created" | "clinic_professional.updated" | "clinic_professional.deleted" | "clinic_service.created" | "clinic_service.updated" | "clinic_service.deleted" | "clinic_price_list.updated" | "clinic_pack_purchase.created" | "clinic_pack_purchase.session_consumed" | "clinic_pack_purchase.cancelled" | "clinic_budget.created" | "clinic_budget.sent" | "clinic_budget.accepted" | "clinic_budget.rejected" | "clinic_budget.voided" | "clinic_budget.mirror_changed" | "clinic_cash_session.opened" | "clinic_cash_session.closed" | "clinic_patient.created" | "clinic_patient.updated" | "clinic_patient.deleted" | "clinic_patient.merged" | "clinic_encounter.opened" | "clinic_encounter.closed" | "clinic_note.signed" | "clinic_note.amended" | "clinic_consent.signed" | "clinic_consent.revoked" | "clinic_document.uploaded" | "clinic_document.deleted" | "clinic_privacy_request.completed")[];
11128
11128
  enabled?: boolean;
11129
11129
  description?: string | null;
11130
11130
  /** @description «Incluir datos del recurso». `false` (the default) = every delivery is the notice: resource, changes, author, time and `url`, with `data_omitted: "not_requested"`. `true` = each delivery also carries `data` when, at dispatch time, this subscription's OWNER — whoever created it or last changed its url, events or this flag — holds the resource read scope (`read_scope` in the catalogue) and sees every record; otherwise `data_omitted` says why. An event about a dato sensible is always the notice. */
@@ -13154,6 +13154,422 @@ interface paths {
13154
13154
  patch?: never;
13155
13155
  trace?: never;
13156
13156
  };
13157
+ "/entitlements": {
13158
+ parameters: {
13159
+ query?: never;
13160
+ header?: never;
13161
+ path?: never;
13162
+ cookie?: never;
13163
+ };
13164
+ /**
13165
+ * List the add-on catalog, this workspace's entitlements, and live usage
13166
+ * @description The Complementos hub read. `catalog` is the typed feature catalog (prices are PR-reviewed code, never a runtime SKU table); `entitlements` is one row per add-on this workspace has ever held; `usage` carries the live meter for each metered add-on over the current **Santiago** month — `usage.tasador` is `{ used, free_allowance, period }`, where `used` is aggregated on read from `usage_event` (never a counter) and `free_allowance` reflects any per-workspace override, so it is the same pair of numbers the access gate decides on.
13167
+ */
13168
+ get: {
13169
+ parameters: {
13170
+ query?: never;
13171
+ header?: never;
13172
+ path?: never;
13173
+ cookie?: never;
13174
+ };
13175
+ requestBody?: never;
13176
+ responses: {
13177
+ /** @description Catalog, the workspace's entitlements, and live usage */
13178
+ 200: {
13179
+ headers: {
13180
+ [name: string]: unknown;
13181
+ };
13182
+ content: {
13183
+ /**
13184
+ * @example {
13185
+ * "data": {
13186
+ * "catalog": [
13187
+ * {
13188
+ * "key": "vitrina_ads",
13189
+ * "access": "entitlement",
13190
+ * "flatClpMonth": 99000
13191
+ * },
13192
+ * {
13193
+ * "key": "tasador",
13194
+ * "access": "quota",
13195
+ * "flatUfMonth": 0.5,
13196
+ * "freeAllowance": 10,
13197
+ * "meter": "tasador_valuation"
13198
+ * }
13199
+ * ],
13200
+ * "entitlements": [
13201
+ * {
13202
+ * "tenant_id": "11111111-1111-4111-8111-111111111111",
13203
+ * "feature": "vitrina_ads",
13204
+ * "status": "active",
13205
+ * "source": "self_serve",
13206
+ * "granted_at": "2026-09-01T12:00:00.000Z",
13207
+ * "cancel_at_period_end": false,
13208
+ * "canceled_at": null,
13209
+ * "metadata": {},
13210
+ * "created_at": "2026-09-01T12:00:00.000Z",
13211
+ * "updated_at": "2026-09-01T12:00:00.000Z"
13212
+ * }
13213
+ * ],
13214
+ * "usage": {
13215
+ * "tasador": {
13216
+ * "used": 3,
13217
+ * "free_allowance": 10,
13218
+ * "period": "2026-09"
13219
+ * }
13220
+ * }
13221
+ * }
13222
+ * }
13223
+ */
13224
+ "application/json": {
13225
+ data: {
13226
+ catalog: {
13227
+ key: string;
13228
+ /** @enum {string} */
13229
+ access: "entitlement" | "quota";
13230
+ flatUfMonth?: number;
13231
+ flatClpMonth?: number;
13232
+ freeAllowance?: number;
13233
+ unitUf?: number;
13234
+ meter?: string;
13235
+ perUnitClpMonth?: number | null;
13236
+ billedUnit?: string;
13237
+ }[];
13238
+ entitlements: {
13239
+ tenant_id: string;
13240
+ feature: string;
13241
+ /** @enum {string} */
13242
+ status: "active" | "canceled" | "suspended";
13243
+ /** @enum {string} */
13244
+ source: "self_serve" | "billing" | "admin";
13245
+ granted_at: string;
13246
+ cancel_at_period_end: boolean;
13247
+ canceled_at: string | null;
13248
+ metadata: {
13249
+ [key: string]: unknown;
13250
+ };
13251
+ created_at: string;
13252
+ updated_at: string;
13253
+ }[];
13254
+ usage: {
13255
+ tasador: {
13256
+ used: number;
13257
+ free_allowance: number;
13258
+ period: string;
13259
+ };
13260
+ };
13261
+ };
13262
+ };
13263
+ };
13264
+ };
13265
+ /** @description Validation error */
13266
+ 400: {
13267
+ headers: {
13268
+ [name: string]: unknown;
13269
+ };
13270
+ content: {
13271
+ "application/json": components["schemas"]["Error"];
13272
+ };
13273
+ };
13274
+ /** @description Unauthorized */
13275
+ 401: {
13276
+ headers: {
13277
+ [name: string]: unknown;
13278
+ };
13279
+ content: {
13280
+ "application/json": components["schemas"]["Error"];
13281
+ };
13282
+ };
13283
+ /** @description Forbidden */
13284
+ 403: {
13285
+ headers: {
13286
+ [name: string]: unknown;
13287
+ };
13288
+ content: {
13289
+ "application/json": components["schemas"]["Error"];
13290
+ };
13291
+ };
13292
+ /** @description Not found */
13293
+ 404: {
13294
+ headers: {
13295
+ [name: string]: unknown;
13296
+ };
13297
+ content: {
13298
+ "application/json": components["schemas"]["Error"];
13299
+ };
13300
+ };
13301
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
13302
+ 409: {
13303
+ headers: {
13304
+ [name: string]: unknown;
13305
+ };
13306
+ content: {
13307
+ "application/json": components["schemas"]["Error"];
13308
+ };
13309
+ };
13310
+ /** @description Rate limited */
13311
+ 429: {
13312
+ headers: {
13313
+ [name: string]: unknown;
13314
+ };
13315
+ content: {
13316
+ "application/json": components["schemas"]["Error"];
13317
+ };
13318
+ };
13319
+ };
13320
+ };
13321
+ put?: never;
13322
+ post?: never;
13323
+ delete?: never;
13324
+ options?: never;
13325
+ head?: never;
13326
+ patch?: never;
13327
+ trace?: never;
13328
+ };
13329
+ "/entitlements/{feature}/activate": {
13330
+ parameters: {
13331
+ query?: never;
13332
+ header?: never;
13333
+ path?: never;
13334
+ cookie?: never;
13335
+ };
13336
+ get?: never;
13337
+ put?: never;
13338
+ /**
13339
+ * Self-serve activate an add-on (returns needs_enrollment without a payment mandate)
13340
+ * @description Grants `feature` to the workspace once an active payment mandate exists (`{ status: "active", entitlement }`); with none, answers `{ status: "needs_enrollment" }` and grants nothing — the caller routes the dealer through the Fintoc/Mercado Pago enrollment step and retries. Idempotent on an already-active feature (re-answers the same `active` row rather than erroring).
13341
+ */
13342
+ post: {
13343
+ parameters: {
13344
+ query?: never;
13345
+ header?: {
13346
+ /** @description Replay-safe retries: resending the SAME key with the SAME body returns the original response (`X-Idempotent-Replay: 1`) instead of creating a second copy — safe to send whenever a response might not have arrived. The same key with a DIFFERENT body answers `409 IDEMPOTENCY_KEY_CONFLICT`; use a fresh key per operation. */
13347
+ "Idempotency-Key"?: string;
13348
+ };
13349
+ path: {
13350
+ feature: string;
13351
+ };
13352
+ cookie?: never;
13353
+ };
13354
+ requestBody?: never;
13355
+ responses: {
13356
+ /** @description Activation result */
13357
+ 200: {
13358
+ headers: {
13359
+ [name: string]: unknown;
13360
+ };
13361
+ content: {
13362
+ /**
13363
+ * @example {
13364
+ * "data": {
13365
+ * "status": "active",
13366
+ * "entitlement": {
13367
+ * "tenant_id": "11111111-1111-4111-8111-111111111111",
13368
+ * "feature": "vitrina_ads",
13369
+ * "status": "active",
13370
+ * "source": "self_serve",
13371
+ * "granted_at": "2026-09-23T15:00:00.000Z",
13372
+ * "cancel_at_period_end": false,
13373
+ * "canceled_at": null,
13374
+ * "metadata": {},
13375
+ * "created_at": "2026-09-23T15:00:00.000Z",
13376
+ * "updated_at": "2026-09-23T15:00:00.000Z"
13377
+ * }
13378
+ * }
13379
+ * }
13380
+ */
13381
+ "application/json": {
13382
+ data?: unknown;
13383
+ meta?: {
13384
+ [key: string]: unknown;
13385
+ };
13386
+ };
13387
+ };
13388
+ };
13389
+ /** @description Validation error */
13390
+ 400: {
13391
+ headers: {
13392
+ [name: string]: unknown;
13393
+ };
13394
+ content: {
13395
+ "application/json": components["schemas"]["Error"];
13396
+ };
13397
+ };
13398
+ /** @description Unauthorized */
13399
+ 401: {
13400
+ headers: {
13401
+ [name: string]: unknown;
13402
+ };
13403
+ content: {
13404
+ "application/json": components["schemas"]["Error"];
13405
+ };
13406
+ };
13407
+ /** @description Forbidden */
13408
+ 403: {
13409
+ headers: {
13410
+ [name: string]: unknown;
13411
+ };
13412
+ content: {
13413
+ "application/json": components["schemas"]["Error"];
13414
+ };
13415
+ };
13416
+ /** @description Not found */
13417
+ 404: {
13418
+ headers: {
13419
+ [name: string]: unknown;
13420
+ };
13421
+ content: {
13422
+ "application/json": components["schemas"]["Error"];
13423
+ };
13424
+ };
13425
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
13426
+ 409: {
13427
+ headers: {
13428
+ [name: string]: unknown;
13429
+ };
13430
+ content: {
13431
+ "application/json": components["schemas"]["Error"];
13432
+ };
13433
+ };
13434
+ /** @description Rate limited */
13435
+ 429: {
13436
+ headers: {
13437
+ [name: string]: unknown;
13438
+ };
13439
+ content: {
13440
+ "application/json": components["schemas"]["Error"];
13441
+ };
13442
+ };
13443
+ };
13444
+ };
13445
+ delete?: never;
13446
+ options?: never;
13447
+ head?: never;
13448
+ patch?: never;
13449
+ trace?: never;
13450
+ };
13451
+ "/entitlements/{feature}/cancel": {
13452
+ parameters: {
13453
+ query?: never;
13454
+ header?: never;
13455
+ path?: never;
13456
+ cookie?: never;
13457
+ };
13458
+ get?: never;
13459
+ put?: never;
13460
+ /**
13461
+ * Cancel an add-on at period end
13462
+ * @description Flags the workspace’s `feature` row `cancel_at_period_end: true` — the add-on stays active through the period already paid for and turns off at rollover, never immediately. 404 when the workspace holds no entitlement for `feature` to cancel.
13463
+ */
13464
+ post: {
13465
+ parameters: {
13466
+ query?: never;
13467
+ header?: {
13468
+ /** @description Replay-safe retries: resending the SAME key with the SAME body returns the original response (`X-Idempotent-Replay: 1`) instead of creating a second copy — safe to send whenever a response might not have arrived. The same key with a DIFFERENT body answers `409 IDEMPOTENCY_KEY_CONFLICT`; use a fresh key per operation. */
13469
+ "Idempotency-Key"?: string;
13470
+ };
13471
+ path: {
13472
+ feature: string;
13473
+ };
13474
+ cookie?: never;
13475
+ };
13476
+ requestBody?: never;
13477
+ responses: {
13478
+ /** @description Cancellation result */
13479
+ 200: {
13480
+ headers: {
13481
+ [name: string]: unknown;
13482
+ };
13483
+ content: {
13484
+ /**
13485
+ * @example {
13486
+ * "data": {
13487
+ * "status": "canceling",
13488
+ * "entitlement": {
13489
+ * "tenant_id": "11111111-1111-4111-8111-111111111111",
13490
+ * "feature": "vitrina_ads",
13491
+ * "status": "active",
13492
+ * "source": "self_serve",
13493
+ * "granted_at": "2026-09-01T12:00:00.000Z",
13494
+ * "cancel_at_period_end": true,
13495
+ * "canceled_at": "2026-09-23T15:00:00.000Z",
13496
+ * "metadata": {},
13497
+ * "created_at": "2026-09-01T12:00:00.000Z",
13498
+ * "updated_at": "2026-09-23T15:00:00.000Z"
13499
+ * }
13500
+ * }
13501
+ * }
13502
+ */
13503
+ "application/json": {
13504
+ data?: unknown;
13505
+ meta?: {
13506
+ [key: string]: unknown;
13507
+ };
13508
+ };
13509
+ };
13510
+ };
13511
+ /** @description Validation error */
13512
+ 400: {
13513
+ headers: {
13514
+ [name: string]: unknown;
13515
+ };
13516
+ content: {
13517
+ "application/json": components["schemas"]["Error"];
13518
+ };
13519
+ };
13520
+ /** @description Unauthorized */
13521
+ 401: {
13522
+ headers: {
13523
+ [name: string]: unknown;
13524
+ };
13525
+ content: {
13526
+ "application/json": components["schemas"]["Error"];
13527
+ };
13528
+ };
13529
+ /** @description Forbidden */
13530
+ 403: {
13531
+ headers: {
13532
+ [name: string]: unknown;
13533
+ };
13534
+ content: {
13535
+ "application/json": components["schemas"]["Error"];
13536
+ };
13537
+ };
13538
+ /** @description Not found */
13539
+ 404: {
13540
+ headers: {
13541
+ [name: string]: unknown;
13542
+ };
13543
+ content: {
13544
+ "application/json": components["schemas"]["Error"];
13545
+ };
13546
+ };
13547
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
13548
+ 409: {
13549
+ headers: {
13550
+ [name: string]: unknown;
13551
+ };
13552
+ content: {
13553
+ "application/json": components["schemas"]["Error"];
13554
+ };
13555
+ };
13556
+ /** @description Rate limited */
13557
+ 429: {
13558
+ headers: {
13559
+ [name: string]: unknown;
13560
+ };
13561
+ content: {
13562
+ "application/json": components["schemas"]["Error"];
13563
+ };
13564
+ };
13565
+ };
13566
+ };
13567
+ delete?: never;
13568
+ options?: never;
13569
+ head?: never;
13570
+ patch?: never;
13571
+ trace?: never;
13572
+ };
13157
13573
  "/vehicles/catalog/brands": {
13158
13574
  parameters: {
13159
13575
  query?: never;
@@ -16318,6 +16734,8 @@ interface paths {
16318
16734
  * @description One round trip per portal named in `integration_ids`, and the response is a per-integration outcome list — a 200 does not mean every portal accepted the ad. `status` is `published` (Vitrina pushed or updated the ad), `already_published` (the double-publish guard found a live ad on this (vehicle, integration) that Vitrina did not itself push — nothing was sent, nothing was duplicated) or `error` (`error` names why).
16319
16735
  *
16320
16736
  * ⚠ **Facebook Marketplace is asynchronous and has no HTTP API at all.** There is no portal to call: `publish()` inserts a `device_task` into a queue a real Chrome extension — running in the salesperson’s own logged-in profile — polls and executes at a human pace. This call answers `status: "pending"` the instant that task is enqueued, honestly — never a fabricated `published`. `external_id` in that case is the PROVISIONAL `fbm-task:<taskId>` handle, not a real Facebook item id, and the publication carries no `permalink` yet. **The task may never complete** — the extension can be offline, paused or blocked by a Facebook checkpoint. Poll `GET /vehicles/{id}/publications` for the row to turn `published` (with a real `external_id`/`permalink`) or `error`, or subscribe to `vehicle.published` / `vehicle.publish_failed`.
16737
+ *
16738
+ * **Chileautos (Panel) (`chileautos_panel`) is asynchronous too.** It is driven through a browser session on the dealer’s control panel, which only Vitrina’s scraper workers can run, so this call answers `status: "pending"` the instant the job is queued (the publication row reads `pending`, or `updating` when the ad already exists). Same polling and webhooks as above; the row turns `published` or `error` (with `last_error`), usually within a few minutes.
16321
16739
  */
16322
16740
  post: {
16323
16741
  parameters: {
@@ -16494,7 +16912,7 @@ interface paths {
16494
16912
  * Unpublish a vehicle from a marketplace
16495
16913
  * @description Removes ONE publication (contrast `POST /vehicles/{id}/close-ads`, which closes every portal at once and is always enqueued). Returns the publication row with `status`, the real `PublicationStatus` — whatever a portal calls its own removed state (Chileautos has no hard delete and writes `Withdrawn` on its side) still lands here as `deleted`. The row itself is kept as a tombstone, never removed from this table, so "where did publication `pubId` go?" always has an answer.
16496
16914
  *
16497
- * ⚠ **Facebook Marketplace has no HTTP API**, so this call enqueues a `device_task` for the extension exactly as publish does, and answers honestly: `status: "removing"`, never a fabricated `deleted`. The ad is presumptively **still live** on Facebook until the extension confirms the removal — poll `GET /vehicles/{id}/publications` for the row to turn `deleted` (or `error`, if the removal failed and the ad is still there), or subscribe to `vehicle.unpublished` / `vehicle.publish_failed`, fired only on that confirmation, never at enqueue.
16915
+ * ⚠ **Facebook Marketplace has no HTTP API**, so this call enqueues a `device_task` for the extension exactly as publish does, and answers honestly: `status: "removing"`, never a fabricated `deleted`. The ad is presumptively **still live** on Facebook until the extension confirms the removal — poll `GET /vehicles/{id}/publications` for the row to turn `deleted` (or `error`, if the removal failed and the ad is still there), or subscribe to `vehicle.unpublished` / `vehicle.publish_failed`, fired only on that confirmation, never at enqueue. A `chileautos_panel` publication behaves the same way: the removal runs on Vitrina’s scraper workers, so the call answers `removing` and the row turns `deleted` (or `error`) when it completes.
16498
16916
  */
16499
16917
  delete: {
16500
16918
  parameters: {
@@ -41183,7 +41601,7 @@ interface paths {
41183
41601
  };
41184
41602
  trace?: never;
41185
41603
  };
41186
- "/clinic/pricing/agreements": {
41604
+ "/clinic/labs": {
41187
41605
  parameters: {
41188
41606
  query?: never;
41189
41607
  header?: never;
@@ -41191,8 +41609,8 @@ interface paths {
41191
41609
  cookie?: never;
41192
41610
  };
41193
41611
  /**
41194
- * List convenios
41195
- * @description Empresas, colegios and cajas with their validity, their own arancel (if any), who is billed, and how many members they have.
41612
+ * List laboratorios
41613
+ * @description The dental labs the clinic sends work to — imported from Dentalink (`/laboratorios`) by the migration importer, or native. Each row carries the lab's `contact` (address, phone) as the clinic recorded it. Disabled labs included unless `?active=true`.
41196
41614
  *
41197
41615
  * **Connected apps:** every patient and contact in the response is a Seudónimo de paciente — initials plus a stable number, `"M.F. · #1001"` — unless the clinic allowed patient names, with RUT, phone and email masked in free text and `meta.patient_privacy` saying so. Clinical alerts (`flags`) are withheld in both modes, and a non-JSON body (an export, a file) is refused with `403 CONNECTED_APP_SENSITIVE_DATA`.
41198
41616
  */
@@ -41207,7 +41625,7 @@ interface paths {
41207
41625
  };
41208
41626
  requestBody?: never;
41209
41627
  responses: {
41210
- /** @description Clinic agreements */
41628
+ /** @description Clinic labs */
41211
41629
  200: {
41212
41630
  headers: {
41213
41631
  [name: string]: unknown;
@@ -41217,22 +41635,18 @@ interface paths {
41217
41635
  * @example {
41218
41636
  * "data": [
41219
41637
  * {
41220
- * "id": "c0e57121-0000-4000-8000-000000000001",
41638
+ * "id": "c0e57121-0000-4000-8000-0000000001ab",
41221
41639
  * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
41222
- * "source": "native",
41223
- * "external_id": null,
41224
- * "name": "Convenio Empresa Andina",
41225
- * "organization_name": "Empresa Andina SpA",
41226
- * "organization_rut": "76.543.210-3",
41227
- * "price_list_id": null,
41228
- * "billing_mode": "patient",
41229
- * "valid_from": "2026-01-01",
41230
- * "valid_to": null,
41640
+ * "source": "healthatom",
41641
+ * "external_id": "9",
41642
+ * "name": "Laboratorio Ejemplo",
41643
+ * "contact": {
41644
+ * "direccion": "Avenida Ejemplo 456",
41645
+ * "telefono": "+56 9 0000 0200"
41646
+ * },
41231
41647
  * "active": true,
41232
- * "notes": null,
41233
- * "created_at": "2026-09-22T22:21:14.651Z",
41234
- * "updated_at": "2026-09-22T22:21:14.651Z",
41235
- * "member_count": 0
41648
+ * "created_at": "2026-09-23T18:00:00.000Z",
41649
+ * "updated_at": "2026-09-23T18:00:00.000Z"
41236
41650
  * }
41237
41651
  * ]
41238
41652
  * }
@@ -41302,175 +41716,74 @@ interface paths {
41302
41716
  };
41303
41717
  };
41304
41718
  put?: never;
41305
- /**
41306
- * Create a convenio
41307
- * @description Create a convenio
41308
- *
41309
- * **Connected apps:** every patient and contact in the response is a Seudónimo de paciente — initials plus a stable number, `"M.F. · #1001"` — unless the clinic allowed patient names, with RUT, phone and email masked in free text and `meta.patient_privacy` saying so. Clinical alerts (`flags`) are withheld in both modes, and a non-JSON body (an export, a file) is refused with `403 CONNECTED_APP_SENSITIVE_DATA`.
41310
- */
41311
- post: {
41312
- parameters: {
41313
- query?: never;
41314
- header?: {
41315
- /** @description Replay-safe retries: resending the SAME key with the SAME body returns the original response (`X-Idempotent-Replay: 1`) instead of creating a second copy — safe to send whenever a response might not have arrived. The same key with a DIFFERENT body answers `409 IDEMPOTENCY_KEY_CONFLICT`; use a fresh key per operation. */
41316
- "Idempotency-Key"?: string;
41317
- };
41318
- path?: never;
41319
- cookie?: never;
41320
- };
41321
- requestBody?: {
41322
- content: {
41323
- /**
41324
- * @example {
41325
- * "name": "Convenio Empresa Andina",
41326
- * "organization_name": "Empresa Andina SpA",
41327
- * "organization_rut": "76.543.210-3",
41328
- * "billing_mode": "patient",
41329
- * "valid_from": "2026-01-01"
41330
- * }
41331
- */
41332
- "application/json": {
41333
- name: string;
41334
- organization_name?: string | null;
41335
- organization_rut?: string | null;
41336
- /** Format: uuid */
41337
- price_list_id?: string | null;
41338
- /** @enum {string} */
41339
- billing_mode?: "patient" | "organization" | "split";
41340
- valid_from?: string | null;
41341
- valid_to?: string | null;
41342
- active?: boolean;
41343
- notes?: string | null;
41344
- };
41345
- };
41346
- };
41347
- responses: {
41348
- /** @description Clinic agreement */
41349
- 201: {
41350
- headers: {
41351
- [name: string]: unknown;
41352
- };
41353
- content: {
41354
- /**
41355
- * @example {
41356
- * "data": {
41357
- * "id": "c0e57121-0000-4000-8000-000000000001",
41358
- * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
41359
- * "source": "native",
41360
- * "external_id": null,
41361
- * "name": "Convenio Empresa Andina",
41362
- * "organization_name": "Empresa Andina SpA",
41363
- * "organization_rut": "76.543.210-3",
41364
- * "price_list_id": null,
41365
- * "billing_mode": "patient",
41366
- * "valid_from": "2026-01-01",
41367
- * "valid_to": null,
41368
- * "active": true,
41369
- * "notes": null,
41370
- * "created_at": "2026-09-22T22:21:14.651Z",
41371
- * "updated_at": "2026-09-22T22:21:14.651Z",
41372
- * "member_count": 0
41373
- * }
41374
- * }
41375
- */
41376
- "application/json": {
41377
- data?: unknown;
41378
- };
41379
- };
41380
- };
41381
- /** @description Validation error */
41382
- 400: {
41383
- headers: {
41384
- [name: string]: unknown;
41385
- };
41386
- content: {
41387
- "application/json": components["schemas"]["Error"];
41388
- };
41389
- };
41390
- /** @description Unauthorized */
41391
- 401: {
41392
- headers: {
41393
- [name: string]: unknown;
41394
- };
41395
- content: {
41396
- "application/json": components["schemas"]["Error"];
41397
- };
41398
- };
41399
- /** @description Forbidden */
41400
- 403: {
41401
- headers: {
41402
- [name: string]: unknown;
41403
- };
41404
- content: {
41405
- "application/json": components["schemas"]["Error"];
41406
- };
41407
- };
41408
- /** @description Not found */
41409
- 404: {
41410
- headers: {
41411
- [name: string]: unknown;
41412
- };
41413
- content: {
41414
- "application/json": components["schemas"]["Error"];
41415
- };
41416
- };
41417
- /** @description Conflict (incl. Idempotency-Key reuse with different body) */
41418
- 409: {
41419
- headers: {
41420
- [name: string]: unknown;
41421
- };
41422
- content: {
41423
- "application/json": components["schemas"]["Error"];
41424
- };
41425
- };
41426
- /** @description Rate limited */
41427
- 429: {
41428
- headers: {
41429
- [name: string]: unknown;
41430
- };
41431
- content: {
41432
- "application/json": components["schemas"]["Error"];
41433
- };
41434
- };
41435
- };
41436
- };
41719
+ post?: never;
41437
41720
  delete?: never;
41438
41721
  options?: never;
41439
41722
  head?: never;
41440
41723
  patch?: never;
41441
41724
  trace?: never;
41442
41725
  };
41443
- "/clinic/pricing/agreements/{id}": {
41726
+ "/clinic/pricing/agreements": {
41444
41727
  parameters: {
41445
41728
  query?: never;
41446
41729
  header?: never;
41447
41730
  path?: never;
41448
41731
  cookie?: never;
41449
41732
  };
41450
- get?: never;
41451
- put?: never;
41452
- post?: never;
41453
41733
  /**
41454
- * Delete a convenio
41455
- * @description Memberships and the rules that name it cascade.
41734
+ * List convenios
41735
+ * @description Empresas, colegios and cajas with their validity, their own arancel (if any), who is billed, and how many members they have.
41456
41736
  *
41457
41737
  * **Connected apps:** every patient and contact in the response is a Seudónimo de paciente — initials plus a stable number, `"M.F. · #1001"` — unless the clinic allowed patient names, with RUT, phone and email masked in free text and `meta.patient_privacy` saying so. Clinical alerts (`flags`) are withheld in both modes, and a non-JSON body (an export, a file) is refused with `403 CONNECTED_APP_SENSITIVE_DATA`.
41458
41738
  */
41459
- delete: {
41739
+ get: {
41460
41740
  parameters: {
41461
- query?: never;
41741
+ query?: {
41742
+ active?: "true" | "false";
41743
+ };
41462
41744
  header?: never;
41463
41745
  path?: never;
41464
41746
  cookie?: never;
41465
41747
  };
41466
41748
  requestBody?: never;
41467
41749
  responses: {
41468
- /** @description No content */
41469
- 204: {
41750
+ /** @description Clinic agreements */
41751
+ 200: {
41470
41752
  headers: {
41471
41753
  [name: string]: unknown;
41472
41754
  };
41473
- content?: never;
41755
+ content: {
41756
+ /**
41757
+ * @example {
41758
+ * "data": [
41759
+ * {
41760
+ * "id": "c0e57121-0000-4000-8000-000000000001",
41761
+ * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
41762
+ * "source": "native",
41763
+ * "external_id": null,
41764
+ * "name": "Convenio Empresa Andina",
41765
+ * "organization_name": "Empresa Andina SpA",
41766
+ * "organization_rut": "76.543.210-3",
41767
+ * "price_list_id": null,
41768
+ * "billing_mode": "patient",
41769
+ * "valid_from": "2026-01-01",
41770
+ * "valid_to": null,
41771
+ * "active": true,
41772
+ * "notes": null,
41773
+ * "created_at": "2026-09-22T22:21:14.651Z",
41774
+ * "updated_at": "2026-09-22T22:21:14.651Z",
41775
+ * "member_count": 0
41776
+ * }
41777
+ * ]
41778
+ * }
41779
+ */
41780
+ "application/json": {
41781
+ data?: unknown;
41782
+ meta?: {
41783
+ [key: string]: unknown;
41784
+ };
41785
+ };
41786
+ };
41474
41787
  };
41475
41788
  /** @description Validation error */
41476
41789
  400: {
@@ -41528,18 +41841,20 @@ interface paths {
41528
41841
  };
41529
41842
  };
41530
41843
  };
41531
- options?: never;
41532
- head?: never;
41844
+ put?: never;
41533
41845
  /**
41534
- * Edit a convenio
41535
- * @description Edit a convenio
41846
+ * Create a convenio
41847
+ * @description Create a convenio
41536
41848
  *
41537
41849
  * **Connected apps:** every patient and contact in the response is a Seudónimo de paciente — initials plus a stable number, `"M.F. · #1001"` — unless the clinic allowed patient names, with RUT, phone and email masked in free text and `meta.patient_privacy` saying so. Clinical alerts (`flags`) are withheld in both modes, and a non-JSON body (an export, a file) is refused with `403 CONNECTED_APP_SENSITIVE_DATA`.
41538
41850
  */
41539
- patch: {
41851
+ post: {
41540
41852
  parameters: {
41541
41853
  query?: never;
41542
- header?: never;
41854
+ header?: {
41855
+ /** @description Replay-safe retries: resending the SAME key with the SAME body returns the original response (`X-Idempotent-Replay: 1`) instead of creating a second copy — safe to send whenever a response might not have arrived. The same key with a DIFFERENT body answers `409 IDEMPOTENCY_KEY_CONFLICT`; use a fresh key per operation. */
41856
+ "Idempotency-Key"?: string;
41857
+ };
41543
41858
  path?: never;
41544
41859
  cookie?: never;
41545
41860
  };
@@ -41547,11 +41862,15 @@ interface paths {
41547
41862
  content: {
41548
41863
  /**
41549
41864
  * @example {
41550
- * "notes": "Presentar credencial de la empresa"
41865
+ * "name": "Convenio Empresa Andina",
41866
+ * "organization_name": "Empresa Andina SpA",
41867
+ * "organization_rut": "76.543.210-3",
41868
+ * "billing_mode": "patient",
41869
+ * "valid_from": "2026-01-01"
41551
41870
  * }
41552
41871
  */
41553
41872
  "application/json": {
41554
- name?: string;
41873
+ name: string;
41555
41874
  organization_name?: string | null;
41556
41875
  organization_rut?: string | null;
41557
41876
  /** Format: uuid */
@@ -41567,7 +41886,7 @@ interface paths {
41567
41886
  };
41568
41887
  responses: {
41569
41888
  /** @description Clinic agreement */
41570
- 200: {
41889
+ 201: {
41571
41890
  headers: {
41572
41891
  [name: string]: unknown;
41573
41892
  };
@@ -41587,18 +41906,15 @@ interface paths {
41587
41906
  * "valid_from": "2026-01-01",
41588
41907
  * "valid_to": null,
41589
41908
  * "active": true,
41590
- * "notes": "Presentar credencial de la empresa",
41909
+ * "notes": null,
41591
41910
  * "created_at": "2026-09-22T22:21:14.651Z",
41592
- * "updated_at": "2026-09-22T22:21:14.663Z",
41911
+ * "updated_at": "2026-09-22T22:21:14.651Z",
41593
41912
  * "member_count": 0
41594
41913
  * }
41595
41914
  * }
41596
41915
  */
41597
41916
  "application/json": {
41598
41917
  data?: unknown;
41599
- meta?: {
41600
- [key: string]: unknown;
41601
- };
41602
41918
  };
41603
41919
  };
41604
41920
  };
@@ -41658,22 +41974,29 @@ interface paths {
41658
41974
  };
41659
41975
  };
41660
41976
  };
41977
+ delete?: never;
41978
+ options?: never;
41979
+ head?: never;
41980
+ patch?: never;
41661
41981
  trace?: never;
41662
41982
  };
41663
- "/clinic/pricing/agreements/{id}/members": {
41983
+ "/clinic/pricing/agreements/{id}": {
41664
41984
  parameters: {
41665
41985
  query?: never;
41666
41986
  header?: never;
41667
41987
  path?: never;
41668
41988
  cookie?: never;
41669
41989
  };
41990
+ get?: never;
41991
+ put?: never;
41992
+ post?: never;
41670
41993
  /**
41671
- * List a convenio’s members
41672
- * @description Each membership with the patient’s name and RUT, its member number and its OWN validity window — the window the loyalty tier is measured from.
41994
+ * Delete a convenio
41995
+ * @description Memberships and the rules that name it cascade.
41673
41996
  *
41674
41997
  * **Connected apps:** every patient and contact in the response is a Seudónimo de paciente — initials plus a stable number, `"M.F. · #1001"` — unless the clinic allowed patient names, with RUT, phone and email masked in free text and `meta.patient_privacy` saying so. Clinical alerts (`flags`) are withheld in both modes, and a non-JSON body (an export, a file) is refused with `403 CONNECTED_APP_SENSITIVE_DATA`.
41675
41998
  */
41676
- get: {
41999
+ delete: {
41677
42000
  parameters: {
41678
42001
  query?: never;
41679
42002
  header?: never;
@@ -41682,39 +42005,256 @@ interface paths {
41682
42005
  };
41683
42006
  requestBody?: never;
41684
42007
  responses: {
41685
- /** @description Clinic agreement members */
41686
- 200: {
42008
+ /** @description No content */
42009
+ 204: {
41687
42010
  headers: {
41688
42011
  [name: string]: unknown;
41689
42012
  };
41690
- content: {
41691
- /**
41692
- * @example {
41693
- * "data": [
41694
- * {
41695
- * "id": "6467baa3-0000-4000-8000-000000000001",
41696
- * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
41697
- * "clinic_patient_id": "b1b0b8de-0000-4000-8000-000000000001",
41698
- * "agreement_id": "c0e57121-0000-4000-8000-000000000001",
41699
- * "member_number": "EA-0042",
41700
- * "valid_from": null,
41701
- * "valid_to": null,
41702
- * "created_at": "2026-09-22T22:21:14.673Z",
41703
- * "updated_at": "2026-09-22T22:21:14.673Z",
41704
- * "patient_nombre": "María José",
41705
- * "patient_apellidos": "Fuentes Lagos",
41706
- * "patient_rut": "11.111.111-1"
41707
- * }
41708
- * ]
41709
- * }
41710
- */
41711
- "application/json": {
41712
- data?: unknown;
41713
- meta?: {
41714
- [key: string]: unknown;
41715
- };
41716
- };
41717
- };
42013
+ content?: never;
42014
+ };
42015
+ /** @description Validation error */
42016
+ 400: {
42017
+ headers: {
42018
+ [name: string]: unknown;
42019
+ };
42020
+ content: {
42021
+ "application/json": components["schemas"]["Error"];
42022
+ };
42023
+ };
42024
+ /** @description Unauthorized */
42025
+ 401: {
42026
+ headers: {
42027
+ [name: string]: unknown;
42028
+ };
42029
+ content: {
42030
+ "application/json": components["schemas"]["Error"];
42031
+ };
42032
+ };
42033
+ /** @description Forbidden */
42034
+ 403: {
42035
+ headers: {
42036
+ [name: string]: unknown;
42037
+ };
42038
+ content: {
42039
+ "application/json": components["schemas"]["Error"];
42040
+ };
42041
+ };
42042
+ /** @description Not found */
42043
+ 404: {
42044
+ headers: {
42045
+ [name: string]: unknown;
42046
+ };
42047
+ content: {
42048
+ "application/json": components["schemas"]["Error"];
42049
+ };
42050
+ };
42051
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
42052
+ 409: {
42053
+ headers: {
42054
+ [name: string]: unknown;
42055
+ };
42056
+ content: {
42057
+ "application/json": components["schemas"]["Error"];
42058
+ };
42059
+ };
42060
+ /** @description Rate limited */
42061
+ 429: {
42062
+ headers: {
42063
+ [name: string]: unknown;
42064
+ };
42065
+ content: {
42066
+ "application/json": components["schemas"]["Error"];
42067
+ };
42068
+ };
42069
+ };
42070
+ };
42071
+ options?: never;
42072
+ head?: never;
42073
+ /**
42074
+ * Edit a convenio
42075
+ * @description Edit a convenio
42076
+ *
42077
+ * **Connected apps:** every patient and contact in the response is a Seudónimo de paciente — initials plus a stable number, `"M.F. · #1001"` — unless the clinic allowed patient names, with RUT, phone and email masked in free text and `meta.patient_privacy` saying so. Clinical alerts (`flags`) are withheld in both modes, and a non-JSON body (an export, a file) is refused with `403 CONNECTED_APP_SENSITIVE_DATA`.
42078
+ */
42079
+ patch: {
42080
+ parameters: {
42081
+ query?: never;
42082
+ header?: never;
42083
+ path?: never;
42084
+ cookie?: never;
42085
+ };
42086
+ requestBody?: {
42087
+ content: {
42088
+ /**
42089
+ * @example {
42090
+ * "notes": "Presentar credencial de la empresa"
42091
+ * }
42092
+ */
42093
+ "application/json": {
42094
+ name?: string;
42095
+ organization_name?: string | null;
42096
+ organization_rut?: string | null;
42097
+ /** Format: uuid */
42098
+ price_list_id?: string | null;
42099
+ /** @enum {string} */
42100
+ billing_mode?: "patient" | "organization" | "split";
42101
+ valid_from?: string | null;
42102
+ valid_to?: string | null;
42103
+ active?: boolean;
42104
+ notes?: string | null;
42105
+ };
42106
+ };
42107
+ };
42108
+ responses: {
42109
+ /** @description Clinic agreement */
42110
+ 200: {
42111
+ headers: {
42112
+ [name: string]: unknown;
42113
+ };
42114
+ content: {
42115
+ /**
42116
+ * @example {
42117
+ * "data": {
42118
+ * "id": "c0e57121-0000-4000-8000-000000000001",
42119
+ * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
42120
+ * "source": "native",
42121
+ * "external_id": null,
42122
+ * "name": "Convenio Empresa Andina",
42123
+ * "organization_name": "Empresa Andina SpA",
42124
+ * "organization_rut": "76.543.210-3",
42125
+ * "price_list_id": null,
42126
+ * "billing_mode": "patient",
42127
+ * "valid_from": "2026-01-01",
42128
+ * "valid_to": null,
42129
+ * "active": true,
42130
+ * "notes": "Presentar credencial de la empresa",
42131
+ * "created_at": "2026-09-22T22:21:14.651Z",
42132
+ * "updated_at": "2026-09-22T22:21:14.663Z",
42133
+ * "member_count": 0
42134
+ * }
42135
+ * }
42136
+ */
42137
+ "application/json": {
42138
+ data?: unknown;
42139
+ meta?: {
42140
+ [key: string]: unknown;
42141
+ };
42142
+ };
42143
+ };
42144
+ };
42145
+ /** @description Validation error */
42146
+ 400: {
42147
+ headers: {
42148
+ [name: string]: unknown;
42149
+ };
42150
+ content: {
42151
+ "application/json": components["schemas"]["Error"];
42152
+ };
42153
+ };
42154
+ /** @description Unauthorized */
42155
+ 401: {
42156
+ headers: {
42157
+ [name: string]: unknown;
42158
+ };
42159
+ content: {
42160
+ "application/json": components["schemas"]["Error"];
42161
+ };
42162
+ };
42163
+ /** @description Forbidden */
42164
+ 403: {
42165
+ headers: {
42166
+ [name: string]: unknown;
42167
+ };
42168
+ content: {
42169
+ "application/json": components["schemas"]["Error"];
42170
+ };
42171
+ };
42172
+ /** @description Not found */
42173
+ 404: {
42174
+ headers: {
42175
+ [name: string]: unknown;
42176
+ };
42177
+ content: {
42178
+ "application/json": components["schemas"]["Error"];
42179
+ };
42180
+ };
42181
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
42182
+ 409: {
42183
+ headers: {
42184
+ [name: string]: unknown;
42185
+ };
42186
+ content: {
42187
+ "application/json": components["schemas"]["Error"];
42188
+ };
42189
+ };
42190
+ /** @description Rate limited */
42191
+ 429: {
42192
+ headers: {
42193
+ [name: string]: unknown;
42194
+ };
42195
+ content: {
42196
+ "application/json": components["schemas"]["Error"];
42197
+ };
42198
+ };
42199
+ };
42200
+ };
42201
+ trace?: never;
42202
+ };
42203
+ "/clinic/pricing/agreements/{id}/members": {
42204
+ parameters: {
42205
+ query?: never;
42206
+ header?: never;
42207
+ path?: never;
42208
+ cookie?: never;
42209
+ };
42210
+ /**
42211
+ * List a convenio’s members
42212
+ * @description Each membership with the patient’s name and RUT, its member number and its OWN validity window — the window the loyalty tier is measured from.
42213
+ *
42214
+ * **Connected apps:** every patient and contact in the response is a Seudónimo de paciente — initials plus a stable number, `"M.F. · #1001"` — unless the clinic allowed patient names, with RUT, phone and email masked in free text and `meta.patient_privacy` saying so. Clinical alerts (`flags`) are withheld in both modes, and a non-JSON body (an export, a file) is refused with `403 CONNECTED_APP_SENSITIVE_DATA`.
42215
+ */
42216
+ get: {
42217
+ parameters: {
42218
+ query?: never;
42219
+ header?: never;
42220
+ path?: never;
42221
+ cookie?: never;
42222
+ };
42223
+ requestBody?: never;
42224
+ responses: {
42225
+ /** @description Clinic agreement members */
42226
+ 200: {
42227
+ headers: {
42228
+ [name: string]: unknown;
42229
+ };
42230
+ content: {
42231
+ /**
42232
+ * @example {
42233
+ * "data": [
42234
+ * {
42235
+ * "id": "6467baa3-0000-4000-8000-000000000001",
42236
+ * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
42237
+ * "clinic_patient_id": "b1b0b8de-0000-4000-8000-000000000001",
42238
+ * "agreement_id": "c0e57121-0000-4000-8000-000000000001",
42239
+ * "member_number": "EA-0042",
42240
+ * "valid_from": null,
42241
+ * "valid_to": null,
42242
+ * "created_at": "2026-09-22T22:21:14.673Z",
42243
+ * "updated_at": "2026-09-22T22:21:14.673Z",
42244
+ * "patient_nombre": "María José",
42245
+ * "patient_apellidos": "Fuentes Lagos",
42246
+ * "patient_rut": "11.111.111-1"
42247
+ * }
42248
+ * ]
42249
+ * }
42250
+ */
42251
+ "application/json": {
42252
+ data?: unknown;
42253
+ meta?: {
42254
+ [key: string]: unknown;
42255
+ };
42256
+ };
42257
+ };
41718
42258
  };
41719
42259
  /** @description Validation error */
41720
42260
  400: {
@@ -44763,7 +45303,7 @@ interface paths {
44763
45303
  patch?: never;
44764
45304
  trace?: never;
44765
45305
  };
44766
- "/clinic/budgets/{id}": {
45306
+ "/clinic/budgets/mirror-plans": {
44767
45307
  parameters: {
44768
45308
  query?: never;
44769
45309
  header?: never;
@@ -44771,23 +45311,23 @@ interface paths {
44771
45311
  cookie?: never;
44772
45312
  };
44773
45313
  /**
44774
- * One presupuesto, by UUID or folio
44775
- * @description `{id}` accepts a UUID or the folio (`E-47`).
45314
+ * A patient's mirrored Dentalink plans, for «Crear desde Dentalink»
45315
+ * @description The patient's plans in the espejo de ingresos (a Dentalink clinic's tratamientos, copied read-only), newest first, each with `lines_count`, `unmapped_count` (lines whose prestación is not in the local catalogue yet — the plan cannot be photographed until the catalog importer runs) and `already_budgeted` / `budget_id` (a non-voided presupuesto already photographs it). `available: false` means the workspace has no enabled Dentalink mirror, and `items` is empty.
44776
45316
  *
44777
45317
  * **Connected apps:** every patient and contact in the response is a Seudónimo de paciente — initials plus a stable number, `"M.F. · #1001"` — unless the clinic allowed patient names, with RUT, phone and email masked in free text and `meta.patient_privacy` saying so. Clinical alerts (`flags`) are withheld in both modes, and a non-JSON body (an export, a file) is refused with `403 CONNECTED_APP_SENSITIVE_DATA`.
44778
45318
  */
44779
45319
  get: {
44780
45320
  parameters: {
44781
- query?: never;
44782
- header?: never;
44783
- path: {
44784
- id: string;
45321
+ query: {
45322
+ patient_id: string;
44785
45323
  };
45324
+ header?: never;
45325
+ path?: never;
44786
45326
  cookie?: never;
44787
45327
  };
44788
45328
  requestBody?: never;
44789
45329
  responses: {
44790
- /** @description Clinic budget */
45330
+ /** @description Mirrored plans */
44791
45331
  200: {
44792
45332
  headers: {
44793
45333
  [name: string]: unknown;
@@ -44796,118 +45336,453 @@ interface paths {
44796
45336
  /**
44797
45337
  * @example {
44798
45338
  * "data": {
44799
- * "id": "81e4a552-0000-4000-8000-000000000001",
44800
- * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
44801
- * "source": "native",
44802
- * "external_id": null,
44803
- * "display_seq": 1,
44804
- * "display_id": "E-1",
44805
- * "clinic_patient_id": "b1b0b8de-0000-4000-8000-000000000001",
44806
- * "contact_id": "1a73af9e-0000-4000-8000-000000000001",
44807
- * "treatment_plan_id": "1ccffee2-0000-4000-8000-000000000001",
44808
- * "lead_id": null,
44809
- * "lineage_id": "81e4a552-0000-4000-8000-000000000001",
44810
- * "reissued_from_id": null,
44811
- * "conversation_id": null,
44812
- * "professional_id": "18342d1b-0000-4000-8000-000000000001",
44813
- * "location_id": "b1b1b1b1-0000-4000-8000-000000000002",
44814
- * "price_list_id": null,
44815
- * "agreement_id": null,
44816
- * "legal_entity_id": null,
44817
- * "status": "draft",
44818
- * "subtotal_clp": 147000,
44819
- * "discount_clp": 5000,
44820
- * "total_clp": 142000,
44821
- * "tax_treatment": "afecto",
44822
- * "valid_until": "2026-12-31",
44823
- * "installments": 3,
44824
- * "notes": "Incluye los cuatro controles del primer semestre",
44825
- * "obligation_group_id": null,
44826
- * "rendered_document_id": null,
44827
- * "created_by_user_id": null,
44828
- * "sent_at": null,
44829
- * "accepted_at": null,
44830
- * "accepted_via": null,
44831
- * "rejected_at": null,
44832
- * "rejected_reason": null,
44833
- * "expired_at": null,
44834
- * "voided_at": null,
44835
- * "voided_by": null,
44836
- * "voided_reason": null,
44837
- * "created_at": "2026-09-22T22:21:15.369Z",
44838
- * "updated_at": "2026-09-22T22:21:15.412Z",
44839
- * "patient_name": "María José Fuentes Lagos",
44840
- * "professional_name": "Ana Rojas Vidal",
45339
+ * "available": true,
44841
45340
  * "items": [
44842
45341
  * {
44843
- * "id": "3a7d9767-0000-4000-8000-000000000004",
44844
- * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
44845
- * "budget_id": "81e4a552-0000-4000-8000-000000000001",
44846
- * "clinic_service_id": "4cf5bc59-0000-4000-8000-000000000001",
44847
- * "pack_id": null,
44848
- * "label": "Control de ortodoncia",
44849
- * "quantity": 4,
44850
- * "unit_price_clp": 28000,
44851
- * "discount_clp": 0,
44852
- * "total_clp": 112000,
44853
- * "price_explain": [
44854
- * {
44855
- * "kind": null,
44856
- * "label": "Arancel particular 2026",
44857
- * "order": 1,
44858
- * "value": null,
44859
- * "source": "price_list",
44860
- * "rule_id": null,
44861
- * "modifier": null,
44862
- * "delta_clp": 0,
44863
- * "amount_after_clp": 28000,
44864
- * "amount_before_clp": null
44865
- * }
44866
- * ],
44867
- * "tax_treatment": "afecto",
44868
- * "phase": 1,
44869
- * "note": null,
44870
- * "sort_order": 0,
44871
- * "created_at": "2026-09-22T22:21:15.392Z",
44872
- * "updated_at": "2026-09-22T22:21:15.392Z",
44873
- * "service_name": "Control de ortodoncia"
44874
- * },
44875
- * {
44876
- * "id": "3a7d9767-0000-4000-8000-000000000005",
44877
- * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
44878
- * "budget_id": "81e4a552-0000-4000-8000-000000000001",
44879
- * "clinic_service_id": "4cf5bc59-0000-4000-8000-000000000002",
44880
- * "pack_id": null,
44881
- * "label": "Limpieza dental",
44882
- * "quantity": 1,
44883
- * "unit_price_clp": 35000,
44884
- * "discount_clp": 5000,
44885
- * "total_clp": 30000,
44886
- * "price_explain": [
44887
- * {
44888
- * "kind": null,
44889
- * "label": "Arancel particular 2026",
44890
- * "order": 1,
44891
- * "value": null,
44892
- * "source": "price_list",
44893
- * "rule_id": null,
44894
- * "modifier": null,
44895
- * "delta_clp": 0,
44896
- * "amount_after_clp": 35000,
44897
- * "amount_before_clp": null
44898
- * }
44899
- * ],
44900
- * "tax_treatment": "afecto",
44901
- * "phase": 2,
44902
- * "note": null,
44903
- * "sort_order": 1,
44904
- * "created_at": "2026-09-22T22:21:15.410Z",
44905
- * "updated_at": "2026-09-22T22:21:15.410Z",
44906
- * "service_name": "Limpieza dental"
45342
+ * "id": "6d2c1f0a-0000-4000-8000-000000000001",
45343
+ * "external_id": 90412,
45344
+ * "fecha": "2026-09-10",
45345
+ * "finalizado": false,
45346
+ * "bloqueado": false,
45347
+ * "total": 150000,
45348
+ * "deuda": 150000,
45349
+ * "clinic_professional_id": "18342d1b-0000-4000-8000-000000000001",
45350
+ * "professional_name": "Camila Rojas",
45351
+ * "lines_count": 2,
45352
+ * "unmapped_count": 0,
45353
+ * "already_budgeted": false,
45354
+ * "budget_id": null
44907
45355
  * }
44908
45356
  * ],
44909
- * "is_live": true,
44910
- * "days_left": 100
45357
+ * "total": 1
45358
+ * }
45359
+ * }
45360
+ */
45361
+ "application/json": {
45362
+ data?: unknown;
45363
+ meta?: {
45364
+ [key: string]: unknown;
45365
+ };
45366
+ };
45367
+ };
45368
+ };
45369
+ /** @description Validation error */
45370
+ 400: {
45371
+ headers: {
45372
+ [name: string]: unknown;
45373
+ };
45374
+ content: {
45375
+ "application/json": components["schemas"]["Error"];
45376
+ };
45377
+ };
45378
+ /** @description Unauthorized */
45379
+ 401: {
45380
+ headers: {
45381
+ [name: string]: unknown;
45382
+ };
45383
+ content: {
45384
+ "application/json": components["schemas"]["Error"];
45385
+ };
45386
+ };
45387
+ /** @description Forbidden */
45388
+ 403: {
45389
+ headers: {
45390
+ [name: string]: unknown;
45391
+ };
45392
+ content: {
45393
+ "application/json": components["schemas"]["Error"];
45394
+ };
45395
+ };
45396
+ /** @description Not found */
45397
+ 404: {
45398
+ headers: {
45399
+ [name: string]: unknown;
45400
+ };
45401
+ content: {
45402
+ "application/json": components["schemas"]["Error"];
45403
+ };
45404
+ };
45405
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
45406
+ 409: {
45407
+ headers: {
45408
+ [name: string]: unknown;
45409
+ };
45410
+ content: {
45411
+ "application/json": components["schemas"]["Error"];
45412
+ };
45413
+ };
45414
+ /** @description Rate limited */
45415
+ 429: {
45416
+ headers: {
45417
+ [name: string]: unknown;
45418
+ };
45419
+ content: {
45420
+ "application/json": components["schemas"]["Error"];
45421
+ };
45422
+ };
45423
+ };
45424
+ };
45425
+ put?: never;
45426
+ post?: never;
45427
+ delete?: never;
45428
+ options?: never;
45429
+ head?: never;
45430
+ patch?: never;
45431
+ trace?: never;
45432
+ };
45433
+ "/clinic/budgets/from-mirror-plan": {
45434
+ parameters: {
45435
+ query?: never;
45436
+ header?: never;
45437
+ path?: never;
45438
+ cookie?: never;
45439
+ };
45440
+ get?: never;
45441
+ put?: never;
45442
+ /**
45443
+ * Create a presupuesto (draft) from a mirrored Dentalink plan
45444
+ * @description On a Dentalink clinic the plan is born in Dentalink; this composes the presupuesto FROM its mirrored copy in one action. Every line of the plan becomes a line at Dentalink's net price (after its descuentos), frozen with an explanation that names the source; the plan's professional becomes the presupuesto's (per-line performers are not kept). The response carries `mirror: {plan_id, snapshot_at, changed_at}`. When the plan later changes in Dentalink — a line added, removed or repriced, even at the same total — `mirror.changed_at` is set and `clinic_budget.mirror_changed` fires; `POST /clinic/budgets/{id}/supersede` then writes a new version from the live plan. 409 `MIRROR_LINES_UNMAPPED` lists the prestaciones missing from the local catalogue (`details.fix` names the importer); 409 with `details.reason` for a plan whose patient is not linked, a plan with no lines yet, or one another presupuesto already photographs. Vitrina never writes to Dentalink.
45445
+ *
45446
+ * **Connected apps:** every patient and contact in the response is a Seudónimo de paciente — initials plus a stable number, `"M.F. · #1001"` — unless the clinic allowed patient names, with RUT, phone and email masked in free text and `meta.patient_privacy` saying so. Clinical alerts (`flags`) are withheld in both modes, and a non-JSON body (an export, a file) is refused with `403 CONNECTED_APP_SENSITIVE_DATA`.
45447
+ */
45448
+ post: {
45449
+ parameters: {
45450
+ query?: never;
45451
+ header?: {
45452
+ /** @description Replay-safe retries: resending the SAME key with the SAME body returns the original response (`X-Idempotent-Replay: 1`) instead of creating a second copy — safe to send whenever a response might not have arrived. The same key with a DIFFERENT body answers `409 IDEMPOTENCY_KEY_CONFLICT`; use a fresh key per operation. */
45453
+ "Idempotency-Key"?: string;
45454
+ };
45455
+ path?: never;
45456
+ cookie?: never;
45457
+ };
45458
+ requestBody?: {
45459
+ content: {
45460
+ /**
45461
+ * @example {
45462
+ * "mirror_plan_id": "6d2c1f0a-0000-4000-8000-000000000001"
45463
+ * }
45464
+ */
45465
+ "application/json": {
45466
+ /** Format: uuid */
45467
+ mirror_plan_id: string;
45468
+ /** Format: uuid */
45469
+ clinic_patient_id?: string;
45470
+ /** Format: uuid */
45471
+ contact_id?: string | null;
45472
+ /** Format: uuid */
45473
+ location_id?: string | null;
45474
+ /** Format: uuid */
45475
+ conversation_id?: string | null;
45476
+ /** Format: uuid */
45477
+ lead_id?: string | null;
45478
+ /** @enum {string} */
45479
+ tax_treatment?: "afecto" | "exento" | "no_gravado";
45480
+ valid_until?: string | null;
45481
+ installments?: number | null;
45482
+ notes?: string | null;
45483
+ };
45484
+ };
45485
+ };
45486
+ responses: {
45487
+ /** @description Clinic budget */
45488
+ 201: {
45489
+ headers: {
45490
+ [name: string]: unknown;
45491
+ };
45492
+ content: {
45493
+ /**
45494
+ * @example {
45495
+ * "data": {
45496
+ * "id": "458363ad-0000-4000-8000-000000000009",
45497
+ * "display_id": "E-52",
45498
+ * "status": "draft",
45499
+ * "clinic_patient_id": "b1b0b8de-0000-4000-8000-000000000001",
45500
+ * "contact_id": "1a73af9e-0000-4000-8000-000000000001",
45501
+ * "professional_id": "18342d1b-0000-4000-8000-000000000001",
45502
+ * "lineage_id": "458363ad-0000-4000-8000-000000000009",
45503
+ * "reissued_from_id": null,
45504
+ * "subtotal_clp": 150000,
45505
+ * "discount_clp": 0,
45506
+ * "total_clp": 150000,
45507
+ * "tax_treatment": "afecto",
45508
+ * "valid_until": "2026-10-23",
45509
+ * "mirror": {
45510
+ * "plan_id": "6d2c1f0a-0000-4000-8000-000000000001",
45511
+ * "snapshot_at": "2026-09-23T14:02:11.000Z",
45512
+ * "changed_at": null
45513
+ * },
45514
+ * "items": [
45515
+ * {
45516
+ * "id": "a1c0ffee-0000-4000-8000-000000000001",
45517
+ * "clinic_service_id": "5e5e5e5e-0000-4000-8000-000000000001",
45518
+ * "label": "Resina compuesta",
45519
+ * "quantity": 1,
45520
+ * "unit_price_clp": 100000,
45521
+ * "discount_clp": 0,
45522
+ * "total_clp": 100000,
45523
+ * "price_explain": [
45524
+ * {
45525
+ * "order": 1,
45526
+ * "source": "mirror_snapshot",
45527
+ * "label": "Precio del tratamiento en Dentalink",
45528
+ * "amount_before_clp": null,
45529
+ * "amount_after_clp": 120000,
45530
+ * "delta_clp": 0,
45531
+ * "external_id": 1,
45532
+ * "external_plan": 90412
45533
+ * },
45534
+ * {
45535
+ * "order": 2,
45536
+ * "source": "mirror_snapshot",
45537
+ * "label": "Descuento registrado en Dentalink",
45538
+ * "amount_before_clp": 120000,
45539
+ * "amount_after_clp": 100000,
45540
+ * "delta_clp": -20000,
45541
+ * "external_id": 1,
45542
+ * "external_plan": 90412
45543
+ * }
45544
+ * ]
45545
+ * },
45546
+ * {
45547
+ * "id": "a1c0ffee-0000-4000-8000-000000000002",
45548
+ * "clinic_service_id": "5e5e5e5e-0000-4000-8000-000000000002",
45549
+ * "label": "Sellante",
45550
+ * "quantity": 1,
45551
+ * "unit_price_clp": 50000,
45552
+ * "discount_clp": 0,
45553
+ * "total_clp": 50000,
45554
+ * "price_explain": [
45555
+ * {
45556
+ * "order": 1,
45557
+ * "source": "mirror_snapshot",
45558
+ * "label": "Precio del tratamiento en Dentalink",
45559
+ * "amount_before_clp": null,
45560
+ * "amount_after_clp": 50000,
45561
+ * "delta_clp": 0,
45562
+ * "external_id": 2,
45563
+ * "external_plan": 90412
45564
+ * }
45565
+ * ]
45566
+ * }
45567
+ * ],
45568
+ * "version": 1,
45569
+ * "lineage_size": 1,
45570
+ * "reissued_by_id": null
45571
+ * }
45572
+ * }
45573
+ */
45574
+ "application/json": {
45575
+ data?: unknown;
45576
+ };
45577
+ };
45578
+ };
45579
+ /** @description Validation error */
45580
+ 400: {
45581
+ headers: {
45582
+ [name: string]: unknown;
45583
+ };
45584
+ content: {
45585
+ "application/json": components["schemas"]["Error"];
45586
+ };
45587
+ };
45588
+ /** @description Unauthorized */
45589
+ 401: {
45590
+ headers: {
45591
+ [name: string]: unknown;
45592
+ };
45593
+ content: {
45594
+ "application/json": components["schemas"]["Error"];
45595
+ };
45596
+ };
45597
+ /** @description Forbidden */
45598
+ 403: {
45599
+ headers: {
45600
+ [name: string]: unknown;
45601
+ };
45602
+ content: {
45603
+ "application/json": components["schemas"]["Error"];
45604
+ };
45605
+ };
45606
+ /** @description Not found */
45607
+ 404: {
45608
+ headers: {
45609
+ [name: string]: unknown;
45610
+ };
45611
+ content: {
45612
+ "application/json": components["schemas"]["Error"];
45613
+ };
45614
+ };
45615
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
45616
+ 409: {
45617
+ headers: {
45618
+ [name: string]: unknown;
45619
+ };
45620
+ content: {
45621
+ "application/json": components["schemas"]["Error"];
45622
+ };
45623
+ };
45624
+ /** @description Rate limited */
45625
+ 429: {
45626
+ headers: {
45627
+ [name: string]: unknown;
45628
+ };
45629
+ content: {
45630
+ "application/json": components["schemas"]["Error"];
45631
+ };
45632
+ };
45633
+ };
45634
+ };
45635
+ delete?: never;
45636
+ options?: never;
45637
+ head?: never;
45638
+ patch?: never;
45639
+ trace?: never;
45640
+ };
45641
+ "/clinic/budgets/{id}": {
45642
+ parameters: {
45643
+ query?: never;
45644
+ header?: never;
45645
+ path?: never;
45646
+ cookie?: never;
45647
+ };
45648
+ /**
45649
+ * One presupuesto, by UUID or folio
45650
+ * @description `{id}` accepts a UUID or the folio (`E-47`).
45651
+ *
45652
+ * **Connected apps:** every patient and contact in the response is a Seudónimo de paciente — initials plus a stable number, `"M.F. · #1001"` — unless the clinic allowed patient names, with RUT, phone and email masked in free text and `meta.patient_privacy` saying so. Clinical alerts (`flags`) are withheld in both modes, and a non-JSON body (an export, a file) is refused with `403 CONNECTED_APP_SENSITIVE_DATA`.
45653
+ */
45654
+ get: {
45655
+ parameters: {
45656
+ query?: never;
45657
+ header?: never;
45658
+ path: {
45659
+ id: string;
45660
+ };
45661
+ cookie?: never;
45662
+ };
45663
+ requestBody?: never;
45664
+ responses: {
45665
+ /** @description Clinic budget */
45666
+ 200: {
45667
+ headers: {
45668
+ [name: string]: unknown;
45669
+ };
45670
+ content: {
45671
+ /**
45672
+ * @example {
45673
+ * "data": {
45674
+ * "id": "81e4a552-0000-4000-8000-000000000001",
45675
+ * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
45676
+ * "source": "native",
45677
+ * "external_id": null,
45678
+ * "display_seq": 1,
45679
+ * "display_id": "E-1",
45680
+ * "clinic_patient_id": "b1b0b8de-0000-4000-8000-000000000001",
45681
+ * "contact_id": "1a73af9e-0000-4000-8000-000000000001",
45682
+ * "treatment_plan_id": "1ccffee2-0000-4000-8000-000000000001",
45683
+ * "lead_id": null,
45684
+ * "lineage_id": "81e4a552-0000-4000-8000-000000000001",
45685
+ * "reissued_from_id": null,
45686
+ * "conversation_id": null,
45687
+ * "professional_id": "18342d1b-0000-4000-8000-000000000001",
45688
+ * "location_id": "b1b1b1b1-0000-4000-8000-000000000002",
45689
+ * "price_list_id": null,
45690
+ * "agreement_id": null,
45691
+ * "legal_entity_id": null,
45692
+ * "status": "draft",
45693
+ * "subtotal_clp": 147000,
45694
+ * "discount_clp": 5000,
45695
+ * "total_clp": 142000,
45696
+ * "tax_treatment": "afecto",
45697
+ * "valid_until": "2026-12-31",
45698
+ * "installments": 3,
45699
+ * "notes": "Incluye los cuatro controles del primer semestre",
45700
+ * "obligation_group_id": null,
45701
+ * "rendered_document_id": null,
45702
+ * "created_by_user_id": null,
45703
+ * "sent_at": null,
45704
+ * "accepted_at": null,
45705
+ * "accepted_via": null,
45706
+ * "rejected_at": null,
45707
+ * "rejected_reason": null,
45708
+ * "expired_at": null,
45709
+ * "voided_at": null,
45710
+ * "voided_by": null,
45711
+ * "voided_reason": null,
45712
+ * "created_at": "2026-09-22T22:21:15.369Z",
45713
+ * "updated_at": "2026-09-22T22:21:15.412Z",
45714
+ * "patient_name": "María José Fuentes Lagos",
45715
+ * "professional_name": "Ana Rojas Vidal",
45716
+ * "items": [
45717
+ * {
45718
+ * "id": "3a7d9767-0000-4000-8000-000000000004",
45719
+ * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
45720
+ * "budget_id": "81e4a552-0000-4000-8000-000000000001",
45721
+ * "clinic_service_id": "4cf5bc59-0000-4000-8000-000000000001",
45722
+ * "pack_id": null,
45723
+ * "label": "Control de ortodoncia",
45724
+ * "quantity": 4,
45725
+ * "unit_price_clp": 28000,
45726
+ * "discount_clp": 0,
45727
+ * "total_clp": 112000,
45728
+ * "price_explain": [
45729
+ * {
45730
+ * "kind": null,
45731
+ * "label": "Arancel particular 2026",
45732
+ * "order": 1,
45733
+ * "value": null,
45734
+ * "source": "price_list",
45735
+ * "rule_id": null,
45736
+ * "modifier": null,
45737
+ * "delta_clp": 0,
45738
+ * "amount_after_clp": 28000,
45739
+ * "amount_before_clp": null
45740
+ * }
45741
+ * ],
45742
+ * "tax_treatment": "afecto",
45743
+ * "phase": 1,
45744
+ * "note": null,
45745
+ * "sort_order": 0,
45746
+ * "created_at": "2026-09-22T22:21:15.392Z",
45747
+ * "updated_at": "2026-09-22T22:21:15.392Z",
45748
+ * "service_name": "Control de ortodoncia"
45749
+ * },
45750
+ * {
45751
+ * "id": "3a7d9767-0000-4000-8000-000000000005",
45752
+ * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
45753
+ * "budget_id": "81e4a552-0000-4000-8000-000000000001",
45754
+ * "clinic_service_id": "4cf5bc59-0000-4000-8000-000000000002",
45755
+ * "pack_id": null,
45756
+ * "label": "Limpieza dental",
45757
+ * "quantity": 1,
45758
+ * "unit_price_clp": 35000,
45759
+ * "discount_clp": 5000,
45760
+ * "total_clp": 30000,
45761
+ * "price_explain": [
45762
+ * {
45763
+ * "kind": null,
45764
+ * "label": "Arancel particular 2026",
45765
+ * "order": 1,
45766
+ * "value": null,
45767
+ * "source": "price_list",
45768
+ * "rule_id": null,
45769
+ * "modifier": null,
45770
+ * "delta_clp": 0,
45771
+ * "amount_after_clp": 35000,
45772
+ * "amount_before_clp": null
45773
+ * }
45774
+ * ],
45775
+ * "tax_treatment": "afecto",
45776
+ * "phase": 2,
45777
+ * "note": null,
45778
+ * "sort_order": 1,
45779
+ * "created_at": "2026-09-22T22:21:15.410Z",
45780
+ * "updated_at": "2026-09-22T22:21:15.410Z",
45781
+ * "service_name": "Limpieza dental"
45782
+ * }
45783
+ * ],
45784
+ * "is_live": true,
45785
+ * "days_left": 100
44911
45786
  * }
44912
45787
  * }
44913
45788
  */
@@ -46402,7 +47277,7 @@ interface paths {
46402
47277
  put?: never;
46403
47278
  /**
46404
47279
  * Accept it (STAFF path)
46405
- * @description Stamps `accepted_via: "staff"` — the route decides, never the body. Opens an `obligation_group` of kind `presupuesto` plus one obligation per line in the payments ledger, creates the treatment plan, and moves the lead to «Aceptado». Idempotent: a second call returns the same objects with `accepted_now: false`. An AGENT can reach neither this route nor the public one.
47280
+ * @description Stamps `accepted_via: "staff"` — the route decides, never the body. Accepts every line still presented, or (#2448) only `item_ids`: `status: "accepted"` means AT LEAST ONE line accepted, and the lines not yet accepted stay presented — the patient link keeps working for them, staff can accept more later, and `valid_until` still applies to them. Opens an `obligation_group` of kind `presupuesto` (one per lineage) plus one obligation per NEWLY accepted line in the payments ledger, creates or grows the treatment plan, and moves the lead to «Aceptado». Idempotent: a call with nothing left to accept returns the same objects with `accepted_now: false`; `accepted_item_ids` names the lines this call accepted. An AGENT can reach neither this route nor the public one.
46406
47281
  *
46407
47282
  * **Connected apps:** every patient and contact in the response is a Seudónimo de paciente — initials plus a stable number, `"M.F. · #1001"` — unless the clinic allowed patient names, with RUT, phone and email masked in free text and `meta.patient_privacy` saying so. Clinical alerts (`flags`) are withheld in both modes, and a non-JSON body (an export, a file) is refused with `403 CONNECTED_APP_SENSITIVE_DATA`.
46408
47283
  */
@@ -46421,7 +47296,9 @@ interface paths {
46421
47296
  requestBody?: {
46422
47297
  content: {
46423
47298
  /** @example {} */
46424
- "application/json": Record<string, never>;
47299
+ "application/json": {
47300
+ item_ids?: string[];
47301
+ };
46425
47302
  };
46426
47303
  };
46427
47304
  responses: {
@@ -46634,7 +47511,11 @@ interface paths {
46634
47511
  * "b44936d0-0000-4000-8000-000000000002",
46635
47512
  * "b44936d0-0000-4000-8000-000000000003"
46636
47513
  * ],
46637
- * "accepted_now": true
47514
+ * "accepted_now": true,
47515
+ * "accepted_item_ids": [
47516
+ * "3a7d9767-0000-4000-8000-000000000007",
47517
+ * "3a7d9767-0000-4000-8000-000000000008"
47518
+ * ]
46638
47519
  * }
46639
47520
  * }
46640
47521
  */
@@ -46708,7 +47589,7 @@ interface paths {
46708
47589
  patch?: never;
46709
47590
  trace?: never;
46710
47591
  };
46711
- "/clinic/budgets/{id}/reject": {
47592
+ "/clinic/budgets/{id}/accept-and-collect": {
46712
47593
  parameters: {
46713
47594
  query?: never;
46714
47595
  header?: never;
@@ -46718,8 +47599,8 @@ interface paths {
46718
47599
  get?: never;
46719
47600
  put?: never;
46720
47601
  /**
46721
- * Record the patient declining
46722
- * @description Record the patient declining
47602
+ * Collect a payment and accept the lines it pays (the counter)
47603
+ * @description Reception's one gesture (#2448): the lines in `item_ids` become accepted (`accepted_via: "staff"`, stamped with the cashier), their obligations open in the presupuesto group, and the payment is recorded and allocated to exactly those obligations — in ONE transaction, so a refused payment or allocation leaves the lines presented. The payer is the budget's `contact_id` (409 `payer_unknown` without one) and the caja its `location_id`. Money beyond the lines' total stays as the patient's credit; less leaves the last line partly paid. A POS swipe is a `tarjeta*` instrument with `source: "card_terminal"`. Requires BOTH `clinic_money:write` and `payments:write`. 409 `nothing_to_accept` when the lines are already accepted, `expired` / `not_sent` like accept. `Idempotency-Key` is stored on the payment. An AGENT cannot reach it.
46723
47604
  *
46724
47605
  * **Connected apps:** every patient and contact in the response is a Seudónimo de paciente — initials plus a stable number, `"M.F. · #1001"` — unless the clinic allowed patient names, with RUT, phone and email masked in free text and `meta.patient_privacy` saying so. Clinical alerts (`flags`) are withheld in both modes, and a non-JSON body (an export, a file) is refused with `403 CONNECTED_APP_SENSITIVE_DATA`.
46725
47606
  */
@@ -46739,17 +47620,37 @@ interface paths {
46739
47620
  content: {
46740
47621
  /**
46741
47622
  * @example {
46742
- * "reason": "El paciente prefiere esperar al próximo semestre"
47623
+ * "item_ids": [
47624
+ * "3a7d9767-0000-4000-8000-000000000007"
47625
+ * ],
47626
+ * "payment": {
47627
+ * "instrument": "tarjeta_debito",
47628
+ * "source": "card_terminal",
47629
+ * "amount_clp": 112000
47630
+ * }
46743
47631
  * }
46744
47632
  */
46745
47633
  "application/json": {
46746
- reason?: string | null;
47634
+ item_ids: string[];
47635
+ payment: {
47636
+ /** @enum {string} */
47637
+ instrument: "efectivo" | "transferencia" | "cheque" | "vale_vista" | "tarjeta" | "tarjeta_debito" | "tarjeta_credito" | "bono" | "otro";
47638
+ /** @enum {string} */
47639
+ source?: "manual" | "card_terminal";
47640
+ amount_clp: number;
47641
+ paid_on?: string | null;
47642
+ bank?: string | null;
47643
+ account_number?: string | null;
47644
+ document_number?: string | null;
47645
+ note?: string | null;
47646
+ card_fee_bps?: number | null;
47647
+ };
46747
47648
  };
46748
47649
  };
46749
47650
  };
46750
47651
  responses: {
46751
- /** @description Clinic budget */
46752
- 200: {
47652
+ /** @description Accept-and-collect result */
47653
+ 201: {
46753
47654
  headers: {
46754
47655
  [name: string]: unknown;
46755
47656
  };
@@ -46757,126 +47658,245 @@ interface paths {
46757
47658
  /**
46758
47659
  * @example {
46759
47660
  * "data": {
46760
- * "id": "90afb8c1-0000-4000-8000-000000000001",
46761
- * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
46762
- * "source": "native",
46763
- * "external_id": null,
46764
- * "display_seq": 3,
46765
- * "display_id": "E-3",
46766
- * "clinic_patient_id": "b1b0b8de-0000-4000-8000-000000000001",
46767
- * "contact_id": "1a73af9e-0000-4000-8000-000000000001",
46768
- * "treatment_plan_id": "1ccffee2-0000-4000-8000-000000000001",
46769
- * "lead_id": "8cb33b27-0000-4000-8000-000000000001",
46770
- * "lineage_id": "90afb8c1-0000-4000-8000-000000000001",
46771
- * "reissued_from_id": null,
46772
- * "conversation_id": null,
46773
- * "professional_id": "18342d1b-0000-4000-8000-000000000001",
46774
- * "location_id": "b1b1b1b1-0000-4000-8000-000000000002",
46775
- * "price_list_id": null,
46776
- * "agreement_id": null,
46777
- * "legal_entity_id": null,
46778
- * "status": "rejected",
46779
- * "subtotal_clp": 147000,
46780
- * "discount_clp": 5000,
46781
- * "total_clp": 142000,
46782
- * "tax_treatment": "afecto",
46783
- * "valid_until": "2026-12-31",
46784
- * "installments": 3,
46785
- * "notes": "Incluye los cuatro controles del primer semestre",
46786
- * "obligation_group_id": null,
46787
- * "rendered_document_id": null,
46788
- * "created_by_user_id": null,
46789
- * "sent_at": "2026-09-22T22:21:16.137Z",
46790
- * "accepted_at": null,
46791
- * "accepted_via": null,
46792
- * "rejected_at": "2026-09-22T22:21:16.460Z",
46793
- * "rejected_reason": "El paciente prefiere esperar al próximo semestre",
46794
- * "expired_at": null,
46795
- * "voided_at": null,
46796
- * "voided_by": null,
46797
- * "voided_reason": null,
46798
- * "created_at": "2026-09-22T22:21:16.091Z",
46799
- * "updated_at": "2026-09-22T22:21:16.459Z",
46800
- * "patient_name": "María José Fuentes Lagos",
46801
- * "professional_name": "Ana Rojas Vidal",
46802
- * "items": [
46803
- * {
46804
- * "id": "3a7d9767-0000-4000-8000-000000000009",
46805
- * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
46806
- * "budget_id": "90afb8c1-0000-4000-8000-000000000001",
46807
- * "clinic_service_id": "4cf5bc59-0000-4000-8000-000000000001",
46808
- * "pack_id": null,
46809
- * "label": "Control de ortodoncia",
46810
- * "quantity": 4,
46811
- * "unit_price_clp": 28000,
46812
- * "discount_clp": 0,
46813
- * "total_clp": 112000,
46814
- * "price_explain": [
47661
+ * "budget": {
47662
+ * "id": "81e4a552-0000-4000-8000-000000000002",
47663
+ * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
47664
+ * "source": "native",
47665
+ * "external_id": null,
47666
+ * "display_seq": 2,
47667
+ * "display_id": "E-2",
47668
+ * "clinic_patient_id": "b1b0b8de-0000-4000-8000-000000000001",
47669
+ * "contact_id": "1a73af9e-0000-4000-8000-000000000001",
47670
+ * "treatment_plan_id": "1ccffee2-0000-4000-8000-000000000001",
47671
+ * "lead_id": "8cb33b27-0000-4000-8000-000000000001",
47672
+ * "lineage_id": "81e4a552-0000-4000-8000-000000000002",
47673
+ * "reissued_from_id": null,
47674
+ * "conversation_id": null,
47675
+ * "professional_id": "18342d1b-0000-4000-8000-000000000001",
47676
+ * "location_id": "b1b1b1b1-0000-4000-8000-000000000002",
47677
+ * "price_list_id": null,
47678
+ * "agreement_id": null,
47679
+ * "legal_entity_id": null,
47680
+ * "status": "accepted",
47681
+ * "subtotal_clp": 147000,
47682
+ * "discount_clp": 5000,
47683
+ * "total_clp": 142000,
47684
+ * "tax_treatment": "afecto",
47685
+ * "valid_until": "2026-12-31",
47686
+ * "installments": 3,
47687
+ * "notes": "Incluye los cuatro controles del primer semestre",
47688
+ * "obligation_group_id": "a067dce6-0000-4000-8000-000000000002",
47689
+ * "rendered_document_id": null,
47690
+ * "created_by_user_id": null,
47691
+ * "sent_at": "2026-09-22T22:21:15.544Z",
47692
+ * "accepted_at": "2026-09-22T22:21:16.040Z",
47693
+ * "accepted_via": "staff",
47694
+ * "rejected_at": null,
47695
+ * "rejected_reason": null,
47696
+ * "expired_at": null,
47697
+ * "voided_at": null,
47698
+ * "voided_by": null,
47699
+ * "voided_reason": null,
47700
+ * "created_at": "2026-09-22T22:21:15.502Z",
47701
+ * "updated_at": "2026-09-22T22:21:16.048Z",
47702
+ * "patient_name": "María José Fuentes Lagos",
47703
+ * "professional_name": "Ana Rojas Vidal",
47704
+ * "items": [
47705
+ * {
47706
+ * "id": "3a7d9767-0000-4000-8000-000000000007",
47707
+ * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
47708
+ * "budget_id": "81e4a552-0000-4000-8000-000000000002",
47709
+ * "clinic_service_id": "4cf5bc59-0000-4000-8000-000000000001",
47710
+ * "pack_id": null,
47711
+ * "label": "Control de ortodoncia",
47712
+ * "quantity": 4,
47713
+ * "unit_price_clp": 28000,
47714
+ * "discount_clp": 0,
47715
+ * "total_clp": 112000,
47716
+ * "price_explain": [
47717
+ * {
47718
+ * "kind": null,
47719
+ * "label": "Arancel particular 2026",
47720
+ * "order": 1,
47721
+ * "value": null,
47722
+ * "source": "price_list",
47723
+ * "rule_id": null,
47724
+ * "modifier": null,
47725
+ * "delta_clp": 0,
47726
+ * "amount_after_clp": 28000,
47727
+ * "amount_before_clp": null
47728
+ * }
47729
+ * ],
47730
+ * "tax_treatment": "afecto",
47731
+ * "phase": 1,
47732
+ * "note": null,
47733
+ * "sort_order": 0,
47734
+ * "created_at": "2026-09-22T22:21:15.515Z",
47735
+ * "updated_at": "2026-09-22T22:21:15.515Z",
47736
+ * "service_name": "Control de ortodoncia"
47737
+ * },
47738
+ * {
47739
+ * "id": "3a7d9767-0000-4000-8000-000000000008",
47740
+ * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
47741
+ * "budget_id": "81e4a552-0000-4000-8000-000000000002",
47742
+ * "clinic_service_id": "4cf5bc59-0000-4000-8000-000000000002",
47743
+ * "pack_id": null,
47744
+ * "label": "Limpieza dental",
47745
+ * "quantity": 1,
47746
+ * "unit_price_clp": 35000,
47747
+ * "discount_clp": 5000,
47748
+ * "total_clp": 30000,
47749
+ * "price_explain": [
47750
+ * {
47751
+ * "kind": null,
47752
+ * "label": "Arancel particular 2026",
47753
+ * "order": 1,
47754
+ * "value": null,
47755
+ * "source": "price_list",
47756
+ * "rule_id": null,
47757
+ * "modifier": null,
47758
+ * "delta_clp": 0,
47759
+ * "amount_after_clp": 35000,
47760
+ * "amount_before_clp": null
47761
+ * }
47762
+ * ],
47763
+ * "tax_treatment": "afecto",
47764
+ * "phase": 2,
47765
+ * "note": null,
47766
+ * "sort_order": 1,
47767
+ * "created_at": "2026-09-22T22:21:15.530Z",
47768
+ * "updated_at": "2026-09-22T22:21:15.530Z",
47769
+ * "service_name": "Limpieza dental"
47770
+ * }
47771
+ * ],
47772
+ * "is_live": false,
47773
+ * "days_left": 100
47774
+ * },
47775
+ * "plan": {
47776
+ * "id": "1ccffee2-0000-4000-8000-000000000001",
47777
+ * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
47778
+ * "source": "native",
47779
+ * "external_id": null,
47780
+ * "clinic_patient_id": "b1b0b8de-0000-4000-8000-000000000001",
47781
+ * "name": "Ortodoncia fija superior e inferior",
47782
+ * "diagnosis": "Apiñamiento anterosuperior moderado",
47783
+ * "professional_id": "18342d1b-0000-4000-8000-000000000001",
47784
+ * "status": "proposed",
47785
+ * "accepted_at": null,
47786
+ * "completed_at": null,
47787
+ * "abandoned_reason": null,
47788
+ * "created_at": "2026-09-22T22:21:15.213Z",
47789
+ * "updated_at": "2026-09-22T22:21:15.285Z",
47790
+ * "patient_name": "María José Fuentes Lagos",
47791
+ * "professional_name": "Ana Rojas Vidal",
47792
+ * "items": [
47793
+ * {
47794
+ * "id": "3a7d9767-0000-4000-8000-000000000002",
47795
+ * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
47796
+ * "treatment_plan_id": "1ccffee2-0000-4000-8000-000000000001",
47797
+ * "clinic_service_id": "4cf5bc59-0000-4000-8000-000000000001",
47798
+ * "phase": 1,
47799
+ * "quantity": 4,
47800
+ * "tooth_or_zone": null,
47801
+ * "status": "scheduled",
47802
+ * "appointment_id": "d93e8eec-0000-4000-8000-000000000001",
47803
+ * "budget_item_id": null,
47804
+ * "sort_order": 0,
47805
+ * "created_at": "2026-09-22T22:21:15.215Z",
47806
+ * "updated_at": "2026-09-22T22:21:15.337Z",
47807
+ * "service_name": "Control de ortodoncia"
47808
+ * },
47809
+ * {
47810
+ * "id": "3a7d9767-0000-4000-8000-000000000003",
47811
+ * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
47812
+ * "treatment_plan_id": "1ccffee2-0000-4000-8000-000000000001",
47813
+ * "clinic_service_id": "4cf5bc59-0000-4000-8000-000000000002",
47814
+ * "phase": 2,
47815
+ * "quantity": 1,
47816
+ * "tooth_or_zone": null,
47817
+ * "status": "pending",
47818
+ * "appointment_id": null,
47819
+ * "budget_item_id": null,
47820
+ * "sort_order": 1,
47821
+ * "created_at": "2026-09-22T22:21:15.215Z",
47822
+ * "updated_at": "2026-09-22T22:21:15.215Z",
47823
+ * "service_name": "Limpieza dental"
47824
+ * }
47825
+ * ],
47826
+ * "progress": {
47827
+ * "pending": 1,
47828
+ * "scheduled": 4,
47829
+ * "performed": 0,
47830
+ * "cancelled": 0,
47831
+ * "active": 5,
47832
+ * "percent": 0,
47833
+ * "phases": [
46815
47834
  * {
46816
- * "kind": null,
46817
- * "label": "Arancel particular 2026",
46818
- * "order": 1,
46819
- * "value": null,
46820
- * "source": "price_list",
46821
- * "rule_id": null,
46822
- * "modifier": null,
46823
- * "delta_clp": 0,
46824
- * "amount_after_clp": 28000,
46825
- * "amount_before_clp": null
46826
- * }
46827
- * ],
46828
- * "tax_treatment": "afecto",
46829
- * "phase": 1,
46830
- * "note": null,
46831
- * "sort_order": 0,
46832
- * "created_at": "2026-09-22T22:21:16.106Z",
46833
- * "updated_at": "2026-09-22T22:21:16.106Z",
46834
- * "service_name": "Control de ortodoncia"
46835
- * },
46836
- * {
46837
- * "id": "3a7d9767-0000-4000-8000-00000000000a",
46838
- * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
46839
- * "budget_id": "90afb8c1-0000-4000-8000-000000000001",
46840
- * "clinic_service_id": "4cf5bc59-0000-4000-8000-000000000002",
46841
- * "pack_id": null,
46842
- * "label": "Limpieza dental",
46843
- * "quantity": 1,
46844
- * "unit_price_clp": 35000,
46845
- * "discount_clp": 5000,
46846
- * "total_clp": 30000,
46847
- * "price_explain": [
47835
+ * "phase": 1,
47836
+ * "pending": 0,
47837
+ * "scheduled": 4,
47838
+ * "performed": 0,
47839
+ * "cancelled": 0,
47840
+ * "active": 4,
47841
+ * "percent": 0
47842
+ * },
46848
47843
  * {
46849
- * "kind": null,
46850
- * "label": "Arancel particular 2026",
46851
- * "order": 1,
46852
- * "value": null,
46853
- * "source": "price_list",
46854
- * "rule_id": null,
46855
- * "modifier": null,
46856
- * "delta_clp": 0,
46857
- * "amount_after_clp": 35000,
46858
- * "amount_before_clp": null
47844
+ * "phase": 2,
47845
+ * "pending": 1,
47846
+ * "scheduled": 0,
47847
+ * "performed": 0,
47848
+ * "cancelled": 0,
47849
+ * "active": 1,
47850
+ * "percent": 0
46859
47851
  * }
46860
47852
  * ],
46861
- * "tax_treatment": "afecto",
46862
- * "phase": 2,
46863
- * "note": null,
46864
- * "sort_order": 1,
46865
- * "created_at": "2026-09-22T22:21:16.121Z",
46866
- * "updated_at": "2026-09-22T22:21:16.121Z",
46867
- * "service_name": "Limpieza dental"
47853
+ * "current_phase": 1
46868
47854
  * }
47855
+ * },
47856
+ * "obligation_group_id": "a067dce6-0000-4000-8000-000000000002",
47857
+ * "obligation_ids": [
47858
+ * "b44936d0-0000-4000-8000-000000000002"
46869
47859
  * ],
46870
- * "is_live": false,
46871
- * "days_left": 100
47860
+ * "accepted_now": true,
47861
+ * "accepted_item_ids": [
47862
+ * "3a7d9767-0000-4000-8000-000000000007"
47863
+ * ],
47864
+ * "payment": {
47865
+ * "payment": {
47866
+ * "id": "9a7e0000-0000-4000-8000-000000000001",
47867
+ * "contact_id": "1a73af9e-0000-4000-8000-000000000001",
47868
+ * "source": "card_terminal",
47869
+ * "provenance": "manual",
47870
+ * "instrument": "tarjeta_debito",
47871
+ * "amount_clp": 112000,
47872
+ * "paid_on": "2026-09-22",
47873
+ * "location_id": "b1b1b1b1-0000-4000-8000-000000000002",
47874
+ * "allocated_clp": 112000,
47875
+ * "unallocated_clp": 0
47876
+ * },
47877
+ * "applied": [
47878
+ * {
47879
+ * "obligationId": "b44936d0-0000-4000-8000-000000000002",
47880
+ * "amountClp": 112000,
47881
+ * "allocatedClp": 112000,
47882
+ * "outstandingClp": 0,
47883
+ * "expectedClp": 112000,
47884
+ * "state": "paid",
47885
+ * "label": "Control de ortodoncia"
47886
+ * }
47887
+ * ],
47888
+ * "surplus_clp": 0,
47889
+ * "reasons": [
47890
+ * "payer_recorded_by_staff",
47891
+ * "allocation_staff_manual"
47892
+ * ],
47893
+ * "replayed": false
47894
+ * }
46872
47895
  * }
46873
47896
  * }
46874
47897
  */
46875
47898
  "application/json": {
46876
47899
  data?: unknown;
46877
- meta?: {
46878
- [key: string]: unknown;
46879
- };
46880
47900
  };
46881
47901
  };
46882
47902
  };
@@ -46942,7 +47962,7 @@ interface paths {
46942
47962
  patch?: never;
46943
47963
  trace?: never;
46944
47964
  };
46945
- "/clinic/budgets/{id}/supersede": {
47965
+ "/clinic/budgets/{id}/reject": {
46946
47966
  parameters: {
46947
47967
  query?: never;
46948
47968
  header?: never;
@@ -46952,8 +47972,8 @@ interface paths {
46952
47972
  get?: never;
46953
47973
  put?: never;
46954
47974
  /**
46955
- * Write a new version (Nueva versión)
46956
- * @description From `sent`, `accepted`, `rejected` or `expired` (409 otherwise, and 409 when a version already supersedes it). Creates a DRAFT copying the header and every line verbatim, in the same lineage. Lines already ACCEPTED are carried forward (`carried_from_item_id`, their original `accepted_at`), are immutable on the draft (409 `carried_item`), and open no second obligation when the new version is accepted — which reuses the predecessor's obligation group. Nothing is withdrawn until the draft is SENT: that voids a sent, rejected or expired predecessor with reason `superseded` in the same transaction. An ACCEPTED predecessor stays accepted until the new version is itself accepted, so its debt always has an accepted document. Discarding the draft leaves the predecessor untouched. Same rules as `POST /clinic/budgets` with `reissued_from_id`.
47975
+ * Record the patient declining
47976
+ * @description Record the patient declining
46957
47977
  *
46958
47978
  * **Connected apps:** every patient and contact in the response is a Seudónimo de paciente — initials plus a stable number, `"M.F. · #1001"` — unless the clinic allowed patient names, with RUT, phone and email masked in free text and `meta.patient_privacy` saying so. Clinical alerts (`flags`) are withheld in both modes, and a non-JSON body (an export, a file) is refused with `403 CONNECTED_APP_SENSITIVE_DATA`.
46959
47979
  */
@@ -46971,13 +47991,19 @@ interface paths {
46971
47991
  };
46972
47992
  requestBody?: {
46973
47993
  content: {
46974
- /** @example {} */
46975
- "application/json": Record<string, never>;
47994
+ /**
47995
+ * @example {
47996
+ * "reason": "El paciente prefiere esperar al próximo semestre"
47997
+ * }
47998
+ */
47999
+ "application/json": {
48000
+ reason?: string | null;
48001
+ };
46976
48002
  };
46977
48003
  };
46978
48004
  responses: {
46979
48005
  /** @description Clinic budget */
46980
- 201: {
48006
+ 200: {
46981
48007
  headers: {
46982
48008
  [name: string]: unknown;
46983
48009
  };
@@ -46985,7 +48011,7 @@ interface paths {
46985
48011
  /**
46986
48012
  * @example {
46987
48013
  * "data": {
46988
- * "id": "458363ad-0000-4000-8000-000000000001",
48014
+ * "id": "90afb8c1-0000-4000-8000-000000000001",
46989
48015
  * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
46990
48016
  * "source": "native",
46991
48017
  * "external_id": null,
@@ -46995,15 +48021,15 @@ interface paths {
46995
48021
  * "contact_id": "1a73af9e-0000-4000-8000-000000000001",
46996
48022
  * "treatment_plan_id": "1ccffee2-0000-4000-8000-000000000001",
46997
48023
  * "lead_id": "8cb33b27-0000-4000-8000-000000000001",
46998
- * "lineage_id": "81e4a552-0000-4000-8000-000000000002",
46999
- * "reissued_from_id": "81e4a552-0000-4000-8000-000000000002",
48024
+ * "lineage_id": "90afb8c1-0000-4000-8000-000000000001",
48025
+ * "reissued_from_id": null,
47000
48026
  * "conversation_id": null,
47001
48027
  * "professional_id": "18342d1b-0000-4000-8000-000000000001",
47002
48028
  * "location_id": "b1b1b1b1-0000-4000-8000-000000000002",
47003
48029
  * "price_list_id": null,
47004
48030
  * "agreement_id": null,
47005
48031
  * "legal_entity_id": null,
47006
- * "status": "draft",
48032
+ * "status": "rejected",
47007
48033
  * "subtotal_clp": 147000,
47008
48034
  * "discount_clp": 5000,
47009
48035
  * "total_clp": 142000,
@@ -47014,26 +48040,24 @@ interface paths {
47014
48040
  * "obligation_group_id": null,
47015
48041
  * "rendered_document_id": null,
47016
48042
  * "created_by_user_id": null,
47017
- * "sent_at": null,
48043
+ * "sent_at": "2026-09-22T22:21:16.137Z",
47018
48044
  * "accepted_at": null,
47019
48045
  * "accepted_via": null,
47020
- * "rejected_at": null,
47021
- * "rejected_reason": null,
48046
+ * "rejected_at": "2026-09-22T22:21:16.460Z",
48047
+ * "rejected_reason": "El paciente prefiere esperar al próximo semestre",
47022
48048
  * "expired_at": null,
47023
48049
  * "voided_at": null,
47024
48050
  * "voided_by": null,
47025
48051
  * "voided_reason": null,
47026
- * "first_viewed_at": null,
47027
- * "last_viewed_at": null,
47028
- * "created_at": "2026-09-23T01:07:07.990Z",
47029
- * "updated_at": "2026-09-23T01:07:07.990Z",
48052
+ * "created_at": "2026-09-22T22:21:16.091Z",
48053
+ * "updated_at": "2026-09-22T22:21:16.459Z",
47030
48054
  * "patient_name": "María José Fuentes Lagos",
47031
48055
  * "professional_name": "Ana Rojas Vidal",
47032
48056
  * "items": [
47033
48057
  * {
47034
48058
  * "id": "3a7d9767-0000-4000-8000-000000000009",
47035
48059
  * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
47036
- * "budget_id": "458363ad-0000-4000-8000-000000000001",
48060
+ * "budget_id": "90afb8c1-0000-4000-8000-000000000001",
47037
48061
  * "clinic_service_id": "4cf5bc59-0000-4000-8000-000000000001",
47038
48062
  * "pack_id": null,
47039
48063
  * "label": "Control de ortodoncia",
@@ -47059,16 +48083,14 @@ interface paths {
47059
48083
  * "phase": 1,
47060
48084
  * "note": null,
47061
48085
  * "sort_order": 0,
47062
- * "accepted_at": "2026-09-23T01:07:07.912Z",
47063
- * "carried_from_item_id": "3a7d9767-0000-4000-8000-000000000007",
47064
- * "created_at": "2026-09-23T01:07:07.990Z",
47065
- * "updated_at": "2026-09-23T01:07:07.990Z",
48086
+ * "created_at": "2026-09-22T22:21:16.106Z",
48087
+ * "updated_at": "2026-09-22T22:21:16.106Z",
47066
48088
  * "service_name": "Control de ortodoncia"
47067
48089
  * },
47068
48090
  * {
47069
48091
  * "id": "3a7d9767-0000-4000-8000-00000000000a",
47070
48092
  * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
47071
- * "budget_id": "458363ad-0000-4000-8000-000000000001",
48093
+ * "budget_id": "90afb8c1-0000-4000-8000-000000000001",
47072
48094
  * "clinic_service_id": "4cf5bc59-0000-4000-8000-000000000002",
47073
48095
  * "pack_id": null,
47074
48096
  * "label": "Limpieza dental",
@@ -47094,23 +48116,21 @@ interface paths {
47094
48116
  * "phase": 2,
47095
48117
  * "note": null,
47096
48118
  * "sort_order": 1,
47097
- * "accepted_at": "2026-09-23T01:07:07.912Z",
47098
- * "carried_from_item_id": "3a7d9767-0000-4000-8000-000000000008",
47099
- * "created_at": "2026-09-23T01:07:07.990Z",
47100
- * "updated_at": "2026-09-23T01:07:07.990Z",
48119
+ * "created_at": "2026-09-22T22:21:16.121Z",
48120
+ * "updated_at": "2026-09-22T22:21:16.121Z",
47101
48121
  * "service_name": "Limpieza dental"
47102
48122
  * }
47103
48123
  * ],
47104
- * "is_live": true,
47105
- * "days_left": 100,
47106
- * "version": 2,
47107
- * "lineage_size": 2,
47108
- * "reissued_by_id": null
48124
+ * "is_live": false,
48125
+ * "days_left": 100
47109
48126
  * }
47110
48127
  * }
47111
48128
  */
47112
48129
  "application/json": {
47113
48130
  data?: unknown;
48131
+ meta?: {
48132
+ [key: string]: unknown;
48133
+ };
47114
48134
  };
47115
48135
  };
47116
48136
  };
@@ -47176,7 +48196,7 @@ interface paths {
47176
48196
  patch?: never;
47177
48197
  trace?: never;
47178
48198
  };
47179
- "/clinic/budgets/{id}/void": {
48199
+ "/clinic/budgets/{id}/supersede": {
47180
48200
  parameters: {
47181
48201
  query?: never;
47182
48202
  header?: never;
@@ -47186,8 +48206,8 @@ interface paths {
47186
48206
  get?: never;
47187
48207
  put?: never;
47188
48208
  /**
47189
- * Void it — never DELETE
47190
- * @description Keeps the folio and stays listable (ADR 0058 §10). `reason` is required by the service AND by a database CHECK: "why did we withdraw 40 quotes this month" is only answerable if it was written down. An ACCEPTED presupuesto cannot be voided here, and the reason `superseded` is reserved — write a new version instead (`POST /clinic/budgets/{id}/supersede`).
48209
+ * Write a new version (Nueva versión)
48210
+ * @description From `sent`, `accepted`, `rejected` or `expired` (409 otherwise, and 409 when a version already supersedes it). Creates a DRAFT copying the header and every line verbatim, in the same lineage. Lines already ACCEPTED are carried forward (`carried_from_item_id`, their original `accepted_at`), are immutable on the draft (409 `carried_item`), and open no second obligation when the new version is accepted — which reuses the predecessor's obligation group. Nothing is withdrawn until the draft is SENT: that voids a sent, rejected or expired predecessor with reason `superseded` in the same transaction. An ACCEPTED predecessor stays accepted until the new version is itself accepted, so its debt always has an accepted document. Discarding the draft leaves the predecessor untouched. Same rules as `POST /clinic/budgets` with `reissued_from_id`. A presupuesto photographed from a mirrored Dentalink plan (`mirror` set) is RE-PHOTOGRAPHED instead: accepted lines are still carried, every other line comes from the plan's live state, and the new version records that state — born without `mirror.changed_at` (409 `MIRROR_LINES_UNMAPPED` if the live plan has a prestación missing from the catalogue).
47191
48211
  *
47192
48212
  * **Connected apps:** every patient and contact in the response is a Seudónimo de paciente — initials plus a stable number, `"M.F. · #1001"` — unless the clinic allowed patient names, with RUT, phone and email masked in free text and `meta.patient_privacy` saying so. Clinical alerts (`flags`) are withheld in both modes, and a non-JSON body (an export, a file) is refused with `403 CONNECTED_APP_SENSITIVE_DATA`.
47193
48213
  */
@@ -47205,19 +48225,13 @@ interface paths {
47205
48225
  };
47206
48226
  requestBody?: {
47207
48227
  content: {
47208
- /**
47209
- * @example {
47210
- * "reason": "Se emitió con el arancel equivocado"
47211
- * }
47212
- */
47213
- "application/json": {
47214
- reason: string;
47215
- };
48228
+ /** @example {} */
48229
+ "application/json": Record<string, never>;
47216
48230
  };
47217
48231
  };
47218
48232
  responses: {
47219
48233
  /** @description Clinic budget */
47220
- 200: {
48234
+ 201: {
47221
48235
  headers: {
47222
48236
  [name: string]: unknown;
47223
48237
  };
@@ -47225,25 +48239,25 @@ interface paths {
47225
48239
  /**
47226
48240
  * @example {
47227
48241
  * "data": {
47228
- * "id": "e9cede9b-0000-4000-8000-000000000001",
48242
+ * "id": "458363ad-0000-4000-8000-000000000001",
47229
48243
  * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
47230
48244
  * "source": "native",
47231
48245
  * "external_id": null,
47232
- * "display_seq": 4,
47233
- * "display_id": "E-4",
48246
+ * "display_seq": 3,
48247
+ * "display_id": "E-3",
47234
48248
  * "clinic_patient_id": "b1b0b8de-0000-4000-8000-000000000001",
47235
48249
  * "contact_id": "1a73af9e-0000-4000-8000-000000000001",
47236
48250
  * "treatment_plan_id": "1ccffee2-0000-4000-8000-000000000001",
47237
48251
  * "lead_id": "8cb33b27-0000-4000-8000-000000000001",
47238
- * "lineage_id": "e9cede9b-0000-4000-8000-000000000001",
47239
- * "reissued_from_id": null,
48252
+ * "lineage_id": "81e4a552-0000-4000-8000-000000000002",
48253
+ * "reissued_from_id": "81e4a552-0000-4000-8000-000000000002",
47240
48254
  * "conversation_id": null,
47241
48255
  * "professional_id": "18342d1b-0000-4000-8000-000000000001",
47242
48256
  * "location_id": "b1b1b1b1-0000-4000-8000-000000000002",
47243
48257
  * "price_list_id": null,
47244
48258
  * "agreement_id": null,
47245
48259
  * "legal_entity_id": null,
47246
- * "status": "voided",
48260
+ * "status": "draft",
47247
48261
  * "subtotal_clp": 147000,
47248
48262
  * "discount_clp": 5000,
47249
48263
  * "total_clp": 142000,
@@ -47254,24 +48268,26 @@ interface paths {
47254
48268
  * "obligation_group_id": null,
47255
48269
  * "rendered_document_id": null,
47256
48270
  * "created_by_user_id": null,
47257
- * "sent_at": "2026-09-22T22:21:16.514Z",
48271
+ * "sent_at": null,
47258
48272
  * "accepted_at": null,
47259
48273
  * "accepted_via": null,
47260
48274
  * "rejected_at": null,
47261
48275
  * "rejected_reason": null,
47262
48276
  * "expired_at": null,
47263
- * "voided_at": "2026-09-22T22:21:16.806Z",
48277
+ * "voided_at": null,
47264
48278
  * "voided_by": null,
47265
- * "voided_reason": "Se emitió con el arancel equivocado",
47266
- * "created_at": "2026-09-22T22:21:16.473Z",
47267
- * "updated_at": "2026-09-22T22:21:16.805Z",
48279
+ * "voided_reason": null,
48280
+ * "first_viewed_at": null,
48281
+ * "last_viewed_at": null,
48282
+ * "created_at": "2026-09-23T01:07:07.990Z",
48283
+ * "updated_at": "2026-09-23T01:07:07.990Z",
47268
48284
  * "patient_name": "María José Fuentes Lagos",
47269
48285
  * "professional_name": "Ana Rojas Vidal",
47270
48286
  * "items": [
47271
48287
  * {
47272
- * "id": "3a7d9767-0000-4000-8000-00000000000b",
48288
+ * "id": "3a7d9767-0000-4000-8000-000000000009",
47273
48289
  * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
47274
- * "budget_id": "e9cede9b-0000-4000-8000-000000000001",
48290
+ * "budget_id": "458363ad-0000-4000-8000-000000000001",
47275
48291
  * "clinic_service_id": "4cf5bc59-0000-4000-8000-000000000001",
47276
48292
  * "pack_id": null,
47277
48293
  * "label": "Control de ortodoncia",
@@ -47297,14 +48313,252 @@ interface paths {
47297
48313
  * "phase": 1,
47298
48314
  * "note": null,
47299
48315
  * "sort_order": 0,
47300
- * "created_at": "2026-09-22T22:21:16.485Z",
47301
- * "updated_at": "2026-09-22T22:21:16.485Z",
48316
+ * "accepted_at": "2026-09-23T01:07:07.912Z",
48317
+ * "carried_from_item_id": "3a7d9767-0000-4000-8000-000000000007",
48318
+ * "created_at": "2026-09-23T01:07:07.990Z",
48319
+ * "updated_at": "2026-09-23T01:07:07.990Z",
47302
48320
  * "service_name": "Control de ortodoncia"
47303
48321
  * },
47304
48322
  * {
47305
- * "id": "3a7d9767-0000-4000-8000-00000000000c",
48323
+ * "id": "3a7d9767-0000-4000-8000-00000000000a",
47306
48324
  * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
47307
- * "budget_id": "e9cede9b-0000-4000-8000-000000000001",
48325
+ * "budget_id": "458363ad-0000-4000-8000-000000000001",
48326
+ * "clinic_service_id": "4cf5bc59-0000-4000-8000-000000000002",
48327
+ * "pack_id": null,
48328
+ * "label": "Limpieza dental",
48329
+ * "quantity": 1,
48330
+ * "unit_price_clp": 35000,
48331
+ * "discount_clp": 5000,
48332
+ * "total_clp": 30000,
48333
+ * "price_explain": [
48334
+ * {
48335
+ * "kind": null,
48336
+ * "label": "Arancel particular 2026",
48337
+ * "order": 1,
48338
+ * "value": null,
48339
+ * "source": "price_list",
48340
+ * "rule_id": null,
48341
+ * "modifier": null,
48342
+ * "delta_clp": 0,
48343
+ * "amount_after_clp": 35000,
48344
+ * "amount_before_clp": null
48345
+ * }
48346
+ * ],
48347
+ * "tax_treatment": "afecto",
48348
+ * "phase": 2,
48349
+ * "note": null,
48350
+ * "sort_order": 1,
48351
+ * "accepted_at": "2026-09-23T01:07:07.912Z",
48352
+ * "carried_from_item_id": "3a7d9767-0000-4000-8000-000000000008",
48353
+ * "created_at": "2026-09-23T01:07:07.990Z",
48354
+ * "updated_at": "2026-09-23T01:07:07.990Z",
48355
+ * "service_name": "Limpieza dental"
48356
+ * }
48357
+ * ],
48358
+ * "is_live": true,
48359
+ * "days_left": 100,
48360
+ * "version": 2,
48361
+ * "lineage_size": 2,
48362
+ * "reissued_by_id": null
48363
+ * }
48364
+ * }
48365
+ */
48366
+ "application/json": {
48367
+ data?: unknown;
48368
+ };
48369
+ };
48370
+ };
48371
+ /** @description Validation error */
48372
+ 400: {
48373
+ headers: {
48374
+ [name: string]: unknown;
48375
+ };
48376
+ content: {
48377
+ "application/json": components["schemas"]["Error"];
48378
+ };
48379
+ };
48380
+ /** @description Unauthorized */
48381
+ 401: {
48382
+ headers: {
48383
+ [name: string]: unknown;
48384
+ };
48385
+ content: {
48386
+ "application/json": components["schemas"]["Error"];
48387
+ };
48388
+ };
48389
+ /** @description Forbidden */
48390
+ 403: {
48391
+ headers: {
48392
+ [name: string]: unknown;
48393
+ };
48394
+ content: {
48395
+ "application/json": components["schemas"]["Error"];
48396
+ };
48397
+ };
48398
+ /** @description Not found */
48399
+ 404: {
48400
+ headers: {
48401
+ [name: string]: unknown;
48402
+ };
48403
+ content: {
48404
+ "application/json": components["schemas"]["Error"];
48405
+ };
48406
+ };
48407
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
48408
+ 409: {
48409
+ headers: {
48410
+ [name: string]: unknown;
48411
+ };
48412
+ content: {
48413
+ "application/json": components["schemas"]["Error"];
48414
+ };
48415
+ };
48416
+ /** @description Rate limited */
48417
+ 429: {
48418
+ headers: {
48419
+ [name: string]: unknown;
48420
+ };
48421
+ content: {
48422
+ "application/json": components["schemas"]["Error"];
48423
+ };
48424
+ };
48425
+ };
48426
+ };
48427
+ delete?: never;
48428
+ options?: never;
48429
+ head?: never;
48430
+ patch?: never;
48431
+ trace?: never;
48432
+ };
48433
+ "/clinic/budgets/{id}/void": {
48434
+ parameters: {
48435
+ query?: never;
48436
+ header?: never;
48437
+ path?: never;
48438
+ cookie?: never;
48439
+ };
48440
+ get?: never;
48441
+ put?: never;
48442
+ /**
48443
+ * Void it — never DELETE
48444
+ * @description Keeps the folio and stays listable (ADR 0058 §10). `reason` is required by the service AND by a database CHECK: "why did we withdraw 40 quotes this month" is only answerable if it was written down. An ACCEPTED presupuesto cannot be voided here, and the reason `superseded` is reserved — write a new version instead (`POST /clinic/budgets/{id}/supersede`).
48445
+ *
48446
+ * **Connected apps:** every patient and contact in the response is a Seudónimo de paciente — initials plus a stable number, `"M.F. · #1001"` — unless the clinic allowed patient names, with RUT, phone and email masked in free text and `meta.patient_privacy` saying so. Clinical alerts (`flags`) are withheld in both modes, and a non-JSON body (an export, a file) is refused with `403 CONNECTED_APP_SENSITIVE_DATA`.
48447
+ */
48448
+ post: {
48449
+ parameters: {
48450
+ query?: never;
48451
+ header?: {
48452
+ /** @description Replay-safe retries: resending the SAME key with the SAME body returns the original response (`X-Idempotent-Replay: 1`) instead of creating a second copy — safe to send whenever a response might not have arrived. The same key with a DIFFERENT body answers `409 IDEMPOTENCY_KEY_CONFLICT`; use a fresh key per operation. */
48453
+ "Idempotency-Key"?: string;
48454
+ };
48455
+ path: {
48456
+ id: string;
48457
+ };
48458
+ cookie?: never;
48459
+ };
48460
+ requestBody?: {
48461
+ content: {
48462
+ /**
48463
+ * @example {
48464
+ * "reason": "Se emitió con el arancel equivocado"
48465
+ * }
48466
+ */
48467
+ "application/json": {
48468
+ reason: string;
48469
+ };
48470
+ };
48471
+ };
48472
+ responses: {
48473
+ /** @description Clinic budget */
48474
+ 200: {
48475
+ headers: {
48476
+ [name: string]: unknown;
48477
+ };
48478
+ content: {
48479
+ /**
48480
+ * @example {
48481
+ * "data": {
48482
+ * "id": "e9cede9b-0000-4000-8000-000000000001",
48483
+ * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
48484
+ * "source": "native",
48485
+ * "external_id": null,
48486
+ * "display_seq": 4,
48487
+ * "display_id": "E-4",
48488
+ * "clinic_patient_id": "b1b0b8de-0000-4000-8000-000000000001",
48489
+ * "contact_id": "1a73af9e-0000-4000-8000-000000000001",
48490
+ * "treatment_plan_id": "1ccffee2-0000-4000-8000-000000000001",
48491
+ * "lead_id": "8cb33b27-0000-4000-8000-000000000001",
48492
+ * "lineage_id": "e9cede9b-0000-4000-8000-000000000001",
48493
+ * "reissued_from_id": null,
48494
+ * "conversation_id": null,
48495
+ * "professional_id": "18342d1b-0000-4000-8000-000000000001",
48496
+ * "location_id": "b1b1b1b1-0000-4000-8000-000000000002",
48497
+ * "price_list_id": null,
48498
+ * "agreement_id": null,
48499
+ * "legal_entity_id": null,
48500
+ * "status": "voided",
48501
+ * "subtotal_clp": 147000,
48502
+ * "discount_clp": 5000,
48503
+ * "total_clp": 142000,
48504
+ * "tax_treatment": "afecto",
48505
+ * "valid_until": "2026-12-31",
48506
+ * "installments": 3,
48507
+ * "notes": "Incluye los cuatro controles del primer semestre",
48508
+ * "obligation_group_id": null,
48509
+ * "rendered_document_id": null,
48510
+ * "created_by_user_id": null,
48511
+ * "sent_at": "2026-09-22T22:21:16.514Z",
48512
+ * "accepted_at": null,
48513
+ * "accepted_via": null,
48514
+ * "rejected_at": null,
48515
+ * "rejected_reason": null,
48516
+ * "expired_at": null,
48517
+ * "voided_at": "2026-09-22T22:21:16.806Z",
48518
+ * "voided_by": null,
48519
+ * "voided_reason": "Se emitió con el arancel equivocado",
48520
+ * "created_at": "2026-09-22T22:21:16.473Z",
48521
+ * "updated_at": "2026-09-22T22:21:16.805Z",
48522
+ * "patient_name": "María José Fuentes Lagos",
48523
+ * "professional_name": "Ana Rojas Vidal",
48524
+ * "items": [
48525
+ * {
48526
+ * "id": "3a7d9767-0000-4000-8000-00000000000b",
48527
+ * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
48528
+ * "budget_id": "e9cede9b-0000-4000-8000-000000000001",
48529
+ * "clinic_service_id": "4cf5bc59-0000-4000-8000-000000000001",
48530
+ * "pack_id": null,
48531
+ * "label": "Control de ortodoncia",
48532
+ * "quantity": 4,
48533
+ * "unit_price_clp": 28000,
48534
+ * "discount_clp": 0,
48535
+ * "total_clp": 112000,
48536
+ * "price_explain": [
48537
+ * {
48538
+ * "kind": null,
48539
+ * "label": "Arancel particular 2026",
48540
+ * "order": 1,
48541
+ * "value": null,
48542
+ * "source": "price_list",
48543
+ * "rule_id": null,
48544
+ * "modifier": null,
48545
+ * "delta_clp": 0,
48546
+ * "amount_after_clp": 28000,
48547
+ * "amount_before_clp": null
48548
+ * }
48549
+ * ],
48550
+ * "tax_treatment": "afecto",
48551
+ * "phase": 1,
48552
+ * "note": null,
48553
+ * "sort_order": 0,
48554
+ * "created_at": "2026-09-22T22:21:16.485Z",
48555
+ * "updated_at": "2026-09-22T22:21:16.485Z",
48556
+ * "service_name": "Control de ortodoncia"
48557
+ * },
48558
+ * {
48559
+ * "id": "3a7d9767-0000-4000-8000-00000000000c",
48560
+ * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
48561
+ * "budget_id": "e9cede9b-0000-4000-8000-000000000001",
47308
48562
  * "clinic_service_id": "4cf5bc59-0000-4000-8000-000000000002",
47309
48563
  * "pack_id": null,
47310
48564
  * "label": "Limpieza dental",
@@ -85264,15 +86518,740 @@ interface paths {
85264
86518
  };
85265
86519
  };
85266
86520
  };
85267
- put?: never;
85268
- post?: never;
86521
+ put?: never;
86522
+ post?: never;
86523
+ delete?: never;
86524
+ options?: never;
86525
+ head?: never;
86526
+ patch?: never;
86527
+ trace?: never;
86528
+ };
86529
+ "/insights/generate-pdf": {
86530
+ parameters: {
86531
+ query?: never;
86532
+ header?: never;
86533
+ path?: never;
86534
+ cookie?: never;
86535
+ };
86536
+ get?: never;
86537
+ put?: never;
86538
+ /**
86539
+ * Render a report as a PDF
86540
+ * @description **The one endpoint on the tenant API that does not answer the `{ data }` envelope.** It replies with raw `application/pdf` bytes and a `Content-Disposition: attachment` header, so a client that pipes every response through the usual JSON parse will fail here. On an error it reverts to the JSON error envelope, which means the response content-type is what tells the two apart.
86541
+ *
86542
+ * Generation is SYNCHRONOUS: it queries the report, runs an LLM pass to write the narrative, then renders. The connection is held for all of that, there is no job id, and nothing is persisted — a client or proxy timeout loses the document with no way to retrieve it other than asking again. Treat a wide range as a slow request.
86543
+ *
86544
+ * The LLM pass degrades rather than fails: if the narrative cannot be generated you still get a 200 and a complete PDF, with a Spanish note in place of the executive summary and every raw figure intact. So a successful response does not by itself mean the analysis is there.
86545
+ *
86546
+ * `range.preset` is not a range selector — `from`/`to` alone decide the data. It is the window’s NAME: printed as the cover subtitle and passed into the summariser’s prompt, so a preset that disagrees with `from`/`to` mislabels the cover and misleads the narrative while the figures stay correct. Defaults to `custom`. Needs only `analytics:read`.
86547
+ */
86548
+ post: {
86549
+ parameters: {
86550
+ query?: never;
86551
+ header?: {
86552
+ /** @description Replay-safe retries: resending the SAME key with the SAME body returns the original response (`X-Idempotent-Replay: 1`) instead of creating a second copy — safe to send whenever a response might not have arrived. The same key with a DIFFERENT body answers `409 IDEMPOTENCY_KEY_CONFLICT`; use a fresh key per operation. */
86553
+ "Idempotency-Key"?: string;
86554
+ };
86555
+ path?: never;
86556
+ cookie?: never;
86557
+ };
86558
+ requestBody?: {
86559
+ content: {
86560
+ /**
86561
+ * @example {
86562
+ * "report": "conversations",
86563
+ * "window": {
86564
+ * "preset": "7d"
86565
+ * },
86566
+ * "range": {
86567
+ * "preset": "7d"
86568
+ * }
86569
+ * }
86570
+ */
86571
+ "application/json": {
86572
+ /** @enum {string} */
86573
+ report_type: "overview" | "conversations" | "agents" | "ai_agents" | "bots" | "tags" | "channels" | "teams" | "leads" | "csat" | "sla" | "clinic_ocupacion" | "clinic_inasistencias" | "clinic_produccion" | "clinic_packs";
86574
+ range: {
86575
+ from: string;
86576
+ to: string;
86577
+ preset?: string;
86578
+ };
86579
+ };
86580
+ };
86581
+ };
86582
+ responses: {
86583
+ /** @description The rendered PDF as an attachment */
86584
+ 200: {
86585
+ headers: {
86586
+ [name: string]: unknown;
86587
+ };
86588
+ content: {
86589
+ "application/pdf": string;
86590
+ };
86591
+ };
86592
+ /** @description Validation error */
86593
+ 400: {
86594
+ headers: {
86595
+ [name: string]: unknown;
86596
+ };
86597
+ content: {
86598
+ "application/json": components["schemas"]["Error"];
86599
+ };
86600
+ };
86601
+ /** @description Unauthorized */
86602
+ 401: {
86603
+ headers: {
86604
+ [name: string]: unknown;
86605
+ };
86606
+ content: {
86607
+ "application/json": components["schemas"]["Error"];
86608
+ };
86609
+ };
86610
+ /** @description Forbidden */
86611
+ 403: {
86612
+ headers: {
86613
+ [name: string]: unknown;
86614
+ };
86615
+ content: {
86616
+ "application/json": components["schemas"]["Error"];
86617
+ };
86618
+ };
86619
+ /** @description Not found */
86620
+ 404: {
86621
+ headers: {
86622
+ [name: string]: unknown;
86623
+ };
86624
+ content: {
86625
+ "application/json": components["schemas"]["Error"];
86626
+ };
86627
+ };
86628
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
86629
+ 409: {
86630
+ headers: {
86631
+ [name: string]: unknown;
86632
+ };
86633
+ content: {
86634
+ "application/json": components["schemas"]["Error"];
86635
+ };
86636
+ };
86637
+ /** @description Rate limited */
86638
+ 429: {
86639
+ headers: {
86640
+ [name: string]: unknown;
86641
+ };
86642
+ content: {
86643
+ "application/json": components["schemas"]["Error"];
86644
+ };
86645
+ };
86646
+ };
86647
+ };
86648
+ delete?: never;
86649
+ options?: never;
86650
+ head?: never;
86651
+ patch?: never;
86652
+ trace?: never;
86653
+ };
86654
+ "/insights/schedules": {
86655
+ parameters: {
86656
+ query?: never;
86657
+ header?: never;
86658
+ path?: never;
86659
+ cookie?: never;
86660
+ };
86661
+ /**
86662
+ * List report schedules
86663
+ * @description The standing subscriptions that mail a rendered report out on a cadence. Unpaginated, and with no `meta.total` — this list is small by construction.
86664
+ */
86665
+ get: {
86666
+ parameters: {
86667
+ query?: never;
86668
+ header?: never;
86669
+ path?: never;
86670
+ cookie?: never;
86671
+ };
86672
+ requestBody?: never;
86673
+ responses: {
86674
+ /** @description Report schedules */
86675
+ 200: {
86676
+ headers: {
86677
+ [name: string]: unknown;
86678
+ };
86679
+ content: {
86680
+ /**
86681
+ * @example {
86682
+ * "data": [
86683
+ * {
86684
+ * "id": "cccccccc-2000-4000-8000-000000000001",
86685
+ * "report_type": "conversations",
86686
+ * "range_preset": "7d",
86687
+ * "cadence": "weekly",
86688
+ * "recipients": [
86689
+ * "gerencia@midealer.cl"
86690
+ * ],
86691
+ * "next_run_at": "2026-09-29T09:00:00.000Z",
86692
+ * "enabled": true
86693
+ * }
86694
+ * ]
86695
+ * }
86696
+ */
86697
+ "application/json": {
86698
+ data?: unknown;
86699
+ meta?: {
86700
+ [key: string]: unknown;
86701
+ };
86702
+ };
86703
+ };
86704
+ };
86705
+ /** @description Validation error */
86706
+ 400: {
86707
+ headers: {
86708
+ [name: string]: unknown;
86709
+ };
86710
+ content: {
86711
+ "application/json": components["schemas"]["Error"];
86712
+ };
86713
+ };
86714
+ /** @description Unauthorized */
86715
+ 401: {
86716
+ headers: {
86717
+ [name: string]: unknown;
86718
+ };
86719
+ content: {
86720
+ "application/json": components["schemas"]["Error"];
86721
+ };
86722
+ };
86723
+ /** @description Forbidden */
86724
+ 403: {
86725
+ headers: {
86726
+ [name: string]: unknown;
86727
+ };
86728
+ content: {
86729
+ "application/json": components["schemas"]["Error"];
86730
+ };
86731
+ };
86732
+ /** @description Not found */
86733
+ 404: {
86734
+ headers: {
86735
+ [name: string]: unknown;
86736
+ };
86737
+ content: {
86738
+ "application/json": components["schemas"]["Error"];
86739
+ };
86740
+ };
86741
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
86742
+ 409: {
86743
+ headers: {
86744
+ [name: string]: unknown;
86745
+ };
86746
+ content: {
86747
+ "application/json": components["schemas"]["Error"];
86748
+ };
86749
+ };
86750
+ /** @description Rate limited */
86751
+ 429: {
86752
+ headers: {
86753
+ [name: string]: unknown;
86754
+ };
86755
+ content: {
86756
+ "application/json": components["schemas"]["Error"];
86757
+ };
86758
+ };
86759
+ };
86760
+ };
86761
+ put?: never;
86762
+ post?: never;
86763
+ delete?: never;
86764
+ options?: never;
86765
+ head?: never;
86766
+ patch?: never;
86767
+ trace?: never;
86768
+ };
86769
+ "/integrations/meta-ads": {
86770
+ parameters: {
86771
+ query?: never;
86772
+ header?: never;
86773
+ path?: never;
86774
+ cookie?: never;
86775
+ };
86776
+ /**
86777
+ * Read the workspace’s Meta Ads connection
86778
+ * @description The tenant’s single Meta Ads row, or `null` when it has never started a connect. A placeholder object with `status: "disconnected"` is deliberately NOT returned in its place: "never connected" and "was connected and is not any more" are different states and the card says different things about them.
86779
+ *
86780
+ * `handoff` is populated only while `status` is `pending` and `candidates` only while it is `pending_selection` — a spent consent URL would render a button leading to a dead page.
86781
+ *
86782
+ * Admin-scoped (`integrations:read`), like the rest of Integraciones — that scope lives only in the admin bundle, so a `supervisor` or `agent` gets 403 here and never sees the card. The two writes need `integrations:write` on top.
86783
+ */
86784
+ get: {
86785
+ parameters: {
86786
+ query?: never;
86787
+ header?: never;
86788
+ path?: never;
86789
+ cookie?: never;
86790
+ };
86791
+ requestBody?: never;
86792
+ responses: {
86793
+ /** @description The Meta Ads integration, or `null` */
86794
+ 200: {
86795
+ headers: {
86796
+ [name: string]: unknown;
86797
+ };
86798
+ content: {
86799
+ /**
86800
+ * @example {
86801
+ * "data": null
86802
+ * }
86803
+ */
86804
+ "application/json": {
86805
+ data: components["schemas"]["MetaAdsIntegration"];
86806
+ };
86807
+ };
86808
+ };
86809
+ /** @description Validation error */
86810
+ 400: {
86811
+ headers: {
86812
+ [name: string]: unknown;
86813
+ };
86814
+ content: {
86815
+ "application/json": components["schemas"]["Error"];
86816
+ };
86817
+ };
86818
+ /** @description Unauthorized */
86819
+ 401: {
86820
+ headers: {
86821
+ [name: string]: unknown;
86822
+ };
86823
+ content: {
86824
+ "application/json": components["schemas"]["Error"];
86825
+ };
86826
+ };
86827
+ /** @description Forbidden */
86828
+ 403: {
86829
+ headers: {
86830
+ [name: string]: unknown;
86831
+ };
86832
+ content: {
86833
+ "application/json": components["schemas"]["Error"];
86834
+ };
86835
+ };
86836
+ /** @description Not found */
86837
+ 404: {
86838
+ headers: {
86839
+ [name: string]: unknown;
86840
+ };
86841
+ content: {
86842
+ "application/json": components["schemas"]["Error"];
86843
+ };
86844
+ };
86845
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
86846
+ 409: {
86847
+ headers: {
86848
+ [name: string]: unknown;
86849
+ };
86850
+ content: {
86851
+ "application/json": components["schemas"]["Error"];
86852
+ };
86853
+ };
86854
+ /** @description Rate limited */
86855
+ 429: {
86856
+ headers: {
86857
+ [name: string]: unknown;
86858
+ };
86859
+ content: {
86860
+ "application/json": components["schemas"]["Error"];
86861
+ };
86862
+ };
86863
+ };
86864
+ };
86865
+ put?: never;
86866
+ post?: never;
86867
+ delete?: never;
86868
+ options?: never;
86869
+ head?: never;
86870
+ patch?: never;
86871
+ trace?: never;
86872
+ };
86873
+ "/integrations/meta-ads/connect": {
86874
+ parameters: {
86875
+ query?: never;
86876
+ header?: never;
86877
+ path?: never;
86878
+ cookie?: never;
86879
+ };
86880
+ get?: never;
86881
+ put?: never;
86882
+ /**
86883
+ * Start a Meta Ads connect and get the consent URL
86884
+ * @description Mints Atribu’s **connect hand-off** for `meta_ads` and answers the session-less consent URL to redirect the WHOLE PAGE to. It is not an iframe target: Meta’s own consent dialog renders inside it.
86885
+ *
86886
+ * `return_to` must be an absolute URL on the app’s own origin. The backend appends `meta_ads=return` and a short opaque `state`, preserving any query the URL already carried, and passes the result to Atribu as `return_url`. An origin that is not the app’s is a 400 here rather than a silent substitution — Atribu itself only checks the origin when the human CLICKS, where it surfaces as a failed hand-off (`result.reason: origin_not_allowed`) after the dealer has already walked through a consent screen for nothing.
86887
+ *
86888
+ * **A second click reuses the live hand-off.** Atribu’s URL is single-use and 45-minute-lived, and minting twice yields two hand-offs rather than an error, so a dealer who clicks, gets distracted and clicks again gets the SAME `url` and `handoff_id` back until it expires.
86889
+ *
86890
+ * Before anything is minted, the tenant’s attribution profile and its delegated key are ensured (ADR 0099). This rail never uses the global `ATRIBU_API_KEY`.
86891
+ */
86892
+ post: {
86893
+ parameters: {
86894
+ query?: never;
86895
+ header?: {
86896
+ /** @description Replay-safe retries: resending the SAME key with the SAME body returns the original response (`X-Idempotent-Replay: 1`) instead of creating a second copy — safe to send whenever a response might not have arrived. The same key with a DIFFERENT body answers `409 IDEMPOTENCY_KEY_CONFLICT`; use a fresh key per operation. */
86897
+ "Idempotency-Key"?: string;
86898
+ };
86899
+ path?: never;
86900
+ cookie?: never;
86901
+ };
86902
+ requestBody?: {
86903
+ content: {
86904
+ /**
86905
+ * @example {
86906
+ * "return_to": "https://app.vitrinadev.com/settings/integraciones?meta_ads=return"
86907
+ * }
86908
+ */
86909
+ "application/json": components["schemas"]["MetaAdsConnectBody"];
86910
+ };
86911
+ };
86912
+ responses: {
86913
+ /** @description The consent URL, its hand-off id, and its expiry */
86914
+ 200: {
86915
+ headers: {
86916
+ [name: string]: unknown;
86917
+ };
86918
+ content: {
86919
+ /**
86920
+ * @example {
86921
+ * "data": {
86922
+ * "url": "https://consent.atribu.app/connect/meta-ads/ho_4d8f2a91c6b3",
86923
+ * "handoff_id": "ho_4d8f2a91c6b3",
86924
+ * "expires_at": "2026-09-23T15:45:00.000Z"
86925
+ * }
86926
+ * }
86927
+ */
86928
+ "application/json": {
86929
+ data: components["schemas"]["MetaAdsConnectResult"];
86930
+ };
86931
+ };
86932
+ };
86933
+ /** @description Validation error */
86934
+ 400: {
86935
+ headers: {
86936
+ [name: string]: unknown;
86937
+ };
86938
+ content: {
86939
+ "application/json": components["schemas"]["Error"];
86940
+ };
86941
+ };
86942
+ /** @description Unauthorized */
86943
+ 401: {
86944
+ headers: {
86945
+ [name: string]: unknown;
86946
+ };
86947
+ content: {
86948
+ "application/json": components["schemas"]["Error"];
86949
+ };
86950
+ };
86951
+ /** @description Forbidden */
86952
+ 403: {
86953
+ headers: {
86954
+ [name: string]: unknown;
86955
+ };
86956
+ content: {
86957
+ "application/json": components["schemas"]["Error"];
86958
+ };
86959
+ };
86960
+ /** @description Not found */
86961
+ 404: {
86962
+ headers: {
86963
+ [name: string]: unknown;
86964
+ };
86965
+ content: {
86966
+ "application/json": components["schemas"]["Error"];
86967
+ };
86968
+ };
86969
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
86970
+ 409: {
86971
+ headers: {
86972
+ [name: string]: unknown;
86973
+ };
86974
+ content: {
86975
+ "application/json": components["schemas"]["Error"];
86976
+ };
86977
+ };
86978
+ /** @description Rate limited */
86979
+ 429: {
86980
+ headers: {
86981
+ [name: string]: unknown;
86982
+ };
86983
+ content: {
86984
+ "application/json": components["schemas"]["Error"];
86985
+ };
86986
+ };
86987
+ };
86988
+ };
86989
+ delete?: never;
86990
+ options?: never;
86991
+ head?: never;
86992
+ patch?: never;
86993
+ trace?: never;
86994
+ };
86995
+ "/integrations/meta-ads/return": {
86996
+ parameters: {
86997
+ query?: never;
86998
+ header?: never;
86999
+ path?: never;
87000
+ cookie?: never;
87001
+ };
87002
+ get?: never;
87003
+ put?: never;
87004
+ /**
87005
+ * Settle a Meta Ads connect after the dealer comes back
87006
+ * @description Reads the hand-off ONCE and settles the row:
87007
+ *
87008
+ * * `completed` with a connection id → the connection is read back from Atribu and the row becomes `connected`, carrying the ad account’s name, id, currency, timezone and whether the platform has ever delivered spend.
87009
+ * * `completed` with a pending selection → the row becomes `pending_selection` and carries the candidates the picker renders. **A consent that resolved to exactly one account never reaches this branch** — Atribu finalizes it in its own callback, which is why there is no auto-finalize step on this side.
87010
+ * * `expired` / `cancelled` / `failed` → the row becomes `error` with a retryable `reason` of `handoff_<status>`. The recovery is identical for all three: mint a fresh hand-off.
87011
+ * * still `pending` → nothing is settled and the row comes back unchanged.
87012
+ *
87013
+ * **Neither field is required.** The hand-off id only exists in the RESPONSE to the mint while `return_url` is an argument to that same mint, so the return URL structurally cannot carry it — it carries `meta_ads=return` and the opaque `state` instead. Send `handoff_id` if you kept it, `state` if you read it off the URL, or an empty body, in which case the backend settles the row’s own pending hand-off (unambiguous: a tenant has at most one).
87014
+ *
87015
+ * Safe to repeat — a settled hand-off stays readable at Atribu, so a re-post on a refresh re-derives the same state.
87016
+ *
87017
+ * 409 `handoff_mismatch` when the id or state presented does not name the hand-off this tenant’s row is waiting on, and for a tenant with no connect in flight at all (the two are deliberately the same answer).
87018
+ */
87019
+ post: {
87020
+ parameters: {
87021
+ query?: never;
87022
+ header?: {
87023
+ /** @description Replay-safe retries: resending the SAME key with the SAME body returns the original response (`X-Idempotent-Replay: 1`) instead of creating a second copy — safe to send whenever a response might not have arrived. The same key with a DIFFERENT body answers `409 IDEMPOTENCY_KEY_CONFLICT`; use a fresh key per operation. */
87024
+ "Idempotency-Key"?: string;
87025
+ };
87026
+ path?: never;
87027
+ cookie?: never;
87028
+ };
87029
+ requestBody?: {
87030
+ content: {
87031
+ /**
87032
+ * @example {
87033
+ * "state": "9f3a2d7c8b1e4a2f"
87034
+ * }
87035
+ */
87036
+ "application/json": components["schemas"]["MetaAdsReturnBody"];
87037
+ };
87038
+ };
87039
+ responses: {
87040
+ /** @description The settled integration */
87041
+ 200: {
87042
+ headers: {
87043
+ [name: string]: unknown;
87044
+ };
87045
+ content: {
87046
+ /**
87047
+ * @example {
87048
+ * "data": {
87049
+ * "id": "22222222-2222-4222-8222-222222222222",
87050
+ * "provider": "meta_ads",
87051
+ * "status": "connected",
87052
+ * "account_label": "Cuenta Meta Ads",
87053
+ * "connected_at": "2026-09-23T15:04:00.000Z",
87054
+ * "account": {
87055
+ * "external_account_id": "act_1234567890",
87056
+ * "name": "Automotora Ejemplo",
87057
+ * "currency": "CLP",
87058
+ * "timezone": "America/Santiago",
87059
+ * "delivers_spend": true,
87060
+ * "atribu_connection_id": "conn_9f3a2d7c8b1e"
87061
+ * },
87062
+ * "error": null,
87063
+ * "handoff": null,
87064
+ * "candidates": null,
87065
+ * "updated_at": "2026-09-23T15:04:00.000Z"
87066
+ * }
87067
+ * }
87068
+ */
87069
+ "application/json": {
87070
+ data: components["schemas"]["MetaAdsIntegration"] & Record<string, never>;
87071
+ };
87072
+ };
87073
+ };
87074
+ /** @description Validation error */
87075
+ 400: {
87076
+ headers: {
87077
+ [name: string]: unknown;
87078
+ };
87079
+ content: {
87080
+ "application/json": components["schemas"]["Error"];
87081
+ };
87082
+ };
87083
+ /** @description Unauthorized */
87084
+ 401: {
87085
+ headers: {
87086
+ [name: string]: unknown;
87087
+ };
87088
+ content: {
87089
+ "application/json": components["schemas"]["Error"];
87090
+ };
87091
+ };
87092
+ /** @description Forbidden */
87093
+ 403: {
87094
+ headers: {
87095
+ [name: string]: unknown;
87096
+ };
87097
+ content: {
87098
+ "application/json": components["schemas"]["Error"];
87099
+ };
87100
+ };
87101
+ /** @description Not found */
87102
+ 404: {
87103
+ headers: {
87104
+ [name: string]: unknown;
87105
+ };
87106
+ content: {
87107
+ "application/json": components["schemas"]["Error"];
87108
+ };
87109
+ };
87110
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
87111
+ 409: {
87112
+ headers: {
87113
+ [name: string]: unknown;
87114
+ };
87115
+ content: {
87116
+ "application/json": components["schemas"]["Error"];
87117
+ };
87118
+ };
87119
+ /** @description Rate limited */
87120
+ 429: {
87121
+ headers: {
87122
+ [name: string]: unknown;
87123
+ };
87124
+ content: {
87125
+ "application/json": components["schemas"]["Error"];
87126
+ };
87127
+ };
87128
+ };
87129
+ };
87130
+ delete?: never;
87131
+ options?: never;
87132
+ head?: never;
87133
+ patch?: never;
87134
+ trace?: never;
87135
+ };
87136
+ "/integrations/meta-ads/disconnect": {
87137
+ parameters: {
87138
+ query?: never;
87139
+ header?: never;
87140
+ path?: never;
87141
+ cookie?: never;
87142
+ };
87143
+ get?: never;
87144
+ put?: never;
87145
+ /**
87146
+ * Disconnect the workspace’s Meta Ads ad account
87147
+ * @description Calls Atribu’s `connections/{id}/disconnect` operation on the delegated key and settles the row `disconnected`, keeping its history: `account_label` and `connected_at` stay, and `config.last_account` remembers which account this was so the card can still name it. Reconnecting afterwards is a plain new `/connect` — it mints a fresh hand-off. A tenant must always be able to walk away from a connection it made.
87148
+ *
87149
+ * A row with nothing at Atribu to revoke — `pending` / `pending_selection` with no connection — is cancelled LOCALLY: no Atribu call, the row moves straight to `disconnected`, and the pending hand-off simply expires on its own (Atribu has no endpoint to cancel one early). A row already `disconnected` answers 200 unchanged (idempotent).
87150
+ *
87151
+ * 409 `sync_in_flight` when Atribu is mid-sync on the connection — the row is left exactly as it was; the whole recovery is trying again in a few minutes. 502 `atribu_refused` when Atribu’s own 403 says the delegated key is no longer good for this connection — also left unchanged. A 404 from Atribu (the connection is already gone there) is treated as success: the state this call exists to ensure already holds.
87152
+ */
87153
+ post: {
87154
+ parameters: {
87155
+ query?: never;
87156
+ header?: {
87157
+ /** @description Replay-safe retries: resending the SAME key with the SAME body returns the original response (`X-Idempotent-Replay: 1`) instead of creating a second copy — safe to send whenever a response might not have arrived. The same key with a DIFFERENT body answers `409 IDEMPOTENCY_KEY_CONFLICT`; use a fresh key per operation. */
87158
+ "Idempotency-Key"?: string;
87159
+ };
87160
+ path?: never;
87161
+ cookie?: never;
87162
+ };
87163
+ requestBody?: never;
87164
+ responses: {
87165
+ /** @description The disconnected integration */
87166
+ 200: {
87167
+ headers: {
87168
+ [name: string]: unknown;
87169
+ };
87170
+ content: {
87171
+ /**
87172
+ * @example {
87173
+ * "data": {
87174
+ * "id": "22222222-2222-4222-8222-222222222222",
87175
+ * "provider": "meta_ads",
87176
+ * "status": "disconnected",
87177
+ * "account_label": "Cuenta Meta Ads",
87178
+ * "connected_at": "2026-09-20T12:00:00.000Z",
87179
+ * "account": null,
87180
+ * "error": null,
87181
+ * "handoff": null,
87182
+ * "candidates": null,
87183
+ * "updated_at": "2026-09-23T15:10:00.000Z"
87184
+ * }
87185
+ * }
87186
+ */
87187
+ "application/json": {
87188
+ data: components["schemas"]["MetaAdsIntegration"] & Record<string, never>;
87189
+ };
87190
+ };
87191
+ };
87192
+ /** @description Validation error */
87193
+ 400: {
87194
+ headers: {
87195
+ [name: string]: unknown;
87196
+ };
87197
+ content: {
87198
+ "application/json": components["schemas"]["Error"];
87199
+ };
87200
+ };
87201
+ /** @description Unauthorized */
87202
+ 401: {
87203
+ headers: {
87204
+ [name: string]: unknown;
87205
+ };
87206
+ content: {
87207
+ "application/json": components["schemas"]["Error"];
87208
+ };
87209
+ };
87210
+ /** @description Forbidden */
87211
+ 403: {
87212
+ headers: {
87213
+ [name: string]: unknown;
87214
+ };
87215
+ content: {
87216
+ "application/json": components["schemas"]["Error"];
87217
+ };
87218
+ };
87219
+ /** @description Not found */
87220
+ 404: {
87221
+ headers: {
87222
+ [name: string]: unknown;
87223
+ };
87224
+ content: {
87225
+ "application/json": components["schemas"]["Error"];
87226
+ };
87227
+ };
87228
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
87229
+ 409: {
87230
+ headers: {
87231
+ [name: string]: unknown;
87232
+ };
87233
+ content: {
87234
+ "application/json": components["schemas"]["Error"];
87235
+ };
87236
+ };
87237
+ /** @description Rate limited */
87238
+ 429: {
87239
+ headers: {
87240
+ [name: string]: unknown;
87241
+ };
87242
+ content: {
87243
+ "application/json": components["schemas"]["Error"];
87244
+ };
87245
+ };
87246
+ };
87247
+ };
85269
87248
  delete?: never;
85270
87249
  options?: never;
85271
87250
  head?: never;
85272
87251
  patch?: never;
85273
87252
  trace?: never;
85274
87253
  };
85275
- "/insights/generate-pdf": {
87254
+ "/integrations/meta-ads/finalize": {
85276
87255
  parameters: {
85277
87256
  query?: never;
85278
87257
  header?: never;
@@ -85282,14 +87261,16 @@ interface paths {
85282
87261
  get?: never;
85283
87262
  put?: never;
85284
87263
  /**
85285
- * Render a report as a PDF
85286
- * @description **The one endpoint on the tenant API that does not answer the `{ data }` envelope.** It replies with raw `application/pdf` bytes and a `Content-Disposition: attachment` header, so a client that pipes every response through the usual JSON parse will fail here. On an error it reverts to the JSON error envelope, which means the response content-type is what tells the two apart.
87264
+ * Finalize a Meta Ads pending selection with a chosen candidate
87265
+ * @description Only meaningful while `status` is `pending_selection`. Calls Atribu’s finalize on the parked provider token with the chosen `candidate_id` — a `MetaAdsCandidate.candidate_id` from the SAME row’s `candidates`, sent back verbatim — reads the resulting connection back (Atribu’s `connections?channel=meta_ads` operation) and runs it through the same settle path `/return` uses, so the row reads identically whichever produced it: `connected`, with `account` populated.
85287
87266
  *
85288
- * Generation is SYNCHRONOUS: it queries the report, runs an LLM pass to write the narrative, then renders. The connection is held for all of that, there is no job id, and nothing is persisted — a client or proxy timeout loses the document with no way to retrieve it other than asking again. Treat a wide range as a slow request.
87267
+ * **Retrying the same `candidate_id` is safe** and answers 200 with the current row — Atribu’s `already_finalized: true` on its own idempotent replay, reapplied through the same write path a fresh finalize uses.
85289
87268
  *
85290
- * The LLM pass degrades rather than fails: if the narrative cannot be generated you still get a 200 and a complete PDF, with a Spanish note in place of the executive summary and every raw figure intact. So a successful response does not by itself mean the analysis is there.
87269
+ * **A DIFFERENT `candidate_id`** after Atribu’s parked token already finalized a choice is 409 `start_again` (the row moves to `error`, `reason: selection_conflict`, retryable) — switching accounts needs a fresh connect, there is no token left to retarget.
85291
87270
  *
85292
- * `range.preset` is not a range selector — `from`/`to` alone decide the data. It is the window’s NAME: printed as the cover subtitle and passed into the summariser’s prompt, so a preset that disagrees with `from`/`to` mislabels the cover and misleads the narrative while the figures stay correct. Defaults to `custom`. Needs only `analytics:read`.
87271
+ * **The picker’s 60-minute parked token already gone** (elapsed, or never existed for this profile) is 410 `reconnect` (the row moves to `error`, `reason: selection_expired`, retryable).
87272
+ *
87273
+ * **The row is not `pending_selection`** — nothing started, already connected, or already in `error` — is 409 `handoff_mismatch`, checked before Atribu is ever called.
85293
87274
  */
85294
87275
  post: {
85295
87276
  parameters: {
@@ -85305,34 +87286,45 @@ interface paths {
85305
87286
  content: {
85306
87287
  /**
85307
87288
  * @example {
85308
- * "report": "conversations",
85309
- * "window": {
85310
- * "preset": "7d"
85311
- * },
85312
- * "range": {
85313
- * "preset": "7d"
85314
- * }
87289
+ * "candidate_id": "cnd_7b1f0a4e9d2c"
85315
87290
  * }
85316
87291
  */
85317
- "application/json": {
85318
- /** @enum {string} */
85319
- report_type: "overview" | "conversations" | "agents" | "ai_agents" | "bots" | "tags" | "channels" | "teams" | "leads" | "csat" | "sla" | "clinic_ocupacion" | "clinic_inasistencias" | "clinic_produccion" | "clinic_packs";
85320
- range: {
85321
- from: string;
85322
- to: string;
85323
- preset?: string;
85324
- };
85325
- };
87292
+ "application/json": components["schemas"]["MetaAdsFinalizeBody"];
85326
87293
  };
85327
87294
  };
85328
87295
  responses: {
85329
- /** @description The rendered PDF as an attachment */
87296
+ /** @description The finalized integration, now `connected` */
85330
87297
  200: {
85331
87298
  headers: {
85332
87299
  [name: string]: unknown;
85333
87300
  };
85334
87301
  content: {
85335
- "application/pdf": string;
87302
+ /**
87303
+ * @example {
87304
+ * "data": {
87305
+ * "id": "22222222-2222-4222-8222-222222222222",
87306
+ * "provider": "meta_ads",
87307
+ * "status": "connected",
87308
+ * "account_label": "Cuenta Meta Ads",
87309
+ * "connected_at": "2026-09-23T15:04:00.000Z",
87310
+ * "account": {
87311
+ * "external_account_id": "act_1234567890",
87312
+ * "name": "Automotora Ejemplo",
87313
+ * "currency": "CLP",
87314
+ * "timezone": "America/Santiago",
87315
+ * "delivers_spend": true,
87316
+ * "atribu_connection_id": "conn_9f3a2d7c8b1e"
87317
+ * },
87318
+ * "error": null,
87319
+ * "handoff": null,
87320
+ * "candidates": null,
87321
+ * "updated_at": "2026-09-23T15:04:00.000Z"
87322
+ * }
87323
+ * }
87324
+ */
87325
+ "application/json": {
87326
+ data: components["schemas"]["MetaAdsIntegration"] & Record<string, never>;
87327
+ };
85336
87328
  };
85337
87329
  };
85338
87330
  /** @description Validation error */
@@ -85380,6 +87372,15 @@ interface paths {
85380
87372
  "application/json": components["schemas"]["Error"];
85381
87373
  };
85382
87374
  };
87375
+ /** @description The picker’s parked provider token is gone — `{ error: { code: "reconnect" } }` */
87376
+ 410: {
87377
+ headers: {
87378
+ [name: string]: unknown;
87379
+ };
87380
+ content: {
87381
+ "application/json": components["schemas"]["Error"];
87382
+ };
87383
+ };
85383
87384
  /** @description Rate limited */
85384
87385
  429: {
85385
87386
  headers: {
@@ -85397,7 +87398,7 @@ interface paths {
85397
87398
  patch?: never;
85398
87399
  trace?: never;
85399
87400
  };
85400
- "/insights/schedules": {
87401
+ "/integrations/meta-ads/ads": {
85401
87402
  parameters: {
85402
87403
  query?: never;
85403
87404
  header?: never;
@@ -85405,19 +87406,32 @@ interface paths {
85405
87406
  cookie?: never;
85406
87407
  };
85407
87408
  /**
85408
- * List report schedules
85409
- * @description The standing subscriptions that mail a rendered report out on a cadence. Unpaginated, and with no `meta.total` — this list is small by construction.
87409
+ * The tenant's click-to-WhatsApp ads, with connect/greeting checks
87410
+ * @description Proxies Atribu’s partner click-to-WhatsApp ads list with the tenant’s WhatsApp **partner** token — a different credential than the connect rail above’s delegated key — and derives two facts per ad: `checks.destination_connected` (the ad’s WhatsApp number, compared as E.164, is one of the tenant’s connected WhatsApp messaging accounts) and `checks.greeting_configured` (a "Saludo automático" — text or tappable ice breakers — is actually set).
87411
+ *
87412
+ * An admin-scoped read (`integrations:read` is admin-only in the scope catalog, not "any member"), free for every tenant (no Add-on gate).
87413
+ *
87414
+ * `data.state` is `not_connected` in TWO cases, told apart by an optional `reason`:
87415
+ * * no `reason` — the tenant has never connected a Meta Ads account (the integration row is missing or not `connected`).
87416
+ * * `reason: "whatsapp_not_connected"` — Meta Ads may be connected, but the tenant holds no `whatsapp_cloud` account carrying an Atribu partner token, so there is no scope to list ads under.
87417
+ *
87418
+ * `cursor` is Atribu’s own opaque keyset cursor (its `pagination.cursor`, a Meta ad id ascending), passed straight through as `after`. `next_cursor` is `null` once Atribu reports `has_next: false`. `last_synced_at` is the max over the returned PAGE only, not a tenant-wide sync timestamp.
87419
+ *
87420
+ * 502 `UPSTREAM_ERROR` on an Atribu 5xx, timeout, or a response shape this route does not recognise. 502 `partner_token_invalid` when Atribu answers 401 on the WhatsApp partner token — that token is never auto-rotated; the dealer must reconnect WhatsApp.
85410
87421
  */
85411
87422
  get: {
85412
87423
  parameters: {
85413
- query?: never;
87424
+ query?: {
87425
+ cursor?: string;
87426
+ limit?: number;
87427
+ };
85414
87428
  header?: never;
85415
87429
  path?: never;
85416
87430
  cookie?: never;
85417
87431
  };
85418
87432
  requestBody?: never;
85419
87433
  responses: {
85420
- /** @description Report schedules */
87434
+ /** @description A `not_connected` state (with or without a `reason`), or the connected page of ads */
85421
87435
  200: {
85422
87436
  headers: {
85423
87437
  [name: string]: unknown;
@@ -85425,26 +87439,51 @@ interface paths {
85425
87439
  content: {
85426
87440
  /**
85427
87441
  * @example {
85428
- * "data": [
85429
- * {
85430
- * "id": "cccccccc-2000-4000-8000-000000000001",
85431
- * "report_type": "conversations",
85432
- * "range_preset": "7d",
85433
- * "cadence": "weekly",
85434
- * "recipients": [
85435
- * "gerencia@midealer.cl"
85436
- * ],
85437
- * "next_run_at": "2026-09-29T09:00:00.000Z",
85438
- * "enabled": true
85439
- * }
85440
- * ]
87442
+ * "data": {
87443
+ * "state": "connected",
87444
+ * "items": [
87445
+ * {
87446
+ * "ad_id": "1234567890123",
87447
+ * "ad_name": "Test drive fin de semana",
87448
+ * "ad_status": "ACTIVE",
87449
+ * "campaign": {
87450
+ * "id": "6543210987654",
87451
+ * "name": "Leads · WhatsApp"
87452
+ * },
87453
+ * "ad_set": {
87454
+ * "id": "6543210987655",
87455
+ * "name": "Región Metropolitana"
87456
+ * },
87457
+ * "destination": {
87458
+ * "type": "whatsapp",
87459
+ * "whatsapp_phone_number": "+56912345678",
87460
+ * "page_id": "998877665544"
87461
+ * },
87462
+ * "cta_type": "WHATSAPP_MESSAGE",
87463
+ * "greeting": {
87464
+ * "text": "¡Hola! Cuéntanos qué auto buscas.",
87465
+ * "autofill_message": "Quiero agendar un test drive",
87466
+ * "ice_breakers": [
87467
+ * "Ver stock disponible",
87468
+ * "Agendar test drive"
87469
+ * ],
87470
+ * "landing_screen_type": "welcome_message"
87471
+ * },
87472
+ * "greeting_status": "present",
87473
+ * "checks": {
87474
+ * "destination_connected": true,
87475
+ * "greeting_configured": true
87476
+ * },
87477
+ * "last_synced_at": "2026-09-23T14:00:00.000Z"
87478
+ * }
87479
+ * ],
87480
+ * "next_cursor": null,
87481
+ * "last_synced_at": "2026-09-23T14:00:00.000Z"
87482
+ * }
85441
87483
  * }
85442
87484
  */
85443
87485
  "application/json": {
85444
- data?: unknown;
85445
- meta?: {
85446
- [key: string]: unknown;
85447
- };
87486
+ data: components["schemas"]["MetaAdsAdsResponse"];
85448
87487
  };
85449
87488
  };
85450
87489
  };
@@ -86415,10 +88454,12 @@ interface paths {
86415
88454
  cookie?: never;
86416
88455
  };
86417
88456
  /**
86418
- * The tenant's Atribu tracking key and snippet
86419
- * @description Ensures an active Atribu tracking key exists for the tenant (minting one on the first call — idempotent, a repeat never mints a second key) and returns it alongside the raw tracker `<script>` snippet, ready to paste before `</head>` for a direct, non-GTM install of the tracking half alone. `combined_snippet` / `meta_pixel_id` are present only when the tenant also has a Meta CAPI pixel configured.
88457
+ * The workspace's tracking key and the tag to paste
88458
+ * @description Ensures an active tracking key exists for the workspace (minting one on the first call — idempotent, a repeat never mints a second key) and returns the tag to paste. `combined_snippet` is THE tag: Vitrina's one-line loader (`<script src=".../tag.js?site=pk_…">`), which boots the assistant and the measurement from the same tag. Its site key (`site_key`) is the newest unexpired publishable key of the workspace, or — when it has none — one minted on this read for the workspace's Vitrina site, registered domains and declared website, and listed afterwards among its publishable keys. `combined_snippet` and `site_key` are `null` only when no origin can be derived at all.
88459
+ *
88460
+ * `snippet` is the measurement provider's raw tracker script (the tracking half alone), kept for API consumers that self-host it; Vitrina's own UI renders `combined_snippet` only. `meta_pixel_id` is present when the workspace has a Meta pixel configured.
86420
88461
  *
86421
- * 402 `ENTITLEMENT_NOT_ACTIVE` (`feature: vitrina_ads`) when Vitrina Ads is not active for this tenant; 409 `ADS_KEY_NEEDS_REMINT` when the Add-on is on but the delegated key has not finished rotating. Admin-scoped (`ads:read`).
88462
+ * 402 `ENTITLEMENT_NOT_ACTIVE` (`feature: vitrina_ads`) when Vitrina Ads is not active for this workspace; 409 `ADS_KEY_NEEDS_REMINT` when the Add-on is on but the delegated key has not finished rotating. Admin-scoped (`ads:read`).
86422
88463
  */
86423
88464
  get: {
86424
88465
  parameters: {
@@ -86429,7 +88470,7 @@ interface paths {
86429
88470
  };
86430
88471
  requestBody?: never;
86431
88472
  responses: {
86432
- /** @description The tracking key and snippet */
88473
+ /** @description The tracking key and the tag to paste */
86433
88474
  200: {
86434
88475
  headers: {
86435
88476
  [name: string]: unknown;
@@ -86441,7 +88482,8 @@ interface paths {
86441
88482
  * "key_id": "abababab-0000-4000-8000-000000000001",
86442
88483
  * "public_key": "trk_live_abc123",
86443
88484
  * "snippet": "<script src=\"https://track.atribu.app/t.js?k=trk_live_abc123\" async></script>",
86444
- * "combined_snippet": null,
88485
+ * "combined_snippet": "<script src=\"https://api.vitrinadev.com/tag.js?site=pk_live_3f9c2a\" async></script>",
88486
+ * "site_key": "pk_live_3f9c2a",
86445
88487
  * "meta_pixel_id": null
86446
88488
  * }
86447
88489
  * }
@@ -86559,17 +88601,17 @@ interface paths {
86559
88601
  cookie?: never;
86560
88602
  };
86561
88603
  /**
86562
- * The combined tag as a ready-to-paste GTM Custom HTML installer
86563
- * @description Mirrors Atribu's own GTM installer shape (tag name, "All Pages" trigger, snippet, setup checklist) — but the `snippet` here is the COMBINED loader (`<script src=".../tag.js?site=…">`, #1610), not Atribu's raw tracker script: pasting this ONE tag boots the assistant AND starts Atribu tracking (#1611).
88604
+ * The tag as a ready-to-paste Google Tag Manager installer
88605
+ * @description The tag name, "All Pages" trigger, snippet and setup checklist for a Google Tag Manager Custom HTML tag. The `snippet` is the COMBINED loader (`<script src=".../tag.js?site=…">`): pasting this ONE tag boots the assistant AND starts the measurement. `tag_name` and `setup_checklist` are Vitrina-branded user-facing copy (Spanish) that names only `tag.js`.
86564
88606
  *
86565
- * `site_id` (required) is the widget's publishable `pk_…` key for the site this tag is being installed on — embedded into the snippet's `?site=` query so the tag survives GTM stripping `data-*` off the `<script>` tag it re-creates.
88607
+ * `site_id` (optional) is the publishable `pk_…` key of the site the tag is being installed on — embedded into the snippet's `?site=` query so the tag survives GTM stripping `data-*` off the `<script>` tag it re-creates. Absent → the workspace's own site key (the `site_key` of `GET /ads/tracking/key`, minted on first read); 400 when the workspace has none and no origin to mint one for.
86566
88608
  *
86567
88609
  * Same entitlement gate as `GET /ads/tracking/key`. Admin-scoped (`ads:read`).
86568
88610
  */
86569
88611
  get: {
86570
88612
  parameters: {
86571
- query: {
86572
- site_id: string;
88613
+ query?: {
88614
+ site_id?: string;
86573
88615
  };
86574
88616
  header?: never;
86575
88617
  path?: never;
@@ -86588,13 +88630,16 @@ interface paths {
86588
88630
  * "data": {
86589
88631
  * "key_id": "abababab-0000-4000-8000-000000000001",
86590
88632
  * "public_key": "trk_live_abc123",
86591
- * "tag_name": "Vitrina — Asistente + Atribu (tag único)",
88633
+ * "site_key": "pk_live_3f9c2a",
88634
+ * "tag_name": "Vitrina Ads · tag",
86592
88635
  * "trigger": "All Pages",
86593
88636
  * "snippet": "<script src=\"https://api.vitrinadev.com/tag.js?site=pk_live_3f9c2a\" async></script>",
86594
88637
  * "setup_checklist": [
86595
- * "Crea una etiqueta HTML personalizada y pega el fragmento.",
88638
+ * "En Google Tag Manager, crea una etiqueta nueva de tipo «HTML personalizado».",
88639
+ * "Pega el fragmento de Vitrina (tag.js) tal cual.",
86596
88640
  * "Activador: All Pages.",
86597
- * "El asistente y el rastreo de Atribu se cargan desde ESTE MISMO tag — no agregues el snippet de Atribu por separado ni el widget del asistente aparte."
88641
+ * "Guarda la etiqueta y publica el contenedor.",
88642
+ * "El asistente y la medición se cargan desde este mismo tag.js: no agregues otro fragmento de Vitrina aparte."
86598
88643
  * ]
86599
88644
  * }
86600
88645
  * }
@@ -86704,6 +88749,152 @@ interface paths {
86704
88749
  patch?: never;
86705
88750
  trace?: never;
86706
88751
  };
88752
+ "/ads/tracking/status": {
88753
+ parameters: {
88754
+ query?: never;
88755
+ header?: never;
88756
+ path?: never;
88757
+ cookie?: never;
88758
+ };
88759
+ /**
88760
+ * Is the tag installed? Last event seen, events in 24 h, domain
88761
+ * @description Tag detection for the workspace's tracking key. `source: tracker` (the normal case) reads the measurement provider's per-key last-event time (`last_seen_at`), the tracker events of the last 24 hours (`events_24h`) and the hostname of the latest verified install check (`domain`). `installed` is `true` only when the tag sent an event in the last 30 days — never without a timestamp.
88762
+ *
88763
+ * When the per-key read is unavailable the answer falls back to the health read's daily UTM scan: `source: health`, `installed` = the refreshed scan counted events, `last_seen_at` / `events_24h` / `domain` = `null`. `events_24h` is `null` (never `0`) whenever the count could not be read.
88764
+ *
88765
+ * Same entitlement gate as `GET /ads/tracking/key`. Admin-scoped (`ads:read`).
88766
+ */
88767
+ get: {
88768
+ parameters: {
88769
+ query?: never;
88770
+ header?: never;
88771
+ path?: never;
88772
+ cookie?: never;
88773
+ };
88774
+ requestBody?: never;
88775
+ responses: {
88776
+ /** @description The tag detection status */
88777
+ 200: {
88778
+ headers: {
88779
+ [name: string]: unknown;
88780
+ };
88781
+ content: {
88782
+ /**
88783
+ * @example {
88784
+ * "data": {
88785
+ * "installed": true,
88786
+ * "last_seen_at": "2026-09-23T14:02:11.000Z",
88787
+ * "events_24h": 184,
88788
+ * "domain": "www.clinica-ejemplo.cl",
88789
+ * "source": "tracker"
88790
+ * }
88791
+ * }
88792
+ */
88793
+ "application/json": {
88794
+ data: components["schemas"]["AdsTrackingStatus"];
88795
+ };
88796
+ };
88797
+ };
88798
+ /** @description Validation error */
88799
+ 400: {
88800
+ headers: {
88801
+ [name: string]: unknown;
88802
+ };
88803
+ content: {
88804
+ "application/json": components["schemas"]["Error"];
88805
+ };
88806
+ };
88807
+ /** @description Unauthorized */
88808
+ 401: {
88809
+ headers: {
88810
+ [name: string]: unknown;
88811
+ };
88812
+ content: {
88813
+ "application/json": components["schemas"]["Error"];
88814
+ };
88815
+ };
88816
+ /** @description Vitrina Ads is not active for this workspace. `error.code` is `ENTITLEMENT_NOT_ACTIVE`, `error.details.feature` is `vitrina_ads`. */
88817
+ 402: {
88818
+ headers: {
88819
+ [name: string]: unknown;
88820
+ };
88821
+ content: {
88822
+ /**
88823
+ * @example {
88824
+ * "error": {
88825
+ * "code": "ENTITLEMENT_NOT_ACTIVE",
88826
+ * "message": "El complemento Vitrina Ads no está activo en este espacio de trabajo.",
88827
+ * "details": {
88828
+ * "required": [
88829
+ * "vitrina_ads"
88830
+ * ],
88831
+ * "active": [],
88832
+ * "feature": "vitrina_ads",
88833
+ * "entitlement_state": "off"
88834
+ * }
88835
+ * }
88836
+ * }
88837
+ */
88838
+ "application/json": components["schemas"]["Error"];
88839
+ };
88840
+ };
88841
+ /** @description Forbidden */
88842
+ 403: {
88843
+ headers: {
88844
+ [name: string]: unknown;
88845
+ };
88846
+ content: {
88847
+ "application/json": components["schemas"]["Error"];
88848
+ };
88849
+ };
88850
+ /** @description Not found */
88851
+ 404: {
88852
+ headers: {
88853
+ [name: string]: unknown;
88854
+ };
88855
+ content: {
88856
+ "application/json": components["schemas"]["Error"];
88857
+ };
88858
+ };
88859
+ /** @description Vitrina Ads is active but the delegated key has not finished rotating (`ADS_KEY_NEEDS_REMINT`) — retry once `GET /ads/state` reports `needs_remint: false`. Also the generic conflict of a write. */
88860
+ 409: {
88861
+ headers: {
88862
+ [name: string]: unknown;
88863
+ };
88864
+ content: {
88865
+ /**
88866
+ * @example {
88867
+ * "error": {
88868
+ * "code": "ADS_KEY_NEEDS_REMINT",
88869
+ * "message": "Vitrina Ads is active but the delegated key has not finished rotating (key_kind: core)",
88870
+ * "details": {
88871
+ * "key_kind": "core"
88872
+ * }
88873
+ * }
88874
+ * }
88875
+ */
88876
+ "application/json": components["schemas"]["Error"];
88877
+ };
88878
+ };
88879
+ /** @description Rate limited */
88880
+ 429: {
88881
+ headers: {
88882
+ [name: string]: unknown;
88883
+ };
88884
+ content: {
88885
+ "application/json": components["schemas"]["Error"];
88886
+ };
88887
+ };
88888
+ };
88889
+ };
88890
+ put?: never;
88891
+ post?: never;
88892
+ delete?: never;
88893
+ options?: never;
88894
+ head?: never;
88895
+ patch?: never;
88896
+ trace?: never;
88897
+ };
86707
88898
  "/kb-files": {
86708
88899
  parameters: {
86709
88900
  query?: never;
@@ -92982,7 +95173,7 @@ interface paths {
92982
95173
  * Publish many vehicles to one portal
92983
95174
  * @description N vehicles × ONE portal — `integration_id` is singular. To publish to several portals, call this once per portal.
92984
95175
  *
92985
- * Each vehicle is isolated: the response is a per-vehicle outcome list, and a **200 does not mean every vehicle published**. `status` is `published`, `already_published` (a live ad already existed and nothing was sent), `skipped` (never reached the portal — vendido, inactive or gone; `reason` says which), `error` (`error` says why) or, for `facebook_marketplace` (no HTTP API — see `POST /vehicles/{id}/publish`), `pending`: a device_task was enqueued and the real outcome arrives later via `vehicle.published` / `vehicle.publish_failed`. Up to 100 vehicles per call, and unlike the close-ads path this runs the portal round-trips synchronously, so a full batch is a slow request. Automotive-vertical only: a workspace on another vertical gets 403 here however its scopes are set.
95176
+ * Each vehicle is isolated: the response is a per-vehicle outcome list, and a **200 does not mean every vehicle published**. `status` is `published`, `already_published` (a live ad already existed and nothing was sent), `skipped` (never reached the portal — vendido, inactive or gone; `reason` says which), `error` (`error` says why) or, for `facebook_marketplace` and `chileautos_panel` (see `POST /vehicles/{id}/publish`), `pending`: the portal call was queued and the real outcome arrives later via `vehicle.published` / `vehicle.publish_failed`. Up to 100 vehicles per call, and unlike the close-ads path this runs the portal round-trips synchronously, so a full batch is a slow request. Automotive-vertical only: a workspace on another vertical gets 403 here however its scopes are set.
92986
95177
  */
92987
95178
  post: {
92988
95179
  parameters: {
@@ -105169,7 +107360,7 @@ interface components {
105169
107360
  };
105170
107361
  WebhookEventDoc: {
105171
107362
  /** @enum {string} */
105172
- name: "ai_agent.publish" | "ai_agent_graph.publish" | "agent_scenario_run.completed" | "agent_scenario_suite.completed" | "conversation.created" | "conversation.assigned" | "conversation.resolved" | "message.received" | "message.sent" | "ticket.opened" | "ticket.reopened" | "ticket.resolved" | "ticket.closed" | "sla.breached" | "kb.source.create" | "kb.source.embed" | "kb.source.update" | "kb.source.delete" | "kb_file.uploaded" | "kb_file.deleted" | "skill.created" | "skill.updated" | "skill.deleted" | "custom_tool.created" | "custom_tool.updated" | "custom_tool.deleted" | "macro.applied" | "cost.budget_alert" | "runtime.budget_exceeded" | "lead.created" | "lead.stage_changed" | "lead.pipeline_changed" | "lead.assigned" | "lead.won" | "lead.lost" | "lead.unqualified" | "stock.synced" | "stock.source_retired" | "vehicle.published" | "vehicle.unpublished" | "vehicle.publish_failed" | "vehicle.created" | "vehicle.attachment.created" | "mercadolibre.order" | "mercadolibre.vis_lead" | "chileautos.lead" | "yapo.lead" | "website.lead" | "consignment.candidate.created" | "quote.issued" | "quote.voided" | "quote.extended" | "quote.archived" | "reservation.created" | "reservation.voided" | "reservation.abono_disposed" | "reservation.converted" | "sale_note.issued" | "sale_note.approved" | "sale_note.voided" | "purchase_note.issued" | "purchase_note.corrected" | "purchase_note.voided" | "payment.recorded" | "consignment.created" | "consignment.returned" | "consignment.sold" | "credit_application.recorded" | "credit_application.submitted" | "credit_application.decided" | "credit_application.withdrawn" | "price_approval.requested" | "price_approval.decided" | "contact.created" | "contact.updated" | "contact.merged" | "appointment.booked" | "appointment.rescheduled" | "appointment.cancelled" | "appointment.completed" | "appointment.no_show" | "appointment.reminded" | "appointment.imported" | "campaign.sent" | "campaign.paused" | "sending_domain.verified" | "coach.proposals_ready" | "coach.finding_ready" | "voice.autonomous_call" | "safety_hold.placed" | "safety_hold.ack_overdue" | "safety_hold.first_response_overdue" | "team.created" | "team.updated" | "team.deleted" | "custom_role.created" | "custom_role.updated" | "custom_role.deleted" | "macro.created" | "macro.updated" | "macro.deleted" | "assignment_rule.created" | "assignment_rule.updated" | "assignment_rule.deleted" | "sla_policy.created" | "sla_policy.updated" | "sla_policy.deleted" | "automation_trigger.created" | "automation_trigger.updated" | "automation_trigger.deleted" | "sending_domain.created" | "sending_domain.deleted" | "whatsapp_template.created" | "whatsapp_template.status_changed" | "whatsapp_template.deleted" | "whatsapp_flow.created" | "whatsapp_flow.published" | "whatsapp_flow.deprecated" | "whatsapp_flow.deleted" | "channel.connected" | "channel.updated" | "channel.disconnected" | "membership.created" | "membership.updated" | "membership.removed" | "clinic_professional.created" | "clinic_professional.updated" | "clinic_professional.deleted" | "clinic_service.created" | "clinic_service.updated" | "clinic_service.deleted" | "clinic_price_list.updated" | "clinic_pack_purchase.created" | "clinic_pack_purchase.session_consumed" | "clinic_pack_purchase.cancelled" | "clinic_budget.created" | "clinic_budget.sent" | "clinic_budget.accepted" | "clinic_budget.rejected" | "clinic_budget.voided" | "clinic_cash_session.opened" | "clinic_cash_session.closed" | "clinic_patient.created" | "clinic_patient.updated" | "clinic_patient.deleted" | "clinic_patient.merged" | "clinic_encounter.opened" | "clinic_encounter.closed" | "clinic_note.signed" | "clinic_note.amended" | "clinic_consent.signed" | "clinic_consent.revoked" | "clinic_document.uploaded" | "clinic_document.deleted" | "clinic_privacy_request.completed";
107363
+ name: "ai_agent.publish" | "ai_agent_graph.publish" | "agent_scenario_run.completed" | "agent_scenario_suite.completed" | "conversation.created" | "conversation.assigned" | "conversation.resolved" | "message.received" | "message.sent" | "ticket.opened" | "ticket.reopened" | "ticket.resolved" | "ticket.closed" | "sla.breached" | "kb.source.create" | "kb.source.embed" | "kb.source.update" | "kb.source.delete" | "kb_file.uploaded" | "kb_file.deleted" | "skill.created" | "skill.updated" | "skill.deleted" | "custom_tool.created" | "custom_tool.updated" | "custom_tool.deleted" | "macro.applied" | "cost.budget_alert" | "runtime.budget_exceeded" | "lead.created" | "lead.stage_changed" | "lead.pipeline_changed" | "lead.assigned" | "lead.won" | "lead.lost" | "lead.unqualified" | "stock.synced" | "stock.source_retired" | "vehicle.published" | "vehicle.unpublished" | "vehicle.publish_failed" | "vehicle.created" | "vehicle.attachment.created" | "mercadolibre.order" | "mercadolibre.vis_lead" | "chileautos.lead" | "yapo.lead" | "website.lead" | "consignment.candidate.created" | "quote.issued" | "quote.voided" | "quote.extended" | "quote.archived" | "reservation.created" | "reservation.voided" | "reservation.abono_disposed" | "reservation.converted" | "sale_note.issued" | "sale_note.approved" | "sale_note.voided" | "purchase_note.issued" | "purchase_note.corrected" | "purchase_note.voided" | "payment.recorded" | "consignment.created" | "consignment.returned" | "consignment.sold" | "credit_application.recorded" | "credit_application.submitted" | "credit_application.decided" | "credit_application.withdrawn" | "price_approval.requested" | "price_approval.decided" | "contact.created" | "contact.updated" | "contact.merged" | "appointment.booked" | "appointment.rescheduled" | "appointment.cancelled" | "appointment.completed" | "appointment.no_show" | "appointment.reminded" | "appointment.imported" | "campaign.sent" | "campaign.paused" | "sending_domain.verified" | "coach.proposals_ready" | "coach.finding_ready" | "voice.autonomous_call" | "safety_hold.placed" | "safety_hold.ack_overdue" | "safety_hold.first_response_overdue" | "team.created" | "team.updated" | "team.deleted" | "custom_role.created" | "custom_role.updated" | "custom_role.deleted" | "macro.created" | "macro.updated" | "macro.deleted" | "assignment_rule.created" | "assignment_rule.updated" | "assignment_rule.deleted" | "sla_policy.created" | "sla_policy.updated" | "sla_policy.deleted" | "automation_trigger.created" | "automation_trigger.updated" | "automation_trigger.deleted" | "sending_domain.created" | "sending_domain.deleted" | "whatsapp_template.created" | "whatsapp_template.status_changed" | "whatsapp_template.deleted" | "whatsapp_flow.created" | "whatsapp_flow.published" | "whatsapp_flow.deprecated" | "whatsapp_flow.deleted" | "channel.connected" | "channel.updated" | "channel.disconnected" | "membership.created" | "membership.updated" | "membership.removed" | "clinic_professional.created" | "clinic_professional.updated" | "clinic_professional.deleted" | "clinic_service.created" | "clinic_service.updated" | "clinic_service.deleted" | "clinic_price_list.updated" | "clinic_pack_purchase.created" | "clinic_pack_purchase.session_consumed" | "clinic_pack_purchase.cancelled" | "clinic_budget.created" | "clinic_budget.sent" | "clinic_budget.accepted" | "clinic_budget.rejected" | "clinic_budget.voided" | "clinic_budget.mirror_changed" | "clinic_cash_session.opened" | "clinic_cash_session.closed" | "clinic_patient.created" | "clinic_patient.updated" | "clinic_patient.deleted" | "clinic_patient.merged" | "clinic_encounter.opened" | "clinic_encounter.closed" | "clinic_note.signed" | "clinic_note.amended" | "clinic_consent.signed" | "clinic_consent.revoked" | "clinic_document.uploaded" | "clinic_document.deleted" | "clinic_privacy_request.completed";
105173
107364
  /** @description The schema version of this event type — every delivery carries it as `version`. Bumped only on a breaking change to `data`. */
105174
107365
  version: number;
105175
107366
  /** @description What the event is about — the `resource.type` of every delivery (`lead`, `vehicle`, `contact`, …). */
@@ -105236,7 +107427,7 @@ interface components {
105236
107427
  CreateWebhookBody: {
105237
107428
  /** Format: uri */
105238
107429
  url: string;
105239
- events: ("*" | "ai_agent.publish" | "ai_agent_graph.publish" | "agent_scenario_run.completed" | "agent_scenario_suite.completed" | "conversation.created" | "conversation.assigned" | "conversation.resolved" | "message.received" | "message.sent" | "ticket.opened" | "ticket.reopened" | "ticket.resolved" | "ticket.closed" | "sla.breached" | "kb.source.create" | "kb.source.embed" | "kb.source.update" | "kb.source.delete" | "kb_file.uploaded" | "kb_file.deleted" | "skill.created" | "skill.updated" | "skill.deleted" | "custom_tool.created" | "custom_tool.updated" | "custom_tool.deleted" | "macro.applied" | "cost.budget_alert" | "runtime.budget_exceeded" | "lead.created" | "lead.stage_changed" | "lead.pipeline_changed" | "lead.assigned" | "lead.won" | "lead.lost" | "lead.unqualified" | "stock.synced" | "stock.source_retired" | "vehicle.published" | "vehicle.unpublished" | "vehicle.publish_failed" | "vehicle.created" | "vehicle.attachment.created" | "mercadolibre.order" | "mercadolibre.vis_lead" | "chileautos.lead" | "yapo.lead" | "website.lead" | "consignment.candidate.created" | "quote.issued" | "quote.voided" | "quote.extended" | "quote.archived" | "reservation.created" | "reservation.voided" | "reservation.abono_disposed" | "reservation.converted" | "sale_note.issued" | "sale_note.approved" | "sale_note.voided" | "purchase_note.issued" | "purchase_note.corrected" | "purchase_note.voided" | "payment.recorded" | "consignment.created" | "consignment.returned" | "consignment.sold" | "credit_application.recorded" | "credit_application.submitted" | "credit_application.decided" | "credit_application.withdrawn" | "price_approval.requested" | "price_approval.decided" | "contact.created" | "contact.updated" | "contact.merged" | "appointment.booked" | "appointment.rescheduled" | "appointment.cancelled" | "appointment.completed" | "appointment.no_show" | "appointment.reminded" | "appointment.imported" | "campaign.sent" | "campaign.paused" | "sending_domain.verified" | "coach.proposals_ready" | "coach.finding_ready" | "voice.autonomous_call" | "safety_hold.placed" | "safety_hold.ack_overdue" | "safety_hold.first_response_overdue" | "team.created" | "team.updated" | "team.deleted" | "custom_role.created" | "custom_role.updated" | "custom_role.deleted" | "macro.created" | "macro.updated" | "macro.deleted" | "assignment_rule.created" | "assignment_rule.updated" | "assignment_rule.deleted" | "sla_policy.created" | "sla_policy.updated" | "sla_policy.deleted" | "automation_trigger.created" | "automation_trigger.updated" | "automation_trigger.deleted" | "sending_domain.created" | "sending_domain.deleted" | "whatsapp_template.created" | "whatsapp_template.status_changed" | "whatsapp_template.deleted" | "whatsapp_flow.created" | "whatsapp_flow.published" | "whatsapp_flow.deprecated" | "whatsapp_flow.deleted" | "channel.connected" | "channel.updated" | "channel.disconnected" | "membership.created" | "membership.updated" | "membership.removed" | "clinic_professional.created" | "clinic_professional.updated" | "clinic_professional.deleted" | "clinic_service.created" | "clinic_service.updated" | "clinic_service.deleted" | "clinic_price_list.updated" | "clinic_pack_purchase.created" | "clinic_pack_purchase.session_consumed" | "clinic_pack_purchase.cancelled" | "clinic_budget.created" | "clinic_budget.sent" | "clinic_budget.accepted" | "clinic_budget.rejected" | "clinic_budget.voided" | "clinic_cash_session.opened" | "clinic_cash_session.closed" | "clinic_patient.created" | "clinic_patient.updated" | "clinic_patient.deleted" | "clinic_patient.merged" | "clinic_encounter.opened" | "clinic_encounter.closed" | "clinic_note.signed" | "clinic_note.amended" | "clinic_consent.signed" | "clinic_consent.revoked" | "clinic_document.uploaded" | "clinic_document.deleted" | "clinic_privacy_request.completed")[];
107430
+ events: ("*" | "ai_agent.publish" | "ai_agent_graph.publish" | "agent_scenario_run.completed" | "agent_scenario_suite.completed" | "conversation.created" | "conversation.assigned" | "conversation.resolved" | "message.received" | "message.sent" | "ticket.opened" | "ticket.reopened" | "ticket.resolved" | "ticket.closed" | "sla.breached" | "kb.source.create" | "kb.source.embed" | "kb.source.update" | "kb.source.delete" | "kb_file.uploaded" | "kb_file.deleted" | "skill.created" | "skill.updated" | "skill.deleted" | "custom_tool.created" | "custom_tool.updated" | "custom_tool.deleted" | "macro.applied" | "cost.budget_alert" | "runtime.budget_exceeded" | "lead.created" | "lead.stage_changed" | "lead.pipeline_changed" | "lead.assigned" | "lead.won" | "lead.lost" | "lead.unqualified" | "stock.synced" | "stock.source_retired" | "vehicle.published" | "vehicle.unpublished" | "vehicle.publish_failed" | "vehicle.created" | "vehicle.attachment.created" | "mercadolibre.order" | "mercadolibre.vis_lead" | "chileautos.lead" | "yapo.lead" | "website.lead" | "consignment.candidate.created" | "quote.issued" | "quote.voided" | "quote.extended" | "quote.archived" | "reservation.created" | "reservation.voided" | "reservation.abono_disposed" | "reservation.converted" | "sale_note.issued" | "sale_note.approved" | "sale_note.voided" | "purchase_note.issued" | "purchase_note.corrected" | "purchase_note.voided" | "payment.recorded" | "consignment.created" | "consignment.returned" | "consignment.sold" | "credit_application.recorded" | "credit_application.submitted" | "credit_application.decided" | "credit_application.withdrawn" | "price_approval.requested" | "price_approval.decided" | "contact.created" | "contact.updated" | "contact.merged" | "appointment.booked" | "appointment.rescheduled" | "appointment.cancelled" | "appointment.completed" | "appointment.no_show" | "appointment.reminded" | "appointment.imported" | "campaign.sent" | "campaign.paused" | "sending_domain.verified" | "coach.proposals_ready" | "coach.finding_ready" | "voice.autonomous_call" | "safety_hold.placed" | "safety_hold.ack_overdue" | "safety_hold.first_response_overdue" | "team.created" | "team.updated" | "team.deleted" | "custom_role.created" | "custom_role.updated" | "custom_role.deleted" | "macro.created" | "macro.updated" | "macro.deleted" | "assignment_rule.created" | "assignment_rule.updated" | "assignment_rule.deleted" | "sla_policy.created" | "sla_policy.updated" | "sla_policy.deleted" | "automation_trigger.created" | "automation_trigger.updated" | "automation_trigger.deleted" | "sending_domain.created" | "sending_domain.deleted" | "whatsapp_template.created" | "whatsapp_template.status_changed" | "whatsapp_template.deleted" | "whatsapp_flow.created" | "whatsapp_flow.published" | "whatsapp_flow.deprecated" | "whatsapp_flow.deleted" | "channel.connected" | "channel.updated" | "channel.disconnected" | "membership.created" | "membership.updated" | "membership.removed" | "clinic_professional.created" | "clinic_professional.updated" | "clinic_professional.deleted" | "clinic_service.created" | "clinic_service.updated" | "clinic_service.deleted" | "clinic_price_list.updated" | "clinic_pack_purchase.created" | "clinic_pack_purchase.session_consumed" | "clinic_pack_purchase.cancelled" | "clinic_budget.created" | "clinic_budget.sent" | "clinic_budget.accepted" | "clinic_budget.rejected" | "clinic_budget.voided" | "clinic_budget.mirror_changed" | "clinic_cash_session.opened" | "clinic_cash_session.closed" | "clinic_patient.created" | "clinic_patient.updated" | "clinic_patient.deleted" | "clinic_patient.merged" | "clinic_encounter.opened" | "clinic_encounter.closed" | "clinic_note.signed" | "clinic_note.amended" | "clinic_consent.signed" | "clinic_consent.revoked" | "clinic_document.uploaded" | "clinic_document.deleted" | "clinic_privacy_request.completed")[];
105240
107431
  description?: string | null;
105241
107432
  /** @description «Incluir datos del recurso». `false` (the default) = every delivery is the notice: resource, changes, author, time and `url`, with `data_omitted: "not_requested"`. `true` = each delivery also carries `data` when, at dispatch time, this subscription's OWNER — whoever created it or last changed its url, events or this flag — holds the resource read scope (`read_scope` in the catalogue) and sees every record; otherwise `data_omitted` says why. An event about a dato sensible is always the notice. */
105242
107433
  include_data?: boolean;
@@ -105452,6 +107643,106 @@ interface components {
105452
107643
  requestId?: string;
105453
107644
  };
105454
107645
  };
107646
+ MetaAdsAccount: {
107647
+ external_account_id: string;
107648
+ name: string;
107649
+ currency: string | null;
107650
+ timezone: string | null;
107651
+ delivers_spend: boolean;
107652
+ atribu_connection_id: string;
107653
+ } | null;
107654
+ MetaAdsCandidate: {
107655
+ candidate_id: string;
107656
+ external_account_id: string;
107657
+ name: string;
107658
+ currency: string | null;
107659
+ account_status: string;
107660
+ timezone: string | null;
107661
+ };
107662
+ MetaAdsIntegration: {
107663
+ /** Format: uuid */
107664
+ id: string;
107665
+ /** @enum {string} */
107666
+ provider: "meta_ads";
107667
+ /** @enum {string} */
107668
+ status: "pending" | "pending_selection" | "connected" | "error" | "disconnected";
107669
+ account_label: string | null;
107670
+ connected_at: string | null;
107671
+ account: components["schemas"]["MetaAdsAccount"];
107672
+ error: {
107673
+ reason: string;
107674
+ retryable: boolean;
107675
+ } | null;
107676
+ handoff: {
107677
+ id: string;
107678
+ expires_at: string;
107679
+ } | null;
107680
+ candidates: components["schemas"]["MetaAdsCandidate"][] | null;
107681
+ updated_at: string;
107682
+ } | null;
107683
+ MetaAdsConnectResult: {
107684
+ url: string;
107685
+ handoff_id: string;
107686
+ expires_at: string;
107687
+ };
107688
+ MetaAdsConnectBody: {
107689
+ /** Format: uri */
107690
+ return_to: string;
107691
+ };
107692
+ MetaAdsReturnBody: {
107693
+ handoff_id?: string;
107694
+ state?: string;
107695
+ };
107696
+ MetaAdsFinalizeBody: {
107697
+ candidate_id: string;
107698
+ };
107699
+ MetaAdsAdsNotConnected: {
107700
+ /** @enum {string} */
107701
+ state: "not_connected";
107702
+ /** @enum {string} */
107703
+ reason?: "whatsapp_not_connected";
107704
+ };
107705
+ MetaAdsAdGreeting: {
107706
+ text: string | null;
107707
+ autofill_message: string | null;
107708
+ ice_breakers: string[];
107709
+ landing_screen_type: string | null;
107710
+ } | null;
107711
+ MetaAdsAdRow: {
107712
+ ad_id: string;
107713
+ ad_name: string;
107714
+ ad_status: string;
107715
+ campaign: {
107716
+ id: string;
107717
+ name: string;
107718
+ };
107719
+ ad_set: {
107720
+ id: string;
107721
+ name: string;
107722
+ };
107723
+ destination: {
107724
+ type: string;
107725
+ whatsapp_phone_number: string | null;
107726
+ page_id: string | null;
107727
+ };
107728
+ cta_type: string | null;
107729
+ greeting: components["schemas"]["MetaAdsAdGreeting"];
107730
+ /** @enum {string} */
107731
+ greeting_status: "present" | "none" | "unreadable";
107732
+ checks: {
107733
+ destination_connected: boolean | null;
107734
+ greeting_configured: boolean;
107735
+ };
107736
+ last_synced_at: string | null;
107737
+ };
107738
+ MetaAdsAdsConnected: {
107739
+ /** @enum {string} */
107740
+ state: "connected";
107741
+ items: components["schemas"]["MetaAdsAdRow"][];
107742
+ next_cursor: string | null;
107743
+ last_synced_at: string | null;
107744
+ };
107745
+ MetaAdsAdsResponse: components["schemas"]["MetaAdsAdsNotConnected"] | components["schemas"]["MetaAdsAdsConnected"];
105455
107746
  AdsOverview: {
105456
107747
  current: {
105457
107748
  spend: number | null;
@@ -105613,16 +107904,26 @@ interface components {
105613
107904
  public_key: string;
105614
107905
  snippet: string;
105615
107906
  combined_snippet: string | null;
107907
+ site_key: string | null;
105616
107908
  meta_pixel_id: string | null;
105617
107909
  };
105618
107910
  AdsGtmInstaller: {
105619
107911
  key_id: string;
105620
107912
  public_key: string;
107913
+ site_key: string;
105621
107914
  tag_name: string;
105622
107915
  trigger: string;
105623
107916
  snippet: string;
105624
107917
  setup_checklist: string[];
105625
107918
  };
107919
+ AdsTrackingStatus: {
107920
+ installed: boolean;
107921
+ last_seen_at: string | null;
107922
+ events_24h: number | null;
107923
+ domain: string | null;
107924
+ /** @enum {string} */
107925
+ source: "tracker" | "health";
107926
+ };
105626
107927
  };
105627
107928
  responses: never;
105628
107929
  parameters: never;
@@ -105683,7 +107984,7 @@ declare function createClient(opts: CreateClientOptions): VitrinaClient;
105683
107984
  * is regenerated — narrow on the ones you handle, never assume this
105684
107985
  * list is exhaustive at runtime.
105685
107986
  */
105686
- type ErrorCode = 'VALIDATION_ERROR' | 'NOT_FOUND' | 'UNAUTHORIZED' | 'FORBIDDEN' | 'CONFLICT' | 'UNIQUE_CONFLICT' | 'IDEMPOTENCY_KEY_CONFLICT' | 'VERTICAL_NOT_ENABLED' | 'ENTITLEMENT_NOT_ACTIVE' | 'UNSUPPORTED_VEHICLE_TYPE' | 'NO_OFFERING_ADAPTER' | 'PAYLOAD_TOO_LARGE' | 'UNSUPPORTED_MEDIA_TYPE' | 'UPSTREAM_ERROR' | 'RATE_LIMITED' | 'GONE' | 'INTERNAL_ERROR' | 'MESSAGING_ACCOUNT_TENANT_MISSING' | 'COPILOT_APPROVALS_UNAVAILABLE' | 'COPILOT_APPROVAL_REPLAY_BLOCKED' | 'DEALER_SITES_NOT_CONFIGURED' | 'STOREFRONT_ZONES_NOT_CONFIGURED' | 'RECONTACTO_NOT_ENABLED' | 'SYNC_QUEUE_UNAVAILABLE' | 'ATTRIBUTION_PROFILE_UNAVAILABLE' | 'ATTRIBUTION_PROFILE_MISMATCH' | 'ADS_KEY_NEEDS_REMINT' | 'MISSING_SIGNATURE' | 'MALFORMED_SIGNATURE' | 'STALE_SIGNATURE' | 'INVALID_SIGNATURE' | 'REPLAY_DETECTED' | 'TURNSTILE_UNAVAILABLE' | 'TASADOR_QUOTA_EXHAUSTED' | 'TASADOR_ANON_DAILY_LIMIT' | 'TASADOR_CAPACITY_REACHED' | 'CLINIC_PLAN_REQUIRED' | 'TENANT_BILLING_PAUSED' | 'FACEBOOK_MARKETPLACE_NOT_AVAILABLE' | 'WORKSPACE_MEMBER_INACTIVE' | 'DEVICE_AGENT_ALREADY_PAIRED' | 'DEVICE_AGENT_SELF_REQUIRES_USER' | 'DEVICE_AGENT_KIND_NOT_ALLOWED' | 'DEVICE_TASK_STATUS_NOT_ALLOWED' | 'FACEBOOK_MARKETPLACE_NO_PHONE_AGENT' | 'FACEBOOK_MARKETPLACE_THREAD_NOT_ADDRESSABLE' | 'FACEBOOK_MARKETPLACE_ATTACHMENT_UNSUPPORTED' | 'REPLY_PACING_LOCKED' | 'SANDBOX_CHANNEL_FORBIDDEN' | 'SANDBOX_BILLING_FORBIDDEN' | 'SANDBOX_NOT_PROVISIONED' | 'SANDBOX_RESET_UNAVAILABLE' | 'CONNECTED_APP_SENSITIVE_DATA' | 'handoff_mismatch' | 'sync_in_flight' | 'atribu_refused' | 'start_again' | 'reconnect' | 'partner_token_invalid' | 'OUTBOUND_BLOCKED' | 'OUTBOUND_WARNING' | 'dpa_acceptance_required' | 'EMAIL_SENDER_UNRESOLVED' | 'CAMPAIGN_FROM_CONNECTED_MAILBOX' | 'BANK_FEED_NOT_CONFIGURED' | 'ADDON_NOT_PRICED';
107987
+ type ErrorCode = 'VALIDATION_ERROR' | 'NOT_FOUND' | 'UNAUTHORIZED' | 'FORBIDDEN' | 'CONFLICT' | 'UNIQUE_CONFLICT' | 'IDEMPOTENCY_KEY_CONFLICT' | 'VERTICAL_NOT_ENABLED' | 'ENTITLEMENT_NOT_ACTIVE' | 'UNSUPPORTED_VEHICLE_TYPE' | 'NO_OFFERING_ADAPTER' | 'PAYLOAD_TOO_LARGE' | 'UNSUPPORTED_MEDIA_TYPE' | 'UPSTREAM_ERROR' | 'RATE_LIMITED' | 'GONE' | 'INTERNAL_ERROR' | 'MESSAGING_ACCOUNT_TENANT_MISSING' | 'COPILOT_APPROVALS_UNAVAILABLE' | 'COPILOT_APPROVAL_REPLAY_BLOCKED' | 'DEALER_SITES_NOT_CONFIGURED' | 'STOREFRONT_ZONES_NOT_CONFIGURED' | 'RECONTACTO_NOT_ENABLED' | 'SYNC_QUEUE_UNAVAILABLE' | 'ATTRIBUTION_PROFILE_UNAVAILABLE' | 'ATTRIBUTION_PROFILE_MISMATCH' | 'ADS_KEY_NEEDS_REMINT' | 'MISSING_SIGNATURE' | 'MALFORMED_SIGNATURE' | 'STALE_SIGNATURE' | 'INVALID_SIGNATURE' | 'REPLAY_DETECTED' | 'TURNSTILE_UNAVAILABLE' | 'TASADOR_QUOTA_EXHAUSTED' | 'TASADOR_ANON_DAILY_LIMIT' | 'TASADOR_CAPACITY_REACHED' | 'CLINIC_PLAN_REQUIRED' | 'TENANT_BILLING_PAUSED' | 'FACEBOOK_MARKETPLACE_NOT_AVAILABLE' | 'WORKSPACE_MEMBER_INACTIVE' | 'DEVICE_AGENT_ALREADY_PAIRED' | 'DEVICE_AGENT_SELF_REQUIRES_USER' | 'DEVICE_AGENT_KIND_NOT_ALLOWED' | 'DEVICE_TASK_STATUS_NOT_ALLOWED' | 'FACEBOOK_MARKETPLACE_NO_PHONE_AGENT' | 'FACEBOOK_MARKETPLACE_THREAD_NOT_ADDRESSABLE' | 'FACEBOOK_MARKETPLACE_ATTACHMENT_UNSUPPORTED' | 'REPLY_PACING_LOCKED' | 'SANDBOX_CHANNEL_FORBIDDEN' | 'SANDBOX_BILLING_FORBIDDEN' | 'SANDBOX_NOT_PROVISIONED' | 'SANDBOX_RESET_UNAVAILABLE' | 'CONNECTED_APP_SENSITIVE_DATA' | 'handoff_mismatch' | 'sync_in_flight' | 'atribu_refused' | 'start_again' | 'reconnect' | 'partner_token_invalid' | 'OUTBOUND_BLOCKED' | 'OUTBOUND_WARNING' | 'dpa_acceptance_required' | 'EMAIL_SENDER_UNRESOLVED' | 'CAMPAIGN_FROM_CONNECTED_MAILBOX' | 'BANK_FEED_NOT_CONFIGURED' | 'ADDON_NOT_PRICED' | 'MIRROR_LINES_UNMAPPED';
105687
107988
  declare const ERROR_CODES: readonly ErrorCode[];
105688
107989
 
105689
107990
  /**