@vitrina/api 15.29.0 → 15.30.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 +1671 -444
  2. package/dist/index.d.ts +1671 -444
  3. package/package.json +1 -1
package/dist/index.d.cts CHANGED
@@ -68979,7 +68979,7 @@ interface paths {
68979
68979
  };
68980
68980
  /**
68981
68981
  * How this business charges, and its Mercado Pago connection
68982
- * @description `charging.reservation` (refundable reservations: booking deposits, vehicle reservation deposits) and `charging.final` (balances, budgets, packs, services), each with the effective `mode`, whether it is the workspace's choice or the vertical default (`source`), and the `default_mode`. Defaults: healthcare `mp_first` for both; automotive `transfer_first` for reservations (a Mercado Pago refund does not return the commission) and `mp_first` for final payments; any other vertical `mp_first`. `provider` is which connected provider payment links go through (`preferred`: the business's choice or null; `active`: what a new link would use now or null when none is connected; `connected`: every connected provider, which the buyer chooses among on the link page when there are two or more); `webpay` is the Webpay Plus connection status and `fintoc`, `flow` and `khipu` the Fintoc, Flow and Khipu ones. `mercadopago` is the connection status plus `configured` (the environment can connect at all). `installments.min_clp`: from which amount a final-charge link offers cuotas (`null` = off). `budgets.accept_charge`: what a presupuesto's «aceptar y pagar» charges (`full` | `first_installment`). Requires `tenant_bank_accounts:read` (or `clinic_money:read`).
68982
+ * @description `charging.reservation` (refundable reservations: booking deposits, vehicle reservation deposits) and `charging.final` (balances, budgets, packs, services), each with the effective `mode`, whether it is the workspace's choice or the vertical default (`source`), and the `default_mode`. Defaults: healthcare `mp_first` for both; automotive `transfer_first` for reservations (a Mercado Pago refund does not return the commission) and `mp_first` for final payments; any other vertical `mp_first`. `provider` is which connected provider payment links go through (`preferred`: the business's choice or null; `active`: what a new link would use now or null when none is connected; `connected`: every connected provider, which the buyer chooses among on the link page when there are two or more); `webpay` is the Webpay Plus connection status and `fintoc`, `flow`, `khipu` and `bancame` the Fintoc, Flow, Khipu and banca.me («cuotas sin tarjeta») ones. `mercadopago` is the connection status plus `configured` (the environment can connect at all). `installments.min_clp`: from which amount a final-charge link offers cuotas (`null` = off). `budgets.accept_charge`: what a presupuesto's «aceptar y pagar» charges (`full` | `first_installment`). Requires `tenant_bank_accounts:read` (or `clinic_money:read`).
68983
68983
  */
