@vitrina/api 15.19.0 → 15.21.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.
Files changed (3) hide show
  1. package/dist/index.d.cts +2477 -147
  2. package/dist/index.d.ts +2477 -147
  3. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -74388,6 +74388,7 @@ interface paths {
74388
74388
  * "operation_id": null,
74389
74389
  * "payer": null,
74390
74390
  * "comment_count": 0,
74391
+ * "ads_document_id": null,
74391
74392
  * "created_at": "2026-10-28T09:00:00.000Z"
74392
74393
  * }
74393
74394
  * },
@@ -75229,6 +75230,7 @@ interface paths {
75229
75230
  * "operation_id": null,
75230
75231
  * "payer": null,
75231
75232
  * "comment_count": 1,
75233
+ * "ads_document_id": null,
75232
75234
  * "created_at": "2026-10-30T08:00:00.000Z"
75233
75235
  * }
75234
75236
  * ],
@@ -75385,6 +75387,7 @@ interface paths {
75385
75387
  * "operation_id": null,
75386
75388
  * "payer": null,
75387
75389
  * "comment_count": 1,
75390
+ * "ads_document_id": null,
75388
75391
  * "created_at": "2026-10-30T08:00:00.000Z",
75389
75392
  * "comments": [
75390
75393
  * {
@@ -76078,6 +76081,7 @@ interface paths {
76078
76081
  query?: {
76079
76082
  kind?: "purchase" | "sale" | "honorario" | "manual_expense" | "tax";
76080
76083
  source?: "sii" | "vitrina" | "manual" | "chipax";
76084
+ origin?: "ads";
76081
76085
  period?: string;
76082
76086
  from?: string;
76083
76087
  to?: string;
@@ -80941,6 +80945,7 @@ interface paths {
80941
80945
  * "operation_id": null,
80942
80946
  * "payer": null,
80943
80947
  * "comment_count": 0,
80948
+ * "ads_document_id": null,
80944
80949
  * "created_at": "2026-10-30T08:00:00.000Z"
80945
80950
  * },
80946
80951
  * "money_mirrored": false,
@@ -81476,6 +81481,7 @@ interface paths {
81476
81481
  * "operation_id": null,
81477
81482
  * "payer": null,
81478
81483
  * "comment_count": 0,
81484
+ * "ads_document_id": null,
81479
81485
  * "created_at": "2026-10-30T08:00:00.000Z"
81480
81486
  * },
81481
81487
  * "money_mirrored": false,
@@ -82077,7 +82083,7 @@ interface paths {
82077
82083
  get: {
82078
82084
  parameters: {
82079
82085
  query?: {
82080
- kind?: "reconcile" | "transfer" | "classify" | "missing_document" | "unknown";
82086
+ kind?: "reconcile" | "transfer" | "classify" | "missing_document" | "unknown" | "ads_charge";
82081
82087
  limit?: number;
82082
82088
  offset?: number | null;
82083
82089
  };
@@ -83610,7 +83616,11 @@ interface paths {
83610
83616
  * "unreviewed_count": 4,
83611
83617
  * "unclassified_count": 0,
83612
83618
  * "unmatched_count": 0,
83613
- * "unmatched_pending_clp": 0
83619
+ * "unmatched_movements_count": 0,
83620
+ * "unmatched_documents_count": 0,
83621
+ * "unmatched_pending_clp": 0,
83622
+ * "unmatched_movements_pending_clp": 0,
83623
+ * "unmatched_documents_pending_clp": 0
83614
83624
  * },
83615
83625
  * "close": {
83616
83626
  * "unreviewed_count": 4,
@@ -83656,6 +83666,10 @@ interface paths {
83656
83666
  * "unmatched_movements": {
83657
83667
  * "count": 0,
83658
83668
  * "pending_clp": 0
83669
+ * },
83670
+ * "unmatched_documents": {
83671
+ * "count": 0,
83672
+ * "pending_clp": 0
83659
83673
  * }
83660
83674
  * }
83661
83675
  * },
@@ -83803,7 +83817,11 @@ interface paths {
83803
83817
  * "unreviewed_count": 4,
83804
83818
  * "unclassified_count": 0,
83805
83819
  * "unmatched_count": 0,
83806
- * "unmatched_pending_clp": 0
83820
+ * "unmatched_movements_count": 0,
83821
+ * "unmatched_documents_count": 0,
83822
+ * "unmatched_pending_clp": 0,
83823
+ * "unmatched_movements_pending_clp": 0,
83824
+ * "unmatched_documents_pending_clp": 0
83807
83825
  * },
83808
83826
  * "close": {
83809
83827
  * "unreviewed_count": 4,
@@ -83849,6 +83867,10 @@ interface paths {
83849
83867
  * "unmatched_movements": {
83850
83868
  * "count": 0,
83851
83869
  * "pending_clp": 0
83870
+ * },
83871
+ * "unmatched_documents": {
83872
+ * "count": 0,
83873
+ * "pending_clp": 0
83852
83874
  * }
83853
83875
  * }
83854
83876
  * },
@@ -84087,7 +84109,7 @@ interface paths {
84087
84109
  patch?: never;
84088
84110
  trace?: never;
84089
84111
  };
84090
- "/finanzas/chipax": {
84112
+ "/finanzas/chipax/shadow": {
84091
84113
  parameters: {
84092
84114
  query?: never;
84093
84115
  header?: never;
@@ -84095,8 +84117,8 @@ interface paths {
84095
84117
  cookie?: never;
84096
84118
  };
84097
84119
  /**
84098
- * Importar desde Chipax: connection and runs
84099
- * @description Whether the workspace stored its Chipax API credentials (only a masked App ID hint, never the secret), the run in progress and the last finished one. Vitrina only READS Chipax: it logs in and sends GET requests; it never creates, edits or deletes anything in the Chipax account. Requires the `finanzas` add-on — without it every Finanzas operation answers `402 ENTITLEMENT_NOT_ACTIVE` (`details.required = ["finanzas"]`). Requires `finanzas:read`.
84120
+ * Mes en paralelo: the months read from Chipax
84121
+ * @description Each month with a Chipax read, newest first: its newest read (any status) and when it was last read successfully. Requires the `finanzas` add-on — without it every Finanzas operation answers `402 ENTITLEMENT_NOT_ACTIVE` (`details.required = ["finanzas"]`). Requires `finanzas:read` and `finanzas_reports:read` (the Contador seat, owners and admins).
84100
84122
  */
84101
84123
  get: {
84102
84124
  parameters: {
@@ -84107,7 +84129,7 @@ interface paths {
84107
84129
  };
84108
84130
  requestBody?: never;
84109
84131
  responses: {
84110
- /** @description Connection and runs */
84132
+ /** @description Months */
84111
84133
  200: {
84112
84134
  headers: {
84113
84135
  [name: string]: unknown;
@@ -84115,30 +84137,51 @@ interface paths {
84115
84137
  content: {
84116
84138
  /**
84117
84139
  * @example {
84118
- * "data": {
84119
- * "connected": true,
84120
- * "app_id_preview": "a1b…9f2",
84121
- * "verified_at": "2026-10-30T21:58:40.000Z",
84122
- * "active_import": null,
84123
- * "last_import": {
84124
- * "id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f5a16",
84125
- * "mode": "dry_run",
84126
- * "status": "done",
84127
- * "from": "2025-01-01",
84128
- * "to": "2026-10-30",
84129
- * "account_map": [],
84130
- * "requested_by": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f4f01",
84131
- * "error": null,
84132
- * "started_at": "2026-10-30T22:01:04.000Z",
84133
- * "finished_at": "2026-10-30T22:14:51.000Z",
84134
- * "created_at": "2026-10-30T22:01:02.000Z",
84135
- * "report": null
84140
+ * "data": [
84141
+ * {
84142
+ * "month": "2026-10",
84143
+ * "label": "octubre 2026",
84144
+ * "latest_read": {
84145
+ * "id": "01930000-0000-7000-8000-000000000017",
84146
+ * "month": "2026-10",
84147
+ * "status": "done",
84148
+ * "history_from": "2025-01-01",
84149
+ * "error": null,
84150
+ * "requested_by": "00000000-0000-4000-8000-000000000001",
84151
+ * "started_at": null,
84152
+ * "finished_at": null,
84153
+ * "created_at": "2026-11-02T12:00:00.000Z"
84154
+ * },
84155
+ * "read_at": "2026-11-02T12:04:10.000Z"
84136
84156
  * }
84137
- * }
84157
+ * ]
84138
84158
  * }
84139
84159
  */
84140
84160
  "application/json": {
84141
- data: components["schemas"]["FinanzasChipaxStatus"];
84161
+ data: {
84162
+ month: string;
84163
+ /** @description «septiembre 2026». */
84164
+ label: string;
84165
+ latest_read: {
84166
+ /** Format: uuid */
84167
+ id: string;
84168
+ month: string;
84169
+ /** @enum {string} */
84170
+ status: "queued" | "running" | "done" | "failed";
84171
+ /** @description Payables are compared among documents issued since this day (the earliest Chipax import, else a year before the month). */
84172
+ history_from: string;
84173
+ error: string | null;
84174
+ requested_by: string | null;
84175
+ /** @description ISO 8601 timestamp. */
84176
+ started_at: string | null;
84177
+ /** @description ISO 8601 timestamp. */
84178
+ finished_at: string | null;
84179
+ /** @description ISO 8601 timestamp. */
84180
+ created_at: string;
84181
+ };
84182
+ /** @description When the month was last read successfully. */
84183
+ read_at: string | null;
84184
+ }[];
84142
84185
  };
84143
84186
  };
84144
84187
  };
@@ -84199,37 +84242,161 @@ interface paths {
84199
84242
  };
84200
84243
  };
84201
84244
  put?: never;
84202
- post?: never;
84245
+ /**
84246
+ * Mes en paralelo: read Chipax's side of a month
84247
+ * @description Queues a read of Chipax for the month (bank lines and balances, open payables, classified items, Resultado Operacional), over the documents issued since `history_from`. Takes minutes (Chipax's rate limit). One read at a time; refused while a Chipax import runs (409 `import_running`) or another read runs (409 `read_running`); 409 `not_connected` without Chipax credentials; 409 `chipax_credential_unreadable` when the stored credential cannot be decrypted (connect Chipax again). Vitrina only READS Chipax: it logs in and sends GET requests; it never creates, edits or deletes anything in the Chipax account. Requires the `finanzas` add-on — without it every Finanzas operation answers `402 ENTITLEMENT_NOT_ACTIVE` (`details.required = ["finanzas"]`). Requires `finanzas_admin:write`.
84248
+ */
84249
+ post: {
84250
+ parameters: {
84251
+ query?: never;
84252
+ header?: {
84253
+ /** @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. */
84254
+ "Idempotency-Key"?: string;
84255
+ };
84256
+ path?: never;
84257
+ cookie?: never;
84258
+ };
84259
+ requestBody?: {
84260
+ content: {
84261
+ /**
84262
+ * @example {
84263
+ * "month": "2026-10"
84264
+ * }
84265
+ */
84266
+ "application/json": {
84267
+ /** @description The shadow month (default: the month before the current one, America/Santiago). Up to the current month; a future month answers 400. */
84268
+ month?: string;
84269
+ };
84270
+ };
84271
+ };
84272
+ responses: {
84273
+ /** @description Read queued */
84274
+ 202: {
84275
+ headers: {
84276
+ [name: string]: unknown;
84277
+ };
84278
+ content: {
84279
+ /**
84280
+ * @example {
84281
+ * "data": {
84282
+ * "id": "01930000-0000-7000-8000-000000000017",
84283
+ * "month": "2026-10",
84284
+ * "status": "queued",
84285
+ * "history_from": "2025-01-01",
84286
+ * "error": null,
84287
+ * "requested_by": "00000000-0000-4000-8000-000000000001",
84288
+ * "started_at": null,
84289
+ * "finished_at": null,
84290
+ * "created_at": "2026-11-02T12:00:00.000Z"
84291
+ * }
84292
+ * }
84293
+ */
84294
+ "application/json": {
84295
+ data: {
84296
+ /** Format: uuid */
84297
+ id: string;
84298
+ month: string;
84299
+ /** @enum {string} */
84300
+ status: "queued" | "running" | "done" | "failed";
84301
+ /** @description Payables are compared among documents issued since this day (the earliest Chipax import, else a year before the month). */
84302
+ history_from: string;
84303
+ error: string | null;
84304
+ requested_by: string | null;
84305
+ /** @description ISO 8601 timestamp. */
84306
+ started_at: string | null;
84307
+ /** @description ISO 8601 timestamp. */
84308
+ finished_at: string | null;
84309
+ /** @description ISO 8601 timestamp. */
84310
+ created_at: string;
84311
+ };
84312
+ };
84313
+ };
84314
+ };
84315
+ /** @description Validation error */
84316
+ 400: {
84317
+ headers: {
84318
+ [name: string]: unknown;
84319
+ };
84320
+ content: {
84321
+ "application/json": components["schemas"]["Error"];
84322
+ };
84323
+ };
84324
+ /** @description Unauthorized */
84325
+ 401: {
84326
+ headers: {
84327
+ [name: string]: unknown;
84328
+ };
84329
+ content: {
84330
+ "application/json": components["schemas"]["Error"];
84331
+ };
84332
+ };
84333
+ /** @description Forbidden */
84334
+ 403: {
84335
+ headers: {
84336
+ [name: string]: unknown;
84337
+ };
84338
+ content: {
84339
+ "application/json": components["schemas"]["Error"];
84340
+ };
84341
+ };
84342
+ /** @description Not found */
84343
+ 404: {
84344
+ headers: {
84345
+ [name: string]: unknown;
84346
+ };
84347
+ content: {
84348
+ "application/json": components["schemas"]["Error"];
84349
+ };
84350
+ };
84351
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
84352
+ 409: {
84353
+ headers: {
84354
+ [name: string]: unknown;
84355
+ };
84356
+ content: {
84357
+ "application/json": components["schemas"]["Error"];
84358
+ };
84359
+ };
84360
+ /** @description Rate limited */
84361
+ 429: {
84362
+ headers: {
84363
+ [name: string]: unknown;
84364
+ };
84365
+ content: {
84366
+ "application/json": components["schemas"]["Error"];
84367
+ };
84368
+ };
84369
+ };
84370
+ };
84203
84371
  delete?: never;
84204
84372
  options?: never;
84205
84373
  head?: never;
84206
84374
  patch?: never;
84207
84375
  trace?: never;
84208
84376
  };
84209
- "/finanzas/chipax/credentials": {
84377
+ "/finanzas/chipax/shadow/{month}": {
84210
84378
  parameters: {
84211
84379
  query?: never;
84212
84380
  header?: never;
84213
84381
  path?: never;
84214
84382
  cookie?: never;
84215
84383
  };
84216
- get?: never;
84217
- put?: never;
84218
- post?: never;
84219
84384
  /**
84220
- * Importar desde Chipax: «Eliminar credenciales»
84221
- * @description Deletes the stored Chipax credentials. What was already imported stays. Idempotent. Requires the `finanzas` add-on — without it every Finanzas operation answers `402 ENTITLEMENT_NOT_ACTIVE` (`details.required = ["finanzas"]`). Requires `finanzas_admin:write`.
84385
+ * Mes en paralelo: the diff against Chipax for a month
84386
+ * @description Balances (per bank account, at month end), payables (per Contraparte, open at month end) and costs (per costo / gasto account, NET as the Resultado counts) must match to the peso. Income is a bridge: Chipax counts it when cashed, Vitrina the documents issued in the month, so the gap is explained line by line. Vitrina's side is computed live; Chipax's side is the newest finished read. `clean` = all three match and the bridge is explained (the exit criterion). Each row's `key` drills down to its items. Before a finished read: `status` not_read / reading / failed and null dimensions. A caller without the patient register (the Contador) sees a patient as «Paciente A. P.» with no RUT and no glosa, on both sides; Chipax boletas carry neither RUT nor name. Requires the `finanzas` add-on — without it every Finanzas operation answers `402 ENTITLEMENT_NOT_ACTIVE` (`details.required = ["finanzas"]`). Requires `finanzas:read` and `finanzas_reports:read` (the Contador seat, owners and admins).
84222
84387
  */
84223
- delete: {
84388
+ get: {
84224
84389
  parameters: {
84225
84390
  query?: never;
84226
84391
  header?: never;
84227
- path?: never;
84392
+ path: {
84393
+ month: string;
84394
+ };
84228
84395
  cookie?: never;
84229
84396
  };
84230
84397
  requestBody?: never;
84231
84398
  responses: {
84232
- /** @description Deleted */
84399
+ /** @description The diff */
84233
84400
  200: {
84234
84401
  headers: {
84235
84402
  [name: string]: unknown;
@@ -84238,29 +84405,873 @@ interface paths {
84238
84405
  /**
84239
84406
  * @example {
84240
84407
  * "data": {
84241
- * "connected": false,
84242
- * "app_id_preview": null,
84243
- * "verified_at": null,
84244
- * "active_import": null,
84245
- * "last_import": {
84246
- * "id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f5a16",
84247
- * "mode": "dry_run",
84408
+ * "month": "2026-10",
84409
+ * "label": "octubre 2026",
84410
+ * "status": "ready",
84411
+ * "read": {
84412
+ * "id": "01930000-0000-7000-8000-000000000017",
84413
+ * "month": "2026-10",
84248
84414
  * "status": "done",
84249
- * "from": "2025-01-01",
84250
- * "to": "2026-10-30",
84251
- * "account_map": [],
84252
- * "requested_by": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f4f01",
84415
+ * "history_from": "2025-01-01",
84253
84416
  * "error": null,
84254
- * "started_at": "2026-10-30T22:01:04.000Z",
84255
- * "finished_at": "2026-10-30T22:14:51.000Z",
84256
- * "created_at": "2026-10-30T22:01:02.000Z",
84257
- * "report": null
84417
+ * "requested_by": "00000000-0000-4000-8000-000000000001",
84418
+ * "started_at": null,
84419
+ * "finished_at": null,
84420
+ * "created_at": "2026-11-02T12:00:00.000Z"
84421
+ * },
84422
+ * "active_read": null,
84423
+ * "last_error": null,
84424
+ * "history_from": "2025-01-01",
84425
+ * "clean": false,
84426
+ * "warnings": [],
84427
+ * "balances": {
84428
+ * "matches": true,
84429
+ * "difference_count": 0,
84430
+ * "rows": [
84431
+ * {
84432
+ * "key": "bank:01930000-0000-7000-8000-0000000000b1",
84433
+ * "label": "Cuenta corriente",
84434
+ * "chipax_clp": 12480300,
84435
+ * "vitrina_clp": 12480300,
84436
+ * "difference_clp": 0,
84437
+ * "matches": true,
84438
+ * "item_count": 212,
84439
+ * "difference_count": 0,
84440
+ * "basis": "closing",
84441
+ * "vitrina_account": {
84442
+ * "id": "01930000-0000-7000-8000-0000000000b1",
84443
+ * "name": "Cuenta corriente",
84444
+ * "institution_name": "Banco de Chile",
84445
+ * "number_masked": "•••• 4321"
84446
+ * },
84447
+ * "chipax_account": {
84448
+ * "external_id": "881",
84449
+ * "name": "Cuenta corriente",
84450
+ * "bank": "Banco de Chile",
84451
+ * "number_masked": "•••• 4321"
84452
+ * },
84453
+ * "movements": {
84454
+ * "chipax_in_clp": 30100000,
84455
+ * "chipax_out_clp": 27620000,
84456
+ * "vitrina_in_clp": 30100000,
84457
+ * "vitrina_out_clp": 27620000
84458
+ * }
84459
+ * }
84460
+ * ]
84461
+ * },
84462
+ * "payables": {
84463
+ * "matches": false,
84464
+ * "chipax_clp": 4210000,
84465
+ * "vitrina_clp": 3800000,
84466
+ * "difference_clp": 410000,
84467
+ * "difference_count": 1,
84468
+ * "rows": [
84469
+ * {
84470
+ * "key": "p_0000000000000001",
84471
+ * "label": "Laboratorio Dental Andes Ltda",
84472
+ * "chipax_clp": 410000,
84473
+ * "vitrina_clp": null,
84474
+ * "difference_clp": 410000,
84475
+ * "matches": false,
84476
+ * "item_count": 1,
84477
+ * "difference_count": 1,
84478
+ * "rut": "76086428-5",
84479
+ * "contraparte_id": null
84480
+ * }
84481
+ * ]
84482
+ * },
84483
+ * "costs": {
84484
+ * "matches": true,
84485
+ * "chipax_clp": 9340000,
84486
+ * "vitrina_clp": 9340000,
84487
+ * "difference_clp": 0,
84488
+ * "difference_count": 0,
84489
+ * "rows": []
84490
+ * },
84491
+ * "income": {
84492
+ * "bridge": {
84493
+ * "vitrina_clp": 31500000,
84494
+ * "chipax_clp": 30100000,
84495
+ * "difference_clp": -1400000,
84496
+ * "explained": true,
84497
+ * "lines": [
84498
+ * {
84499
+ * "key": "timing_vitrina",
84500
+ * "label": "Emitidos en el mes que Chipax no cuenta en el mes (los cuenta al cobrarlos)",
84501
+ * "amount_clp": -2100000,
84502
+ * "item_count": 14
84503
+ * },
84504
+ * {
84505
+ * "key": "timing_chipax",
84506
+ * "label": "Documentos de otros meses que Chipax cuenta en este mes",
84507
+ * "amount_clp": 700000,
84508
+ * "item_count": 5
84509
+ * }
84510
+ * ]
84511
+ * },
84512
+ * "rows": [],
84513
+ * "production": null
84258
84514
  * }
84259
84515
  * }
84260
84516
  * }
84261
84517
  */
84262
84518
  "application/json": {
84263
- data: components["schemas"]["FinanzasChipaxStatus"];
84519
+ data: {
84520
+ month: string;
84521
+ label: string;
84522
+ /** @enum {string} */
84523
+ status: "not_read" | "reading" | "ready" | "failed";
84524
+ read: {
84525
+ /** Format: uuid */
84526
+ id: string;
84527
+ month: string;
84528
+ /** @enum {string} */
84529
+ status: "queued" | "running" | "done" | "failed";
84530
+ /** @description Payables are compared among documents issued since this day (the earliest Chipax import, else a year before the month). */
84531
+ history_from: string;
84532
+ error: string | null;
84533
+ requested_by: string | null;
84534
+ /** @description ISO 8601 timestamp. */
84535
+ started_at: string | null;
84536
+ /** @description ISO 8601 timestamp. */
84537
+ finished_at: string | null;
84538
+ /** @description ISO 8601 timestamp. */
84539
+ created_at: string;
84540
+ } | null;
84541
+ active_read: {
84542
+ /** Format: uuid */
84543
+ id: string;
84544
+ month: string;
84545
+ /** @enum {string} */
84546
+ status: "queued" | "running" | "done" | "failed";
84547
+ /** @description Payables are compared among documents issued since this day (the earliest Chipax import, else a year before the month). */
84548
+ history_from: string;
84549
+ error: string | null;
84550
+ requested_by: string | null;
84551
+ /** @description ISO 8601 timestamp. */
84552
+ started_at: string | null;
84553
+ /** @description ISO 8601 timestamp. */
84554
+ finished_at: string | null;
84555
+ /** @description ISO 8601 timestamp. */
84556
+ created_at: string;
84557
+ } | null;
84558
+ last_error: string | null;
84559
+ history_from: string | null;
84560
+ /** @description Balances, payables and costs match and the income bridge is fully explained: the exit criterion of the shadow month. */
84561
+ clean: boolean | null;
84562
+ warnings: string[];
84563
+ balances: {
84564
+ matches: boolean;
84565
+ difference_count: number;
84566
+ rows: {
84567
+ /** @description Pass as `key` to the items endpoint. */
84568
+ key: string;
84569
+ label: string;
84570
+ /** @description Whole CLP. */
84571
+ chipax_clp: number | null;
84572
+ /** @description Whole CLP. */
84573
+ vitrina_clp: number | null;
84574
+ /** @description Chipax − Vitrina. */
84575
+ difference_clp: number;
84576
+ /** @description Zero tolerance: equal figures AND every item pairs. */
84577
+ matches: boolean;
84578
+ item_count: number;
84579
+ difference_count: number;
84580
+ /**
84581
+ * @description paired: both sides have the account (zero tolerance). only_vitrina: Chipax never tracked it (e.g. Mercado Pago); shown, never breaks `clean`, difference_clp is 0 and it has no items. only_chipax: Vitrina lacks the account; breaks `clean`.
84582
+ * @enum {string}
84583
+ */
84584
+ side: "paired" | "only_vitrina" | "only_chipax";
84585
+ /**
84586
+ * @description closing = balances at month end; movements = the month's net movements (a side has no balance).
84587
+ * @enum {string}
84588
+ */
84589
+ basis: "closing" | "movements";
84590
+ vitrina_account: {
84591
+ id: string;
84592
+ name: string;
84593
+ institution_name: string | null;
84594
+ number_masked: string | null;
84595
+ } | null;
84596
+ chipax_account: {
84597
+ /** @description Chipax's id of the account. */
84598
+ external_id: string;
84599
+ name: string | null;
84600
+ bank: string | null;
84601
+ number_masked: string | null;
84602
+ } | null;
84603
+ movements: {
84604
+ /** @description Whole CLP. */
84605
+ chipax_in_clp: number;
84606
+ /** @description Whole CLP. */
84607
+ chipax_out_clp: number;
84608
+ /** @description Whole CLP. */
84609
+ vitrina_in_clp: number;
84610
+ /** @description Whole CLP. */
84611
+ vitrina_out_clp: number;
84612
+ };
84613
+ }[];
84614
+ } | null;
84615
+ payables: {
84616
+ matches: boolean;
84617
+ /** @description Whole CLP. */
84618
+ chipax_clp: number;
84619
+ /** @description Whole CLP. */
84620
+ vitrina_clp: number;
84621
+ /** @description Whole CLP. */
84622
+ difference_clp: number;
84623
+ difference_count: number;
84624
+ rows: {
84625
+ /** @description Pass as `key` to the items endpoint. */
84626
+ key: string;
84627
+ label: string;
84628
+ /** @description Whole CLP. */
84629
+ chipax_clp: number | null;
84630
+ /** @description Whole CLP. */
84631
+ vitrina_clp: number | null;
84632
+ /** @description Chipax − Vitrina. */
84633
+ difference_clp: number;
84634
+ /** @description Zero tolerance: equal figures AND every item pairs. */
84635
+ matches: boolean;
84636
+ item_count: number;
84637
+ difference_count: number;
84638
+ rut: string | null;
84639
+ contraparte_id: string | null;
84640
+ }[];
84641
+ } | null;
84642
+ costs: {
84643
+ matches: boolean;
84644
+ /** @description Whole CLP. */
84645
+ chipax_clp: number;
84646
+ /** @description Whole CLP. */
84647
+ vitrina_clp: number;
84648
+ /** @description Whole CLP. */
84649
+ difference_clp: number;
84650
+ difference_count: number;
84651
+ rows: {
84652
+ /** @description Pass as `key` to the items endpoint. */
84653
+ key: string;
84654
+ label: string;
84655
+ /** @description Whole CLP. */
84656
+ chipax_clp: number | null;
84657
+ /** @description Whole CLP. */
84658
+ vitrina_clp: number | null;
84659
+ /** @description Chipax − Vitrina. */
84660
+ difference_clp: number;
84661
+ /** @description Zero tolerance: equal figures AND every item pairs. */
84662
+ matches: boolean;
84663
+ item_count: number;
84664
+ difference_count: number;
84665
+ vitrina_account: {
84666
+ id: string;
84667
+ name: string;
84668
+ path: string;
84669
+ kind: string;
84670
+ } | null;
84671
+ chipax_accounts: {
84672
+ external_id: number;
84673
+ name: string;
84674
+ path: string;
84675
+ }[];
84676
+ }[];
84677
+ } | null;
84678
+ income: {
84679
+ bridge: {
84680
+ /** @description Whole CLP. */
84681
+ vitrina_clp: number;
84682
+ /** @description Whole CLP. */
84683
+ chipax_clp: number;
84684
+ /** @description Whole CLP. */
84685
+ difference_clp: number;
84686
+ explained: boolean;
84687
+ lines: {
84688
+ /** @enum {string} */
84689
+ key: "timing_vitrina" | "timing_chipax" | "document_not_in_vitrina" | "cash_without_document" | "amount_basis" | "unitemised";
84690
+ label: string;
84691
+ /** @description Whole CLP. */
84692
+ amount_clp: number;
84693
+ item_count: number;
84694
+ }[];
84695
+ };
84696
+ rows: {
84697
+ /** @description Pass as `key` to the items endpoint. */
84698
+ key: string;
84699
+ label: string;
84700
+ /** @description Whole CLP. */
84701
+ chipax_clp: number | null;
84702
+ /** @description Whole CLP. */
84703
+ vitrina_clp: number | null;
84704
+ /** @description Chipax − Vitrina. */
84705
+ difference_clp: number;
84706
+ /** @description Zero tolerance: equal figures AND every item pairs. */
84707
+ matches: boolean;
84708
+ item_count: number;
84709
+ difference_count: number;
84710
+ vitrina_account: {
84711
+ id: string;
84712
+ name: string;
84713
+ path: string;
84714
+ kind: string;
84715
+ } | null;
84716
+ chipax_accounts: {
84717
+ external_id: number;
84718
+ name: string;
84719
+ path: string;
84720
+ }[];
84721
+ }[];
84722
+ production: {
84723
+ /** @description Whole CLP. */
84724
+ produccion_clp: number;
84725
+ /** @description Whole CLP. */
84726
+ por_cobrar_clp: number;
84727
+ /** @description Whole CLP. */
84728
+ anticipos_clp: number;
84729
+ /** @description Whole CLP. */
84730
+ cobrado_clp: number;
84731
+ /** @description Whole CLP. */
84732
+ boleteado_clp: number;
84733
+ /** @description Whole CLP. */
84734
+ cobrado_sin_boleta_clp: number;
84735
+ /** @description Whole CLP. */
84736
+ boletas_sin_pago_clp: number;
84737
+ } | null;
84738
+ } | null;
84739
+ };
84740
+ };
84741
+ };
84742
+ };
84743
+ /** @description Validation error */
84744
+ 400: {
84745
+ headers: {
84746
+ [name: string]: unknown;
84747
+ };
84748
+ content: {
84749
+ "application/json": components["schemas"]["Error"];
84750
+ };
84751
+ };
84752
+ /** @description Unauthorized */
84753
+ 401: {
84754
+ headers: {
84755
+ [name: string]: unknown;
84756
+ };
84757
+ content: {
84758
+ "application/json": components["schemas"]["Error"];
84759
+ };
84760
+ };
84761
+ /** @description Forbidden */
84762
+ 403: {
84763
+ headers: {
84764
+ [name: string]: unknown;
84765
+ };
84766
+ content: {
84767
+ "application/json": components["schemas"]["Error"];
84768
+ };
84769
+ };
84770
+ /** @description Not found */
84771
+ 404: {
84772
+ headers: {
84773
+ [name: string]: unknown;
84774
+ };
84775
+ content: {
84776
+ "application/json": components["schemas"]["Error"];
84777
+ };
84778
+ };
84779
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
84780
+ 409: {
84781
+ headers: {
84782
+ [name: string]: unknown;
84783
+ };
84784
+ content: {
84785
+ "application/json": components["schemas"]["Error"];
84786
+ };
84787
+ };
84788
+ /** @description Rate limited */
84789
+ 429: {
84790
+ headers: {
84791
+ [name: string]: unknown;
84792
+ };
84793
+ content: {
84794
+ "application/json": components["schemas"]["Error"];
84795
+ };
84796
+ };
84797
+ };
84798
+ };
84799
+ put?: never;
84800
+ post?: never;
84801
+ delete?: never;
84802
+ options?: never;
84803
+ head?: never;
84804
+ patch?: never;
84805
+ trace?: never;
84806
+ };
84807
+ "/finanzas/chipax/shadow/{month}/items": {
84808
+ parameters: {
84809
+ query?: never;
84810
+ header?: never;
84811
+ path?: never;
84812
+ cookie?: never;
84813
+ };
84814
+ /**
84815
+ * Mes en paralelo: the items behind a row
84816
+ * @description The items of one row of the diff (`key` from the diff; `bridge:<line>` for an income bridge line), both sides side by side, biggest difference first. By default only the items that do not match. A caller without the patient register (the Contador) sees a patient as «Paciente A. P.» with no RUT and no glosa, on both sides; Chipax boletas carry neither RUT nor name. Requires the `finanzas` add-on — without it every Finanzas operation answers `402 ENTITLEMENT_NOT_ACTIVE` (`details.required = ["finanzas"]`). Requires `finanzas:read` and `finanzas_reports:read` (the Contador seat, owners and admins). 404 before a finished read.
84817
+ */
84818
+ get: {
84819
+ parameters: {
84820
+ query: {
84821
+ dimension: "balances" | "payables" | "costs" | "income";
84822
+ key?: string;
84823
+ status?: "differences" | "all";
84824
+ limit?: number;
84825
+ offset?: number | null;
84826
+ };
84827
+ header?: never;
84828
+ path: {
84829
+ month: string;
84830
+ };
84831
+ cookie?: never;
84832
+ };
84833
+ requestBody?: never;
84834
+ responses: {
84835
+ /** @description Items */
84836
+ 200: {
84837
+ headers: {
84838
+ [name: string]: unknown;
84839
+ };
84840
+ content: {
84841
+ /**
84842
+ * @example {
84843
+ * "data": {
84844
+ * "month": "2026-10",
84845
+ * "dimension": "payables",
84846
+ * "key": "p_0000000000000001",
84847
+ * "items": [
84848
+ * {
84849
+ * "key": "chipax:compra:9002",
84850
+ * "row_key": "p_0000000000000001",
84851
+ * "other_row_key": null,
84852
+ * "status": "chipax_only",
84853
+ * "chipax": {
84854
+ * "type": "document",
84855
+ * "id": null,
84856
+ * "chipax_ref": "compra:9002",
84857
+ * "label": "Factura electrónica N° 452",
84858
+ * "dte_type": 33,
84859
+ * "day": "2026-10-05",
84860
+ * "amount_clp": 410000,
84861
+ * "counterparty_name": "Laboratorio Dental Andes Ltda",
84862
+ * "counterparty_rut": "76086428-5",
84863
+ * "description": null
84864
+ * },
84865
+ * "vitrina": null,
84866
+ * "vitrina_document_id": null,
84867
+ * "difference_clp": 410000,
84868
+ * "bridge_line": null
84869
+ * }
84870
+ * ],
84871
+ * "total": 1,
84872
+ * "limit": 50,
84873
+ * "offset": 0,
84874
+ * "difference_clp": 410000
84875
+ * }
84876
+ * }
84877
+ */
84878
+ "application/json": {
84879
+ data: {
84880
+ month: string;
84881
+ /** @enum {string} */
84882
+ dimension: "balances" | "payables" | "costs" | "income";
84883
+ key: string | null;
84884
+ items: {
84885
+ key: string;
84886
+ row_key: string;
84887
+ other_row_key: string | null;
84888
+ /**
84889
+ * @description match; chipax_only / vitrina_only; amount = both, different amounts; other_row = the other side has it under another row (account or Contraparte); unitemised = Chipax's total holds pesos with no item behind them.
84890
+ * @enum {string}
84891
+ */
84892
+ status: "match" | "chipax_only" | "vitrina_only" | "amount" | "other_row" | "unitemised";
84893
+ chipax: {
84894
+ /** @enum {string} */
84895
+ type: "document" | "movement" | "total";
84896
+ /** @description Vitrina: the document or bank movement id. Chipax: null. */
84897
+ id: string | null;
84898
+ /** @description Chipax: `<model>:<id>` or `cartola:<id>`. Vitrina: null. */
84899
+ chipax_ref: string | null;
84900
+ /** @description «Factura electrónica N° 451». */
84901
+ label: string;
84902
+ dte_type: number | null;
84903
+ day: string | null;
84904
+ /** @description Signed, as the dimension counts it (money in +, out −, on balances). */
84905
+ amount_clp: number;
84906
+ counterparty_name: string | null;
84907
+ counterparty_rut: string | null;
84908
+ description: string | null;
84909
+ } | null;
84910
+ vitrina: {
84911
+ /** @enum {string} */
84912
+ type: "document" | "movement" | "total";
84913
+ /** @description Vitrina: the document or bank movement id. Chipax: null. */
84914
+ id: string | null;
84915
+ /** @description Chipax: `<model>:<id>` or `cartola:<id>`. Vitrina: null. */
84916
+ chipax_ref: string | null;
84917
+ /** @description «Factura electrónica N° 451». */
84918
+ label: string;
84919
+ dte_type: number | null;
84920
+ day: string | null;
84921
+ /** @description Signed, as the dimension counts it (money in +, out −, on balances). */
84922
+ amount_clp: number;
84923
+ counterparty_name: string | null;
84924
+ counterparty_rut: string | null;
84925
+ description: string | null;
84926
+ } | null;
84927
+ vitrina_document_id: string | null;
84928
+ /** @description Chipax − Vitrina. */
84929
+ difference_clp: number;
84930
+ /** @enum {string|null} */
84931
+ bridge_line: "timing_vitrina" | "timing_chipax" | "document_not_in_vitrina" | "cash_without_document" | "amount_basis" | "unitemised" | null;
84932
+ }[];
84933
+ total: number;
84934
+ limit: number;
84935
+ offset: number;
84936
+ /** @description Whole CLP. */
84937
+ difference_clp: number;
84938
+ };
84939
+ };
84940
+ };
84941
+ };
84942
+ /** @description Validation error */
84943
+ 400: {
84944
+ headers: {
84945
+ [name: string]: unknown;
84946
+ };
84947
+ content: {
84948
+ "application/json": components["schemas"]["Error"];
84949
+ };
84950
+ };
84951
+ /** @description Unauthorized */
84952
+ 401: {
84953
+ headers: {
84954
+ [name: string]: unknown;
84955
+ };
84956
+ content: {
84957
+ "application/json": components["schemas"]["Error"];
84958
+ };
84959
+ };
84960
+ /** @description Forbidden */
84961
+ 403: {
84962
+ headers: {
84963
+ [name: string]: unknown;
84964
+ };
84965
+ content: {
84966
+ "application/json": components["schemas"]["Error"];
84967
+ };
84968
+ };
84969
+ /** @description Not found */
84970
+ 404: {
84971
+ headers: {
84972
+ [name: string]: unknown;
84973
+ };
84974
+ content: {
84975
+ "application/json": components["schemas"]["Error"];
84976
+ };
84977
+ };
84978
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
84979
+ 409: {
84980
+ headers: {
84981
+ [name: string]: unknown;
84982
+ };
84983
+ content: {
84984
+ "application/json": components["schemas"]["Error"];
84985
+ };
84986
+ };
84987
+ /** @description Rate limited */
84988
+ 429: {
84989
+ headers: {
84990
+ [name: string]: unknown;
84991
+ };
84992
+ content: {
84993
+ "application/json": components["schemas"]["Error"];
84994
+ };
84995
+ };
84996
+ };
84997
+ };
84998
+ put?: never;
84999
+ post?: never;
85000
+ delete?: never;
85001
+ options?: never;
85002
+ head?: never;
85003
+ patch?: never;
85004
+ trace?: never;
85005
+ };
85006
+ "/finanzas/chipax/shadow/{month}/export": {
85007
+ parameters: {
85008
+ query?: never;
85009
+ header?: never;
85010
+ path?: never;
85011
+ cookie?: never;
85012
+ };
85013
+ /**
85014
+ * Mes en paralelo: download the diff (xlsx)
85015
+ * @description One workbook: «Resumen», «Saldos bancarios», «Por pagar», «Costos y gastos», «Puente de ingresos» and «Diferencias» (every item that does not match, all dimensions). A caller without the patient register (the Contador) sees a patient as «Paciente A. P.» with no RUT and no glosa, on both sides; Chipax boletas carry neither RUT nor name. Requires the `finanzas` add-on — without it every Finanzas operation answers `402 ENTITLEMENT_NOT_ACTIVE` (`details.required = ["finanzas"]`). Requires `finanzas:read`, `finanzas_reports:read` and `finanzas:export`. 404 before a finished read.
85016
+ */
85017
+ get: {
85018
+ parameters: {
85019
+ query?: never;
85020
+ header?: never;
85021
+ path: {
85022
+ month: string;
85023
+ };
85024
+ cookie?: never;
85025
+ };
85026
+ requestBody?: never;
85027
+ responses: {
85028
+ /** @description The workbook, as an attachment */
85029
+ 200: {
85030
+ headers: {
85031
+ [name: string]: unknown;
85032
+ };
85033
+ content: {
85034
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": string;
85035
+ };
85036
+ };
85037
+ /** @description Validation error */
85038
+ 400: {
85039
+ headers: {
85040
+ [name: string]: unknown;
85041
+ };
85042
+ content: {
85043
+ "application/json": components["schemas"]["Error"];
85044
+ };
85045
+ };
85046
+ /** @description Unauthorized */
85047
+ 401: {
85048
+ headers: {
85049
+ [name: string]: unknown;
85050
+ };
85051
+ content: {
85052
+ "application/json": components["schemas"]["Error"];
85053
+ };
85054
+ };
85055
+ /** @description Forbidden */
85056
+ 403: {
85057
+ headers: {
85058
+ [name: string]: unknown;
85059
+ };
85060
+ content: {
85061
+ "application/json": components["schemas"]["Error"];
85062
+ };
85063
+ };
85064
+ /** @description Not found */
85065
+ 404: {
85066
+ headers: {
85067
+ [name: string]: unknown;
85068
+ };
85069
+ content: {
85070
+ "application/json": components["schemas"]["Error"];
85071
+ };
85072
+ };
85073
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
85074
+ 409: {
85075
+ headers: {
85076
+ [name: string]: unknown;
85077
+ };
85078
+ content: {
85079
+ "application/json": components["schemas"]["Error"];
85080
+ };
85081
+ };
85082
+ /** @description Rate limited */
85083
+ 429: {
85084
+ headers: {
85085
+ [name: string]: unknown;
85086
+ };
85087
+ content: {
85088
+ "application/json": components["schemas"]["Error"];
85089
+ };
85090
+ };
85091
+ };
85092
+ };
85093
+ put?: never;
85094
+ post?: never;
85095
+ delete?: never;
85096
+ options?: never;
85097
+ head?: never;
85098
+ patch?: never;
85099
+ trace?: never;
85100
+ };
85101
+ "/finanzas/chipax": {
85102
+ parameters: {
85103
+ query?: never;
85104
+ header?: never;
85105
+ path?: never;
85106
+ cookie?: never;
85107
+ };
85108
+ /**
85109
+ * Importar desde Chipax: connection and runs
85110
+ * @description Whether the workspace stored its Chipax API credentials (only a masked App ID hint, never the secret), the run in progress and the last finished one. Vitrina only READS Chipax: it logs in and sends GET requests; it never creates, edits or deletes anything in the Chipax account. Requires the `finanzas` add-on — without it every Finanzas operation answers `402 ENTITLEMENT_NOT_ACTIVE` (`details.required = ["finanzas"]`). Requires `finanzas:read`.
85111
+ */
85112
+ get: {
85113
+ parameters: {
85114
+ query?: never;
85115
+ header?: never;
85116
+ path?: never;
85117
+ cookie?: never;
85118
+ };
85119
+ requestBody?: never;
85120
+ responses: {
85121
+ /** @description Connection and runs */
85122
+ 200: {
85123
+ headers: {
85124
+ [name: string]: unknown;
85125
+ };
85126
+ content: {
85127
+ /**
85128
+ * @example {
85129
+ * "data": {
85130
+ * "connected": true,
85131
+ * "app_id_preview": "a1b…9f2",
85132
+ * "verified_at": "2026-10-30T21:58:40.000Z",
85133
+ * "active_import": null,
85134
+ * "last_import": {
85135
+ * "id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f5a16",
85136
+ * "mode": "dry_run",
85137
+ * "status": "done",
85138
+ * "from": "2025-01-01",
85139
+ * "to": "2026-10-30",
85140
+ * "account_map": [],
85141
+ * "requested_by": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f4f01",
85142
+ * "error": null,
85143
+ * "started_at": "2026-10-30T22:01:04.000Z",
85144
+ * "finished_at": "2026-10-30T22:14:51.000Z",
85145
+ * "created_at": "2026-10-30T22:01:02.000Z",
85146
+ * "report": null
85147
+ * }
85148
+ * }
85149
+ * }
85150
+ */
85151
+ "application/json": {
85152
+ data: components["schemas"]["FinanzasChipaxStatus"];
85153
+ };
85154
+ };
85155
+ };
85156
+ /** @description Validation error */
85157
+ 400: {
85158
+ headers: {
85159
+ [name: string]: unknown;
85160
+ };
85161
+ content: {
85162
+ "application/json": components["schemas"]["Error"];
85163
+ };
85164
+ };
85165
+ /** @description Unauthorized */
85166
+ 401: {
85167
+ headers: {
85168
+ [name: string]: unknown;
85169
+ };
85170
+ content: {
85171
+ "application/json": components["schemas"]["Error"];
85172
+ };
85173
+ };
85174
+ /** @description Forbidden */
85175
+ 403: {
85176
+ headers: {
85177
+ [name: string]: unknown;
85178
+ };
85179
+ content: {
85180
+ "application/json": components["schemas"]["Error"];
85181
+ };
85182
+ };
85183
+ /** @description Not found */
85184
+ 404: {
85185
+ headers: {
85186
+ [name: string]: unknown;
85187
+ };
85188
+ content: {
85189
+ "application/json": components["schemas"]["Error"];
85190
+ };
85191
+ };
85192
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
85193
+ 409: {
85194
+ headers: {
85195
+ [name: string]: unknown;
85196
+ };
85197
+ content: {
85198
+ "application/json": components["schemas"]["Error"];
85199
+ };
85200
+ };
85201
+ /** @description Rate limited */
85202
+ 429: {
85203
+ headers: {
85204
+ [name: string]: unknown;
85205
+ };
85206
+ content: {
85207
+ "application/json": components["schemas"]["Error"];
85208
+ };
85209
+ };
85210
+ };
85211
+ };
85212
+ put?: never;
85213
+ post?: never;
85214
+ delete?: never;
85215
+ options?: never;
85216
+ head?: never;
85217
+ patch?: never;
85218
+ trace?: never;
85219
+ };
85220
+ "/finanzas/chipax/credentials": {
85221
+ parameters: {
85222
+ query?: never;
85223
+ header?: never;
85224
+ path?: never;
85225
+ cookie?: never;
85226
+ };
85227
+ get?: never;
85228
+ put?: never;
85229
+ post?: never;
85230
+ /**
85231
+ * Importar desde Chipax: «Eliminar credenciales»
85232
+ * @description Deletes the stored Chipax credentials. What was already imported stays. Idempotent. Requires the `finanzas` add-on — without it every Finanzas operation answers `402 ENTITLEMENT_NOT_ACTIVE` (`details.required = ["finanzas"]`). Requires `finanzas_admin:write`.
85233
+ */
85234
+ delete: {
85235
+ parameters: {
85236
+ query?: never;
85237
+ header?: never;
85238
+ path?: never;
85239
+ cookie?: never;
85240
+ };
85241
+ requestBody?: never;
85242
+ responses: {
85243
+ /** @description Deleted */
85244
+ 200: {
85245
+ headers: {
85246
+ [name: string]: unknown;
85247
+ };
85248
+ content: {
85249
+ /**
85250
+ * @example {
85251
+ * "data": {
85252
+ * "connected": false,
85253
+ * "app_id_preview": null,
85254
+ * "verified_at": null,
85255
+ * "active_import": null,
85256
+ * "last_import": {
85257
+ * "id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f5a16",
85258
+ * "mode": "dry_run",
85259
+ * "status": "done",
85260
+ * "from": "2025-01-01",
85261
+ * "to": "2026-10-30",
85262
+ * "account_map": [],
85263
+ * "requested_by": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f4f01",
85264
+ * "error": null,
85265
+ * "started_at": "2026-10-30T22:01:04.000Z",
85266
+ * "finished_at": "2026-10-30T22:14:51.000Z",
85267
+ * "created_at": "2026-10-30T22:01:02.000Z",
85268
+ * "report": null
85269
+ * }
85270
+ * }
85271
+ * }
85272
+ */
85273
+ "application/json": {
85274
+ data: components["schemas"]["FinanzasChipaxStatus"];
84264
85275
  };
84265
85276
  };
84266
85277
  };
@@ -86135,6 +87146,7 @@ interface paths {
86135
87146
  query?: {
86136
87147
  from?: string;
86137
87148
  to?: string;
87149
+ horizon_days?: number;
86138
87150
  granularity?: "day" | "week";
86139
87151
  };
86140
87152
  header?: never;
@@ -86265,6 +87277,10 @@ interface paths {
86265
87277
  * "receivables_clp": 0,
86266
87278
  * "receivables_count": 0
86267
87279
  * },
87280
+ * "typical_income": {
87281
+ * "basis": "history",
87282
+ * "weeks": 12
87283
+ * },
86268
87284
  * "band_basis": {
86269
87285
  * "from": "2026-08-01",
86270
87286
  * "to": "2026-10-29",
@@ -86611,6 +87627,7 @@ interface paths {
86611
87627
  parameters: {
86612
87628
  query?: {
86613
87629
  dry_run?: "true" | "false";
87630
+ horizon_days?: number;
86614
87631
  };
86615
87632
  header?: {
86616
87633
  /** @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. */
@@ -86721,6 +87738,10 @@ interface paths {
86721
87738
  * "high_clp": 4020000
86722
87739
  * }
86723
87740
  * }
87741
+ * },
87742
+ * "horizon": {
87743
+ * "days": 30,
87744
+ * "to": "2026-11-30"
86724
87745
  * }
86725
87746
  * }
86726
87747
  * }
@@ -86809,7 +87830,9 @@ interface paths {
86809
87830
  */
86810
87831
  delete: {
86811
87832
  parameters: {
86812
- query?: never;
87833
+ query?: {
87834
+ horizon_days?: number;
87835
+ };
86813
87836
  header?: never;
86814
87837
  path: {
86815
87838
  id: string;
@@ -86899,6 +87922,10 @@ interface paths {
86899
87922
  * "high_clp": 4020000
86900
87923
  * }
86901
87924
  * }
87925
+ * },
87926
+ * "horizon": {
87927
+ * "days": 30,
87928
+ * "to": "2026-11-30"
86902
87929
  * }
86903
87930
  * }
86904
87931
  * }
@@ -86987,6 +88014,7 @@ interface paths {
86987
88014
  parameters: {
86988
88015
  query?: {
86989
88016
  dry_run?: "true" | "false";
88017
+ horizon_days?: number;
86990
88018
  };
86991
88019
  header?: {
86992
88020
  /** @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. */
@@ -87083,6 +88111,10 @@ interface paths {
87083
88111
  * "high_clp": 4020000
87084
88112
  * }
87085
88113
  * }
88114
+ * },
88115
+ * "horizon": {
88116
+ * "days": 30,
88117
+ * "to": "2026-11-30"
87086
88118
  * }
87087
88119
  * }
87088
88120
  * }
@@ -87176,6 +88208,10 @@ interface paths {
87176
88208
  * "high_clp": 4020000
87177
88209
  * }
87178
88210
  * }
88211
+ * },
88212
+ * "horizon": {
88213
+ * "days": 30,
88214
+ * "to": "2026-11-30"
87179
88215
  * }
87180
88216
  * }
87181
88217
  * }
@@ -87992,6 +89028,156 @@ interface paths {
87992
89028
  patch?: never;
87993
89029
  trace?: never;
87994
89030
  };
89031
+ "/finanzas/digest/preview": {
89032
+ parameters: {
89033
+ query?: never;
89034
+ header?: never;
89035
+ path?: never;
89036
+ cookie?: never;
89037
+ };
89038
+ /**
89039
+ * Preview the weekly Finanzas digest
89040
+ * @description What this week's «Resumen semanal de Finanzas» says to the caller, read now from the Resumen (`GET /finanzas/resumen`), so the figures match the home. The digest goes out every Monday from 09:00 workspace time, at most once per workspace and week, to every member with `finanzas:read`: email by default, WhatsApp only on the opt-in `finanzas_whatsapp` rail; each member turns it off in their notification preferences (`finanzas.weekly_digest`). A workspace with no finance data gets none (`will_send: false`). Without `finanzas_reports:read` there are no cash or result figures; without the patient roster patients read as initials. Sends nothing. Requires the `finanzas` add-on (402 `ENTITLEMENT_NOT_ACTIVE` otherwise) and `finanzas:read`.
89041
+ */
89042
+ get: {
89043
+ parameters: {
89044
+ query?: never;
89045
+ header?: never;
89046
+ path?: never;
89047
+ cookie?: never;
89048
+ };
89049
+ requestBody?: never;
89050
+ responses: {
89051
+ /** @description The digest as the caller would read it this week */
89052
+ 200: {
89053
+ headers: {
89054
+ [name: string]: unknown;
89055
+ };
89056
+ content: {
89057
+ /**
89058
+ * @example {
89059
+ * "data": {
89060
+ * "week_start": "2026-11-02",
89061
+ * "send_at": "2026-11-02T12:00:00.000Z",
89062
+ * "next_send_at": "2026-11-09T12:00:00.000Z",
89063
+ * "status": "pending",
89064
+ * "sent_at": null,
89065
+ * "will_send": true,
89066
+ * "channels": {
89067
+ * "email": true,
89068
+ * "whatsapp": false
89069
+ * },
89070
+ * "email": {
89071
+ * "subject": "Resumen semanal de Finanzas: $12.340.000 en caja",
89072
+ * "hero": {
89073
+ * "label": "Caja hoy",
89074
+ * "value": "$12.340.000",
89075
+ * "caption": "A fin de mes: $8.200.000. En 30 días: $9.100.000."
89076
+ * },
89077
+ * "problem": {
89078
+ * "text": "La caja alcanza hasta el 23 de noviembre. Ese martes pagas Arriendo y quedarías en negativo por $450.000.",
89079
+ * "link": {
89080
+ * "label": "Ver flujo de caja y cómo cubrirlo",
89081
+ * "path": "/finanzas/reportes/flujo-de-caja"
89082
+ * }
89083
+ * },
89084
+ * "lines": [
89085
+ * "Noviembre va en $6.100.000 de ingresos, de $9.800.000 para cubrir costos. Por ahora el mes pierde $1.200.000.",
89086
+ * "3 casos te necesitan en Por resolver, por $840.000."
89087
+ * ],
89088
+ * "primary": {
89089
+ * "label": "Ver Resumen",
89090
+ * "path": "/finanzas"
89091
+ * },
89092
+ * "secondary": {
89093
+ * "label": "Ir a Por resolver",
89094
+ * "path": "/finanzas/por-resolver"
89095
+ * }
89096
+ * },
89097
+ * "whatsapp_text": "Caja hoy: $12.340.000. La caja alcanza hasta el 23 de noviembre. Ese martes pagas Arriendo y quedarías en negativo por $450.000. 3 casos te necesitan en Por resolver, por $840.000.",
89098
+ * "figures": {
89099
+ * "reports_visible": true,
89100
+ * "cash_today_clp": 12340000,
89101
+ * "month_end_clp": 8200000,
89102
+ * "in_30_days_clp": 9100000,
89103
+ * "runs_out_date": "2026-11-24",
89104
+ * "ingresos_clp": 6100000,
89105
+ * "resultado_clp": -1200000,
89106
+ * "equilibrio_clp": 9800000,
89107
+ * "open_cases": 3
89108
+ * }
89109
+ * }
89110
+ * }
89111
+ */
89112
+ "application/json": {
89113
+ data: components["schemas"]["FinanzasDigestPreview"];
89114
+ };
89115
+ };
89116
+ };
89117
+ /** @description Validation error */
89118
+ 400: {
89119
+ headers: {
89120
+ [name: string]: unknown;
89121
+ };
89122
+ content: {
89123
+ "application/json": components["schemas"]["Error"];
89124
+ };
89125
+ };
89126
+ /** @description Unauthorized */
89127
+ 401: {
89128
+ headers: {
89129
+ [name: string]: unknown;
89130
+ };
89131
+ content: {
89132
+ "application/json": components["schemas"]["Error"];
89133
+ };
89134
+ };
89135
+ /** @description Forbidden */
89136
+ 403: {
89137
+ headers: {
89138
+ [name: string]: unknown;
89139
+ };
89140
+ content: {
89141
+ "application/json": components["schemas"]["Error"];
89142
+ };
89143
+ };
89144
+ /** @description Not found */
89145
+ 404: {
89146
+ headers: {
89147
+ [name: string]: unknown;
89148
+ };
89149
+ content: {
89150
+ "application/json": components["schemas"]["Error"];
89151
+ };
89152
+ };
89153
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
89154
+ 409: {
89155
+ headers: {
89156
+ [name: string]: unknown;
89157
+ };
89158
+ content: {
89159
+ "application/json": components["schemas"]["Error"];
89160
+ };
89161
+ };
89162
+ /** @description Rate limited */
89163
+ 429: {
89164
+ headers: {
89165
+ [name: string]: unknown;
89166
+ };
89167
+ content: {
89168
+ "application/json": components["schemas"]["Error"];
89169
+ };
89170
+ };
89171
+ };
89172
+ };
89173
+ put?: never;
89174
+ post?: never;
89175
+ delete?: never;
89176
+ options?: never;
89177
+ head?: never;
89178
+ patch?: never;
89179
+ trace?: never;
89180
+ };
87995
89181
  "/finanzas/costos": {
87996
89182
  parameters: {
87997
89183
  query?: never;
@@ -88477,6 +89663,328 @@ interface paths {
88477
89663
  };
88478
89664
  trace?: never;
88479
89665
  };
89666
+ "/finanzas/resumen": {
89667
+ parameters: {
89668
+ query?: never;
89669
+ header?: never;
89670
+ path?: never;
89671
+ cookie?: never;
89672
+ };
89673
+ /**
89674
+ * Resumen: the Finanzas home, three answers and the context
89675
+ * @description The Finanzas home in one read, every figure from its detail screen: **cash** («¿cuánto me queda a fin de mes?») = the Flujo de caja projection — today’s balance of the operating accounts, the month-end and 30-day balance, the lowest point and `runs_out` (the first day under zero within 30 days, with its biggest payment); **result** («¿cuánto gasto? / ¿este mes gana plata?») = Costos y equilibrio for the current month at net amounts (ingresos, gastos = variables + fijos, «sin clasificar» apart and counted as variable, resultado operacional) against the punto de equilibrio of the last closed month; **inbox** («Te necesita») = the open «Por resolver» cases and the previous month’s close state; **automatic** = this month’s «Hecho por Vitrina» totals and the newest 3; **accounts** with their balances. `problem` is the one thing shown in red (cash running out, else a bank connection that needs a person). A caller without `finanzas_reports:read` gets `cash`, `result` and every account balance (`balance_clp`, `balance_as_of`) null; account names stay (`reports_visible: false`). A Contador sees patients as initials. Requires the `finanzas` add-on — without it every Finanzas operation answers `402 ENTITLEMENT_NOT_ACTIVE` (`details.required = ["finanzas"]`). Requires `finanzas:read`.
89676
+ */
89677
+ get: {
89678
+ parameters: {
89679
+ query?: never;
89680
+ header?: never;
89681
+ path?: never;
89682
+ cookie?: never;
89683
+ };
89684
+ requestBody?: never;
89685
+ responses: {
89686
+ /** @description The Resumen */
89687
+ 200: {
89688
+ headers: {
89689
+ [name: string]: unknown;
89690
+ };
89691
+ content: {
89692
+ /**
89693
+ * @example {
89694
+ * "data": {
89695
+ * "as_of": "2026-10-30",
89696
+ * "month": "2026-10",
89697
+ * "month_label": "octubre 2026",
89698
+ * "currency": "CLP",
89699
+ * "reports_visible": true,
89700
+ * "synced_at": "2026-10-30T11:02:00.000Z",
89701
+ * "problem": {
89702
+ * "kind": "cash_runs_out",
89703
+ * "date": "2026-11-06",
89704
+ * "balance_clp": -412000
89705
+ * },
89706
+ * "cash": {
89707
+ * "today_clp": 4917109,
89708
+ * "balance_as_of": "2026-10-30T11:02:00.000Z",
89709
+ * "accounts_count": 3,
89710
+ * "unknown_count": 0,
89711
+ * "savings_clp": 12000000,
89712
+ * "month_end": {
89713
+ * "date": "2026-10-31",
89714
+ * "balance_clp": 5102000,
89715
+ * "band": {
89716
+ * "low_clp": 4980000,
89717
+ * "high_clp": 5260000
89718
+ * }
89719
+ * },
89720
+ * "in_30_days": {
89721
+ * "date": "2026-11-29",
89722
+ * "balance_clp": 3880000,
89723
+ * "band": {
89724
+ * "low_clp": 2100000,
89725
+ * "high_clp": 5400000
89726
+ * }
89727
+ * },
89728
+ * "lowest": {
89729
+ * "date": "2026-11-06",
89730
+ * "balance_clp": -412000,
89731
+ * "negative": true,
89732
+ * "cause": {
89733
+ * "key": "document:0190a3c2-5d1e-7b6a-9f20-4c1d2e3f6501",
89734
+ * "source": "payable",
89735
+ * "direction": "outflow",
89736
+ * "label": "Factura 4410 · Laboratorio Andes SpA",
89737
+ * "amount_clp": 5800000,
89738
+ * "date": "2026-11-06",
89739
+ * "due_date": "2026-11-06",
89740
+ * "overdue": false,
89741
+ * "movable": true,
89742
+ * "move": null,
89743
+ * "document": {
89744
+ * "id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f6501",
89745
+ * "kind": "purchase",
89746
+ * "dte_type": 33,
89747
+ * "folio": "4410"
89748
+ * },
89749
+ * "contraparte": {
89750
+ * "id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f6601",
89751
+ * "name": "Laboratorio Andes SpA"
89752
+ * },
89753
+ * "recurring_item_id": null,
89754
+ * "rescue_id": null,
89755
+ * "count": null
89756
+ * }
89757
+ * },
89758
+ * "runs_out": {
89759
+ * "date": "2026-11-06",
89760
+ * "covered_until": "2026-11-05",
89761
+ * "balance_clp": -412000,
89762
+ * "cause": {
89763
+ * "key": "document:0190a3c2-5d1e-7b6a-9f20-4c1d2e3f6501",
89764
+ * "source": "payable",
89765
+ * "direction": "outflow",
89766
+ * "label": "Factura 4410 · Laboratorio Andes SpA",
89767
+ * "amount_clp": 5800000,
89768
+ * "date": "2026-11-06",
89769
+ * "due_date": "2026-11-06",
89770
+ * "overdue": false,
89771
+ * "movable": true,
89772
+ * "move": null,
89773
+ * "document": {
89774
+ * "id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f6501",
89775
+ * "kind": "purchase",
89776
+ * "dte_type": 33,
89777
+ * "folio": "4410"
89778
+ * },
89779
+ * "contraparte": {
89780
+ * "id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f6601",
89781
+ * "name": "Laboratorio Andes SpA"
89782
+ * },
89783
+ * "recurring_item_id": null,
89784
+ * "rescue_id": null,
89785
+ * "count": null
89786
+ * }
89787
+ * },
89788
+ * "overdue": {
89789
+ * "payables_clp": 0,
89790
+ * "payables_count": 0,
89791
+ * "stale_payables_clp": 0,
89792
+ * "stale_payables_count": 0,
89793
+ * "receivables_clp": 380000,
89794
+ * "receivables_count": 2
89795
+ * },
89796
+ * "points": [
89797
+ * {
89798
+ * "date": "2026-10-30",
89799
+ * "balance_clp": 4917109,
89800
+ * "band": {
89801
+ * "low_clp": 4917109,
89802
+ * "high_clp": 4917109
89803
+ * }
89804
+ * },
89805
+ * {
89806
+ * "date": "2026-10-31",
89807
+ * "balance_clp": 5102000,
89808
+ * "band": {
89809
+ * "low_clp": 4980000,
89810
+ * "high_clp": 5260000
89811
+ * }
89812
+ * }
89813
+ * ]
89814
+ * },
89815
+ * "result": {
89816
+ * "month": "2026-10",
89817
+ * "label": "octubre 2026",
89818
+ * "proforma": true,
89819
+ * "ingresos_clp": 41200000,
89820
+ * "gastos_clp": 38900000,
89821
+ * "variables_clp": 17400000,
89822
+ * "fijos_clp": 21500000,
89823
+ * "sin_clasificar_clp": 900000,
89824
+ * "resultado_clp": 2300000,
89825
+ * "equilibrio": {
89826
+ * "month": "2026-09",
89827
+ * "label": "septiembre 2026",
89828
+ * "equilibrio_clp": 44600000,
89829
+ * "sin_calculo": null
89830
+ * },
89831
+ * "cobertura_pct": 92.4,
89832
+ * "brecha_clp": -3400000
89833
+ * },
89834
+ * "inbox": {
89835
+ * "open": 4,
89836
+ * "amount_at_stake_clp": 2860000,
89837
+ * "by_kind": {
89838
+ * "reconcile": 2,
89839
+ * "transfer": 0,
89840
+ * "classify": 1,
89841
+ * "missing_document": 1,
89842
+ * "unknown": 0
89843
+ * },
89844
+ * "close": {
89845
+ * "month": "2026-09",
89846
+ * "label": "septiembre 2026",
89847
+ * "state": "closed",
89848
+ * "open_cases": 0
89849
+ * }
89850
+ * },
89851
+ * "automatic": {
89852
+ * "month": "2026-10",
89853
+ * "count": 240,
89854
+ * "total_clp": 61200000,
89855
+ * "unreviewed_count": 31,
89856
+ * "by_actor": {
89857
+ * "rule": 150,
89858
+ * "match": 72,
89859
+ * "ai": 18
89860
+ * },
89861
+ * "recent": [
89862
+ * {
89863
+ * "kind": "link",
89864
+ * "id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f6701",
89865
+ * "actor": "match",
89866
+ * "label": "Pago de la factura 4388 de Laboratorio Andes SpA",
89867
+ * "day": "2026-10-29",
89868
+ * "amount_clp": 1240000,
89869
+ * "applied_at": "2026-10-29T14:10:00.000Z",
89870
+ * "movement": {
89871
+ * "id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f6801",
89872
+ * "day": "2026-10-29",
89873
+ * "amount_clp": 1240000,
89874
+ * "direction": "outbound",
89875
+ * "description": "Transferencia a Laboratorio Andes"
89876
+ * },
89877
+ * "document": null,
89878
+ * "target": "document",
89879
+ * "reasons": [
89880
+ * "rut",
89881
+ * "amount"
89882
+ * ],
89883
+ * "account": null,
89884
+ * "split": false,
89885
+ * "rule": null,
89886
+ * "reviewed_at": null,
89887
+ * "reviewed_by": null,
89888
+ * "group_name": "Laboratorio Andes SpA"
89889
+ * }
89890
+ * ]
89891
+ * },
89892
+ * "accounts": [
89893
+ * {
89894
+ * "id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f6401",
89895
+ * "name": "Cuenta corriente",
89896
+ * "institution_name": "Banco de Chile",
89897
+ * "number_masked": "··4821",
89898
+ * "type": "cuenta_corriente",
89899
+ * "currency": "CLP",
89900
+ * "balance_clp": 3719083,
89901
+ * "balance_as_of": "2026-10-30T11:02:00.000Z",
89902
+ * "in_cash": true
89903
+ * },
89904
+ * {
89905
+ * "id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f6402",
89906
+ * "name": "Ahorro",
89907
+ * "institution_name": "Banco de Chile",
89908
+ * "number_masked": "··0057",
89909
+ * "type": "cuenta_ahorro",
89910
+ * "currency": "CLP",
89911
+ * "balance_clp": 12000000,
89912
+ * "balance_as_of": "2026-10-30T11:02:00.000Z",
89913
+ * "in_cash": false
89914
+ * }
89915
+ * ]
89916
+ * }
89917
+ * }
89918
+ */
89919
+ "application/json": {
89920
+ data: components["schemas"]["FinanzasResumen"];
89921
+ };
89922
+ };
89923
+ };
89924
+ /** @description Validation error */
89925
+ 400: {
89926
+ headers: {
89927
+ [name: string]: unknown;
89928
+ };
89929
+ content: {
89930
+ "application/json": components["schemas"]["Error"];
89931
+ };
89932
+ };
89933
+ /** @description Unauthorized */
89934
+ 401: {
89935
+ headers: {
89936
+ [name: string]: unknown;
89937
+ };
89938
+ content: {
89939
+ "application/json": components["schemas"]["Error"];
89940
+ };
89941
+ };
89942
+ /** @description Forbidden */
89943
+ 403: {
89944
+ headers: {
89945
+ [name: string]: unknown;
89946
+ };
89947
+ content: {
89948
+ "application/json": components["schemas"]["Error"];
89949
+ };
89950
+ };
89951
+ /** @description Not found */
89952
+ 404: {
89953
+ headers: {
89954
+ [name: string]: unknown;
89955
+ };
89956
+ content: {
89957
+ "application/json": components["schemas"]["Error"];
89958
+ };
89959
+ };
89960
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
89961
+ 409: {
89962
+ headers: {
89963
+ [name: string]: unknown;
89964
+ };
89965
+ content: {
89966
+ "application/json": components["schemas"]["Error"];
89967
+ };
89968
+ };
89969
+ /** @description Rate limited */
89970
+ 429: {
89971
+ headers: {
89972
+ [name: string]: unknown;
89973
+ };
89974
+ content: {
89975
+ "application/json": components["schemas"]["Error"];
89976
+ };
89977
+ };
89978
+ };
89979
+ };
89980
+ put?: never;
89981
+ post?: never;
89982
+ delete?: never;
89983
+ options?: never;
89984
+ head?: never;
89985
+ patch?: never;
89986
+ trace?: never;
89987
+ };
88480
89988
  "/finanzas/produccion": {
88481
89989
  parameters: {
88482
89990
  query?: never;
@@ -88746,29 +90254,483 @@ interface paths {
88746
90254
  patch?: never;
88747
90255
  trace?: never;
88748
90256
  };
88749
- "/finanzas/contador-export/manifest": {
90257
+ "/finanzas/contador-export/manifest": {
90258
+ parameters: {
90259
+ query?: never;
90260
+ header?: never;
90261
+ path?: never;
90262
+ cookie?: never;
90263
+ };
90264
+ /**
90265
+ * What the Contador package for a month holds
90266
+ * @description The same package as the download, without the bytes: the period, the zip name and each file (key, label, name, rows, size). Over MCP this is the read that generates and checks the package; the zip itself downloads over HTTPS. A caller without the patient register (the Contador) sees a patient as «Paciente A. P.» with no RUT; the libro de ventas keeps the patient RUT on facturas and on notas de crédito or débito that cite one, and boletas carry neither RUT nor name. Requires the `finanzas` add-on — without it every Finanzas operation answers `402 ENTITLEMENT_NOT_ACTIVE` (`details.required = ["finanzas"]`). Requires `finanzas:read`, `finanzas_reports:read` and `finanzas:export` (the Contador seat, owners and admins).
90267
+ */
90268
+ get: {
90269
+ parameters: {
90270
+ query?: {
90271
+ period?: string;
90272
+ };
90273
+ header?: never;
90274
+ path?: never;
90275
+ cookie?: never;
90276
+ };
90277
+ requestBody?: never;
90278
+ responses: {
90279
+ /** @description The manifest */
90280
+ 200: {
90281
+ headers: {
90282
+ [name: string]: unknown;
90283
+ };
90284
+ content: {
90285
+ /**
90286
+ * @example {
90287
+ * "data": {
90288
+ * "period": "2026-09",
90289
+ * "filename": "paquete-contador-2026-09.zip",
90290
+ * "files": [
90291
+ * {
90292
+ * "key": "libro_compras",
90293
+ * "label": "Libro de compras",
90294
+ * "filename": "01-libro-de-compras-2026-09.xlsx",
90295
+ * "rows": 84,
90296
+ * "size_bytes": 14210
90297
+ * },
90298
+ * {
90299
+ * "key": "libro_ventas",
90300
+ * "label": "Libro de ventas",
90301
+ * "filename": "02-libro-de-ventas-2026-09.xlsx",
90302
+ * "rows": 1312,
90303
+ * "size_bytes": 61904
90304
+ * },
90305
+ * {
90306
+ * "key": "honorarios",
90307
+ * "label": "Honorarios",
90308
+ * "filename": "03-honorarios-2026-09.xlsx",
90309
+ * "rows": 12,
90310
+ * "size_bytes": 7480
90311
+ * },
90312
+ * {
90313
+ * "key": "movimientos",
90314
+ * "label": "Movimientos por cuenta",
90315
+ * "filename": "04-movimientos-por-cuenta-2026-09.xlsx",
90316
+ * "rows": 640,
90317
+ * "size_bytes": 38112
90318
+ * },
90319
+ * {
90320
+ * "key": "clasificaciones",
90321
+ * "label": "Clasificaciones por cuenta",
90322
+ * "filename": "05-clasificaciones-por-cuenta-2026-09.xlsx",
90323
+ * "rows": 702,
90324
+ * "size_bytes": 40356
90325
+ * },
90326
+ * {
90327
+ * "key": "resultado",
90328
+ * "label": "Resultado",
90329
+ * "filename": "06-resultado-2026-09.xlsx",
90330
+ * "rows": 1398,
90331
+ * "size_bytes": 52018
90332
+ * },
90333
+ * {
90334
+ * "key": "ajustes",
90335
+ * "label": "Ajustes posteriores al cierre",
90336
+ * "filename": "07-ajustes-posteriores-al-cierre-2026-09.xlsx",
90337
+ * "rows": 3,
90338
+ * "size_bytes": 6920
90339
+ * }
90340
+ * ]
90341
+ * }
90342
+ * }
90343
+ */
90344
+ "application/json": {
90345
+ data: {
90346
+ /** @description The month, `YYYY-MM`. */
90347
+ period: string;
90348
+ /** @description The zip the download serves. */
90349
+ filename: string;
90350
+ files: {
90351
+ /** @enum {string} */
90352
+ key: "libro_compras" | "libro_ventas" | "honorarios" | "movimientos" | "clasificaciones" | "resultado" | "ajustes";
90353
+ label: string;
90354
+ /** @description The xlsx inside the zip. */
90355
+ filename: string;
90356
+ /** @description Rows of its «Detalle» sheet (documents, items) when it has one, else of its first sheet (movements, adjustments). */
90357
+ rows: number;
90358
+ size_bytes: number;
90359
+ }[];
90360
+ };
90361
+ };
90362
+ };
90363
+ };
90364
+ /** @description Validation error */
90365
+ 400: {
90366
+ headers: {
90367
+ [name: string]: unknown;
90368
+ };
90369
+ content: {
90370
+ "application/json": components["schemas"]["Error"];
90371
+ };
90372
+ };
90373
+ /** @description Unauthorized */
90374
+ 401: {
90375
+ headers: {
90376
+ [name: string]: unknown;
90377
+ };
90378
+ content: {
90379
+ "application/json": components["schemas"]["Error"];
90380
+ };
90381
+ };
90382
+ /** @description Forbidden */
90383
+ 403: {
90384
+ headers: {
90385
+ [name: string]: unknown;
90386
+ };
90387
+ content: {
90388
+ "application/json": components["schemas"]["Error"];
90389
+ };
90390
+ };
90391
+ /** @description Not found */
90392
+ 404: {
90393
+ headers: {
90394
+ [name: string]: unknown;
90395
+ };
90396
+ content: {
90397
+ "application/json": components["schemas"]["Error"];
90398
+ };
90399
+ };
90400
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
90401
+ 409: {
90402
+ headers: {
90403
+ [name: string]: unknown;
90404
+ };
90405
+ content: {
90406
+ "application/json": components["schemas"]["Error"];
90407
+ };
90408
+ };
90409
+ /** @description Rate limited */
90410
+ 429: {
90411
+ headers: {
90412
+ [name: string]: unknown;
90413
+ };
90414
+ content: {
90415
+ "application/json": components["schemas"]["Error"];
90416
+ };
90417
+ };
90418
+ };
90419
+ };
90420
+ put?: never;
90421
+ post?: never;
90422
+ delete?: never;
90423
+ options?: never;
90424
+ head?: never;
90425
+ patch?: never;
90426
+ trace?: never;
90427
+ };
90428
+ "/finanzas/ads-connections": {
90429
+ parameters: {
90430
+ query?: never;
90431
+ header?: never;
90432
+ path?: never;
90433
+ cookie?: never;
90434
+ };
90435
+ /**
90436
+ * Ad accounts reachable for Cargos de publicidad
90437
+ * @description Per platform (Meta Ads, Google Ads): the ad accounts connected to the workspace, their status, last sync and the charges synced and linked, from the last read of the ad data. Each platform says what happens without a connection; connecting is Integraciones › Meta Ads. A card movement whose descriptor names Google Ads (`GOOGLE *ADS<customer id>`) or Meta (`FACEBK *<ref>`, `META*…`, `META PLATFORMS…`) becomes a `manual_expense` document of Contraparte «Google Ads» / «Meta Platforms» (`GET /finanzas/documents?origin=ads`); a refund (money in) a nota de crédito. Vitrina links it when the ad data makes it plausible (Meta: the billing charge of the same amount, count for count in time order; Google and Meta without charge data: the account spend since its previous charge must cover the amount), shown in «Hecho por Vitrina» with the evidence; the rest waits in «Por resolver» (case kind `ads_charge`). Vitrina never holds a Meta or Google token. Requires the `finanzas` add-on — without it every Finanzas operation answers `402 ENTITLEMENT_NOT_ACTIVE` (`details.required = ["finanzas"]`). Requires `finanzas:read`.
90438
+ */
90439
+ get: {
90440
+ parameters: {
90441
+ query?: never;
90442
+ header?: never;
90443
+ path?: never;
90444
+ cookie?: never;
90445
+ };
90446
+ requestBody?: never;
90447
+ responses: {
90448
+ /** @description The connections */
90449
+ 200: {
90450
+ headers: {
90451
+ [name: string]: unknown;
90452
+ };
90453
+ content: {
90454
+ /**
90455
+ * @example {
90456
+ * "data": {
90457
+ * "profile": true,
90458
+ * "last_attempt_at": "2026-10-31T12:30:00.000Z",
90459
+ * "last_sync_at": "2026-10-31T12:30:00.000Z",
90460
+ * "last_error": null,
90461
+ * "platforms": [
90462
+ * {
90463
+ * "platform": "meta_ads",
90464
+ * "label": "Meta Ads",
90465
+ * "status": "connected",
90466
+ * "accounts": [
90467
+ * {
90468
+ * "platform": "meta_ads",
90469
+ * "ad_account_id": "act_969938652650502",
90470
+ * "account_label": "act_969938652650502",
90471
+ * "account_name": "connectmarketing-cl",
90472
+ * "currency": "CLP",
90473
+ * "timezone": "America/Santiago",
90474
+ * "connection_status": "connected",
90475
+ * "healthy": true,
90476
+ * "last_synced_at": "2026-10-31T06:00:58.984Z",
90477
+ * "charges_supported": true,
90478
+ * "charges_synced_at": "2026-10-31T12:26:04.120Z",
90479
+ * "charges_synced": 40,
90480
+ * "charges_linked": 38,
90481
+ * "spend_by_month": [
90482
+ * {
90483
+ * "month": "2026-10",
90484
+ * "spend_minor": 545869,
90485
+ * "currency": "CLP"
90486
+ * }
90487
+ * ]
90488
+ * }
90489
+ * ],
90490
+ * "without_connection": "Sin la conexión, los cargos de Meta quedan en Por resolver hasta que reenvíes el recibo.",
90491
+ * "connect_path": "/settings/integrations"
90492
+ * },
90493
+ * {
90494
+ * "platform": "google_ads",
90495
+ * "label": "Google Ads",
90496
+ * "status": "none",
90497
+ * "accounts": [],
90498
+ * "without_connection": "Sin la conexión, los cargos de Google Ads quedan en Por resolver hasta que reenvíes el recibo.",
90499
+ * "connect_path": "/settings/integrations"
90500
+ * }
90501
+ * ]
90502
+ * }
90503
+ * }
90504
+ */
90505
+ "application/json": {
90506
+ data: components["schemas"]["FinanzasAdsConnections"];
90507
+ };
90508
+ };
90509
+ };
90510
+ /** @description Validation error */
90511
+ 400: {
90512
+ headers: {
90513
+ [name: string]: unknown;
90514
+ };
90515
+ content: {
90516
+ "application/json": components["schemas"]["Error"];
90517
+ };
90518
+ };
90519
+ /** @description Unauthorized */
90520
+ 401: {
90521
+ headers: {
90522
+ [name: string]: unknown;
90523
+ };
90524
+ content: {
90525
+ "application/json": components["schemas"]["Error"];
90526
+ };
90527
+ };
90528
+ /** @description Forbidden */
90529
+ 403: {
90530
+ headers: {
90531
+ [name: string]: unknown;
90532
+ };
90533
+ content: {
90534
+ "application/json": components["schemas"]["Error"];
90535
+ };
90536
+ };
90537
+ /** @description Not found */
90538
+ 404: {
90539
+ headers: {
90540
+ [name: string]: unknown;
90541
+ };
90542
+ content: {
90543
+ "application/json": components["schemas"]["Error"];
90544
+ };
90545
+ };
90546
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
90547
+ 409: {
90548
+ headers: {
90549
+ [name: string]: unknown;
90550
+ };
90551
+ content: {
90552
+ "application/json": components["schemas"]["Error"];
90553
+ };
90554
+ };
90555
+ /** @description Rate limited */
90556
+ 429: {
90557
+ headers: {
90558
+ [name: string]: unknown;
90559
+ };
90560
+ content: {
90561
+ "application/json": components["schemas"]["Error"];
90562
+ };
90563
+ };
90564
+ };
90565
+ };
90566
+ put?: never;
90567
+ post?: never;
90568
+ delete?: never;
90569
+ options?: never;
90570
+ head?: never;
90571
+ patch?: never;
90572
+ trace?: never;
90573
+ };
90574
+ "/finanzas/ads-charges": {
90575
+ parameters: {
90576
+ query?: never;
90577
+ header?: never;
90578
+ path?: never;
90579
+ cookie?: never;
90580
+ };
90581
+ /**
90582
+ * Meta billing charges synced, with their link state
90583
+ * @description Every billing event (charge, refund, chargeback, decline, funding) of the workspace's Meta ad accounts whose day (account time zone) is in [from, to], oldest first, never deduplicated by amount. `linked` = matched to the ads document of a card movement. Amounts in the smallest unit of `currency`. Requires the `finanzas` add-on — without it every Finanzas operation answers `402 ENTITLEMENT_NOT_ACTIVE` (`details.required = ["finanzas"]`). Requires `finanzas:read`.
90584
+ */
90585
+ get: {
90586
+ parameters: {
90587
+ query?: {
90588
+ from?: string;
90589
+ to?: string;
90590
+ };
90591
+ header?: never;
90592
+ path?: never;
90593
+ cookie?: never;
90594
+ };
90595
+ requestBody?: never;
90596
+ responses: {
90597
+ /** @description The charges */
90598
+ 200: {
90599
+ headers: {
90600
+ [name: string]: unknown;
90601
+ };
90602
+ content: {
90603
+ /**
90604
+ * @example {
90605
+ * "data": {
90606
+ * "from": "2026-10-22",
90607
+ * "to": "2026-10-22",
90608
+ * "items": [
90609
+ * {
90610
+ * "id": "0193a1b2-0000-7000-8000-000000000001",
90611
+ * "platform": "meta_ads",
90612
+ * "ad_account_id": "act_969938652650502",
90613
+ * "event_type": "ad_account_billing_charge",
90614
+ * "event_label": "cargo",
90615
+ * "event_time": "2026-10-22T12:14:00.000Z",
90616
+ * "local_date": "2026-10-22",
90617
+ * "meta_transaction_id": "29140315238986117-29184038214613815",
90618
+ * "amount_minor": 4211,
90619
+ * "currency": "CLP",
90620
+ * "link_state": "linked",
90621
+ * "document_id": "0193a1b2-0000-7000-8000-0000000000d1",
90622
+ * "movement_id": "0193a1b2-0000-7000-8000-0000000000a1",
90623
+ * "linked_at": "2026-10-24T09:00:00.000Z"
90624
+ * }
90625
+ * ],
90626
+ * "totals": {
90627
+ * "count": 1,
90628
+ * "linked": 1,
90629
+ * "unlinked": 0
90630
+ * }
90631
+ * }
90632
+ * }
90633
+ */
90634
+ "application/json": {
90635
+ data: components["schemas"]["FinanzasAdsChargesList"];
90636
+ };
90637
+ };
90638
+ };
90639
+ /** @description Validation error */
90640
+ 400: {
90641
+ headers: {
90642
+ [name: string]: unknown;
90643
+ };
90644
+ content: {
90645
+ "application/json": components["schemas"]["Error"];
90646
+ };
90647
+ };
90648
+ /** @description Unauthorized */
90649
+ 401: {
90650
+ headers: {
90651
+ [name: string]: unknown;
90652
+ };
90653
+ content: {
90654
+ "application/json": components["schemas"]["Error"];
90655
+ };
90656
+ };
90657
+ /** @description Forbidden */
90658
+ 403: {
90659
+ headers: {
90660
+ [name: string]: unknown;
90661
+ };
90662
+ content: {
90663
+ "application/json": components["schemas"]["Error"];
90664
+ };
90665
+ };
90666
+ /** @description Not found */
90667
+ 404: {
90668
+ headers: {
90669
+ [name: string]: unknown;
90670
+ };
90671
+ content: {
90672
+ "application/json": components["schemas"]["Error"];
90673
+ };
90674
+ };
90675
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
90676
+ 409: {
90677
+ headers: {
90678
+ [name: string]: unknown;
90679
+ };
90680
+ content: {
90681
+ "application/json": components["schemas"]["Error"];
90682
+ };
90683
+ };
90684
+ /** @description Rate limited */
90685
+ 429: {
90686
+ headers: {
90687
+ [name: string]: unknown;
90688
+ };
90689
+ content: {
90690
+ "application/json": components["schemas"]["Error"];
90691
+ };
90692
+ };
90693
+ };
90694
+ };
90695
+ put?: never;
90696
+ post?: never;
90697
+ delete?: never;
90698
+ options?: never;
90699
+ head?: never;
90700
+ patch?: never;
90701
+ trace?: never;
90702
+ };
90703
+ "/finanzas/ads-charges/sync": {
88750
90704
  parameters: {
88751
90705
  query?: never;
88752
90706
  header?: never;
88753
90707
  path?: never;
88754
90708
  cookie?: never;
88755
90709
  };
90710
+ get?: never;
90711
+ put?: never;
88756
90712
  /**
88757
- * What the Contador package for a month holds
88758
- * @description The same package as the download, without the bytes: the period, the zip name and each file (key, label, name, rows, size). Over MCP this is the read that generates and checks the package; the zip itself downloads over HTTPS. A caller without the patient register (the Contador) sees a patient as «Paciente A. P.» with no RUT; the libro de ventas keeps the patient RUT on facturas and on notas de crédito or débito that cite one, and boletas carry neither RUT nor name. Requires the `finanzas` add-on — without it every Finanzas operation answers `402 ENTITLEMENT_NOT_ACTIVE` (`details.required = ["finanzas"]`). Requires `finanzas:read`, `finanzas_reports:read` and `finanzas:export` (the Contador seat, owners and admins).
90713
+ * Read the ad data now and match the card charges
90714
+ * @description «Sincronizar ahora»: recognise new ad charges among the card movements, read the last 92 days of ad billing and spend, store the charges and link what the evidence supports; then the reconciliation engine and «Por resolver» follow. A failed read is recorded (`read = error`, shown in `GET /finanzas/ads-connections`) and the stored charges still decide what they can. A card movement whose descriptor names Google Ads (`GOOGLE *ADS<customer id>`) or Meta (`FACEBK *<ref>`, `META*…`, `META PLATFORMS…`) becomes a `manual_expense` document of Contraparte «Google Ads» / «Meta Platforms» (`GET /finanzas/documents?origin=ads`); a refund (money in) a nota de crédito. Vitrina links it when the ad data makes it plausible (Meta: the billing charge of the same amount, count for count in time order; Google and Meta without charge data: the account spend since its previous charge must cover the amount), shown in «Hecho por Vitrina» with the evidence; the rest waits in «Por resolver» (case kind `ads_charge`). Vitrina never holds a Meta or Google token. Requires the `finanzas` add-on — without it every Finanzas operation answers `402 ENTITLEMENT_NOT_ACTIVE` (`details.required = ["finanzas"]`). Requires `finanzas_admin:write`.
88759
90715
  */
88760
- get: {
90716
+ post: {
88761
90717
  parameters: {
88762
- query?: {
88763
- period?: string;
90718
+ query?: never;
90719
+ header?: {
90720
+ /** @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. */
90721
+ "Idempotency-Key"?: string;
88764
90722
  };
88765
- header?: never;
88766
90723
  path?: never;
88767
90724
  cookie?: never;
88768
90725
  };
88769
- requestBody?: never;
90726
+ requestBody?: {
90727
+ content: {
90728
+ /** @example {} */
90729
+ "application/json": Record<string, never>;
90730
+ };
90731
+ };
88770
90732
  responses: {
88771
- /** @description The manifest */
90733
+ /** @description What the run did */
88772
90734
  200: {
88773
90735
  headers: {
88774
90736
  [name: string]: unknown;
@@ -88777,79 +90739,27 @@ interface paths {
88777
90739
  /**
88778
90740
  * @example {
88779
90741
  * "data": {
88780
- * "period": "2026-09",
88781
- * "filename": "paquete-contador-2026-09.zip",
88782
- * "files": [
88783
- * {
88784
- * "key": "libro_compras",
88785
- * "label": "Libro de compras",
88786
- * "filename": "01-libro-de-compras-2026-09.xlsx",
88787
- * "rows": 84,
88788
- * "size_bytes": 14210
88789
- * },
88790
- * {
88791
- * "key": "libro_ventas",
88792
- * "label": "Libro de ventas",
88793
- * "filename": "02-libro-de-ventas-2026-09.xlsx",
88794
- * "rows": 1312,
88795
- * "size_bytes": 61904
88796
- * },
88797
- * {
88798
- * "key": "honorarios",
88799
- * "label": "Honorarios",
88800
- * "filename": "03-honorarios-2026-09.xlsx",
88801
- * "rows": 12,
88802
- * "size_bytes": 7480
88803
- * },
88804
- * {
88805
- * "key": "movimientos",
88806
- * "label": "Movimientos por cuenta",
88807
- * "filename": "04-movimientos-por-cuenta-2026-09.xlsx",
88808
- * "rows": 640,
88809
- * "size_bytes": 38112
88810
- * },
88811
- * {
88812
- * "key": "clasificaciones",
88813
- * "label": "Clasificaciones por cuenta",
88814
- * "filename": "05-clasificaciones-por-cuenta-2026-09.xlsx",
88815
- * "rows": 702,
88816
- * "size_bytes": 40356
88817
- * },
88818
- * {
88819
- * "key": "resultado",
88820
- * "label": "Resultado",
88821
- * "filename": "06-resultado-2026-09.xlsx",
88822
- * "rows": 1398,
88823
- * "size_bytes": 52018
88824
- * },
88825
- * {
88826
- * "key": "ajustes",
88827
- * "label": "Ajustes posteriores al cierre",
88828
- * "filename": "07-ajustes-posteriores-al-cierre-2026-09.xlsx",
88829
- * "rows": 3,
88830
- * "size_bytes": 6920
88831
- * }
88832
- * ]
90742
+ * "skipped": false,
90743
+ * "read": "ok",
90744
+ * "accounts": 1,
90745
+ * "charges_new": 3,
90746
+ * "recognize": {
90747
+ * "recognized": 4,
90748
+ * "created": 4,
90749
+ * "receipt_first": 0
90750
+ * },
90751
+ * "match": {
90752
+ * "open": 4,
90753
+ * "linked": 3,
90754
+ * "unconfirmed": 1,
90755
+ * "no_connection": 0,
90756
+ * "pending": 0
90757
+ * }
88833
90758
  * }
88834
90759
  * }
88835
90760
  */
88836
90761
  "application/json": {
88837
- data: {
88838
- /** @description The month, `YYYY-MM`. */
88839
- period: string;
88840
- /** @description The zip the download serves. */
88841
- filename: string;
88842
- files: {
88843
- /** @enum {string} */
88844
- key: "libro_compras" | "libro_ventas" | "honorarios" | "movimientos" | "clasificaciones" | "resultado" | "ajustes";
88845
- label: string;
88846
- /** @description The xlsx inside the zip. */
88847
- filename: string;
88848
- /** @description Rows of its «Detalle» sheet (documents, items) when it has one, else of its first sheet (movements, adjustments). */
88849
- rows: number;
88850
- size_bytes: number;
88851
- }[];
88852
- };
90762
+ data: components["schemas"]["FinanzasAdsSyncResult"];
88853
90763
  };
88854
90764
  };
88855
90765
  };
@@ -88909,8 +90819,6 @@ interface paths {
88909
90819
  };
88910
90820
  };
88911
90821
  };
88912
- put?: never;
88913
- post?: never;
88914
90822
  delete?: never;
88915
90823
  options?: never;
88916
90824
  head?: never;
@@ -139520,7 +141428,7 @@ interface paths {
139520
141428
  *
139521
141429
  * Each row also carries `campaign_origin` — the newest campaign send stored in the thread (`null` when none): its campaign, when it left, whether the send created the thread, and whether it is still the newest message (`awaiting_reply`). `fromCampaign=true` lists every such thread, closed ones included.
139522
141430
  *
139523
- * Each row also carries `waiting_since` — when its customer started waiting on a human, `null` when nobody waits (the «Esperando respuesta» rule; see the `waiting` parameter). `waiting=true` lists only waiting conversations, team-wide; `sort=wait` orders urgent first, then the longest wait.
141431
+ * Each row also carries `waiting_since` — when its customer started waiting on a human, `null` when nobody waits (the «Esperando respuesta» rule; see the `waiting` parameter). `waiting=true` lists only waiting conversations, team-wide; `sort=wait` orders urgent first, then the longest wait. `waiting_state` says why: `owed` (waiting), `closed_by_customer` (the customer only acknowledged, thanked or closed after we answered), `nothing_owed` (they declined, or the message is not for us), `paid_or_in_store` (a transfer receipt right after we sent our bank details, or «llegué» / «voy subiendo»: a suggestion for a person to confirm — nothing moves a lead or records a payment) or `promised_later` (we promised to write on a later day: a dated «Recordatorio acordado» follow-up, due at `waiting_due_at`, after which the thread is waiting again) — the ones left out of the queue by a confident verdict on the newest unanswered customer message, voice notes read as their transcript — and `null` when nobody waits at all. `waiting=closed` lists those left-out threads (still live: resolving stays a person’s click).
139524
141432
  *
139525
141433
  * Rows here do NOT carry `ad_origin_nudge` — that field is single-conversation-read only, to avoid a per-row integration lookup on every page of the inbox.
139526
141434
  *
@@ -139553,8 +141461,8 @@ interface paths {
139553
141461
  aiReplied?: boolean | null;
139554
141462
  fromAd?: boolean | null;
139555
141463
  fromCampaign?: boolean | null;
139556
- /** @description true: only conversations where a customer is waiting on a human («Esperando respuesta»), team-wide. Waiting = open or pending, not filtered, on a channel you can reply in, and either an AI handoff nobody on the team has answered yet (a reply from ANY teammate clears it, including WhatsApp Business / Instagram app replies; a silent «Visita acordada» notice needs no answer) or a human-handled thread whose last message is the customer’s; waits older than 7 days are left out. Each row carries `waiting_since`. Pair with `sort=wait` for the queue order. */
139557
- waiting?: boolean | null;
141464
+ /** @description true: only conversations where a customer is waiting on a human («Esperando respuesta»), team-wide. Waiting = open or pending, not filtered, on a channel you can reply in, and either an AI handoff nobody on the team has answered yet (a reply from ANY teammate clears it, including WhatsApp Business / Instagram app replies; a silent «Visita acordada» notice needs no answer) or a human-handled thread whose last message is the customer’s; waits older than 7 days are left out; and what the customer wrote still asks for a reply: a thread whose newest unanswered customer message was judged, with high confidence, as the customer closing the chat («ok», «gracias», 👍 after we answered) or owing nothing, a customer who paid (a transfer receipt after our bank details) or is at the store («llegué», «voy subiendo»), or a follow-up we promised for a later day that is not due yet, is left out (any other open promise of ours always stays). `closed`: exactly those left-out threads, still live (not resolved) — `waiting_state` says why, `waiting_due_at` when a promised follow-up falls due. Each row carries `waiting_since`, `waiting_state` and `waiting_due_at`. Pair with `sort=wait` for the queue order. */
141465
+ waiting?: boolean | "closed" | null;
139558
141466
  /** @description `wait`: urgent (`handoff_urgent`) first, then by `waiting_since` — `order=desc` (default) is the longest wait first, `asc` the newest; conversations that are not waiting go last. */
139559
141467
  sort?: "created_at" | "updated_at" | "last_message_date" | "wait";
139560
141468
  order?: "asc" | "desc";
@@ -139696,7 +141604,9 @@ interface paths {
139696
141604
  * ],
139697
141605
  * "last_call": null,
139698
141606
  * "handoff_urgent": false,
139699
- * "waiting_since": null
141607
+ * "waiting_since": null,
141608
+ * "waiting_state": null,
141609
+ * "waiting_due_at": null
139700
141610
  * },
139701
141611
  * {
139702
141612
  * "id": "bbbbbbbb-0000-4000-8000-000000000002",
@@ -139834,7 +141744,9 @@ interface paths {
139834
141744
  * "tags": [],
139835
141745
  * "last_call": null,
139836
141746
  * "handoff_urgent": false,
139837
- * "waiting_since": null
141747
+ * "waiting_since": null,
141748
+ * "waiting_state": null,
141749
+ * "waiting_due_at": null
139838
141750
  * }
139839
141751
  * ],
139840
141752
  * "meta": {
@@ -140126,7 +142038,7 @@ interface paths {
140126
142038
  * Inbox badge counts (my open / unread / mentions / unassigned / waiting)
140127
142039
  * @description The four badge counts on their own, scoped to the calling principal: `myOpen` and `myUnread` are the conversations assigned to the member behind the credential, `myMentions` the ones that @-mention them, `unassigned` the whole workspace’s unowned queue. An API key has no member behind it, so its three "my" counts read 0 and only `unassigned` is meaningful — use a personal token to get a person’s badges.
140128
142040
  *
140129
- * «Esperando respuesta» (the waiting queue): `waiting` is how many conversations have a customer waiting on a human, team-wide (the list `GET /conversations?waiting=true` returns exactly these); `waitingUrgent` how many of them are flagged urgent; `waitingMine` how many are assigned to the caller (0 for an API key); `waitingOldestSince` when the longest wait started (ISO, `null` when nobody waits) — render it as «el más antiguo 2 h».
142041
+ * «Esperando respuesta» (the waiting queue): `waiting` is how many conversations have a customer waiting on a human, team-wide (the list `GET /conversations?waiting=true` returns exactly these); `waitingUrgent` how many of them are flagged urgent; `waitingMine` how many are assigned to the caller (0 for an API key); `waitingOldestSince` when the longest wait started (ISO, `null` when nobody waits) — render it as «el más antiguo 2 h»; `waitingClosed` how many live threads were left out because the customer closed the chat, nothing is owed, they paid or are in the store, or a follow-up we promised is not due yet (the list `waiting=closed`).
140130
142042
  *
140131
142043
  * `GET /conversations?include=counts` returns the same payload beside a page of conversations; this route exists for the caller that wants the badges without one.
140132
142044
  */
@@ -140155,7 +142067,8 @@ interface paths {
140155
142067
  * "waiting": 3,
140156
142068
  * "waitingUrgent": 1,
140157
142069
  * "waitingMine": 1,
140158
- * "waitingOldestSince": "2026-10-31T13:05:00.000Z"
142070
+ * "waitingOldestSince": "2026-10-31T13:05:00.000Z",
142071
+ * "waitingClosed": 4
140159
142072
  * }
140160
142073
  * }
140161
142074
  */
@@ -140395,6 +142308,8 @@ interface paths {
140395
142308
  * "last_call": null,
140396
142309
  * "handoff_urgent": false,
140397
142310
  * "waiting_since": null,
142311
+ * "waiting_state": null,
142312
+ * "waiting_due_at": null,
140398
142313
  * "ad_origin_nudge": null,
140399
142314
  * "handoff_resolved_suggested": false,
140400
142315
  * "message": [
@@ -255025,6 +256940,8 @@ interface components {
255025
256940
  account_id?: string;
255026
256941
  template_name?: string;
255027
256942
  template_language?: string;
256943
+ /** @description The weekly Finanzas digest template (resumen_finanzas_semanal_v1), wired on approval. */
256944
+ digest_template_name?: string;
255028
256945
  };
255029
256946
  stock_alert?: {
255030
256947
  /** @description Lead stages that trigger the «Stock faltante» check when a lead moves into them. Empty turns it off. */
@@ -255370,6 +257287,8 @@ interface components {
255370
257287
  account_id?: string;
255371
257288
  template_name?: string;
255372
257289
  template_language?: string;
257290
+ /** @description The weekly Finanzas digest template (resumen_finanzas_semanal_v1), wired on approval. */
257291
+ digest_template_name?: string;
255373
257292
  };
255374
257293
  stock_alert?: {
255375
257294
  /** @description Lead stages that trigger the «Stock faltante» check when a lead moves into them. Empty turns it off. */
@@ -257077,6 +258996,11 @@ interface components {
257077
258996
  email: string | null;
257078
258997
  } | null;
257079
258998
  comment_count: number;
258999
+ /**
259000
+ * Format: uuid
259001
+ * @description Finanzas 30: the ad document (`GET /finanzas/documents/{id}`, `origin = ads`) of this movement when it is an ad charge or refund; null otherwise.
259002
+ */
259003
+ ads_document_id: string | null;
257080
259004
  created_at: string;
257081
259005
  };
257082
259006
  FinanzasDocument: {
@@ -257174,6 +259098,38 @@ interface components {
257174
259098
  /** @enum {string} */
257175
259099
  state: "vigente" | "anulada";
257176
259100
  } | null;
259101
+ /** @description Finanzas 30: a document Vitrina made from a Meta / Google card charge (`origin = ads`); null on every other document. */
259102
+ ads?: {
259103
+ /** @enum {string} */
259104
+ platform: "meta_ads" | "google_ads";
259105
+ /** @enum {string} */
259106
+ kind: "charge" | "refund";
259107
+ /** Format: uuid */
259108
+ movement_id: string | null;
259109
+ /**
259110
+ * @description linked = Vitrina linked the movement (see evidence); unconfirmed / no_connection = waiting in «Por resolver»; pending = the ad data could not be read yet; new = not decided.
259111
+ * @enum {string}
259112
+ */
259113
+ verdict: "new" | "pending" | "linked" | "unconfirmed" | "no_connection";
259114
+ reason: string | null;
259115
+ ad_account_id: string | null;
259116
+ customer_id: string | null;
259117
+ /** @description Meta: the card statement reference (`FACEBK *<ref>`). */
259118
+ reference: string | null;
259119
+ /** @description Meta's «Transaction ID» of the charge, once linked. */
259120
+ meta_transaction_id: string | null;
259121
+ evidence: string | null;
259122
+ spend_window: {
259123
+ ad_account_id: string;
259124
+ from: string;
259125
+ to: string;
259126
+ spend_minor: number;
259127
+ currency: string;
259128
+ } | null;
259129
+ /** @description The card movement's original currency. */
259130
+ currency: string | null;
259131
+ amount_original: number | null;
259132
+ } | null;
257177
259133
  created_at: string;
257178
259134
  updated_at: string;
257179
259135
  };
@@ -258102,10 +260058,10 @@ interface components {
258102
260058
  items: {
258103
260059
  id: string;
258104
260060
  /**
258105
- * @description reconcile = movements ↔ documents; transfer = between own accounts; classify = to an account; missing_document = «Falta documento» (money out classified with no document); unknown = no proposal yet.
260061
+ * @description reconcile = movements ↔ documents; transfer = between own accounts; classify = to an account; missing_document = «Falta documento» (money out classified with no document); unknown = no proposal yet; ads_charge = a Meta / Google card charge Vitrina could not confirm («Cargo de publicidad sin confirmar» / «Sin conexión de publicidad», Finanzas 30): the proposal links each movement to its own ads document.
258106
260062
  * @enum {string}
258107
260063
  */
258108
- kind: "reconcile" | "transfer" | "classify" | "missing_document" | "unknown";
260064
+ kind: "reconcile" | "transfer" | "classify" | "missing_document" | "unknown" | "ads_charge";
258109
260065
  title: string;
258110
260066
  summary: string;
258111
260067
  contraparte: {
@@ -258132,16 +260088,17 @@ interface components {
258132
260088
  classify: number;
258133
260089
  missing_document: number;
258134
260090
  unknown: number;
260091
+ ads_charge: number;
258135
260092
  };
258136
260093
  };
258137
260094
  FinanzasCase: {
258138
260095
  id: string;
258139
260096
  key: string;
258140
260097
  /**
258141
- * @description reconcile = movements ↔ documents; transfer = between own accounts; classify = to an account; missing_document = «Falta documento» (money out classified with no document); unknown = no proposal yet.
260098
+ * @description reconcile = movements ↔ documents; transfer = between own accounts; classify = to an account; missing_document = «Falta documento» (money out classified with no document); unknown = no proposal yet; ads_charge = a Meta / Google card charge Vitrina could not confirm («Cargo de publicidad sin confirmar» / «Sin conexión de publicidad», Finanzas 30): the proposal links each movement to its own ads document.
258142
260099
  * @enum {string}
258143
260100
  */
258144
- kind: "reconcile" | "transfer" | "classify" | "missing_document" | "unknown";
260101
+ kind: "reconcile" | "transfer" | "classify" | "missing_document" | "unknown" | "ads_charge";
258145
260102
  /** @enum {string} */
258146
260103
  status: "open" | "resolved";
258147
260104
  /** @enum {string|null} */
@@ -258255,6 +260212,34 @@ interface components {
258255
260212
  type: "document" | "movement";
258256
260213
  id: string;
258257
260214
  }[];
260215
+ /** @description Finanzas 30, `ads_charge` cases only: the matcher's verdict per movement and the Meta charges / ad accounts that could be it. Amounts in the smallest unit of `currency`. */
260216
+ ads?: {
260217
+ /** @enum {string} */
260218
+ platform: "meta_ads" | "google_ads";
260219
+ /** @enum {string} */
260220
+ verdict: "unconfirmed" | "no_connection";
260221
+ items: {
260222
+ /** Format: uuid */
260223
+ movement_id: string;
260224
+ /** Format: uuid */
260225
+ document_id: string;
260226
+ /** @description no_charge | count_mismatch | customer_id_unknown | spend_does_not_cover | ambiguous | refund_unmatched | undone_by_person | no_connection */
260227
+ reason: string;
260228
+ customer_id: string | null;
260229
+ reference: string | null;
260230
+ candidates: {
260231
+ /** Format: uuid */
260232
+ charge_id: string;
260233
+ ad_account_id: string;
260234
+ meta_transaction_id: string | null;
260235
+ event_time: string;
260236
+ local_date: string;
260237
+ amount_minor: number;
260238
+ currency: string;
260239
+ }[];
260240
+ candidate_accounts: string[];
260241
+ }[];
260242
+ } | null;
258258
260243
  opened_at: string;
258259
260244
  computed_at: string;
258260
260245
  };
@@ -258313,6 +260298,8 @@ interface components {
258313
260298
  /** @enum {string|null} */
258314
260299
  target: "document" | "payment" | "transfer" | "third_party" | "cash_deposit" | null;
258315
260300
  reasons: string[];
260301
+ /** @description Links Vitrina made from ad data (Finanzas 30, reasons include `ads_charge`): the evidence in one Spanish line, e.g. «Meta Ads cobró $4.211 el 22 oct a las 09:14 (cuenta …)» or «Gasto del 22 al 24 oct: $47.824 en la cuenta … de Google Ads; el cargo lo cubre». Null otherwise. */
260302
+ evidence: string | null;
258316
260303
  account: {
258317
260304
  /** Format: uuid */
258318
260305
  id: string;
@@ -258445,8 +260432,16 @@ interface components {
258445
260432
  /** @description Automatic actions of the month nobody reviewed in «Hecho por Vitrina». The close confirms this number. */
258446
260433
  unreviewed_count: number;
258447
260434
  unclassified_count: number;
260435
+ /** @description Still to reconcile in the month: bank movements not fully matched plus income documents (boletas, facturas) issued in the month still «Por conciliar» (the same definition as Resultado). */
258448
260436
  unmatched_count: number;
260437
+ /** @description Bank movements of the month not fully matched. */
260438
+ unmatched_movements_count: number;
260439
+ /** @description Income documents issued in the month still «Por conciliar». */
260440
+ unmatched_documents_count: number;
260441
+ /** @description What those movements and documents still leave unmatched, whole CLP. */
258449
260442
  unmatched_pending_clp: number;
260443
+ unmatched_movements_pending_clp: number;
260444
+ unmatched_documents_pending_clp: number;
258450
260445
  };
258451
260446
  close: {
258452
260447
  unreviewed_count: number;
@@ -258479,6 +260474,11 @@ interface components {
258479
260474
  count: number;
258480
260475
  pending_clp: number;
258481
260476
  };
260477
+ /** @description Income documents still «Por conciliar» at the close (closes made after 2026-10-31). */
260478
+ unmatched_documents?: {
260479
+ count: number;
260480
+ pending_clp: number;
260481
+ };
258482
260482
  };
258483
260483
  } | null;
258484
260484
  changes_since_close: {
@@ -258970,10 +260970,10 @@ interface components {
258970
260970
  /** @description Stable item key: document:<uuid>, recurring:<uuid>:<YYYY-MM-DD>, retention:<YYYY-MM>, rescue:<uuid>, cuotas:<day>, appointments:<day>, cash_pending. */
258971
260971
  key: string;
258972
260972
  /**
258973
- * @description payable = a purchase, honorario or gasto by due date; receivable = a sale or issued honorario by due date; retention = the retención of honorarios received, due with the F29; recurring = a recurring item occurrence; cuotas = patient cuotas of the day; appointments = booked appointments with a price of the day; cash_pending = efectivo por depositar; rescue = a planned «Rescatar fondo».
260973
+ * @description payable = a purchase, honorario or gasto by due date; receivable = a sale or issued honorario by due date; retention = the retención of honorarios received, due with the F29; recurring = a recurring item occurrence; cuotas = patient cuotas of the day; appointments = booked appointments with a price of the day; cash_pending = efectivo por depositar: only payments made in cash, still to deposit, today; card_settlement = card payments a processor has not paid out yet, on their payout day (2 business days, Chile holidays skipped); a transfer with no bank match is not projected (it is a Por resolver case); rescue = a planned «Rescatar fondo».
258974
260974
  * @enum {string}
258975
260975
  */
258976
- source: "payable" | "receivable" | "retention" | "recurring" | "cuotas" | "appointments" | "cash_pending" | "rescue";
260976
+ source: "payable" | "receivable" | "retention" | "recurring" | "cuotas" | "appointments" | "cash_pending" | "card_settlement" | "rescue";
258977
260977
  /** @enum {string} */
258978
260978
  direction: "inflow" | "outflow";
258979
260979
  label: string;
@@ -259091,6 +261091,13 @@ interface components {
259091
261091
  receivables_clp: number;
259092
261092
  receivables_count: number;
259093
261093
  };
261094
+ /** @description What the typical weekday income stands on. `insufficient_history` = fewer than 4 weeks of bank history: no typical income is projected (every `typical_inflow_clp` is 0 and there is no band) and the page should say so. */
261095
+ typical_income: {
261096
+ /** @enum {string} */
261097
+ basis: "history" | "insufficient_history";
261098
+ /** @description Whole weeks of bank history behind the weekday band. */
261099
+ weeks: number;
261100
+ };
259094
261101
  band_basis: {
259095
261102
  from: string | null;
259096
261103
  to: string;
@@ -259157,6 +261164,12 @@ interface components {
259157
261164
  } | null;
259158
261165
  };
259159
261166
  };
261167
+ /** @description `lowest` is measured over today .. `to` (`horizon_days`, default 30: the page's window); `month_end` is the end of the current month. */
261168
+ horizon: {
261169
+ days: number;
261170
+ /** @description Last day of the window. */
261171
+ to: string;
261172
+ };
259160
261173
  };
259161
261174
  FinanzasCashFlowMoveResult: {
259162
261175
  dry_run: boolean;
@@ -259313,6 +261326,72 @@ interface components {
259313
261326
  };
259314
261327
  };
259315
261328
  FinanzasAlertList: components["schemas"]["FinanzasAlert"][];
261329
+ FinanzasDigestPreview: {
261330
+ /** @description Monday of this week (YYYY-MM-DD, workspace time). */
261331
+ week_start: string;
261332
+ /** @description This week's send moment: Monday 09:00 workspace time (ISO). */
261333
+ send_at: string;
261334
+ /** @description Next Monday's 09:00 workspace time (ISO). */
261335
+ next_send_at: string;
261336
+ /**
261337
+ * @description This week's digest: `pending` (Monday's send window has not closed and nothing went out yet), `sent`, `empty` (no finance data, nothing went out) or `missed` (the window closed without a digest: the workspace had data but it did not go, e.g. it joined mid-week or the send failed; the next one is `next_send_at`).
261338
+ * @enum {string}
261339
+ */
261340
+ status: "pending" | "sent" | "empty" | "missed";
261341
+ sent_at: string | null;
261342
+ /** @description The workspace has finance data now; false = no digest would go out. */
261343
+ will_send: boolean;
261344
+ /** @description The caller's own channels: their notification preferences for `finanzas.weekly_digest` and, for WhatsApp, the admin's opt-in `finanzas_whatsapp` rail with an approved digest template. */
261345
+ channels: {
261346
+ email: boolean;
261347
+ whatsapp: boolean;
261348
+ };
261349
+ email: {
261350
+ subject: string;
261351
+ hero: {
261352
+ /** @description «Caja hoy» or «Te necesita». */
261353
+ label: string;
261354
+ /** @description THE big number, formatted. */
261355
+ value: string;
261356
+ caption: string | null;
261357
+ };
261358
+ /** @description The one problem (the only red line): the cash runs out within 30 days, or a bank needs reconnecting. Null when there is none. */
261359
+ problem: {
261360
+ text: string;
261361
+ link: {
261362
+ label: string;
261363
+ /** @description Workspace-relative screen (prefix `/w/<workspace>`). */
261364
+ path: string;
261365
+ };
261366
+ } | null;
261367
+ /** @description The rest: the month against the punto de equilibrio, the open cases, what Vitrina ordered. */
261368
+ lines: string[];
261369
+ primary: {
261370
+ label: string;
261371
+ /** @description Workspace-relative screen (prefix `/w/<workspace>`). */
261372
+ path: string;
261373
+ };
261374
+ secondary: {
261375
+ label: string;
261376
+ /** @description Workspace-relative screen (prefix `/w/<workspace>`). */
261377
+ path: string;
261378
+ };
261379
+ };
261380
+ /** @description The WhatsApp `{{resumen}}` for the caller. */
261381
+ whatsapp_text: string;
261382
+ /** @description The same figures as `GET /finanzas/resumen` (whole CLP). Cash and result are null without `finanzas_reports:read`. */
261383
+ figures: {
261384
+ reports_visible: boolean;
261385
+ cash_today_clp: number | null;
261386
+ month_end_clp: number | null;
261387
+ in_30_days_clp: number | null;
261388
+ runs_out_date: string | null;
261389
+ ingresos_clp: number | null;
261390
+ resultado_clp: number | null;
261391
+ equilibrio_clp: number | null;
261392
+ open_cases: number;
261393
+ };
261394
+ };
259316
261395
  FinanzasCostos: {
259317
261396
  from: string;
259318
261397
  to: string;
@@ -259460,6 +261539,153 @@ interface components {
259460
261539
  updated_by: string | null;
259461
261540
  updated_at: string | null;
259462
261541
  };
261542
+ FinanzasResumenCash: {
261543
+ /** @description «Caja hoy»: today’s balance of the operating accounts (savings apart) = the Flujo de caja opening. */
261544
+ today_clp: number;
261545
+ balance_as_of: string | null;
261546
+ accounts_count: number;
261547
+ /** @description Operating accounts with no known balance (not in the total). */
261548
+ unknown_count: number;
261549
+ savings_clp: number;
261550
+ /** @description Projected balance at the end of the month. */
261551
+ month_end: {
261552
+ date: string;
261553
+ balance_clp: number;
261554
+ band: {
261555
+ low_clp: number;
261556
+ high_clp: number;
261557
+ } | null;
261558
+ };
261559
+ /** @description Projected balance 30 days from today. */
261560
+ in_30_days: {
261561
+ date: string;
261562
+ balance_clp: number;
261563
+ band: {
261564
+ low_clp: number;
261565
+ high_clp: number;
261566
+ } | null;
261567
+ };
261568
+ lowest: components["schemas"]["FinanzasCashFlowLowest"] & unknown;
261569
+ /** @description Null when cash stays ≥ 0 for 30 days. */
261570
+ runs_out: {
261571
+ /** @description The first projected day under zero. */
261572
+ date: string;
261573
+ /** @description «Alcanza hasta el …»: the day before. */
261574
+ covered_until: string;
261575
+ balance_clp: number;
261576
+ cause: components["schemas"]["FinanzasCashFlowItem"];
261577
+ } | null;
261578
+ overdue: {
261579
+ payables_clp: number;
261580
+ payables_count: number;
261581
+ stale_payables_clp: number;
261582
+ stale_payables_count: number;
261583
+ receivables_clp: number;
261584
+ receivables_count: number;
261585
+ };
261586
+ /** @description The runway: one point per day, today … today + 30. */
261587
+ points: {
261588
+ date: string;
261589
+ balance_clp: number;
261590
+ band: {
261591
+ low_clp: number;
261592
+ high_clp: number;
261593
+ } | null;
261594
+ }[];
261595
+ } | null;
261596
+ FinanzasResumenResult: {
261597
+ month: string;
261598
+ label: string;
261599
+ proforma: boolean;
261600
+ /** @description Net, as the Resultado. */
261601
+ ingresos_clp: number;
261602
+ /** @description «¿Cuánto gasto?»: variables + fijos. */
261603
+ gastos_clp: number;
261604
+ variables_clp: number;
261605
+ fijos_clp: number;
261606
+ /** @description Part of `variables_clp`: «Egresos sin clasificar», shown apart. */
261607
+ sin_clasificar_clp: number;
261608
+ /** @description The month’s Resultado operacional. */
261609
+ resultado_clp: number;
261610
+ /** @description The break-even line: Costos y equilibrio’s punto de equilibrio of the last closed month (its headline). */
261611
+ equilibrio: {
261612
+ month: string;
261613
+ label: string;
261614
+ equilibrio_clp: number | null;
261615
+ /** @enum {string|null} */
261616
+ sin_calculo: "sin_ingresos" | "margen_no_positivo" | null;
261617
+ } | null;
261618
+ /** @description Percent, one decimal. */
261619
+ cobertura_pct: number | null;
261620
+ /** @description ingresos − equilibrio (negative: still short of it). */
261621
+ brecha_clp: number | null;
261622
+ } | null;
261623
+ FinanzasResumen: {
261624
+ /** @description Today (America/Santiago). */
261625
+ as_of: string;
261626
+ month: string;
261627
+ month_label: string;
261628
+ /** @enum {string} */
261629
+ currency: "CLP";
261630
+ /** @description False for a caller without `finanzas_reports:read` (the «Finanzas» staff permission): `cash` and `result` are null. */
261631
+ reports_visible: boolean;
261632
+ /** @description The newest successful bank / Mercado Pago sync. */
261633
+ synced_at: string | null;
261634
+ /** @description The one problem shown in red: cash running out within 30 days first, else a bank connection that needs a person. */
261635
+ problem: {
261636
+ /** @enum {string} */
261637
+ kind: "cash_runs_out";
261638
+ date: string;
261639
+ balance_clp: number;
261640
+ } | {
261641
+ /** @enum {string} */
261642
+ kind: "connection";
261643
+ connection_id: string;
261644
+ institution_name: string | null;
261645
+ /** @enum {string} */
261646
+ status: "ok" | "pending" | "stale" | "error" | "login_required" | "disconnected";
261647
+ } | null;
261648
+ cash: components["schemas"]["FinanzasResumenCash"];
261649
+ result: components["schemas"]["FinanzasResumenResult"];
261650
+ inbox: components["schemas"]["FinanzasCaseCount"] & {
261651
+ /** @description The previous month, for «Cerrar {mes}» when nothing is open. Null (no prompt) when that month is before the month the add-on became active and holds no bank movements or documents. */
261652
+ close: {
261653
+ month: string;
261654
+ label: string;
261655
+ /** @enum {string} */
261656
+ state: "open" | "ready_to_close" | "closed";
261657
+ open_cases: number;
261658
+ } | null;
261659
+ };
261660
+ automatic: {
261661
+ month: string;
261662
+ count: number;
261663
+ total_clp: number;
261664
+ unreviewed_count: number;
261665
+ by_actor: {
261666
+ rule: number;
261667
+ match: number;
261668
+ ai: number;
261669
+ };
261670
+ /** @description The newest 3 automatic actions of the month; undo through POST /finanzas/automatic-actions/{kind}/{id}/undo. */
261671
+ recent: (components["schemas"]["FinanzasAutomaticAction"] & {
261672
+ group_name: string;
261673
+ })[];
261674
+ };
261675
+ accounts: {
261676
+ id: string;
261677
+ name: string;
261678
+ institution_name: string | null;
261679
+ number_masked: string | null;
261680
+ type: string;
261681
+ /** @enum {string} */
261682
+ currency: "CLP" | "USD";
261683
+ balance_clp: number | null;
261684
+ balance_as_of: string | null;
261685
+ /** @description False for savings accounts (not in «Caja hoy»). */
261686
+ in_cash: boolean;
261687
+ }[];
261688
+ };
259463
261689
  FinanzasPuente: {
259464
261690
  from: string;
259465
261691
  to: string;
@@ -259563,6 +261789,110 @@ interface components {
259563
261789
  payments: number;
259564
261790
  }[];
259565
261791
  };
261792
+ FinanzasAdsConnections: {
261793
+ /** @description The workspace has its ad-data link (provisioned when it connects Meta Ads). */
261794
+ profile: boolean;
261795
+ last_attempt_at: string | null;
261796
+ last_sync_at: string | null;
261797
+ /** @description Spanish copy when the last read failed, else null. */
261798
+ last_error: string | null;
261799
+ platforms: {
261800
+ /** @enum {string} */
261801
+ platform: "meta_ads" | "google_ads";
261802
+ /** @example Meta Ads */
261803
+ label: string;
261804
+ /**
261805
+ * @description connected = at least one healthy account; expired = accounts, none healthy; none = no account.
261806
+ * @enum {string}
261807
+ */
261808
+ status: "connected" | "expired" | "none";
261809
+ accounts: {
261810
+ /** @enum {string} */
261811
+ platform: "meta_ads" | "google_ads" | "tiktok_ads";
261812
+ /**
261813
+ * @description The platform's own id: Meta `act_…`, Google the 10-digit customer id.
261814
+ * @example act_969938652650502
261815
+ */
261816
+ ad_account_id: string;
261817
+ /** @description Google: `123-456-7890`; Meta: the `act_…` id. */
261818
+ account_label: string;
261819
+ account_name: string | null;
261820
+ currency: string | null;
261821
+ timezone: string | null;
261822
+ /** @description connected | syncing | error | disconnected | reconnect_required | revoked */
261823
+ connection_status: string;
261824
+ /** @description connected or syncing. */
261825
+ healthy: boolean;
261826
+ last_synced_at: string | null;
261827
+ /** @description True only for Meta. */
261828
+ charges_supported: boolean;
261829
+ /** @description When Meta's activity log was last read in full; null = never. */
261830
+ charges_synced_at: string | null;
261831
+ charges_synced: number;
261832
+ charges_linked: number;
261833
+ /** @description Spend per month over the last read (92 days), smallest unit of `currency`. */
261834
+ spend_by_month: {
261835
+ /** @example 2026-10 */
261836
+ month: string;
261837
+ spend_minor: number;
261838
+ currency: string | null;
261839
+ }[];
261840
+ }[];
261841
+ without_connection: string;
261842
+ /** @description Where to connect: Integraciones › Meta Ads (no connect flow here). */
261843
+ connect_path: string;
261844
+ }[];
261845
+ };
261846
+ FinanzasAdsCharge: {
261847
+ id: string;
261848
+ /** @enum {string} */
261849
+ platform: "meta_ads" | "google_ads" | "tiktok_ads";
261850
+ ad_account_id: string;
261851
+ event_type: string;
261852
+ /** @description cargo | reembolso | contracargo | rechazo | fondos */
261853
+ event_label: string;
261854
+ event_time: string;
261855
+ local_date: string;
261856
+ /** @description Meta's «Transaction ID» (Billing & payments), unique per charge. */
261857
+ meta_transaction_id: string | null;
261858
+ /** @description Smallest unit of `currency` (CLP pesos, USD cents). Null when Meta stated none. */
261859
+ amount_minor: number | null;
261860
+ currency: string | null;
261861
+ /** @enum {string} */
261862
+ link_state: "linked" | "unlinked";
261863
+ document_id: string | null;
261864
+ movement_id: string | null;
261865
+ linked_at: string | null;
261866
+ };
261867
+ FinanzasAdsChargesList: {
261868
+ from: string;
261869
+ to: string;
261870
+ items: components["schemas"]["FinanzasAdsCharge"][];
261871
+ totals: {
261872
+ count: number;
261873
+ linked: number;
261874
+ unlinked: number;
261875
+ };
261876
+ };
261877
+ FinanzasAdsSyncResult: {
261878
+ skipped: boolean;
261879
+ /** @enum {string} */
261880
+ read: "ok" | "no_profile" | "error" | "skipped";
261881
+ accounts: number;
261882
+ charges_new: number;
261883
+ recognize: {
261884
+ recognized: number;
261885
+ created: number;
261886
+ receipt_first: number;
261887
+ };
261888
+ match: {
261889
+ open: number;
261890
+ linked: number;
261891
+ unconfirmed: number;
261892
+ no_connection: number;
261893
+ pending: number;
261894
+ };
261895
+ };
259566
261896
  ClinicImportedBalanceBudget: {
259567
261897
  /** Format: uuid */
259568
261898
  budget_id: string;