68984
68984
  get: {
68985
68985
  parameters: {
@@ -69019,7 +69019,8 @@ interface paths {
69019
69019
  * "webpay",
69020
69020
  * "fintoc",
69021
69021
  * "flow",
69022
- * "khipu"
69022
+ * "khipu",
69023
+ * "bancame"
69023
69024
  * ]
69024
69025
  * },
69025
69026
  * "webpay": {
@@ -69047,6 +69048,14 @@ interface paths {
69047
69048
  * "api_key_preview": "9d2f••••a7",
69048
69049
  * "connected_at": "2026-10-20T14:00:00.000Z"
69049
69050
  * },
69051
+ * "bancame": {
69052
+ * "connected": true,
69053
+ * "environment": "automation",
69054
+ * "merchant_entity": "ex-46df3310759e9000",
69055
+ * "public_key": "pk_bancame_example",
69056
+ * "private_key_preview": "eyJh••••c5",
69057
+ * "connected_at": "2026-11-02T14:00:00.000Z"
69058
+ * },
69050
69059
  * "installments": {
69051
69060
  * "min_clp": null
69052
69061
  * },
@@ -69949,7 +69958,7 @@ interface paths {
69949
69958
  get?: never;
69950
69959
  /**
69951
69960
  * Choose which connected provider payment links use
69952
- * @description When the business connected more than one customer payment provider (Mercado Pago, Webpay Plus, Fintoc, Flow, Khipu), payment links go through the one chosen here; `null` clears the choice (the first connected one is used). A choice that is not connected is ignored at link time. Returns the choice and the provider a new link would use now. Requires `tenant_bank_accounts:write` (or `clinic_money:write`).
69961
+ * @description When the business connected more than one customer payment provider (Mercado Pago, Webpay Plus, Fintoc, Flow, Khipu, banca.me), payment links go through the one chosen here; `null` clears the choice (the first connected one is used). A choice that is not connected is ignored at link time. Returns the choice and the provider a new link would use now. Requires `tenant_bank_accounts:write` (or `clinic_money:write`).
69953
69962
  */
69954
69963
  put: {
69955
69964
  parameters: {
@@ -69971,7 +69980,7 @@ interface paths {
69971
69980
  * @example webpay
69972
69981
  * @enum {string|null}
69973
69982
  */
69974
- provider: "mercadopago" | "webpay" | "fintoc" | "flow" | "khipu" | null;
69983
+ provider: "mercadopago" | "webpay" | "fintoc" | "flow" | "khipu" | "bancame" | null;
69975
69984
  };
69976
69985
  };
69977
69986
  };
@@ -71389,7 +71398,7 @@ interface paths {
71389
71398
  patch?: never;
71390
71399
  trace?: never;
71391
71400
  };
71392
- "/clinic/bank-feed/sources": {
71401
+ "/payment-settings/bancame/status": {
71393
71402
  parameters: {
71394
71403
  query?: never;
71395
71404
  header?: never;
@@ -71397,10 +71406,8 @@ interface paths {
71397
71406
  cookie?: never;
71398
71407
  };
71399
71408
  /**
71400
- * Bank feed sources available to this clinic
71401
- * @description The e-mail rail (free, always on), Fintoc (optional add-on `bank_feed_fintoc`, billed per connected bank per month at the provider's list price — `price_clp_per_bank_month` is null until it is set) and BCI API Market (not configured until the partner approval lands). Requires `clinic_money:read`.
71402
- *
71403
- * **Connected apps:** every patient and contact in the response is a Seudónimo de paciente — initials plus a stable number, `"M.F. · #1001"` — unless the clinic allowed patient names, with RUT, phone and email masked in free text and `meta.patient_privacy` saying so. Clinical alerts (`flags`) are withheld in both modes, and a non-JSON body (an export, a file) is refused with `403 CONNECTED_APP_SENSITIVE_DATA`.
71409
+ * banca.me connection status
71410
+ * @description Whether a banca.me partner account («cuotas sin tarjeta») is connected: its `environment`, merchant `merchant_entity` (banca.me’s `entityId`), `public_key` (not a secret) and a masked `private_key_preview`. The private key and the webhook secret are never returned. Requires `tenant_bank_accounts:read` (or `clinic_money:read`).
71404
71411
  */
71405
71412
  get: {
71406
71413
  parameters: {
@@ -71411,7 +71418,7 @@ interface paths {
71411
71418
  };
71412
71419
  requestBody?: never;
71413
71420
  responses: {
71414
- /** @description The sources */
71421
+ /** @description The connection status */
71415
71422
  200: {
71416
71423
  headers: {
71417
71424
  [name: string]: unknown;
@@ -71420,148 +71427,20 @@ interface paths {
71420
71427
  /**
71421
71428
  * @example {
71422
71429
  * "data": {
71423
- * "email": {
71424
- * "available": true,
71425
- * "billed": false
71426
- * },
71427
- * "fintoc": {
71428
- * "configured": true,
71429
- * "entitled": true,
71430
- * "feature": "bank_feed_fintoc",
71431
- * "price_clp_per_bank_month": null,
71432
- * "connected_banks": 1
71433
- * },
71434
- * "bci_api_market": {
71435
- * "configured": false,
71436
- * "reason": "BCI API Market production access is pending partner approval."
71437
- * }
71430
+ * "connected": true,
71431
+ * "environment": "automation",
71432
+ * "merchant_entity": "ex-46df3310759e9000",
71433
+ * "public_key": "pk_bancame_example",
71434
+ * "private_key_preview": "eyJh••••c5",
71435
+ * "connected_at": "2026-11-02T14:00:00.000Z"
71438
71436
  * }
71439
71437
  * }
71440
71438
  */
71441
71439
  "application/json": {
71442
- data: components["schemas"]["BankFeedSources"];
71443
- };
71444
- };
71445
- };
71446
- /** @description Validation error */
71447
- 400: {
71448
- headers: {
71449
- [name: string]: unknown;
71450
- };
71451
- content: {
71452
- "application/json": components["schemas"]["Error"];
71453
- };
71454
- };
71455
- /** @description Unauthorized */
71456
- 401: {
71457
- headers: {
71458
- [name: string]: unknown;
71459
- };
71460
- content: {
71461
- "application/json": components["schemas"]["Error"];
71462
- };
71463
- };
71464
- /** @description Forbidden */
71465
- 403: {
71466
- headers: {
71467
- [name: string]: unknown;
71468
- };
71469
- content: {
71470
- "application/json": components["schemas"]["Error"];
71471
- };
71472
- };
71473
- /** @description Not found */
71474
- 404: {
71475
- headers: {
71476
- [name: string]: unknown;
71477
- };
71478
- content: {
71479
- "application/json": components["schemas"]["Error"];
71480
- };
71481
- };
71482
- /** @description Conflict (incl. Idempotency-Key reuse with different body) */
71483
- 409: {
71484
- headers: {
71485
- [name: string]: unknown;
71486
- };
71487
- content: {
71488
- "application/json": components["schemas"]["Error"];
71489
- };
71490
- };
71491
- /** @description Rate limited */
71492
- 429: {
71493
- headers: {
71494
- [name: string]: unknown;
71495
- };
71496
- content: {
71497
- "application/json": components["schemas"]["Error"];
71498
- };
71499
- };
71500
- };
71501
- };
71502
- put?: never;
71503
- post?: never;
71504
- delete?: never;
71505
- options?: never;
71506
- head?: never;
71507
- patch?: never;
71508
- trace?: never;
71509
- };
71510
- "/clinic/bank-feed/connections": {
71511
- parameters: {
71512
- query?: never;
71513
- header?: never;
71514
- path?: never;
71515
- cookie?: never;
71516
- };
71517
- /**
71518
- * Connected bank links
71519
- * @description Every bank link this clinic connected through an API source, enabled or not, with masked account numbers and the last sync result. Requires `clinic_money:read`.
71520
- *
71521
- * **Connected apps:** every patient and contact in the response is a Seudónimo de paciente — initials plus a stable number, `"M.F. · #1001"` — unless the clinic allowed patient names, with RUT, phone and email masked in free text and `meta.patient_privacy` saying so. Clinical alerts (`flags`) are withheld in both modes, and a non-JSON body (an export, a file) is refused with `403 CONNECTED_APP_SENSITIVE_DATA`.
71522
- */
71523
- get: {
71524
- parameters: {
71525
- query?: never;
71526
- header?: never;
71527
- path?: never;
71528
- cookie?: never;
71529
- };
71530
- requestBody?: never;
71531
- responses: {
71532
- /** @description The connections */
71533
- 200: {
71534
- headers: {
71535
- [name: string]: unknown;
71536
- };
71537
- content: {
71538
- /**
71539
- * @example {
71540
- * "data": [
71541
- * {
71542
- * "id": "bf0bf0bf-0000-4000-8000-000000000001",
71543
- * "provider": "fintoc",
71544
- * "institution_name": "Banco de Chile",
71545
- * "holder_name": "Clínica Ejemplo SpA",
71546
- * "accounts": [
71547
- * {
71548
- * "id": "acc_9Xz2Lm",
71549
- * "number_masked": "••••4821"
71550
- * }
71551
- * ],
71552
- * "enabled": true,
71553
- * "connected_at": "2026-09-20T14:02:11.000Z",
71554
- * "disconnected_at": null,
71555
- * "last_sync_at": "2026-09-22T09:00:04.000Z",
71556
- * "last_sync_status": "ok",
71557
- * "last_sync_error": null,
71558
- * "sync_cursor": "2026-09-22"
71559
- * }
71560
- * ]
71561
- * }
71562
- */
71563
- "application/json": {
71564
- data: components["schemas"]["BankFeedConnection"][];
71440
+ data?: unknown;
71441
+ meta?: {
71442
+ [key: string]: unknown;
71443
+ };
71565
71444
  };
71566
71445
  };
71567
71446
  };
@@ -71629,7 +71508,7 @@ interface paths {
71629
71508
  patch?: never;
71630
71509
  trace?: never;
71631
71510
  };
71632
- "/clinic/bank-feed/fintoc/connect": {
71511
+ "/payment-settings/bancame/connect": {
71633
71512
  parameters: {
71634
71513
  query?: never;
71635
71514
  header?: never;
@@ -71639,10 +71518,8 @@ interface paths {
71639
71518
  get?: never;
71640
71519
  put?: never;
71641
71520
  /**
71642
- * Connect a bank through Fintoc
71643
- * @description Send the `exchange_token` Fintoc's widget returns (or a `link_token`). The server swaps it for the long-lived link token, stores it encrypted, and queues the first pull. Requires the `bank_feed_fintoc` add-on — without it the answer is `402 ENTITLEMENT_NOT_ACTIVE` (the upsell). Reconnecting the same bank updates its connection. Requires `clinic_money:write`.
71644
- *
71645
- * **Connected apps:** every patient and contact in the response is a Seudónimo de paciente — initials plus a stable number, `"M.F. · #1001"` — unless the clinic allowed patient names, with RUT, phone and email masked in free text and `meta.patient_privacy` saying so. Clinical alerts (`flags`) are withheld in both modes, and a non-JSON body (an export, a file) is refused with `403 CONNECTED_APP_SENSITIVE_DATA`.
71521
+ * Connect the business's own banca.me account
71522
+ * @description Connects the business's OWN banca.me partner account (buy now, pay later: the buyer pays in installments from a bank account, no card; banca.me pays the business). The money never passes through Vitrina. The private key is verified against banca.me (400 `bancame_key_rejected` when banca.me refuses it), then the merchant (400 `bancame_entity_rejected` for an unknown or inactive `merchant_entity` or one without BNPL), then Vitrina registers its `loan_approved` webhook on the account (400 `bancame_webhook_limit` when the account already has 10 active webhooks) and stores the private key and the webhook secret encrypted; nothing is stored when a step fails. Use `automation` to try it with banca.me’s fixed test outcomes. A reconnect replaces the credentials and the webhook. Requires `tenant_bank_accounts:write` (or `clinic_money:write`).
71646
71523
  */
71647
71524
  post: {
71648
71525
  parameters: {
@@ -71658,15 +71535,34 @@ interface paths {
71658
71535
  content: {
71659
71536
  /**
71660
71537
  * @example {
71661
- * "exchange_token": "exch_7f3a9b2c1d"
71538
+ * "private_key": "<your partner Private Key>",
71539
+ * "public_key": "<your partner Public Key>",
71540
+ * "merchant_entity": "ex-46df3310759e9000",
71541
+ * "environment": "automation"
71662
71542
  * }
71663
71543
  */
71664
- "application/json": components["schemas"]["BankFeedFintocConnectBody"];
71544
+ "application/json": {
71545
+ /** @description The partner Private Key («llave privada», the API token banca.me shares through 1Password) for the chosen environment. Verified against banca.me, stored encrypted, never returned. */
71546
+ private_key: string;
71547
+ /** @description The partner Public Key: it opens banca.me’s payment page. Not a secret; returned by the status. */
71548
+ public_key: string;
71549
+ /**
71550
+ * @description The merchant id («entityId») banca.me registered for this business. Verified against banca.me.
71551
+ * @example ex-46df3310759e9000
71552
+ */
71553
+ merchant_entity: string;
71554
+ /**
71555
+ * @description `automation` = banca.me’s test environment with fixed outcomes per RUT (33333333-3 approves, 11111111-1 is rejected); `beta` = development copy of production; `production` = real loans.
71556
+ * @example automation
71557
+ * @enum {string}
71558
+ */
71559
+ environment: "automation" | "beta" | "production";
71560
+ };
71665
71561
  };
71666
71562
  };
71667
71563
  responses: {
71668
- /** @description The connection */
71669
- 201: {
71564
+ /** @description The connection status */
71565
+ 200: {
71670
71566
  headers: {
71671
71567
  [name: string]: unknown;
71672
71568
  };
@@ -71674,28 +71570,20 @@ interface paths {
71674
71570
  /**
71675
71571
  * @example {
71676
71572
  * "data": {
71677
- * "id": "bf0bf0bf-0000-4000-8000-000000000001",
71678
- * "provider": "fintoc",
71679
- * "institution_name": "Banco de Chile",
71680
- * "holder_name": "Clínica Ejemplo SpA",
71681
- * "accounts": [
71682
- * {
71683
- * "id": "acc_9Xz2Lm",
71684
- * "number_masked": "••••4821"
71685
- * }
71686
- * ],
71687
- * "enabled": true,
71688
- * "connected_at": "2026-09-20T14:02:11.000Z",
71689
- * "disconnected_at": null,
71690
- * "last_sync_at": "2026-09-22T09:00:04.000Z",
71691
- * "last_sync_status": "ok",
71692
- * "last_sync_error": null,
71693
- * "sync_cursor": "2026-09-22"
71573
+ * "connected": true,
71574
+ * "environment": "automation",
71575
+ * "merchant_entity": "ex-46df3310759e9000",
71576
+ * "public_key": "pk_bancame_example",
71577
+ * "private_key_preview": "eyJh••••c5",
71578
+ * "connected_at": "2026-11-02T14:00:00.000Z"
71694
71579
  * }
71695
71580
  * }
71696
71581
  */
71697
71582
  "application/json": {
71698
- data: components["schemas"]["BankFeedConnection"];
71583
+ data?: unknown;
71584
+ meta?: {
71585
+ [key: string]: unknown;
71586
+ };
71699
71587
  };
71700
71588
  };
71701
71589
  };
@@ -71761,7 +71649,7 @@ interface paths {
71761
71649
  patch?: never;
71762
71650
  trace?: never;
71763
71651
  };
71764
- "/clinic/bank-feed/connections/{id}/sync": {
71652
+ "/payment-settings/bancame/disconnect": {
71765
71653
  parameters: {
71766
71654
  query?: never;
71767
71655
  header?: never;
@@ -71771,10 +71659,8 @@ interface paths {
71771
71659
  get?: never;
71772
71660
  put?: never;
71773
71661
  /**
71774
- * Sincronizar ahora — enqueue a pull of one bank link
71775
- * @description Enqueues the SAME job the daily tick uses; the stable per-connection jobId dedups with an in-flight sync. Requires `clinic_money:write`.
71776
- *
71777
- * **Connected apps:** every patient and contact in the response is a Seudónimo de paciente — initials plus a stable number, `"M.F. · #1001"` — unless the clinic allowed patient names, with RUT, phone and email masked in free text and `meta.patient_privacy` saying so. Clinical alerts (`flags`) are withheld in both modes, and a non-JSON body (an export, a file) is refused with `403 CONNECTED_APP_SENSITIVE_DATA`.
71662
+ * Disconnect banca.me
71663
+ * @description Reversible: the connection survives disabled and a later connect re-enables it (with a new webhook). Vitrina deactivates its webhook on the account. Payment links fall back to another connected provider or the transfer. Requires `tenant_bank_accounts:write` (or `clinic_money:write`).
71778
71664
  */
71779
71665
  post: {
71780
71666
  parameters: {
@@ -71783,32 +71669,17 @@ interface paths {
71783
71669
  /** @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. */
71784
71670
  "Idempotency-Key"?: string;
71785
71671
  };
71786
- path: {
71787
- id: string;
71788
- };
71672
+ path?: never;
71789
71673
  cookie?: never;
71790
71674
  };
71791
71675
  requestBody?: never;
71792
71676
  responses: {
71793
- /** @description Enqueued */
71794
- 202: {
71677
+ /** @description Disconnected */
71678
+ 204: {
71795
71679
  headers: {
71796
71680
  [name: string]: unknown;
71797
71681
  };
71798
- content: {
71799
- /**
71800
- * @example {
71801
- * "data": {
71802
- * "enqueued": true
71803
- * }
71804
- * }
71805
- */
71806
- "application/json": {
71807
- data: {
71808
- enqueued: boolean;
71809
- };
71810
- };
71811
- };
71682
+ content?: never;
71812
71683
  };
71813
71684
  /** @description Validation error */
71814
71685
  400: {
@@ -71872,41 +71743,59 @@ interface paths {
71872
71743
  patch?: never;
71873
71744
  trace?: never;
71874
71745
  };
71875
- "/clinic/bank-feed/connections/{id}/disconnect": {
71746
+ "/clinic/bank-feed/sources": {
71876
71747
  parameters: {
71877
71748
  query?: never;
71878
71749
  header?: never;
71879
71750
  path?: never;
71880
71751
  cookie?: never;
71881
71752
  };
71882
- get?: never;
71883
- put?: never;
71884
71753
  /**
71885
- * Disconnect a bank link
71886
- * @description Reversible: the connection survives disabled (its movements stay in the ledger), stops syncing and stops counting as a billed bank from the next period. Requires `clinic_money:write`.
71754
+ * Bank feed sources available to this clinic
71755
+ * @description The e-mail rail (free, always on), Fintoc (optional add-on `bank_feed_fintoc`, billed per connected bank per month at the provider's list price — `price_clp_per_bank_month` is null until it is set) and BCI API Market (not configured until the partner approval lands). Requires `clinic_money:read`.
71887
71756
  *
71888
71757
  * **Connected apps:** every patient and contact in the response is a Seudónimo de paciente — initials plus a stable number, `"M.F. · #1001"` — unless the clinic allowed patient names, with RUT, phone and email masked in free text and `meta.patient_privacy` saying so. Clinical alerts (`flags`) are withheld in both modes, and a non-JSON body (an export, a file) is refused with `403 CONNECTED_APP_SENSITIVE_DATA`.
71889
71758
  */
71890
- post: {
71759
+ get: {
71891
71760
  parameters: {
71892
71761
  query?: never;
71893
- header?: {
71894
- /** @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. */
71895
- "Idempotency-Key"?: string;
71896
- };
71897
- path: {
71898
- id: string;
71899
- };
71762
+ header?: never;
71763
+ path?: never;
71900
71764
  cookie?: never;
71901
71765
  };
71902
71766
  requestBody?: never;
71903
71767
  responses: {
71904
- /** @description Disconnected */
71905
- 204: {
71768
+ /** @description The sources */
71769
+ 200: {
71906
71770
  headers: {
71907
71771
  [name: string]: unknown;
71908
71772
  };
71909
- content?: never;
71773
+ content: {
71774
+ /**
71775
+ * @example {
71776
+ * "data": {
71777
+ * "email": {
71778
+ * "available": true,
71779
+ * "billed": false
71780
+ * },
71781
+ * "fintoc": {
71782
+ * "configured": true,
71783
+ * "entitled": true,
71784
+ * "feature": "bank_feed_fintoc",
71785
+ * "price_clp_per_bank_month": null,
71786
+ * "connected_banks": 1
71787
+ * },
71788
+ * "bci_api_market": {
71789
+ * "configured": false,
71790
+ * "reason": "BCI API Market production access is pending partner approval."
71791
+ * }
71792
+ * }
71793
+ * }
71794
+ */
71795
+ "application/json": {
71796
+ data: components["schemas"]["BankFeedSources"];
71797
+ };
71798
+ };
71910
71799
  };
71911
71800
  /** @description Validation error */
71912
71801
  400: {
@@ -71964,50 +71853,37 @@ interface paths {
71964
71853
  };
71965
71854
  };
71966
71855
  };
71856
+ put?: never;
71857
+ post?: never;
71967
71858
  delete?: never;
71968
71859
  options?: never;
71969
71860
  head?: never;
71970
71861
  patch?: never;
71971
71862
  trace?: never;
71972
71863
  };
71973
- "/clinic/bank-feed/email/pull": {
71864
+ "/clinic/bank-feed/connections": {
71974
71865
  parameters: {
71975
71866
  query?: never;
71976
71867
  header?: never;
71977
71868
  path?: never;
71978
71869
  cookie?: never;
71979
71870
  };
71980
- get?: never;
71981
- put?: never;
71982
71871
  /**
71983
- * Re-read bank e-mails still in the inbox for a window
71984
- * @description Runs the e-mail source of the bank feed over `[from, to]` (Santiago days, ≤ 92 days): bank comprobantes that are still conversations in a connected mailbox become `bank_movement` rows (provenance `backfill` — historical, never announced to anyone). Idempotent. Requires `clinic_money:write`.
71872
+ * Connected bank links
71873
+ * @description Every bank link this clinic connected through an API source, enabled or not, with masked account numbers and the last sync result. Requires `clinic_money:read`.
71985
71874
  *
71986
71875
  * **Connected apps:** every patient and contact in the response is a Seudónimo de paciente — initials plus a stable number, `"M.F. · #1001"` — unless the clinic allowed patient names, with RUT, phone and email masked in free text and `meta.patient_privacy` saying so. Clinical alerts (`flags`) are withheld in both modes, and a non-JSON body (an export, a file) is refused with `403 CONNECTED_APP_SENSITIVE_DATA`.
71987
71876
  */
71988
- post: {
71877
+ get: {
71989
71878
  parameters: {
71990
71879
  query?: never;
71991
- header?: {
71992
- /** @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. */
71993
- "Idempotency-Key"?: string;
71994
- };
71880
+ header?: never;
71995
71881
  path?: never;
71996
71882
  cookie?: never;
71997
71883
  };
71998
- requestBody?: {
71999
- content: {
72000
- /**
72001
- * @example {
72002
- * "from": "2026-09-01",
72003
- * "to": "2026-09-22"
72004
- * }
72005
- */
72006
- "application/json": components["schemas"]["BankFeedEmailPullBody"];
72007
- };
72008
- };
71884
+ requestBody?: never;
72009
71885
  responses: {
72010
- /** @description What was ingested */
71886
+ /** @description The connections */
72011
71887
  200: {
72012
71888
  headers: {
72013
71889
  [name: string]: unknown;
@@ -72015,16 +71891,31 @@ interface paths {
72015
71891
  content: {
72016
71892
  /**
72017
71893
  * @example {
72018
- * "data": {
72019
- * "drafts": 0,
72020
- * "inserted": 3,
72021
- * "deduped": 1,
72022
- * "cross_source_twins": 1
72023
- * }
71894
+ * "data": [
71895
+ * {
71896
+ * "id": "bf0bf0bf-0000-4000-8000-000000000001",
71897
+ * "provider": "fintoc",
71898
+ * "institution_name": "Banco de Chile",
71899
+ * "holder_name": "Clínica Ejemplo SpA",
71900
+ * "accounts": [
71901
+ * {
71902
+ * "id": "acc_9Xz2Lm",
71903
+ * "number_masked": "••••4821"
71904
+ * }
71905
+ * ],
71906
+ * "enabled": true,
71907
+ * "connected_at": "2026-09-20T14:02:11.000Z",
71908
+ * "disconnected_at": null,
71909
+ * "last_sync_at": "2026-09-22T09:00:04.000Z",
71910
+ * "last_sync_status": "ok",
71911
+ * "last_sync_error": null,
71912
+ * "sync_cursor": "2026-09-22"
71913
+ * }
71914
+ * ]
72024
71915
  * }
72025
71916
  */
72026
71917
  "application/json": {
72027
- data: components["schemas"]["BankFeedIngestResult"];
71918
+ data: components["schemas"]["BankFeedConnection"][];
72028
71919
  };
72029
71920
  };
72030
71921
  };
@@ -72084,36 +71975,52 @@ interface paths {
72084
71975
  };
72085
71976
  };
72086
71977
  };
71978
+ put?: never;
71979
+ post?: never;
72087
71980
  delete?: never;
72088
71981
  options?: never;
72089
71982
  head?: never;
72090
71983
  patch?: never;
72091
71984
  trace?: never;
72092
71985
  };
72093
- "/finanzas/accounts": {
71986
+ "/clinic/bank-feed/fintoc/connect": {
72094
71987
  parameters: {
72095
71988
  query?: never;
72096
71989
  header?: never;
72097
71990
  path?: never;
72098
71991
  cookie?: never;
72099
71992
  };
71993
+ get?: never;
71994
+ put?: never;
72100
71995
  /**
72101
- * Plan de cuentas: the account tree
72102
- * @description Every account of the workspace as a flat list in tree order (parents before children, siblings in screen order), each with `depth` and `path`. The first read of a workspace that holds the add-on creates the starter chart for its vertical (clinic, automotora or generic). Archived accounts are left out unless `include_archived=true`. The plan de cuentas is a classification tree, not double-entry. Each account has a `kind` (`ingreso`, `costo`, `gasto` or `no_operacional`) and, on `costo` and `gasto` only, a `behavior` (`fijo` or `variable`). A sub-account has its parent’s kind. Rule breaks answer `422 FINANZAS_ACCOUNT_INVALID` and state conflicts `409 FINANZAS_ACCOUNT_CONFLICT`, both with `details.reason`. Requires the `finanzas` add-on — without it every Finanzas operation answers `402 ENTITLEMENT_NOT_ACTIVE` (`details.required = ["finanzas"]`). Requires `finanzas:read`.
71996
+ * Connect a bank through Fintoc
71997
+ * @description Send the `exchange_token` Fintoc's widget returns (or a `link_token`). The server swaps it for the long-lived link token, stores it encrypted, and queues the first pull. Requires the `bank_feed_fintoc` add-on — without it the answer is `402 ENTITLEMENT_NOT_ACTIVE` (the upsell). Reconnecting the same bank updates its connection. Requires `clinic_money:write`.
71998
+ *
71999
+ * **Connected apps:** every patient and contact in the response is a Seudónimo de paciente — initials plus a stable number, `"M.F. · #1001"` — unless the clinic allowed patient names, with RUT, phone and email masked in free text and `meta.patient_privacy` saying so. Clinical alerts (`flags`) are withheld in both modes, and a non-JSON body (an export, a file) is refused with `403 CONNECTED_APP_SENSITIVE_DATA`.
72103
72000
  */
72104
- get: {
72001
+ post: {
72105
72002
  parameters: {
72106
- query?: {
72107
- include_archived?: "true" | "false";
72003
+ query?: never;
72004
+ header?: {
72005
+ /** @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. */
72006
+ "Idempotency-Key"?: string;
72108
72007
  };
72109
- header?: never;
72110
72008
  path?: never;
72111
72009
  cookie?: never;
72112
72010
  };
72113
- requestBody?: never;
72011
+ requestBody?: {
72012
+ content: {
72013
+ /**
72014
+ * @example {
72015
+ * "exchange_token": "exch_7f3a9b2c1d"
72016
+ * }
72017
+ */
72018
+ "application/json": components["schemas"]["BankFeedFintocConnectBody"];
72019
+ };
72020
+ };
72114
72021
  responses: {
72115
- /** @description The accounts */
72116
- 200: {
72022
+ /** @description The connection */
72023
+ 201: {
72117
72024
  headers: {
72118
72025
  [name: string]: unknown;
72119
72026
  };
@@ -72121,45 +72028,28 @@ interface paths {
72121
72028
  /**
72122
72029
  * @example {
72123
72030
  * "data": {
72031
+ * "id": "bf0bf0bf-0000-4000-8000-000000000001",
72032
+ * "provider": "fintoc",
72033
+ * "institution_name": "Banco de Chile",
72034
+ * "holder_name": "Clínica Ejemplo SpA",
72124
72035
  * "accounts": [
72125
72036
  * {
72126
- * "id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f4d01",
72127
- * "parent_id": null,
72128
- * "name": "Gastos de administración",
72129
- * "description": null,
72130
- * "kind": "gasto",
72131
- * "behavior": "fijo",
72132
- * "position": 2,
72133
- * "depth": 1,
72134
- * "path": "Gastos de administración",
72135
- * "seeded": true,
72136
- * "has_children": true,
72137
- * "archived_at": null,
72138
- * "created_at": "2026-10-01T14:03:00.000Z",
72139
- * "updated_at": "2026-10-01T14:03:00.000Z"
72140
- * },
72141
- * {
72142
- * "id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f4d02",
72143
- * "parent_id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f4d01",
72144
- * "name": "Arriendo de oficina",
72145
- * "description": "Arriendo mensual de la oficina central.",
72146
- * "kind": "gasto",
72147
- * "behavior": "fijo",
72148
- * "position": 0,
72149
- * "depth": 2,
72150
- * "path": "Gastos de administración > Arriendo de oficina",
72151
- * "seeded": false,
72152
- * "has_children": false,
72153
- * "archived_at": null,
72154
- * "created_at": "2026-10-30T15:20:00.000Z",
72155
- * "updated_at": "2026-10-30T15:20:00.000Z"
72037
+ * "id": "acc_9Xz2Lm",
72038
+ * "number_masked": "••••4821"
72156
72039
  * }
72157
- * ]
72040
+ * ],
72041
+ * "enabled": true,
72042
+ * "connected_at": "2026-09-20T14:02:11.000Z",
72043
+ * "disconnected_at": null,
72044
+ * "last_sync_at": "2026-09-22T09:00:04.000Z",
72045
+ * "last_sync_status": "ok",
72046
+ * "last_sync_error": null,
72047
+ * "sync_cursor": "2026-09-22"
72158
72048
  * }
72159
72049
  * }
72160
72050
  */
72161
72051
  "application/json": {
72162
- data: components["schemas"]["FinanzasAccounts"];
72052
+ data: components["schemas"]["BankFeedConnection"];
72163
72053
  };
72164
72054
  };
72165
72055
  };
@@ -72219,10 +72109,26 @@ interface paths {
72219
72109
  };
72220
72110
  };
72221
72111
  };
72112
+ delete?: never;
72113
+ options?: never;
72114
+ head?: never;
72115
+ patch?: never;
72116
+ trace?: never;
72117
+ };
72118
+ "/clinic/bank-feed/connections/{id}/sync": {
72119
+ parameters: {
72120
+ query?: never;
72121
+ header?: never;
72122
+ path?: never;
72123
+ cookie?: never;
72124
+ };
72125
+ get?: never;
72222
72126
  put?: never;
72223
72127
  /**
72224
- * Add an account
72225
- * @description Adds an account at the end of its group. A top-level account needs `kind`; a sub-account takes its parent’s. `behavior` is required on `costo` and `gasto` (a sub-account inherits its parent’s when omitted) and refused elsewhere. Names are unique among live siblings, case-insensitive. At most 5 levels. The plan de cuentas is a classification tree, not double-entry. Each account has a `kind` (`ingreso`, `costo`, `gasto` or `no_operacional`) and, on `costo` and `gasto` only, a `behavior` (`fijo` or `variable`). A sub-account has its parent’s kind. Rule breaks answer `422 FINANZAS_ACCOUNT_INVALID` and state conflicts `409 FINANZAS_ACCOUNT_CONFLICT`, both with `details.reason`. Requires the `finanzas` add-on — without it every Finanzas operation answers `402 ENTITLEMENT_NOT_ACTIVE` (`details.required = ["finanzas"]`). Requires `finanzas_admin:write`.
72128
+ * Sincronizar ahora — enqueue a pull of one bank link
72129
+ * @description Enqueues the SAME job the daily tick uses; the stable per-connection jobId dedups with an in-flight sync. Requires `clinic_money:write`.
72130
+ *
72131
+ * **Connected apps:** every patient and contact in the response is a Seudónimo de paciente — initials plus a stable number, `"M.F. · #1001"` — unless the clinic allowed patient names, with RUT, phone and email masked in free text and `meta.patient_privacy` saying so. Clinical alerts (`flags`) are withheld in both modes, and a non-JSON body (an export, a file) is refused with `403 CONNECTED_APP_SENSITIVE_DATA`.
72226
72132
  */
72227
72133
  post: {
72228
72134
  parameters: {
@@ -72231,24 +72137,15 @@ interface paths {
72231
72137
  /** @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. */
72232
72138
  "Idempotency-Key"?: string;
72233
72139
  };
72234
- path?: never;
72235
- cookie?: never;
72236
- };
72237
- requestBody?: {
72238
- content: {
72239
- /**
72240
- * @example {
72241
- * "name": "Arriendo de oficina",
72242
- * "parent_id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f4d01",
72243
- * "description": "Arriendo mensual de la oficina central."
72244
- * }
72245
- */
72246
- "application/json": components["schemas"]["FinanzasAccountCreateBody"];
72140
+ path: {
72141
+ id: string;
72247
72142
  };
72143
+ cookie?: never;
72248
72144
  };
72145
+ requestBody?: never;
72249
72146
  responses: {
72250
- /** @description The account */
72251
- 201: {
72147
+ /** @description Enqueued */
72148
+ 202: {
72252
72149
  headers: {
72253
72150
  [name: string]: unknown;
72254
72151
  };
@@ -72256,25 +72153,14 @@ interface paths {
72256
72153
  /**
72257
72154
  * @example {
72258
72155
  * "data": {
72259
- * "id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f4d02",
72260
- * "parent_id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f4d01",
72261
- * "name": "Arriendo de oficina",
72262
- * "description": "Arriendo mensual de la oficina central.",
72263
- * "kind": "gasto",
72264
- * "behavior": "fijo",
72265
- * "position": 0,
72266
- * "depth": 2,
72267
- * "path": "Gastos de administración > Arriendo de oficina",
72268
- * "seeded": false,
72269
- * "has_children": false,
72270
- * "archived_at": null,
72271
- * "created_at": "2026-10-30T15:20:00.000Z",
72272
- * "updated_at": "2026-10-30T15:20:00.000Z"
72156
+ * "enqueued": true
72273
72157
  * }
72274
72158
  * }
72275
72159
  */
72276
72160
  "application/json": {
72277
- data: components["schemas"]["FinanzasAccount"];
72161
+ data: {
72162
+ enqueued: boolean;
72163
+ };
72278
72164
  };
72279
72165
  };
72280
72166
  };
@@ -72340,7 +72226,7 @@ interface paths {
72340
72226
  patch?: never;
72341
72227
  trace?: never;
72342
72228
  };
72343
- "/finanzas/accounts/{id}": {
72229
+ "/clinic/bank-feed/connections/{id}/disconnect": {
72344
72230
  parameters: {
72345
72231
  query?: never;
72346
72232
  header?: never;
@@ -72349,15 +72235,19 @@ interface paths {
72349
72235
  };
72350
72236
  get?: never;
72351
72237
  put?: never;
72352
- post?: never;
72353
72238
  /**
72354
- * Delete an unused account
72355
- * @description Only an account nothing was classified under can be deleted. With sub-accounts it answers `409 has_children`; with classified documents or movements `409 has_history`: archive it instead. Requires the `finanzas` add-on — without it every Finanzas operation answers `402 ENTITLEMENT_NOT_ACTIVE` (`details.required = ["finanzas"]`). Requires `finanzas_admin:write`.
72239
+ * Disconnect a bank link
72240
+ * @description Reversible: the connection survives disabled (its movements stay in the ledger), stops syncing and stops counting as a billed bank from the next period. Requires `clinic_money:write`.
72241
+ *
72242
+ * **Connected apps:** every patient and contact in the response is a Seudónimo de paciente — initials plus a stable number, `"M.F. · #1001"` — unless the clinic allowed patient names, with RUT, phone and email masked in free text and `meta.patient_privacy` saying so. Clinical alerts (`flags`) are withheld in both modes, and a non-JSON body (an export, a file) is refused with `403 CONNECTED_APP_SENSITIVE_DATA`.
72356
72243
  */
72357
- delete: {
72244
+ post: {
72358
72245
  parameters: {
72359
72246
  query?: never;
72360
- header?: never;
72247
+ header?: {
72248
+ /** @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. */
72249
+ "Idempotency-Key"?: string;
72250
+ };
72361
72251
  path: {
72362
72252
  id: string;
72363
72253
  };
@@ -72365,7 +72255,7 @@ interface paths {
72365
72255
  };
72366
72256
  requestBody?: never;
72367
72257
  responses: {
72368
- /** @description Deleted */
72258
+ /** @description Disconnected */
72369
72259
  204: {
72370
72260
  headers: {
72371
72261
  [name: string]: unknown;
@@ -72428,34 +72318,50 @@ interface paths {
72428
72318
  };
72429
72319
  };
72430
72320
  };
72321
+ delete?: never;
72431
72322
  options?: never;
72432
72323
  head?: never;
72324
+ patch?: never;
72325
+ trace?: never;
72326
+ };
72327
+ "/clinic/bank-feed/email/pull": {
72328
+ parameters: {
72329
+ query?: never;
72330
+ header?: never;
72331
+ path?: never;
72332
+ cookie?: never;
72333
+ };
72334
+ get?: never;
72335
+ put?: never;
72433
72336
  /**
72434
- * Rename, move or retag an account
72435
- * @description Change `name`, `description`, `behavior` (costo and gasto only), `position` (order among siblings) or move the account with `parent_id` (`null` = top level). A move keeps the account’s id, so every classification follows it; it is refused under itself or its sub-accounts (`cycle`), under another kind (`kind_mismatch`) or beyond 5 levels (`too_deep`). The kind itself never changes. An archived account cannot be edited. The plan de cuentas is a classification tree, not double-entry. Each account has a `kind` (`ingreso`, `costo`, `gasto` or `no_operacional`) and, on `costo` and `gasto` only, a `behavior` (`fijo` or `variable`). A sub-account has its parent’s kind. Rule breaks answer `422 FINANZAS_ACCOUNT_INVALID` and state conflicts `409 FINANZAS_ACCOUNT_CONFLICT`, both with `details.reason`. Requires the `finanzas` add-on — without it every Finanzas operation answers `402 ENTITLEMENT_NOT_ACTIVE` (`details.required = ["finanzas"]`). Requires `finanzas_admin:write`.
72337
+ * Re-read bank e-mails still in the inbox for a window
72338
+ * @description Runs the e-mail source of the bank feed over `[from, to]` (Santiago days, ≤ 92 days): bank comprobantes that are still conversations in a connected mailbox become `bank_movement` rows (provenance `backfill` — historical, never announced to anyone). Idempotent. Requires `clinic_money:write`.
72339
+ *
72340
+ * **Connected apps:** every patient and contact in the response is a Seudónimo de paciente — initials plus a stable number, `"M.F. · #1001"` — unless the clinic allowed patient names, with RUT, phone and email masked in free text and `meta.patient_privacy` saying so. Clinical alerts (`flags`) are withheld in both modes, and a non-JSON body (an export, a file) is refused with `403 CONNECTED_APP_SENSITIVE_DATA`.
72436
72341
  */
72437
- patch: {
72342
+ post: {
72438
72343
  parameters: {
72439
72344
  query?: never;
72440
- header?: never;
72441
- path: {
72442
- id: string;
72345
+ header?: {
72346
+ /** @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. */
72347
+ "Idempotency-Key"?: string;
72443
72348
  };
72349
+ path?: never;
72444
72350
  cookie?: never;
72445
72351
  };
72446
72352
  requestBody?: {
72447
72353
  content: {
72448
72354
  /**
72449
72355
  * @example {
72450
- * "name": "Arriendo de oficina central",
72451
- * "position": 1
72356
+ * "from": "2026-09-01",
72357
+ * "to": "2026-09-22"
72452
72358
  * }
72453
72359
  */
72454
- "application/json": components["schemas"]["FinanzasAccountUpdateBody"];
72360
+ "application/json": components["schemas"]["BankFeedEmailPullBody"];
72455
72361
  };
72456
72362
  };
72457
72363
  responses: {
72458
- /** @description The account */
72364
+ /** @description What was ingested */
72459
72365
  200: {
72460
72366
  headers: {
72461
72367
  [name: string]: unknown;
@@ -72464,25 +72370,473 @@ interface paths {
72464
72370
  /**
72465
72371
  * @example {
72466
72372
  * "data": {
72467
- * "id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f4d02",
72468
- * "parent_id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f4d01",
72469
- * "name": "Arriendo de oficina central",
72470
- * "description": "Arriendo mensual de la oficina central.",
72471
- * "kind": "gasto",
72472
- * "behavior": "fijo",
72473
- * "position": 1,
72474
- * "depth": 2,
72475
- * "path": "Gastos de administración > Arriendo de oficina",
72476
- * "seeded": false,
72477
- * "has_children": false,
72478
- * "archived_at": null,
72479
- * "created_at": "2026-10-30T15:20:00.000Z",
72480
- * "updated_at": "2026-10-30T15:20:00.000Z"
72373
+ * "drafts": 0,
72374
+ * "inserted": 3,
72375
+ * "deduped": 1,
72376
+ * "cross_source_twins": 1
72481
72377
  * }
72482
72378
  * }
72483
72379
  */
72484
72380
  "application/json": {
72485
- data: components["schemas"]["FinanzasAccount"];
72381
+ data: components["schemas"]["BankFeedIngestResult"];
72382
+ };
72383
+ };
72384
+ };
72385
+ /** @description Validation error */
72386
+ 400: {
72387
+ headers: {
72388
+ [name: string]: unknown;
72389
+ };
72390
+ content: {
72391
+ "application/json": components["schemas"]["Error"];
72392
+ };
72393
+ };
72394
+ /** @description Unauthorized */
72395
+ 401: {
72396
+ headers: {
72397
+ [name: string]: unknown;
72398
+ };
72399
+ content: {
72400
+ "application/json": components["schemas"]["Error"];
72401
+ };
72402
+ };
72403
+ /** @description Forbidden */
72404
+ 403: {
72405
+ headers: {
72406
+ [name: string]: unknown;
72407
+ };
72408
+ content: {
72409
+ "application/json": components["schemas"]["Error"];
72410
+ };
72411
+ };
72412
+ /** @description Not found */
72413
+ 404: {
72414
+ headers: {
72415
+ [name: string]: unknown;
72416
+ };
72417
+ content: {
72418
+ "application/json": components["schemas"]["Error"];
72419
+ };
72420
+ };
72421
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
72422
+ 409: {
72423
+ headers: {
72424
+ [name: string]: unknown;
72425
+ };
72426
+ content: {
72427
+ "application/json": components["schemas"]["Error"];
72428
+ };
72429
+ };
72430
+ /** @description Rate limited */
72431
+ 429: {
72432
+ headers: {
72433
+ [name: string]: unknown;
72434
+ };
72435
+ content: {
72436
+ "application/json": components["schemas"]["Error"];
72437
+ };
72438
+ };
72439
+ };
72440
+ };
72441
+ delete?: never;
72442
+ options?: never;
72443
+ head?: never;
72444
+ patch?: never;
72445
+ trace?: never;
72446
+ };
72447
+ "/finanzas/accounts": {
72448
+ parameters: {
72449
+ query?: never;
72450
+ header?: never;
72451
+ path?: never;
72452
+ cookie?: never;
72453
+ };
72454
+ /**
72455
+ * Plan de cuentas: the account tree
72456
+ * @description Every account of the workspace as a flat list in tree order (parents before children, siblings in screen order), each with `depth` and `path`. The first read of a workspace that holds the add-on creates the starter chart for its vertical (clinic, automotora or generic). Archived accounts are left out unless `include_archived=true`. The plan de cuentas is a classification tree, not double-entry. Each account has a `kind` (`ingreso`, `costo`, `gasto` or `no_operacional`) and, on `costo` and `gasto` only, a `behavior` (`fijo` or `variable`). A sub-account has its parent’s kind. Rule breaks answer `422 FINANZAS_ACCOUNT_INVALID` and state conflicts `409 FINANZAS_ACCOUNT_CONFLICT`, both with `details.reason`. Requires the `finanzas` add-on — without it every Finanzas operation answers `402 ENTITLEMENT_NOT_ACTIVE` (`details.required = ["finanzas"]`). Requires `finanzas:read`.
72457
+ */
72458
+ get: {
72459
+ parameters: {
72460
+ query?: {
72461
+ include_archived?: "true" | "false";
72462
+ };
72463
+ header?: never;
72464
+ path?: never;
72465
+ cookie?: never;
72466
+ };
72467
+ requestBody?: never;
72468
+ responses: {
72469
+ /** @description The accounts */
72470
+ 200: {
72471
+ headers: {
72472
+ [name: string]: unknown;
72473
+ };
72474
+ content: {
72475
+ /**
72476
+ * @example {
72477
+ * "data": {
72478
+ * "accounts": [
72479
+ * {
72480
+ * "id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f4d01",
72481
+ * "parent_id": null,
72482
+ * "name": "Gastos de administración",
72483
+ * "description": null,
72484
+ * "kind": "gasto",
72485
+ * "behavior": "fijo",
72486
+ * "position": 2,
72487
+ * "depth": 1,
72488
+ * "path": "Gastos de administración",
72489
+ * "seeded": true,
72490
+ * "has_children": true,
72491
+ * "archived_at": null,
72492
+ * "created_at": "2026-10-01T14:03:00.000Z",
72493
+ * "updated_at": "2026-10-01T14:03:00.000Z"
72494
+ * },
72495
+ * {
72496
+ * "id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f4d02",
72497
+ * "parent_id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f4d01",
72498
+ * "name": "Arriendo de oficina",
72499
+ * "description": "Arriendo mensual de la oficina central.",
72500
+ * "kind": "gasto",
72501
+ * "behavior": "fijo",
72502
+ * "position": 0,
72503
+ * "depth": 2,
72504
+ * "path": "Gastos de administración > Arriendo de oficina",
72505
+ * "seeded": false,
72506
+ * "has_children": false,
72507
+ * "archived_at": null,
72508
+ * "created_at": "2026-10-30T15:20:00.000Z",
72509
+ * "updated_at": "2026-10-30T15:20:00.000Z"
72510
+ * }
72511
+ * ]
72512
+ * }
72513
+ * }
72514
+ */
72515
+ "application/json": {
72516
+ data: components["schemas"]["FinanzasAccounts"];
72517
+ };
72518
+ };
72519
+ };
72520
+ /** @description Validation error */
72521
+ 400: {
72522
+ headers: {
72523
+ [name: string]: unknown;
72524
+ };
72525
+ content: {
72526
+ "application/json": components["schemas"]["Error"];
72527
+ };
72528
+ };
72529
+ /** @description Unauthorized */
72530
+ 401: {
72531
+ headers: {
72532
+ [name: string]: unknown;
72533
+ };
72534
+ content: {
72535
+ "application/json": components["schemas"]["Error"];
72536
+ };
72537
+ };
72538
+ /** @description Forbidden */
72539
+ 403: {
72540
+ headers: {
72541
+ [name: string]: unknown;
72542
+ };
72543
+ content: {
72544
+ "application/json": components["schemas"]["Error"];
72545
+ };
72546
+ };
72547
+ /** @description Not found */
72548
+ 404: {
72549
+ headers: {
72550
+ [name: string]: unknown;
72551
+ };
72552
+ content: {
72553
+ "application/json": components["schemas"]["Error"];
72554
+ };
72555
+ };
72556
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
72557
+ 409: {
72558
+ headers: {
72559
+ [name: string]: unknown;
72560
+ };
72561
+ content: {
72562
+ "application/json": components["schemas"]["Error"];
72563
+ };
72564
+ };
72565
+ /** @description Rate limited */
72566
+ 429: {
72567
+ headers: {
72568
+ [name: string]: unknown;
72569
+ };
72570
+ content: {
72571
+ "application/json": components["schemas"]["Error"];
72572
+ };
72573
+ };
72574
+ };
72575
+ };
72576
+ put?: never;
72577
+ /**
72578
+ * Add an account
72579
+ * @description Adds an account at the end of its group. A top-level account needs `kind`; a sub-account takes its parent’s. `behavior` is required on `costo` and `gasto` (a sub-account inherits its parent’s when omitted) and refused elsewhere. Names are unique among live siblings, case-insensitive. At most 5 levels. The plan de cuentas is a classification tree, not double-entry. Each account has a `kind` (`ingreso`, `costo`, `gasto` or `no_operacional`) and, on `costo` and `gasto` only, a `behavior` (`fijo` or `variable`). A sub-account has its parent’s kind. Rule breaks answer `422 FINANZAS_ACCOUNT_INVALID` and state conflicts `409 FINANZAS_ACCOUNT_CONFLICT`, both with `details.reason`. Requires the `finanzas` add-on — without it every Finanzas operation answers `402 ENTITLEMENT_NOT_ACTIVE` (`details.required = ["finanzas"]`). Requires `finanzas_admin:write`.
72580
+ */
72581
+ post: {
72582
+ parameters: {
72583
+ query?: never;
72584
+ header?: {
72585
+ /** @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. */
72586
+ "Idempotency-Key"?: string;
72587
+ };
72588
+ path?: never;
72589
+ cookie?: never;
72590
+ };
72591
+ requestBody?: {
72592
+ content: {
72593
+ /**
72594
+ * @example {
72595
+ * "name": "Arriendo de oficina",
72596
+ * "parent_id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f4d01",
72597
+ * "description": "Arriendo mensual de la oficina central."
72598
+ * }
72599
+ */
72600
+ "application/json": components["schemas"]["FinanzasAccountCreateBody"];
72601
+ };
72602
+ };
72603
+ responses: {
72604
+ /** @description The account */
72605
+ 201: {
72606
+ headers: {
72607
+ [name: string]: unknown;
72608
+ };
72609
+ content: {
72610
+ /**
72611
+ * @example {
72612
+ * "data": {
72613
+ * "id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f4d02",
72614
+ * "parent_id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f4d01",
72615
+ * "name": "Arriendo de oficina",
72616
+ * "description": "Arriendo mensual de la oficina central.",
72617
+ * "kind": "gasto",
72618
+ * "behavior": "fijo",
72619
+ * "position": 0,
72620
+ * "depth": 2,
72621
+ * "path": "Gastos de administración > Arriendo de oficina",
72622
+ * "seeded": false,
72623
+ * "has_children": false,
72624
+ * "archived_at": null,
72625
+ * "created_at": "2026-10-30T15:20:00.000Z",
72626
+ * "updated_at": "2026-10-30T15:20:00.000Z"
72627
+ * }
72628
+ * }
72629
+ */
72630
+ "application/json": {
72631
+ data: components["schemas"]["FinanzasAccount"];
72632
+ };
72633
+ };
72634
+ };
72635
+ /** @description Validation error */
72636
+ 400: {
72637
+ headers: {
72638
+ [name: string]: unknown;
72639
+ };
72640
+ content: {
72641
+ "application/json": components["schemas"]["Error"];
72642
+ };
72643
+ };
72644
+ /** @description Unauthorized */
72645
+ 401: {
72646
+ headers: {
72647
+ [name: string]: unknown;
72648
+ };
72649
+ content: {
72650
+ "application/json": components["schemas"]["Error"];
72651
+ };
72652
+ };
72653
+ /** @description Forbidden */
72654
+ 403: {
72655
+ headers: {
72656
+ [name: string]: unknown;
72657
+ };
72658
+ content: {
72659
+ "application/json": components["schemas"]["Error"];
72660
+ };
72661
+ };
72662
+ /** @description Not found */
72663
+ 404: {
72664
+ headers: {
72665
+ [name: string]: unknown;
72666
+ };
72667
+ content: {
72668
+ "application/json": components["schemas"]["Error"];
72669
+ };
72670
+ };
72671
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
72672
+ 409: {
72673
+ headers: {
72674
+ [name: string]: unknown;
72675
+ };
72676
+ content: {
72677
+ "application/json": components["schemas"]["Error"];
72678
+ };
72679
+ };
72680
+ /** @description Rate limited */
72681
+ 429: {
72682
+ headers: {
72683
+ [name: string]: unknown;
72684
+ };
72685
+ content: {
72686
+ "application/json": components["schemas"]["Error"];
72687
+ };
72688
+ };
72689
+ };
72690
+ };
72691
+ delete?: never;
72692
+ options?: never;
72693
+ head?: never;
72694
+ patch?: never;
72695
+ trace?: never;
72696
+ };
72697
+ "/finanzas/accounts/{id}": {
72698
+ parameters: {
72699
+ query?: never;
72700
+ header?: never;
72701
+ path?: never;
72702
+ cookie?: never;
72703
+ };
72704
+ get?: never;
72705
+ put?: never;
72706
+ post?: never;
72707
+ /**
72708
+ * Delete an unused account
72709
+ * @description Only an account nothing was classified under can be deleted. With sub-accounts it answers `409 has_children`; with classified documents or movements `409 has_history`: archive it instead. Requires the `finanzas` add-on — without it every Finanzas operation answers `402 ENTITLEMENT_NOT_ACTIVE` (`details.required = ["finanzas"]`). Requires `finanzas_admin:write`.
72710
+ */
72711
+ delete: {
72712
+ parameters: {
72713
+ query?: never;
72714
+ header?: never;
72715
+ path: {
72716
+ id: string;
72717
+ };
72718
+ cookie?: never;
72719
+ };
72720
+ requestBody?: never;
72721
+ responses: {
72722
+ /** @description Deleted */
72723
+ 204: {
72724
+ headers: {
72725
+ [name: string]: unknown;
72726
+ };
72727
+ content?: never;
72728
+ };
72729
+ /** @description Validation error */
72730
+ 400: {
72731
+ headers: {
72732
+ [name: string]: unknown;
72733
+ };
72734
+ content: {
72735
+ "application/json": components["schemas"]["Error"];
72736
+ };
72737
+ };
72738
+ /** @description Unauthorized */
72739
+ 401: {
72740
+ headers: {
72741
+ [name: string]: unknown;
72742
+ };
72743
+ content: {
72744
+ "application/json": components["schemas"]["Error"];
72745
+ };
72746
+ };
72747
+ /** @description Forbidden */
72748
+ 403: {
72749
+ headers: {
72750
+ [name: string]: unknown;
72751
+ };
72752
+ content: {
72753
+ "application/json": components["schemas"]["Error"];
72754
+ };
72755
+ };
72756
+ /** @description Not found */
72757
+ 404: {
72758
+ headers: {
72759
+ [name: string]: unknown;
72760
+ };
72761
+ content: {
72762
+ "application/json": components["schemas"]["Error"];
72763
+ };
72764
+ };
72765
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
72766
+ 409: {
72767
+ headers: {
72768
+ [name: string]: unknown;
72769
+ };
72770
+ content: {
72771
+ "application/json": components["schemas"]["Error"];
72772
+ };
72773
+ };
72774
+ /** @description Rate limited */
72775
+ 429: {
72776
+ headers: {
72777
+ [name: string]: unknown;
72778
+ };
72779
+ content: {
72780
+ "application/json": components["schemas"]["Error"];
72781
+ };
72782
+ };
72783
+ };
72784
+ };
72785
+ options?: never;
72786
+ head?: never;
72787
+ /**
72788
+ * Rename, move or retag an account
72789
+ * @description Change `name`, `description`, `behavior` (costo and gasto only), `position` (order among siblings) or move the account with `parent_id` (`null` = top level). A move keeps the account’s id, so every classification follows it; it is refused under itself or its sub-accounts (`cycle`), under another kind (`kind_mismatch`) or beyond 5 levels (`too_deep`). The kind itself never changes. An archived account cannot be edited. The plan de cuentas is a classification tree, not double-entry. Each account has a `kind` (`ingreso`, `costo`, `gasto` or `no_operacional`) and, on `costo` and `gasto` only, a `behavior` (`fijo` or `variable`). A sub-account has its parent’s kind. Rule breaks answer `422 FINANZAS_ACCOUNT_INVALID` and state conflicts `409 FINANZAS_ACCOUNT_CONFLICT`, both with `details.reason`. Requires the `finanzas` add-on — without it every Finanzas operation answers `402 ENTITLEMENT_NOT_ACTIVE` (`details.required = ["finanzas"]`). Requires `finanzas_admin:write`.
72790
+ */
72791
+ patch: {
72792
+ parameters: {
72793
+ query?: never;
72794
+ header?: never;
72795
+ path: {
72796
+ id: string;
72797
+ };
72798
+ cookie?: never;
72799
+ };
72800
+ requestBody?: {
72801
+ content: {
72802
+ /**
72803
+ * @example {
72804
+ * "name": "Arriendo de oficina central",
72805
+ * "position": 1
72806
+ * }
72807
+ */
72808
+ "application/json": components["schemas"]["FinanzasAccountUpdateBody"];
72809
+ };
72810
+ };
72811
+ responses: {
72812
+ /** @description The account */
72813
+ 200: {
72814
+ headers: {
72815
+ [name: string]: unknown;
72816
+ };
72817
+ content: {
72818
+ /**
72819
+ * @example {
72820
+ * "data": {
72821
+ * "id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f4d02",
72822
+ * "parent_id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f4d01",
72823
+ * "name": "Arriendo de oficina central",
72824
+ * "description": "Arriendo mensual de la oficina central.",
72825
+ * "kind": "gasto",
72826
+ * "behavior": "fijo",
72827
+ * "position": 1,
72828
+ * "depth": 2,
72829
+ * "path": "Gastos de administración > Arriendo de oficina",
72830
+ * "seeded": false,
72831
+ * "has_children": false,
72832
+ * "archived_at": null,
72833
+ * "created_at": "2026-10-30T15:20:00.000Z",
72834
+ * "updated_at": "2026-10-30T15:20:00.000Z"
72835
+ * }
72836
+ * }
72837
+ */
72838
+ "application/json": {
72839
+ data: components["schemas"]["FinanzasAccount"];
72486
72840
  };
72487
72841
  };
72488
72842
  };
@@ -74478,7 +74832,7 @@ interface paths {
74478
74832
  };
74479
74833
  /**
74480
74834
  * The Contraparte page: balance, terms, linked accounts, rules
74481
- * @description Everything on a Contraparte page except its timeline. `balance.payable` = what the workspace owes it (open purchases, honorarios, gastos); `balance.receivable` = what it owes the workspace (open sales). An open document counts its total minus its live reconciliation links; voided ones, ones no longer at the SII, notas de crédito and taxes are left out. Overdue = due before `as_of` (today, America/Santiago). `terms` gives its own terms and the effective terms per class it has documents in. A document is due its issue date plus the payment terms in days: the Contraparte's own terms, else the workspace default of its class (suppliers = compras, customers = ventas, honorarios, expenses = gastos; built-in 30 / 30 / 0 / 0). Changing terms recomputes the due date of every open document it covers; a paid one keeps its due date, and so does one whose source printed a due date. Taxes and notas de crédito have none. `aliases` are its linked RUTs and bank accounts (accounts masked). `rules` are the active and paused rules that name it. Requires the `finanzas` add-on — without it every Finanzas operation answers `402 ENTITLEMENT_NOT_ACTIVE` (`details.required = ["finanzas"]`). Requires `finanzas:read`.
74835
+ * @description Everything on a Contraparte page except its timeline. `balance.payable` = what the workspace owes it (open purchases, honorarios, gastos); `balance.receivable` = what it owes the workspace (open sales). An open document counts its total minus its live reconciliation links; voided ones, ones no longer at the SII, notas de crédito and taxes are left out. Overdue = due before `as_of` (today, America/Santiago). `terms` gives its own terms and the effective terms per class it has documents in. A document is due its issue date plus the payment terms in days: the Contraparte's own terms, else the workspace default of its class (suppliers = compras, customers = ventas, honorarios, expenses = gastos; built-in 30 / 30 / 0 / 0). Changing terms recomputes the due date of every open document it covers; a paid one keeps its due date, and so does one whose source printed a due date. Taxes and notas de crédito have none. `aliases` are its linked RUTs and bank accounts (accounts masked) and the card / automatic-debit descriptors learned from «Por resolver» (`kind: descriptor`). `rules` are the active and paused rules that name it. Requires the `finanzas` add-on — without it every Finanzas operation answers `402 ENTITLEMENT_NOT_ACTIVE` (`details.required = ["finanzas"]`). Requires `finanzas:read`.
74482
74836
  */
74483
74837
  get: {
74484
74838
  parameters: {
@@ -75141,7 +75495,7 @@ interface paths {
75141
75495
  put?: never;
75142
75496
  post?: never;
75143
75497
  /**
75144
- * Unlink a RUT or a bank account from a Contraparte
75498
+ * Unlink a RUT, bank account or descriptor from a Contraparte
75145
75499
  * @description Linked RUTs and bank accounts: a company Contraparte (RUT 78…) can own a person's account (RUT 16…) it is paid into. The reconciliation engine treats a movement to or from a linked RUT or account as the owning Contraparte's, so that payment matches the company's factura. A RUT or an account belongs to ONE Contraparte per workspace. Unlinking stops new movements from matching through it; links already made stay (undo each one with «Deshacer»). Audited. Requires the `finanzas` add-on — without it every Finanzas operation answers `402 ENTITLEMENT_NOT_ACTIVE` (`details.required = ["finanzas"]`). Requires `finanzas:write`.
75146
75500
  */
75147
75501
  delete: {
@@ -82914,7 +83268,8 @@ interface paths {
82914
83268
  * "accepted": 0
82915
83269
  * },
82916
83270
  * "remaining_case": null,
82917
- * "next_case_id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f4c02"
83271
+ * "next_case_id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f4c02",
83272
+ * "descriptors": []
82918
83273
  * }
82919
83274
  * }
82920
83275
  */
@@ -83131,7 +83486,8 @@ interface paths {
83131
83486
  * "accepted": 0
83132
83487
  * },
83133
83488
  * "remaining_case": null,
83134
- * "next_case_id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f4c02"
83489
+ * "next_case_id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f4c02",
83490
+ * "descriptors": []
83135
83491
  * }
83136
83492
  * }
83137
83493
  */
@@ -89133,7 +89489,600 @@ interface paths {
89133
89489
  };
89134
89490
  trace?: never;
89135
89491
  };
89136
- "/finanzas/cash-flow/recurring-items/{id}/end": {
89492
+ "/finanzas/cash-flow/recurring-items/{id}/end": {
89493
+ parameters: {
89494
+ query?: never;
89495
+ header?: never;
89496
+ path?: never;
89497
+ cookie?: never;
89498
+ };
89499
+ get?: never;
89500
+ put?: never;
89501
+ /**
89502
+ * «Terminar» a recurring item
89503
+ * @description No occurrence after `ends_on` (default: today; the day before it starts when it has not started). Nothing is deleted. An item that already ended answers 409. Audited. Requires the `finanzas` add-on — without it every Finanzas operation answers `402 ENTITLEMENT_NOT_ACTIVE` (`details.required = ["finanzas"]`). Requires `finanzas_reports:read` and `finanzas:write` (the Contador seat reads, never writes).
89504
+ */
89505
+ post: {
89506
+ parameters: {
89507
+ query?: never;
89508
+ header?: {
89509
+ /** @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. */
89510
+ "Idempotency-Key"?: string;
89511
+ };
89512
+ path: {
89513
+ id: string;
89514
+ };
89515
+ cookie?: never;
89516
+ };
89517
+ requestBody?: {
89518
+ content: {
89519
+ /**
89520
+ * @example {
89521
+ * "ends_on": "2026-12-31"
89522
+ * }
89523
+ */
89524
+ "application/json": components["schemas"]["FinanzasRecurringItemEndBody"];
89525
+ };
89526
+ };
89527
+ responses: {
89528
+ /** @description Ended */
89529
+ 200: {
89530
+ headers: {
89531
+ [name: string]: unknown;
89532
+ };
89533
+ content: {
89534
+ /**
89535
+ * @example {
89536
+ * "data": {
89537
+ * "id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f7b01",
89538
+ * "name": "Sueldos",
89539
+ * "direction": "outflow",
89540
+ * "amount_clp": 17592058,
89541
+ * "cadence": "monthly",
89542
+ * "starts_on": "2026-01-26",
89543
+ * "ends_on": "2026-12-31",
89544
+ * "account": {
89545
+ * "id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f4d20",
89546
+ * "name": "Sueldos",
89547
+ * "kind": "gasto",
89548
+ * "archived": false
89549
+ * },
89550
+ * "contraparte": null,
89551
+ * "note": null,
89552
+ * "summary": "Mensual · $17.592.058",
89553
+ * "status": "active",
89554
+ * "next_on": "2026-11-26",
89555
+ * "created_at": "2026-10-30T14:00:00.000Z",
89556
+ * "updated_at": "2026-10-30T14:00:00.000Z"
89557
+ * }
89558
+ * }
89559
+ */
89560
+ "application/json": {
89561
+ data: components["schemas"]["FinanzasRecurringItem"];
89562
+ };
89563
+ };
89564
+ };
89565
+ /** @description Validation error */
89566
+ 400: {
89567
+ headers: {
89568
+ [name: string]: unknown;
89569
+ };
89570
+ content: {
89571
+ "application/json": components["schemas"]["Error"];
89572
+ };
89573
+ };
89574
+ /** @description Unauthorized */
89575
+ 401: {
89576
+ headers: {
89577
+ [name: string]: unknown;
89578
+ };
89579
+ content: {
89580
+ "application/json": components["schemas"]["Error"];
89581
+ };
89582
+ };
89583
+ /** @description Forbidden */
89584
+ 403: {
89585
+ headers: {
89586
+ [name: string]: unknown;
89587
+ };
89588
+ content: {
89589
+ "application/json": components["schemas"]["Error"];
89590
+ };
89591
+ };
89592
+ /** @description Not found */
89593
+ 404: {
89594
+ headers: {
89595
+ [name: string]: unknown;
89596
+ };
89597
+ content: {
89598
+ "application/json": components["schemas"]["Error"];
89599
+ };
89600
+ };
89601
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
89602
+ 409: {
89603
+ headers: {
89604
+ [name: string]: unknown;
89605
+ };
89606
+ content: {
89607
+ "application/json": components["schemas"]["Error"];
89608
+ };
89609
+ };
89610
+ /** @description Rate limited */
89611
+ 429: {
89612
+ headers: {
89613
+ [name: string]: unknown;
89614
+ };
89615
+ content: {
89616
+ "application/json": components["schemas"]["Error"];
89617
+ };
89618
+ };
89619
+ };
89620
+ };
89621
+ delete?: never;
89622
+ options?: never;
89623
+ head?: never;
89624
+ patch?: never;
89625
+ trace?: never;
89626
+ };
89627
+ "/finanzas/alerts": {
89628
+ parameters: {
89629
+ query?: never;
89630
+ header?: never;
89631
+ path?: never;
89632
+ cookie?: never;
89633
+ };
89634
+ /**
89635
+ * Active Finanzas alerts
89636
+ * @description The alerts whose condition still holds: `cash_negative` (the Flujo de caja projection drops below zero in the next 30 days), `f29_due` (an F29 with something to pay is due within 5 days, unpaid) and `supplier_invoice_missing` (a Contraparte that invoiced each of the last 3 months has nothing this month, 3 days past its usual day). Evaluated hourly from 09:00 workspace time; each event is announced once to the owners and admins (bell and email by default; WhatsApp only on the opt-in `finanzas_whatsapp` rail) and leaves this list when its condition ends. Newest first. Requires the `finanzas` add-on (402 `ENTITLEMENT_NOT_ACTIVE` otherwise) and `finanzas:read`; the cash alert is listed only with `finanzas_reports:read` too.
89637
+ */
89638
+ get: {
89639
+ parameters: {
89640
+ query?: never;
89641
+ header?: never;
89642
+ path?: never;
89643
+ cookie?: never;
89644
+ };
89645
+ requestBody?: never;
89646
+ responses: {
89647
+ /** @description The active alerts */
89648
+ 200: {
89649
+ headers: {
89650
+ [name: string]: unknown;
89651
+ };
89652
+ content: {
89653
+ /**
89654
+ * @example {
89655
+ * "data": [
89656
+ * {
89657
+ * "id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f8a01",
89658
+ * "kind": "f29_due",
89659
+ * "title": "El F29 de octubre vence el 20 de noviembre",
89660
+ * "body": "Hay que pagar $842.000 (monto estimado) al SII antes del 20 de noviembre. Cuando el pago aparezca en tus movimientos, el F29 queda como pagado.",
89661
+ * "cta_label": "Ver F29",
89662
+ * "path": "/finanzas/documentos?vista=f29",
89663
+ * "opened_on": "2026-11-15",
89664
+ * "notified_at": "2026-11-15T12:00:04.000Z",
89665
+ * "updated_at": "2026-11-16T12:00:03.000Z",
89666
+ * "data": {
89667
+ * "period": "2026-10",
89668
+ * "due_date": "2026-11-20",
89669
+ * "amount_clp": 842000,
89670
+ * "days_left": 4,
89671
+ * "amount_is_final": false,
89672
+ * "document_id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f7a01"
89673
+ * }
89674
+ * }
89675
+ * ]
89676
+ * }
89677
+ */
89678
+ "application/json": {
89679
+ data: components["schemas"]["FinanzasAlertList"];
89680
+ };
89681
+ };
89682
+ };
89683
+ /** @description Validation error */
89684
+ 400: {
89685
+ headers: {
89686
+ [name: string]: unknown;
89687
+ };
89688
+ content: {
89689
+ "application/json": components["schemas"]["Error"];
89690
+ };
89691
+ };
89692
+ /** @description Unauthorized */
89693
+ 401: {
89694
+ headers: {
89695
+ [name: string]: unknown;
89696
+ };
89697
+ content: {
89698
+ "application/json": components["schemas"]["Error"];
89699
+ };
89700
+ };
89701
+ /** @description Forbidden */
89702
+ 403: {
89703
+ headers: {
89704
+ [name: string]: unknown;
89705
+ };
89706
+ content: {
89707
+ "application/json": components["schemas"]["Error"];
89708
+ };
89709
+ };
89710
+ /** @description Not found */
89711
+ 404: {
89712
+ headers: {
89713
+ [name: string]: unknown;
89714
+ };
89715
+ content: {
89716
+ "application/json": components["schemas"]["Error"];
89717
+ };
89718
+ };
89719
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
89720
+ 409: {
89721
+ headers: {
89722
+ [name: string]: unknown;
89723
+ };
89724
+ content: {
89725
+ "application/json": components["schemas"]["Error"];
89726
+ };
89727
+ };
89728
+ /** @description Rate limited */
89729
+ 429: {
89730
+ headers: {
89731
+ [name: string]: unknown;
89732
+ };
89733
+ content: {
89734
+ "application/json": components["schemas"]["Error"];
89735
+ };
89736
+ };
89737
+ };
89738
+ };
89739
+ put?: never;
89740
+ post?: never;
89741
+ delete?: never;
89742
+ options?: never;
89743
+ head?: never;
89744
+ patch?: never;
89745
+ trace?: never;
89746
+ };
89747
+ "/finanzas/connect-setup": {
89748
+ parameters: {
89749
+ query?: never;
89750
+ header?: never;
89751
+ path?: never;
89752
+ cookie?: never;
89753
+ };
89754
+ /**
89755
+ * What is connected and what comes next (bank, SII, honorarios)
89756
+ * @description «Conecta tus cuentas»: the bank (Fintoc links, Mercado Pago, or bank movements already arriving by e-mail/cartola), the SII connection of one sociedad with its four steps (`razon_social`, `certificate`, `mandato`, `honorarios`, the Clave Tributaria for the boletas de honorarios) and `next_step`, where the guided flow resumes, plus the first-visit onboarding `mode` (`guided` | `checklist` | `done`). Step states: `todo`, `waiting` (the SII or the representante legal is on it), `done`, `problem` (with `reason`), `skipped` (only `honorarios`, after «Mi empresa no recibe boletas de honorarios», never while honorarios documents are on record). Reads the stored SII state; `refresh=1` reads the SII live. `connection_id` picks one sociedad (default: the first not yet complete). Connecting never turns on boleta emission. Requires the `finanzas` add-on (402 `ENTITLEMENT_NOT_ACTIVE` otherwise). Requires `finanzas:read`.
89757
+ */
89758
+ get: {
89759
+ parameters: {
89760
+ query?: {
89761
+ refresh?: "0" | "1";
89762
+ connection_id?: string;
89763
+ };
89764
+ header?: never;
89765
+ path?: never;
89766
+ cookie?: never;
89767
+ };
89768
+ requestBody?: never;
89769
+ responses: {
89770
+ /** @description The connect setup */
89771
+ 200: {
89772
+ headers: {
89773
+ [name: string]: unknown;
89774
+ };
89775
+ content: {
89776
+ /**
89777
+ * @example {
89778
+ * "data": {
89779
+ * "bank": {
89780
+ * "state": "done",
89781
+ * "connected": 1,
89782
+ * "has_movements": true
89783
+ * },
89784
+ * "sii": {
89785
+ * "connection": {
89786
+ * "id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f5b01",
89787
+ * "legal_entity_id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f5b02",
89788
+ * "legal_name": "Clínica Ejemplo SpA",
89789
+ * "rut": "76123456-7",
89790
+ * "emission_on": false
89791
+ * },
89792
+ * "steps": [
89793
+ * {
89794
+ * "key": "razon_social",
89795
+ * "state": "done",
89796
+ * "reason": null
89797
+ * },
89798
+ * {
89799
+ * "key": "certificate",
89800
+ * "state": "done",
89801
+ * "reason": null
89802
+ * },
89803
+ * {
89804
+ * "key": "mandato",
89805
+ * "state": "waiting",
89806
+ * "reason": null
89807
+ * },
89808
+ * {
89809
+ * "key": "honorarios",
89810
+ * "state": "todo",
89811
+ * "reason": null
89812
+ * }
89813
+ * ],
89814
+ * "next_step": "honorarios",
89815
+ * "complete": false,
89816
+ * "honorarios": {
89817
+ * "evidence": false,
89818
+ * "declared_none_at": null,
89819
+ * "can_skip": true
89820
+ * },
89821
+ * "sociedades": [
89822
+ * {
89823
+ * "id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f5b02",
89824
+ * "legal_name": "Clínica Ejemplo SpA",
89825
+ * "tax_id": "76123456-7",
89826
+ * "connected": true
89827
+ * }
89828
+ * ],
89829
+ * "suggestion": null,
89830
+ * "live": false
89831
+ * },
89832
+ * "onboarding": {
89833
+ * "mode": "guided",
89834
+ * "started_at": "2026-11-02T13:00:00.000Z",
89835
+ * "deferred_at": null
89836
+ * }
89837
+ * }
89838
+ * }
89839
+ */
89840
+ "application/json": {
89841
+ data: {
89842
+ bank: {
89843
+ /** @enum {string} */
89844
+ state: "todo" | "done";
89845
+ connected: number;
89846
+ has_movements: boolean;
89847
+ };
89848
+ sii: {
89849
+ connection: {
89850
+ /** Format: uuid */
89851
+ id: string;
89852
+ /** Format: uuid */
89853
+ legal_entity_id: string;
89854
+ legal_name: string | null;
89855
+ rut: string;
89856
+ emission_on: boolean;
89857
+ } | null;
89858
+ steps: {
89859
+ /** @enum {string} */
89860
+ key: "razon_social" | "certificate" | "mandato" | "honorarios";
89861
+ /** @enum {string} */
89862
+ state: "todo" | "waiting" | "done" | "problem" | "skipped";
89863
+ reason: string | null;
89864
+ }[];
89865
+ /** @enum {string|null} */
89866
+ next_step: "razon_social" | "certificate" | "mandato" | "honorarios" | null;
89867
+ complete: boolean;
89868
+ honorarios: {
89869
+ evidence: boolean;
89870
+ declared_none_at: string | null;
89871
+ can_skip: boolean;
89872
+ };
89873
+ sociedades: {
89874
+ /** Format: uuid */
89875
+ id: string;
89876
+ legal_name: string;
89877
+ tax_id: string;
89878
+ connected: boolean;
89879
+ }[];
89880
+ suggestion: {
89881
+ /** @enum {string} */
89882
+ source: "billing" | "sii";
89883
+ rut: string | null;
89884
+ legal_name: string | null;
89885
+ giro: string | null;
89886
+ address_street: string | null;
89887
+ comuna_code: string | null;
89888
+ comuna_name: string | null;
89889
+ } | null;
89890
+ live: boolean;
89891
+ };
89892
+ onboarding: {
89893
+ /** @enum {string} */
89894
+ mode: "guided" | "checklist" | "done";
89895
+ started_at: string | null;
89896
+ deferred_at: string | null;
89897
+ };
89898
+ };
89899
+ };
89900
+ };
89901
+ };
89902
+ /** @description Validation error */
89903
+ 400: {
89904
+ headers: {
89905
+ [name: string]: unknown;
89906
+ };
89907
+ content: {
89908
+ "application/json": components["schemas"]["Error"];
89909
+ };
89910
+ };
89911
+ /** @description Unauthorized */
89912
+ 401: {
89913
+ headers: {
89914
+ [name: string]: unknown;
89915
+ };
89916
+ content: {
89917
+ "application/json": components["schemas"]["Error"];
89918
+ };
89919
+ };
89920
+ /** @description Forbidden */
89921
+ 403: {
89922
+ headers: {
89923
+ [name: string]: unknown;
89924
+ };
89925
+ content: {
89926
+ "application/json": components["schemas"]["Error"];
89927
+ };
89928
+ };
89929
+ /** @description Not found */
89930
+ 404: {
89931
+ headers: {
89932
+ [name: string]: unknown;
89933
+ };
89934
+ content: {
89935
+ "application/json": components["schemas"]["Error"];
89936
+ };
89937
+ };
89938
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
89939
+ 409: {
89940
+ headers: {
89941
+ [name: string]: unknown;
89942
+ };
89943
+ content: {
89944
+ "application/json": components["schemas"]["Error"];
89945
+ };
89946
+ };
89947
+ /** @description Rate limited */
89948
+ 429: {
89949
+ headers: {
89950
+ [name: string]: unknown;
89951
+ };
89952
+ content: {
89953
+ "application/json": components["schemas"]["Error"];
89954
+ };
89955
+ };
89956
+ };
89957
+ };
89958
+ put?: never;
89959
+ post?: never;
89960
+ delete?: never;
89961
+ options?: never;
89962
+ head?: never;
89963
+ patch?: never;
89964
+ trace?: never;
89965
+ };
89966
+ "/finanzas/connect-setup/sociedad-lookup": {
89967
+ parameters: {
89968
+ query?: never;
89969
+ header?: never;
89970
+ path?: never;
89971
+ cookie?: never;
89972
+ };
89973
+ /**
89974
+ * The SII's public record of a RUT (razón social prefill)
89975
+ * @description A suggestion for the razón social form: legal name and a giro that fits the SII's 40 characters, from the SII's public nómina of personas jurídicas. `null` when the RUT is not there (a persona natural) or the lookup is unavailable; 400 for an invalid RUT. Requires the `finanzas` add-on (402 `ENTITLEMENT_NOT_ACTIVE` otherwise). Requires `finanzas_admin:write`.
89976
+ */
89977
+ get: {
89978
+ parameters: {
89979
+ query: {
89980
+ rut: string;
89981
+ };
89982
+ header?: never;
89983
+ path?: never;
89984
+ cookie?: never;
89985
+ };
89986
+ requestBody?: never;
89987
+ responses: {
89988
+ /** @description The suggestion, or null */
89989
+ 200: {
89990
+ headers: {
89991
+ [name: string]: unknown;
89992
+ };
89993
+ content: {
89994
+ /**
89995
+ * @example {
89996
+ * "data": {
89997
+ * "source": "sii",
89998
+ * "rut": "76123456-7",
89999
+ * "legal_name": "CLINICA EJEMPLO SPA",
90000
+ * "giro": "SERVICIOS ODONTOLOGICOS",
90001
+ * "address_street": null,
90002
+ * "comuna_code": null,
90003
+ * "comuna_name": null
90004
+ * }
90005
+ * }
90006
+ */
90007
+ "application/json": {
90008
+ data: {
90009
+ /** @enum {string} */
90010
+ source: "billing" | "sii";
90011
+ rut: string | null;
90012
+ legal_name: string | null;
90013
+ giro: string | null;
90014
+ address_street: string | null;
90015
+ comuna_code: string | null;
90016
+ comuna_name: string | null;
90017
+ } | null;
90018
+ };
90019
+ };
90020
+ };
90021
+ /** @description Validation error */
90022
+ 400: {
90023
+ headers: {
90024
+ [name: string]: unknown;
90025
+ };
90026
+ content: {
90027
+ "application/json": components["schemas"]["Error"];
90028
+ };
90029
+ };
90030
+ /** @description Unauthorized */
90031
+ 401: {
90032
+ headers: {
90033
+ [name: string]: unknown;
90034
+ };
90035
+ content: {
90036
+ "application/json": components["schemas"]["Error"];
90037
+ };
90038
+ };
90039
+ /** @description Forbidden */
90040
+ 403: {
90041
+ headers: {
90042
+ [name: string]: unknown;
90043
+ };
90044
+ content: {
90045
+ "application/json": components["schemas"]["Error"];
90046
+ };
90047
+ };
90048
+ /** @description Not found */
90049
+ 404: {
90050
+ headers: {
90051
+ [name: string]: unknown;
90052
+ };
90053
+ content: {
90054
+ "application/json": components["schemas"]["Error"];
90055
+ };
90056
+ };
90057
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
90058
+ 409: {
90059
+ headers: {
90060
+ [name: string]: unknown;
90061
+ };
90062
+ content: {
90063
+ "application/json": components["schemas"]["Error"];
90064
+ };
90065
+ };
90066
+ /** @description Rate limited */
90067
+ 429: {
90068
+ headers: {
90069
+ [name: string]: unknown;
90070
+ };
90071
+ content: {
90072
+ "application/json": components["schemas"]["Error"];
90073
+ };
90074
+ };
90075
+ };
90076
+ };
90077
+ put?: never;
90078
+ post?: never;
90079
+ delete?: never;
90080
+ options?: never;
90081
+ head?: never;
90082
+ patch?: never;
90083
+ trace?: never;
90084
+ };
90085
+ "/finanzas/connect-setup/sii": {
89137
90086
  parameters: {
89138
90087
  query?: never;
89139
90088
  header?: never;
@@ -89143,8 +90092,8 @@ interface paths {
89143
90092
  get?: never;
89144
90093
  put?: never;
89145
90094
  /**
89146
- * «Terminar» a recurring item
89147
- * @description No occurrence after `ends_on` (default: today; the day before it starts when it has not started). Nothing is deleted. An item that already ended answers 409. Audited. Requires the `finanzas` add-on — without it every Finanzas operation answers `402 ENTITLEMENT_NOT_ACTIVE` (`details.required = ["finanzas"]`). Requires `finanzas_reports:read` and `finanzas:write` (the Contador seat reads, never writes).
90095
+ * Connect a razón social to the SII (step 1)
90096
+ * @description Records the razón social when the workspace has none (`legal_entity`, the Datos legales body) or takes an existing one (`legal_entity_id`), then creates its SII connection. Idempotent per sociedad: an already connected one answers its connection. `resolucion` keeps an existing electronic-emission authorisation. Boleta emission stays OFF. Requires the `finanzas` add-on (402 `ENTITLEMENT_NOT_ACTIVE` otherwise). Requires `finanzas_admin:write`.
89148
90097
  */
89149
90098
  post: {
89150
90099
  parameters: {
@@ -89153,23 +90102,161 @@ interface paths {
89153
90102
  /** @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. */
89154
90103
  "Idempotency-Key"?: string;
89155
90104
  };
89156
- path: {
89157
- id: string;
89158
- };
90105
+ path?: never;
89159
90106
  cookie?: never;
89160
90107
  };
89161
90108
  requestBody?: {
89162
90109
  content: {
89163
90110
  /**
89164
90111
  * @example {
89165
- * "ends_on": "2026-12-31"
90112
+ * "legal_entity_id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f5b02"
89166
90113
  * }
89167
90114
  */
89168
- "application/json": components["schemas"]["FinanzasRecurringItemEndBody"];
90115
+ "application/json": {
90116
+ /** Format: uuid */
90117
+ legal_entity_id?: string;
90118
+ legal_entity?: {
90119
+ legal_name: string;
90120
+ tax_id: string;
90121
+ /** @enum {string} */
90122
+ tax_id_kind?: "rut" | "passport" | "foreign_tax_id";
90123
+ giro: string;
90124
+ address_street: string;
90125
+ address_number?: string | null;
90126
+ address_unit?: string | null;
90127
+ comuna_code: string;
90128
+ representative_name: string;
90129
+ representative_tax_id?: string | null;
90130
+ /** @enum {string|null} */
90131
+ representative_tax_id_kind?: "rut" | "passport" | "foreign_tax_id" | null;
90132
+ escritura_date?: string | null;
90133
+ escritura_notary?: string | null;
90134
+ escritura_comuna_code?: string | null;
90135
+ };
90136
+ resolucion?: {
90137
+ numero: number;
90138
+ fecha: string;
90139
+ };
90140
+ };
89169
90141
  };
89170
90142
  };
89171
90143
  responses: {
89172
- /** @description Ended */
90144
+ /** @description The connection */
90145
+ 201: {
90146
+ headers: {
90147
+ [name: string]: unknown;
90148
+ };
90149
+ content: {
90150
+ /**
90151
+ * @example {
90152
+ * "data": {
90153
+ * "connection_id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f5b01",
90154
+ * "legal_entity_id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f5b02",
90155
+ * "created_legal_entity": false
90156
+ * }
90157
+ * }
90158
+ */
90159
+ "application/json": {
90160
+ data: {
90161
+ /** Format: uuid */
90162
+ connection_id: string;
90163
+ /** Format: uuid */
90164
+ legal_entity_id: string;
90165
+ created_legal_entity: boolean;
90166
+ };
90167
+ };
90168
+ };
90169
+ };
90170
+ /** @description Validation error */
90171
+ 400: {
90172
+ headers: {
90173
+ [name: string]: unknown;
90174
+ };
90175
+ content: {
90176
+ "application/json": components["schemas"]["Error"];
90177
+ };
90178
+ };
90179
+ /** @description Unauthorized */
90180
+ 401: {
90181
+ headers: {
90182
+ [name: string]: unknown;
90183
+ };
90184
+ content: {
90185
+ "application/json": components["schemas"]["Error"];
90186
+ };
90187
+ };
90188
+ /** @description Forbidden */
90189
+ 403: {
90190
+ headers: {
90191
+ [name: string]: unknown;
90192
+ };
90193
+ content: {
90194
+ "application/json": components["schemas"]["Error"];
90195
+ };
90196
+ };
90197
+ /** @description Not found */
90198
+ 404: {
90199
+ headers: {
90200
+ [name: string]: unknown;
90201
+ };
90202
+ content: {
90203
+ "application/json": components["schemas"]["Error"];
90204
+ };
90205
+ };
90206
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
90207
+ 409: {
90208
+ headers: {
90209
+ [name: string]: unknown;
90210
+ };
90211
+ content: {
90212
+ "application/json": components["schemas"]["Error"];
90213
+ };
90214
+ };
90215
+ /** @description Rate limited */
90216
+ 429: {
90217
+ headers: {
90218
+ [name: string]: unknown;
90219
+ };
90220
+ content: {
90221
+ "application/json": components["schemas"]["Error"];
90222
+ };
90223
+ };
90224
+ };
90225
+ };
90226
+ delete?: never;
90227
+ options?: never;
90228
+ head?: never;
90229
+ patch?: never;
90230
+ trace?: never;
90231
+ };
90232
+ "/finanzas/connect-setup/sii/{id}/mandato": {
90233
+ parameters: {
90234
+ query?: never;
90235
+ header?: never;
90236
+ path?: never;
90237
+ cookie?: never;
90238
+ };
90239
+ get?: never;
90240
+ put?: never;
90241
+ /**
90242
+ * A mandato signing link for the representante legal (step 3)
90243
+ * @description The link the representante legal opens to sign the mandato. It is returned ONCE; asking again replaces the previous link. Requires the `finanzas` add-on (402 `ENTITLEMENT_NOT_ACTIVE` otherwise). Requires `finanzas_admin:write`.
90244
+ */
90245
+ post: {
90246
+ parameters: {
90247
+ query?: never;
90248
+ header?: {
90249
+ /** @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. */
90250
+ "Idempotency-Key"?: string;
90251
+ };
90252
+ path: {
90253
+ id: string;
90254
+ };
90255
+ cookie?: never;
90256
+ };
90257
+ requestBody?: never;
90258
+ responses: {
90259
+ /** @description The signing link */
89173
90260
  200: {
89174
90261
  headers: {
89175
90262
  [name: string]: unknown;
@@ -89178,31 +90265,16 @@ interface paths {
89178
90265
  /**
89179
90266
  * @example {
89180
90267
  * "data": {
89181
- * "id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f7b01",
89182
- * "name": "Sueldos",
89183
- * "direction": "outflow",
89184
- * "amount_clp": 17592058,
89185
- * "cadence": "monthly",
89186
- * "starts_on": "2026-01-26",
89187
- * "ends_on": "2026-12-31",
89188
- * "account": {
89189
- * "id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f4d20",
89190
- * "name": "Sueldos",
89191
- * "kind": "gasto",
89192
- * "archived": false
89193
- * },
89194
- * "contraparte": null,
89195
- * "note": null,
89196
- * "summary": "Mensual · $17.592.058",
89197
- * "status": "active",
89198
- * "next_on": "2026-11-26",
89199
- * "created_at": "2026-10-30T14:00:00.000Z",
89200
- * "updated_at": "2026-10-30T14:00:00.000Z"
90268
+ * "signing_url": "https://example.invalid/mandato/abc",
90269
+ * "status": "pending"
89201
90270
  * }
89202
90271
  * }
89203
90272
  */
89204
90273
  "application/json": {
89205
- data: components["schemas"]["FinanzasRecurringItem"];
90274
+ data: {
90275
+ signing_url: string | null;
90276
+ status: string | null;
90277
+ };
89206
90278
  };
89207
90279
  };
89208
90280
  };
@@ -89268,27 +90340,44 @@ interface paths {
89268
90340
  patch?: never;
89269
90341
  trace?: never;
89270
90342
  };
89271
- "/finanzas/alerts": {
90343
+ "/finanzas/connect-setup/onboarding": {
89272
90344
  parameters: {
89273
90345
  query?: never;
89274
90346
  header?: never;
89275
90347
  path?: never;
89276
90348
  cookie?: never;
89277
90349
  };
90350
+ get?: never;
90351
+ put?: never;
89278
90352
  /**
89279
- * Active Finanzas alerts
89280
- * @description The alerts whose condition still holds: `cash_negative` (the Flujo de caja projection drops below zero in the next 30 days), `f29_due` (an F29 with something to pay is due within 5 days, unpaid) and `supplier_invoice_missing` (a Contraparte that invoiced each of the last 3 months has nothing this month, 3 days past its usual day). Evaluated hourly from 09:00 workspace time; each event is announced once to the owners and admins (bell and email by default; WhatsApp only on the opt-in `finanzas_whatsapp` rail) and leaves this list when its condition ends. Newest first. Requires the `finanzas` add-on (402 `ENTITLEMENT_NOT_ACTIVE` otherwise) and `finanzas:read`; the cash alert is listed only with `finanzas_reports:read` too.
90353
+ * Onboarding state: start, defer, or «no recibe boletas de honorarios»
90354
+ * @description Per workspace. `start` keeps the guided start while things get connected; `defer` («Lo hago después») collapses it to the checklist on Resumen; `no_honorarios` marks the honorarios step skipped (409 while honorarios documents are on record); `has_honorarios` undoes it. Answers the setup. Requires the `finanzas` add-on (402 `ENTITLEMENT_NOT_ACTIVE` otherwise). Requires `finanzas_admin:write`.
89281
90355
  */
89282
- get: {
90356
+ post: {
89283
90357
  parameters: {
89284
90358
  query?: never;
89285
- header?: never;
90359
+ header?: {
90360
+ /** @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. */
90361
+ "Idempotency-Key"?: string;
90362
+ };
89286
90363
  path?: never;
89287
90364
  cookie?: never;
89288
90365
  };
89289
- requestBody?: never;
90366
+ requestBody?: {
90367
+ content: {
90368
+ /**
90369
+ * @example {
90370
+ * "action": "defer"
90371
+ * }
90372
+ */
90373
+ "application/json": {
90374
+ /** @enum {string} */
90375
+ action: "start" | "defer" | "no_honorarios" | "has_honorarios";
90376
+ };
90377
+ };
90378
+ };
89290
90379
  responses: {
89291
- /** @description The active alerts */
90380
+ /** @description The setup */
89292
90381
  200: {
89293
90382
  headers: {
89294
90383
  [name: string]: unknown;
@@ -89296,31 +90385,127 @@ interface paths {
89296
90385
  content: {
89297
90386
  /**
89298
90387
  * @example {
89299
- * "data": [
89300
- * {
89301
- * "id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f8a01",
89302
- * "kind": "f29_due",
89303
- * "title": "El F29 de octubre vence el 20 de noviembre",
89304
- * "body": "Hay que pagar $842.000 (monto estimado) al SII antes del 20 de noviembre. Cuando el pago aparezca en tus movimientos, el F29 queda como pagado.",
89305
- * "cta_label": "Ver F29",
89306
- * "path": "/finanzas/documentos?vista=f29",
89307
- * "opened_on": "2026-11-15",
89308
- * "notified_at": "2026-11-15T12:00:04.000Z",
89309
- * "updated_at": "2026-11-16T12:00:03.000Z",
89310
- * "data": {
89311
- * "period": "2026-10",
89312
- * "due_date": "2026-11-20",
89313
- * "amount_clp": 842000,
89314
- * "days_left": 4,
89315
- * "amount_is_final": false,
89316
- * "document_id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f7a01"
89317
- * }
90388
+ * "data": {
90389
+ * "bank": {
90390
+ * "state": "done",
90391
+ * "connected": 1,
90392
+ * "has_movements": true
90393
+ * },
90394
+ * "sii": {
90395
+ * "connection": {
90396
+ * "id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f5b01",
90397
+ * "legal_entity_id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f5b02",
90398
+ * "legal_name": "Clínica Ejemplo SpA",
90399
+ * "rut": "76123456-7",
90400
+ * "emission_on": false
90401
+ * },
90402
+ * "steps": [
90403
+ * {
90404
+ * "key": "razon_social",
90405
+ * "state": "done",
90406
+ * "reason": null
90407
+ * },
90408
+ * {
90409
+ * "key": "certificate",
90410
+ * "state": "done",
90411
+ * "reason": null
90412
+ * },
90413
+ * {
90414
+ * "key": "mandato",
90415
+ * "state": "waiting",
90416
+ * "reason": null
90417
+ * },
90418
+ * {
90419
+ * "key": "honorarios",
90420
+ * "state": "todo",
90421
+ * "reason": null
90422
+ * }
90423
+ * ],
90424
+ * "next_step": "honorarios",
90425
+ * "complete": false,
90426
+ * "honorarios": {
90427
+ * "evidence": false,
90428
+ * "declared_none_at": null,
90429
+ * "can_skip": true
90430
+ * },
90431
+ * "sociedades": [
90432
+ * {
90433
+ * "id": "0190a3c2-5d1e-7b6a-9f20-4c1d2e3f5b02",
90434
+ * "legal_name": "Clínica Ejemplo SpA",
90435
+ * "tax_id": "76123456-7",
90436
+ * "connected": true
90437
+ * }
90438
+ * ],
90439
+ * "suggestion": null,
90440
+ * "live": false
90441
+ * },
90442
+ * "onboarding": {
90443
+ * "mode": "guided",
90444
+ * "started_at": "2026-11-02T13:00:00.000Z",
90445
+ * "deferred_at": null
89318
90446
  * }
89319
- * ]
90447
+ * }
89320
90448
  * }
89321
90449
  */
89322
90450
  "application/json": {
89323
- data: components["schemas"]["FinanzasAlertList"];
90451
+ data: {
90452
+ bank: {
90453
+ /** @enum {string} */
90454
+ state: "todo" | "done";
90455
+ connected: number;
90456
+ has_movements: boolean;
90457
+ };
90458
+ sii: {
90459
+ connection: {
90460
+ /** Format: uuid */
90461
+ id: string;
90462
+ /** Format: uuid */
90463
+ legal_entity_id: string;
90464
+ legal_name: string | null;
90465
+ rut: string;
90466
+ emission_on: boolean;
90467
+ } | null;
90468
+ steps: {
90469
+ /** @enum {string} */
90470
+ key: "razon_social" | "certificate" | "mandato" | "honorarios";
90471
+ /** @enum {string} */
90472
+ state: "todo" | "waiting" | "done" | "problem" | "skipped";
90473
+ reason: string | null;
90474
+ }[];
90475
+ /** @enum {string|null} */
90476
+ next_step: "razon_social" | "certificate" | "mandato" | "honorarios" | null;
90477
+ complete: boolean;
90478
+ honorarios: {
90479
+ evidence: boolean;
90480
+ declared_none_at: string | null;
90481
+ can_skip: boolean;
90482
+ };
90483
+ sociedades: {
90484
+ /** Format: uuid */
90485
+ id: string;
90486
+ legal_name: string;
90487
+ tax_id: string;
90488
+ connected: boolean;
90489
+ }[];
90490
+ suggestion: {
90491
+ /** @enum {string} */
90492
+ source: "billing" | "sii";
90493
+ rut: string | null;
90494
+ legal_name: string | null;
90495
+ giro: string | null;
90496
+ address_street: string | null;
90497
+ comuna_code: string | null;
90498
+ comuna_name: string | null;
90499
+ } | null;
90500
+ live: boolean;
90501
+ };
90502
+ onboarding: {
90503
+ /** @enum {string} */
90504
+ mode: "guided" | "checklist" | "done";
90505
+ started_at: string | null;
90506
+ deferred_at: string | null;
90507
+ };
90508
+ };
89324
90509
  };
89325
90510
  };
89326
90511
  };
@@ -89380,8 +90565,6 @@ interface paths {
89380
90565
  };
89381
90566
  };
89382
90567
  };
89383
- put?: never;
89384
- post?: never;
89385
90568
  delete?: never;
89386
90569
  options?: never;
89387
90570
  head?: never;
@@ -99846,7 +101029,7 @@ interface paths {
99846
101029
  item_ids: string[];
99847
101030
  payment: {
99848
101031
  /** @enum {string} */
99849
- instrument: "efectivo" | "transferencia" | "cheque" | "vale_vista" | "tarjeta" | "tarjeta_debito" | "tarjeta_credito" | "bono" | "otro" | "mercadopago" | "webpay" | "fintoc" | "flow" | "khipu";
101032
+ instrument: "efectivo" | "transferencia" | "cheque" | "vale_vista" | "tarjeta" | "tarjeta_debito" | "tarjeta_credito" | "bono" | "otro" | "mercadopago" | "webpay" | "fintoc" | "flow" | "khipu" | "bancame";
99850
101033
  /** @enum {string} */
99851
101034
  source?: "manual" | "card_terminal";
99852
101035
  amount_clp: number;
@@ -102406,7 +103589,7 @@ interface paths {
102406
103589
  contact_id?: string | null;
102407
103590
  payment?: {
102408
103591
  /** @enum {string} */
102409
- instrument: "efectivo" | "transferencia" | "cheque" | "vale_vista" | "tarjeta" | "tarjeta_debito" | "tarjeta_credito" | "bono" | "otro" | "mercadopago" | "webpay" | "fintoc" | "flow" | "khipu";
103592
+ instrument: "efectivo" | "transferencia" | "cheque" | "vale_vista" | "tarjeta" | "tarjeta_debito" | "tarjeta_credito" | "bono" | "otro" | "mercadopago" | "webpay" | "fintoc" | "flow" | "khipu" | "bancame";
102410
103593
  /** @enum {string} */
102411
103594
  source?: "manual" | "card_terminal";
102412
103595
  amount_clp: number;
@@ -137215,7 +138398,7 @@ interface paths {
137215
138398
  /** @enum {string} */
137216
138399
  source?: "manual" | "card_terminal" | "credit_note";
137217
138400
  /** @enum {string} */
137218
- instrument: "efectivo" | "transferencia" | "cheque" | "vale_vista" | "tarjeta" | "tarjeta_debito" | "tarjeta_credito" | "bono" | "otro" | "mercadopago" | "webpay" | "fintoc" | "flow" | "khipu";
138401
+ instrument: "efectivo" | "transferencia" | "cheque" | "vale_vista" | "tarjeta" | "tarjeta_debito" | "tarjeta_credito" | "bono" | "otro" | "mercadopago" | "webpay" | "fintoc" | "flow" | "khipu" | "bancame";
137219
138402
  amount_clp: number;
137220
138403
  paid_on: string;
137221
138404
  bank?: string | null;
@@ -137502,10 +138685,14 @@ interface paths {
137502
138685
  * {
137503
138686
  * "instrument": "khipu",
137504
138687
  * "required_fields": []
138688
+ * },
138689
+ * {
138690
+ * "instrument": "bancame",
138691
+ * "required_fields": []
137505
138692
  * }
137506
138693
  * ],
137507
138694
  * "meta": {
137508
- * "total": 14
138695
+ * "total": 15
137509
138696
  * }
137510
138697
  * }
137511
138698
  */
@@ -141788,7 +142975,7 @@ interface paths {
141788
142975
  *
141789
142976
  * 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.
141790
142977
  *
141791
- * 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) or `visit_passed` (the customer announced a store visit — «mañana paso», «el martes voy» — for a day that is now over, with nothing newer from them: a «Recordatorio acordado» to check whether they came falls due at `waiting_due_at`, the morning after; the thread does not come back to the queue when it does) — 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).
142978
+ * 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) or `visit_passed` (the customer announced a store visit — «mañana paso», «el martes voy» — for a day that is now over, with nothing newer from them: a «Recordatorio acordado» to check whether they came falls due at `waiting_due_at`, the morning after; the thread does not come back to the queue when it does) or `customer_later` (the customer deferred — «la otra semana», «por la quincena me acerco», «el lunes te aviso» — and an open «Recordatorio acordado» covers it, due at `waiting_due_at`: out of the queue until the customer writes again or it falls due) — 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).
141792
142979
  *
141793
142980
  * 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.
141794
142981
  *
@@ -232254,13 +233441,13 @@ interface paths {
232254
233441
  put?: never;
232255
233442
  /**
232256
233443
  * Open a storefront guest checkout
232257
- * @description A tenant’s own website (server side) sells with one call: the buyer (name, RUT, phone and/or email), the variants, the delivery method and optionally the payment provider in; an order and its payment link out (Mercado Pago by default, or Webpay with `payment_provider: "webpay"` when the tenant connected it: see `GET /orders/checkout/payment-providers`). The buyer is found by email, then phone, or created; their RUT fills the contact’s empty one; an opt-in is recorded; the visit’s ad touch is kept for the Purchase. **Prices come from the catalog** (no price field); only native products.
233444
+ * @description A tenant’s own website (server side) sells with one call: the buyer (name, RUT, phone and/or email), the variants, the delivery method and optionally the payment provider in; an order and its payment link out (Mercado Pago by default, Webpay with `payment_provider: "webpay"`, or banca.me «cuotas sin tarjeta» with `payment_provider: "bancame"`, when the tenant connected it: see `GET /orders/checkout/payment-providers`). The buyer is found by email, then phone, or created; their RUT fills the contact’s empty one; an opt-in is recorded; the visit’s ad touch is kept for the Purchase. **Prices come from the catalog** (no price field); only native products.
232258
233445
  *
232259
- * **Holds.** A variant with inventory policy `deny` («Solo con stock») holds the requested units for 15 minutes: available = on hand − active holds, and the link stops taking money when the hold ends. With fewer units available the call is refused with 409 `insufficient_stock` (`details.available`). Two checkouts for the last unit: exactly one succeeds. A `continue` variant (made to order) never refuses and holds nothing. The hold ends when the payment settles (the sale: on hand goes down by the units), when the order is cancelled, or when it expires (the order is then cancelled and `order.status_changed` fires).
233446
+ * **Holds.** A variant with inventory policy `deny` («Solo con stock») holds the requested units for 15 minutes (50 with `bancame`): available = on hand − active holds, and the link stops taking money when the hold ends. With fewer units available the call is refused with 409 `insufficient_stock` (`details.available`). Two checkouts for the last unit: exactly one succeeds. A `continue` variant (made to order) never refuses and holds nothing. The hold ends when the payment settles (the sale: on hand goes down by the units), when the order is cancelled, or when it expires (the order is then cancelled and `order.status_changed` fires).
232260
233447
  *
232261
233448
  * **event_id** is the browser InitiateCheckout `eventID`: the server InitiateCheckout (when the buyer opens `checkout_url`) and the Purchase ship under it, so Meta deduplicates. It is also the idempotency key (200 + `replayed: true`).
232262
233449
  *
232263
- * Refusals (`error.details.reason`): 400 `buyer_contact_required` · `invalid_phone` · `invalid_rut` · `shipping_quote_required` · `shipping_address_required` · `shipping_phone_required` · `shipping_quote_unknown` · `shipping_service_required` · `shipping_service_unavailable` · `unknown_item` · `inactive_item` · `no_price` · `variant_required`; 409 `insufficient_stock` · `store_item` · `event_id_reused` · `checkout_closed` · `already_paid` · `payment_not_connected` · `shipping_quote_expired` · `shipping_quote_used` · `shipping_quote_items_mismatch` · `shipping_quote_destination_mismatch`; 502 `payment_provider_unavailable`. Fires `order.created`. Requires `orders:checkout`.
233450
+ * Refusals (`error.details.reason`): 400 `buyer_contact_required` · `invalid_phone` · `invalid_rut` · `shipping_quote_required` · `shipping_address_required` · `shipping_phone_required` · `shipping_quote_unknown` · `shipping_service_required` · `shipping_service_unavailable` · `unknown_item` · `inactive_item` · `no_price` · `variant_required`; 409 `insufficient_stock` · `store_item` · `event_id_reused` · `checkout_closed` · `already_paid` · `payment_not_connected` · `payment_provider_not_connected` · `payment_buyer_has_active_loan` (banca.me: the buyer already has a loan) · `shipping_quote_expired` · `shipping_quote_used` · `shipping_quote_items_mismatch` · `shipping_quote_destination_mismatch`; 502 `payment_provider_unavailable`. Fires `order.created`. Requires `orders:checkout`.
232264
233451
  */
232265
233452
  post: {
232266
233453
  parameters: {
@@ -232392,7 +233579,7 @@ interface paths {
232392
233579
  /** @description Meta’s `_fbc` cookie, as read on the site. */
232393
233580
  fbc?: string | null;
232394
233581
  };
232395
- /** @description The site’s own pages the buyer returns to (`pending` defaults to `success`). Mercado Pago appends its own query (`collection_status`, `payment_id`, `external_reference` = the checkout id); Webpay returns through Vitrina, which commits the payment and then redirects here with `webpay_result=paid|rejected|cancelled|error` (`paid` → success, `rejected`/`cancelled` → failure, `error` → pending). Show the result from `GET /orders/checkout/{id}`, never from the query string. */
233582
+ /** @description The site’s own pages the buyer returns to (`pending` defaults to `success`). Mercado Pago appends its own query (`collection_status`, `payment_id`, `external_reference` = the checkout id); Webpay returns through Vitrina, which commits the payment and then redirects here with `webpay_result=paid|rejected|cancelled|error` (`paid` → success, `rejected`/`cancelled` → failure, `error` → pending); banca.me also returns through Vitrina, which re-reads the loan and redirects here with `bancame_result=paid|pending|rejected|expired|error` (`paid` → success, `pending`/`error` → pending, `rejected`/`expired` → failure; `expired` also carries `bancame_reason=TOKEN_EXPIRED`). The query Vitrina appends is well-formed (`?` or `&` as the URL needs): banca.me’s own `?preApproveId=…` never reaches the site. Show the result from `GET /orders/checkout/{id}`, never from the query string. */
232396
233583
  return_urls: {
232397
233584
  /** Format: uri */
232398
233585
  success: string;
@@ -232402,10 +233589,10 @@ interface paths {
232402
233589
  pending?: string;
232403
233590
  };
232404
233591
  /**
232405
- * @description The provider the buyer chose, one the tenant connected (`GET /orders/checkout/payment-providers`). Absent = Mercado Pago (or the only one connected). Another one is refused with 409 `payment_provider_not_connected`. On a replay of the same `event_id`, a different provider points the same checkout at it.
233592
+ * @description The provider the buyer chose, one the tenant connected (`GET /orders/checkout/payment-providers`). Absent = Mercado Pago (or the only one connected). Another one is refused with 409 `payment_provider_not_connected`. `bancame` («cuotas sin tarjeta») holds `deny` units for 50 minutes instead of 15 (the credit application takes longer). On a replay of the same `event_id`, a different provider points the same checkout at it.
232406
233593
  * @enum {string}
232407
233594
  */
232408
- payment_provider?: "mercadopago" | "webpay";
233595
+ payment_provider?: "mercadopago" | "webpay" | "bancame";
232409
233596
  notes?: string;
232410
233597
  };
232411
233598
  };
@@ -232448,6 +233635,7 @@ interface paths {
232448
233635
  * "paid_at": null,
232449
233636
  * "cancelled_at": null,
232450
233637
  * "hold_expires_at": "2026-10-29T15:15:00.000Z",
233638
+ * "payment_failure": null,
232451
233639
  * "created_at": "2026-10-29T15:00:00.000Z"
232452
233640
  * },
232453
233641
  * "checkout": {
@@ -232510,6 +233698,7 @@ interface paths {
232510
233698
  * "paid_at": null,
232511
233699
  * "cancelled_at": null,
232512
233700
  * "hold_expires_at": "2026-10-29T15:15:00.000Z",
233701
+ * "payment_failure": null,
232513
233702
  * "created_at": "2026-10-29T15:00:00.000Z"
232514
233703
  * },
232515
233704
  * "checkout": {
@@ -232606,7 +233795,7 @@ interface paths {
232606
233795
  };
232607
233796
  /**
232608
233797
  * List the payment providers a storefront may offer
232609
- * @description The providers the tenant connected that a storefront checkout can charge through (`mercadopago`, `webpay`), in the order to offer them, and the `default` used when `POST /orders/checkout` names none. Offer a choice only when there are two; pass the buyer’s pick as `payment_provider`. Requires `orders:checkout`.
233798
+ * @description The providers the tenant connected that a storefront checkout can charge through (`mercadopago`, `webpay`, `bancame`), in the order to offer them, and the `default` used when `POST /orders/checkout` names none. Offer a choice only when there are two or more; pass the buyer’s pick as `payment_provider`. Requires `orders:checkout`.
232610
233799
  */
232611
233800
  get: {
232612
233801
  parameters: {
@@ -232718,7 +233907,7 @@ interface paths {
232718
233907
  };
232719
233908
  /**
232720
233909
  * Get a storefront checkout’s status
232721
- * @description The status of an order opened by `POST /orders/checkout` (uuid or `O-42`), for the site’s return page: `pending_payment` (with `hold_expires_at`), `paid`, `cancelled` (expired or cancelled). No buyer data. Any other order answers 404. Requires `orders:checkout`.
233910
+ * @description The status of an order opened by `POST /orders/checkout` (uuid or `O-42`), for the site’s return page: `pending_payment` (with `hold_expires_at`), `paid`, `cancelled` (expired or cancelled; `payment_failure` says when a banca.me application was rejected or expired, #6402). No buyer data. Any other order answers 404. Requires `orders:checkout`.
232722
233911
  */
232723
233912
  get: {
232724
233913
  parameters: {
@@ -232767,6 +233956,7 @@ interface paths {
232767
233956
  * "paid_at": null,
232768
233957
  * "cancelled_at": null,
232769
233958
  * "hold_expires_at": "2026-10-29T15:15:00.000Z",
233959
+ * "payment_failure": null,
232770
233960
  * "created_at": "2026-10-29T15:00:00.000Z"
232771
233961
  * }
232772
233962
  * }
@@ -234233,7 +235423,7 @@ interface paths {
234233
235423
  put?: never;
234234
235424
  /**
234235
235425
  * Refund a paid order in full
234236
- * @description Gives a paid native order back in full (`paid`, `preparing`, `shipped` or `delivered`): retracto, a defect, a unit that could not be delivered. The refund runs at the provider the order was paid with, the workspace's own Mercado Pago or Webpay Plus (Webpay: a reversal the same day, an annulment later), against the order's payment (idempotent per order: a retry never refunds twice), the payment is reversed in the ledger and the ads engine nets the Purchase, the order becomes `refunded` and `order.status_changed` fires with `changes.status.to = refunded` (its `data.payment` names the refunded payment and its provider; `data.refunded_at` and `data.refund_reason` are set). The sold units go back on hand only when the workspace's own stock is Vitrina-managed (`restored_units`); when another system writes on-hand counts (a back office syncing absolute stock) nothing is added: that system reacts to the event. Refunding a refunded order answers 200 with `refunded: false`. Errors: 409 `order_not_paid` (draft, pending payment or cancelled), 409 `payment_not_refundable` (not paid through Mercado Pago or Webpay, e.g. a recorded transfer), 409 `refund_not_supported`, 409 `payment_not_connected`, 409 `store_order`; 502 `refund_refused` (the provider said no: past the refund window, a transaction not committed) or `payment_provider_unavailable`. On a 502 the order is unchanged and the call may be retried. Requires `orders:refund` (staff only; it is not part of any agent or storefront key).
235426
+ * @description Gives a paid native order back in full (`paid`, `preparing`, `shipped` or `delivered`): retracto, a defect, a unit that could not be delivered. The refund runs at the provider the order was paid with, the workspace's own Mercado Pago, Webpay Plus (a reversal the same day, an annulment later) or banca.me (the loan is cancelled and banca.me returns any installment already paid; only within 60 days of the disbursement), against the order's payment (idempotent per order: a retry never refunds twice), the payment is reversed in the ledger and the ads engine nets the Purchase, the order becomes `refunded` and `order.status_changed` fires with `changes.status.to = refunded` (its `data.payment` names the refunded payment and its provider; `data.refunded_at` and `data.refund_reason` are set). The sold units go back on hand only when the workspace's own stock is Vitrina-managed (`restored_units`); when another system writes on-hand counts (a back office syncing absolute stock) nothing is added: that system reacts to the event. Refunding a refunded order answers 200 with `refunded: false`. Errors: 409 `order_not_paid` (draft, pending payment or cancelled), 409 `payment_not_refundable` (not paid through Mercado Pago, Webpay or banca.me, e.g. a recorded transfer), 409 `refund_not_supported`, 409 `payment_not_connected`, 409 `store_order`; 502 `refund_refused` (the provider said no: past the refund window, e.g. banca.me after 60 days, a transaction not committed) or `payment_provider_unavailable`. On a 502 the order is unchanged and the call may be retried. Requires `orders:refund` (staff only; it is not part of any agent or storefront key).
234237
235427
  */
234238
235428
  post: {
234239
235429
  parameters: {
@@ -258913,12 +260103,12 @@ interface components {
258913
260103
  /** @description A Mercado Pago checkout payment: its payment id, a link to it and its status. Null for every other movement. */
258914
260104
  GatewayPaymentRef: {
258915
260105
  /** @enum {string} */
258916
- provider: "mercadopago" | "webpay" | "fintoc" | "flow" | "khipu";
258917
- /** @description The provider’s own payment id (Mercado Pago payment id; Webpay transaction token; Flow token; Khipu payment id). */
260106
+ provider: "mercadopago" | "webpay" | "fintoc" | "flow" | "khipu" | "bancame";
260107
+ /** @description The provider’s own payment id (Mercado Pago payment id; Webpay transaction token; Flow token; Khipu payment id; banca.me externalTrxId, which is the checkout id). */
258918
260108
  payment_id: string;
258919
260109
  /**
258920
260110
  * Format: uri
258921
- * @description Where to look the payment up: the clinic’s Mercado Pago activity search, or the provider’s site for Webpay, Flow and Khipu (no per-payment page).
260111
+ * @description Where to look the payment up: the clinic’s Mercado Pago activity search, or the provider’s site for Webpay, Flow, Khipu and banca.me (no per-payment page).
258922
260112
  */
258923
260113
  url: string;
258924
260114
  /**
@@ -259607,9 +260797,12 @@ interface components {
259607
260797
  };
259608
260798
  FinanzasContraparteAlias: {
259609
260799
  id: string;
259610
- /** @enum {string} */
259611
- kind: "rut" | "bank_account";
259612
- /** @description A RUT formatted (`16.123.456-7`); an account masked. */
260800
+ /**
260801
+ * @description `descriptor`: a card / automatic-debit descriptor (a bank line with no RUT or account) learned when a person confirmed such a movement in «Por resolver» against this Contraparte's documents. Removed like any alias (`DELETE …/aliases/{aliasId}`); never added by hand.
260802
+ * @enum {string}
260803
+ */
260804
+ kind: "rut" | "bank_account" | "descriptor";
260805
+ /** @description A RUT formatted (`16.123.456-7`); an account masked; a descriptor folded (`MERPAGO*MERCADOL`). */
259613
260806
  display: string;
259614
260807
  created_at: string;
259615
260808
  };
@@ -260574,6 +261767,8 @@ interface components {
260574
261767
  /** @enum {string} */
260575
261768
  target: "document" | "payment" | "transfer" | "third_party" | "cash_deposit";
260576
261769
  amount_clp: number;
261770
+ /** @description Pesos the document was credited beyond `amount_clp` (negative when the movement paid more); |x| ≤ 10, only on a matcher link of a known supplier (reason `rounding`). 0 = exact. The document is paid by `amount_clp + rounding_clp`; the movement explains `amount_clp`. */
261771
+ rounding_clp: number;
260577
261772
  /**
260578
261773
  * @description person = Manual, rule = Regla, match = Coincidencia, ai = IA, import = Importación (copied from Chipax, Finanzas 16; reason `chipax_import`).
260579
261774
  * @enum {string}
@@ -260922,7 +262117,7 @@ interface components {
260922
262117
  amount_clp: number;
260923
262118
  })[];
260924
262119
  replace_classification: boolean;
260925
- /** @description Stable codes: folio_and_amount, exact_amount, sum_of_documents, sum_of_movements, oldest_first, cash_deposit, own_account_transfer, history, document_arrived, no_document, ia (the IA proposed it: below the auto-apply threshold, or the IA switch is off). */
262120
+ /** @description Stable codes: folio_and_amount, exact_amount, sum_of_documents, sum_of_movements, nearest_date (a pago a cuenta on the documents issued nearest the payment; cases built before 2026-11 may carry oldest_first), cash_deposit, own_account_transfer, history, document_arrived, no_document, ia (the IA proposed it: below the auto-apply threshold, or the IA switch is off). */
260926
262121
  reasons: string[];
260927
262122
  } | {
260928
262123
  /** @enum {string} */
@@ -260937,13 +262132,13 @@ interface components {
260937
262132
  name: string;
260938
262133
  path: string;
260939
262134
  };
260940
- /** @description Stable codes: folio_and_amount, exact_amount, sum_of_documents, sum_of_movements, oldest_first, cash_deposit, own_account_transfer, history, document_arrived, no_document, ia (the IA proposed it: below the auto-apply threshold, or the IA switch is off). */
262135
+ /** @description Stable codes: folio_and_amount, exact_amount, sum_of_documents, sum_of_movements, nearest_date (a pago a cuenta on the documents issued nearest the payment; cases built before 2026-11 may carry oldest_first), cash_deposit, own_account_transfer, history, document_arrived, no_document, ia (the IA proposed it: below the auto-apply threshold, or the IA switch is off). */
260941
262136
  reasons: string[];
260942
262137
  } | {
260943
262138
  /** @enum {string} */
260944
262139
  type: "accept_without_document";
260945
262140
  movement_id: string;
260946
- /** @description Stable codes: folio_and_amount, exact_amount, sum_of_documents, sum_of_movements, oldest_first, cash_deposit, own_account_transfer, history, document_arrived, no_document, ia (the IA proposed it: below the auto-apply threshold, or the IA switch is off). */
262141
+ /** @description Stable codes: folio_and_amount, exact_amount, sum_of_documents, sum_of_movements, nearest_date (a pago a cuenta on the documents issued nearest the payment; cases built before 2026-11 may carry oldest_first), cash_deposit, own_account_transfer, history, document_arrived, no_document, ia (the IA proposed it: below the auto-apply threshold, or the IA switch is off). */
260947
262142
  reasons: string[];
260948
262143
  })[];
260949
262144
  /** @description Spanish sentences: why Vitrina proposes this. */
@@ -260994,6 +262189,13 @@ interface components {
260994
262189
  };
260995
262190
  remaining_case: components["schemas"]["FinanzasCase"] & (Record<string, never> | null);
260996
262191
  next_case_id: string | null;
262192
+ /** @description Card / automatic-debit descriptors this confirm tied to a Contraparte (`learned`: a movement that named no RUT or account was confirmed against documents of one Contraparte; from now on the engine knows the supplier, shown once as «Desde ahora reconocemos “MERPAGO*MERCADOL” como …»), or untied (`forgotten`: confirmed for a second Contraparte, so it names neither). Listed and removable as the Contraparte's aliases (kind `descriptor`). */
262193
+ descriptors: {
262194
+ descriptor: string;
262195
+ contraparte_id: string;
262196
+ /** @enum {string} */
262197
+ status: "learned" | "forgotten";
262198
+ }[];
260997
262199
  };
260998
262200
  FinanzasNoDocumentUndo: {
260999
262201
  movement_id: string;
@@ -261040,7 +262242,7 @@ interface components {
261040
262242
  /** @enum {string|null} */
261041
262243
  target: "document" | "payment" | "transfer" | "third_party" | "cash_deposit" | null;
261042
262244
  reasons: string[];
261043
- /** @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. */
262245
+ /** @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». A matcher link of a known supplier within rounding (reason `rounding`) or paid before its document was issued (`paid_before_issue`) says so here, e.g. «El pago fue $1 menor que el documento; la diferencia quedó como redondeo y el documento se cerró.». Null otherwise. */
261044
262246
  evidence: string | null;
261045
262247
  account: {
261046
262248
  /** Format: uuid */
@@ -261544,7 +262746,7 @@ interface components {
261544
262746
  [key: string]: number;
261545
262747
  };
261546
262748
  };
261547
- /** @description Chipax's USD lines (a dollar card) and their CLP at each day's dólar observado, a dry run included. The rate cache is filled first, one mindicador call per year; a day still without a rate fails that line alone (skip reason usd_rate_missing). Absent when there are none, and on runs before 2026-11-03. */
262749
+ /** @description Chipax's USD lines (a dollar card) and their CLP at each day's dólar observado, a dry run included. Rule: the dólar observado of the line's day; a day with none published (weekend, holiday) takes the previous business day, at most 4 calendar days back; anything else fails that line alone (skip reason usd_rate_missing), never an older rate. The rate cache is filled first per year (mindicador, then the SII's yearly table). Absent when there are none, and on runs before 2026-11-03. */
261548
262750
  usd_movements?: {
261549
262751
  lines: number;
261550
262752
  converted: number;
@@ -261556,6 +262758,19 @@ interface components {
261556
262758
  [key: string]: "cached" | "fetched" | "failed";
261557
262759
  };
261558
262760
  missing_days: string[];
262761
+ /** @description Every USD line and the rate it used. Absent on runs before 2026-11-03. */
262762
+ items?: {
262763
+ chipax_id: number;
262764
+ day: string;
262765
+ /** @description In cents. */
262766
+ usd: number;
262767
+ /** @enum {string} */
262768
+ status: "converted" | "failed" | "already";
262769
+ /** @description The day of the dólar observado used: the line's day, or the last business day before it (weekend/holiday, at most 4 days back). */
262770
+ rate_date: string | null;
262771
+ rate_clp: number | null;
262772
+ clp: number | null;
262773
+ }[];
261559
262774
  };
261560
262775
  unmapped: {
261561
262776
  /** @enum {string} */
@@ -265076,7 +266291,7 @@ interface components {
265076
266291
  };
265077
266292
  PaymentInstrumentRequirement: {
265078
266293
  /** @enum {string} */
265079
- instrument: "efectivo" | "transferencia" | "cheque" | "vale_vista" | "tarjeta" | "tarjeta_debito" | "tarjeta_credito" | "bono" | "otro" | "mercadopago" | "webpay" | "fintoc" | "flow" | "khipu";
266294
+ instrument: "efectivo" | "transferencia" | "cheque" | "vale_vista" | "tarjeta" | "tarjeta_debito" | "tarjeta_credito" | "bono" | "otro" | "mercadopago" | "webpay" | "fintoc" | "flow" | "khipu" | "bancame";
265080
266295
  /** @description Fields that must be non-blank for this instrument. Empty = only paid_on and amount_clp. */
265081
266296
  required_fields: ("bank" | "account_number" | "document_number" | "note")[];
265082
266297
  };
@@ -271674,6 +272889,18 @@ interface components {
271674
272889
  cancelled_at: string | null;
271675
272890
  /** @description While unpaid: when the held units are released and the link stops taking money. */
271676
272891
  hold_expires_at: string | null;
272892
+ /**
272893
+ * @description Why the online payment failed, when Vitrina knows (#6402). Set when a banca.me application ended `rejected` or `expired`: the order is then `cancelled` at once and its held units are back on sale, so the buyer can start a new checkout with another method. `reason` is banca.me’s code when Vitrina learns it: `TOKEN_EXPIRED` for an expired session; `null` for a rejection read from banca.me’s API, which does not say why (risk rejection and an active loan look the same there). A buyer refused at checkout creation for an existing loan gets 409 `payment_buyer_has_active_loan` instead. Null for every other order.
272894
+ * @example null
272895
+ */
272896
+ payment_failure: {
272897
+ /** @enum {string} */
272898
+ provider: "bancame";
272899
+ /** @enum {string} */
272900
+ outcome: "rejected" | "expired";
272901
+ /** @enum {string|null} */
272902
+ reason: "RISK_REJECTED" | "USER_HAS_ACTIVE_LOAN" | "TOKEN_EXPIRED" | null;
272903
+ } | null;
271677
272904
  created_at: string;
271678
272905
  };
271679
272906
  GuestCheckout: {
@@ -271681,13 +272908,13 @@ interface components {
271681
272908
  checkout: {
271682
272909
  /** Format: uuid */
271683
272910
  checkout_id: string;
271684
- /** @description Send the buyer here (a plain redirect, whatever the provider): Vitrina’s tracked link, which records the server-side InitiateCheckout and then redirects to the Mercado Pago checkout or posts the buyer to the Webpay form. */
272911
+ /** @description Send the buyer here (a plain redirect, whatever the provider): Vitrina’s tracked link, which records the server-side InitiateCheckout and then redirects to the Mercado Pago checkout, posts the buyer to the Webpay form, or redirects to banca.me’s page. */
271685
272912
  checkout_url: string;
271686
272913
  /**
271687
272914
  * @description The provider the link charges through.
271688
272915
  * @enum {string}
271689
272916
  */
271690
- provider: "mercadopago" | "webpay";
272917
+ provider: "mercadopago" | "webpay" | "bancame";
271691
272918
  amount_clp: number;
271692
272919
  expires_at: string | null;
271693
272920
  };
@@ -271704,11 +272931,11 @@ interface components {
271704
272931
  * @description The provider a checkout without `payment_provider` uses; null when none is connected (checkout answers 409 `payment_not_connected`).
271705
272932
  * @enum {string|null}
271706
272933
  */
271707
- default: "mercadopago" | "webpay" | null;
272934
+ default: "mercadopago" | "webpay" | "bancame" | null;
271708
272935
  /** @description The providers the tenant connected, in the order to offer them. */
271709
272936
  providers: {
271710
272937
  /** @enum {string} */
271711
- provider: "mercadopago" | "webpay";
272938
+ provider: "mercadopago" | "webpay" | "bancame";
271712
272939
  /** @example Webpay */
271713
272940
  name: string;
271714
272941
  }[];