@vitrina/api 16.0.0 → 17.0.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 +2505 -73
  2. package/dist/index.d.ts +2505 -73
  3. package/package.json +1 -1
package/dist/index.d.cts CHANGED
@@ -140220,7 +140220,7 @@ interface paths {
140220
140220
  query?: {
140221
140221
  contact_id?: string;
140222
140222
  state?: "pending" | "partial" | "paid" | "overpaid" | "overdue" | "overdue_partial" | "cancelled" | "waived" | "open";
140223
- kind?: "appointment_deposit" | "service" | "pack" | "product" | "vehicle_reservation_deposit" | "sale_note" | "consignment_settlement" | "real_estate_reserva" | "real_estate_pie" | "other";
140223
+ kind?: "appointment_deposit" | "service" | "pack" | "product" | "vehicle_reservation_deposit" | "sale_note" | "consignment_settlement" | "real_estate_reserva" | "real_estate_pie" | "installment" | "other";
140224
140224
  group_id?: string;
140225
140225
  limit?: number;
140226
140226
  offset?: number | null;
@@ -140417,7 +140417,7 @@ interface paths {
140417
140417
  /** Format: uuid */
140418
140418
  contact_id: string;
140419
140419
  /** @enum {string} */
140420
- kind: "appointment_deposit" | "service" | "pack" | "product" | "vehicle_reservation_deposit" | "sale_note" | "consignment_settlement" | "real_estate_reserva" | "real_estate_pie" | "other";
140420
+ kind: "appointment_deposit" | "service" | "pack" | "product" | "vehicle_reservation_deposit" | "sale_note" | "consignment_settlement" | "real_estate_reserva" | "real_estate_pie" | "installment" | "other";
140421
140421
  expected_clp: number;
140422
140422
  label: string;
140423
140423
  opened_on?: string;
@@ -141734,6 +141734,1514 @@ interface paths {
141734
141734
  patch?: never;
141735
141735
  trace?: never;
141736
141736
  };
141737
+ "/installment-plans": {
141738
+ parameters: {
141739
+ query?: never;
141740
+ header?: never;
141741
+ path?: never;
141742
+ cookie?: never;
141743
+ };
141744
+ /**
141745
+ * List installment plans
141746
+ * @description `payments:read`. Plans newest first, each with its cuotas. Filter by `contact_id` or `external_ref`.
141747
+ */
141748
+ get: {
141749
+ parameters: {
141750
+ query?: {
141751
+ contact_id?: string;
141752
+ external_ref?: string;
141753
+ limit?: number;
141754
+ offset?: number | null;
141755
+ };
141756
+ header?: never;
141757
+ path?: never;
141758
+ cookie?: never;
141759
+ };
141760
+ requestBody?: never;
141761
+ responses: {
141762
+ /** @description Installment plans */
141763
+ 200: {
141764
+ headers: {
141765
+ [name: string]: unknown;
141766
+ };
141767
+ content: {
141768
+ /**
141769
+ * @example [
141770
+ * {
141771
+ * "id": "0192f0b2-0000-7000-8000-00000000c000",
141772
+ * "contact_id": "0192f0b2-0000-7000-8000-00000000a001",
141773
+ * "label": "Plan de cuotas",
141774
+ * "external_ref": "CONTRATO-2291",
141775
+ * "currency": "CLP",
141776
+ * "count": 6,
141777
+ * "total_amount": 510000,
141778
+ * "paid_amount": 85000,
141779
+ * "outstanding": 425000,
141780
+ * "status": "active",
141781
+ * "installments": [
141782
+ * {
141783
+ * "id": "0192f0b2-0000-7000-8000-00000000c001",
141784
+ * "plan_id": "0192f0b2-0000-7000-8000-00000000c000",
141785
+ * "contact_id": "0192f0b2-0000-7000-8000-00000000a001",
141786
+ * "number": 2,
141787
+ * "count": 6,
141788
+ * "amount": 85000,
141789
+ * "currency": "CLP",
141790
+ * "due_date": "2026-11-05",
141791
+ * "status": "overdue",
141792
+ * "ledger_state": "overdue",
141793
+ * "paid_amount": 0,
141794
+ * "outstanding": 85000,
141795
+ * "paid_at": null,
141796
+ * "days_overdue": 4,
141797
+ * "payment_link_url": "https://pagos.ejemplo.cl/c/8842"
141798
+ * }
141799
+ * ],
141800
+ * "created_at": "2026-10-05T14:00:00.000Z"
141801
+ * }
141802
+ * ]
141803
+ */
141804
+ "application/json": {
141805
+ data?: unknown;
141806
+ meta?: {
141807
+ [key: string]: unknown;
141808
+ };
141809
+ };
141810
+ };
141811
+ };
141812
+ /** @description Validation error */
141813
+ 400: {
141814
+ headers: {
141815
+ [name: string]: unknown;
141816
+ };
141817
+ content: {
141818
+ "application/json": components["schemas"]["Error"];
141819
+ };
141820
+ };
141821
+ /** @description Unauthorized */
141822
+ 401: {
141823
+ headers: {
141824
+ [name: string]: unknown;
141825
+ };
141826
+ content: {
141827
+ "application/json": components["schemas"]["Error"];
141828
+ };
141829
+ };
141830
+ /** @description Forbidden */
141831
+ 403: {
141832
+ headers: {
141833
+ [name: string]: unknown;
141834
+ };
141835
+ content: {
141836
+ "application/json": components["schemas"]["Error"];
141837
+ };
141838
+ };
141839
+ /** @description Not found */
141840
+ 404: {
141841
+ headers: {
141842
+ [name: string]: unknown;
141843
+ };
141844
+ content: {
141845
+ "application/json": components["schemas"]["Error"];
141846
+ };
141847
+ };
141848
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
141849
+ 409: {
141850
+ headers: {
141851
+ [name: string]: unknown;
141852
+ };
141853
+ content: {
141854
+ "application/json": components["schemas"]["Error"];
141855
+ };
141856
+ };
141857
+ /** @description Rate limited */
141858
+ 429: {
141859
+ headers: {
141860
+ [name: string]: unknown;
141861
+ };
141862
+ content: {
141863
+ "application/json": components["schemas"]["Error"];
141864
+ };
141865
+ };
141866
+ };
141867
+ };
141868
+ put?: never;
141869
+ /**
141870
+ * Create an installment plan
141871
+ * @description `payments:write`. A customer owes money in cuotas. Send the debtor (`contact_id`, or `rut` / `phone` / `email` to find or create them) and either the cuotas (`installments`: amount, due date, optional own `payment_link_url`) or an even `schedule` (`total_amount`, `count`, `first_due_date`: monthly, the last cuota absorbs the rounding). `external_ref` is your own reference (contract, loan): it must be unique (409 otherwise) and is what the import matches on. Amounts are whole CLP. A plan is an obligation group on the payments ledger and each cuota one of its obligations: paid and overdue are derived from payments, never set. Nothing here sends a message: a debtor who is not a contact yet is created silently (no `new_contact` trigger).
141872
+ */
141873
+ post: {
141874
+ parameters: {
141875
+ query?: never;
141876
+ header?: {
141877
+ /** @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. */
141878
+ "Idempotency-Key"?: string;
141879
+ };
141880
+ path?: never;
141881
+ cookie?: never;
141882
+ };
141883
+ requestBody?: {
141884
+ content: {
141885
+ /**
141886
+ * @example {
141887
+ * "rut": "12.345.678-5",
141888
+ * "name": "Marta Rojas",
141889
+ * "external_ref": "CONTRATO-2291",
141890
+ * "schedule": {
141891
+ * "total_amount": 510000,
141892
+ * "count": 6,
141893
+ * "first_due_date": "2026-10-05"
141894
+ * }
141895
+ * }
141896
+ */
141897
+ "application/json": {
141898
+ /** Format: uuid */
141899
+ contact_id?: string;
141900
+ name?: string;
141901
+ phone?: string;
141902
+ email?: string;
141903
+ rut?: string;
141904
+ label?: string;
141905
+ external_ref?: string;
141906
+ installments?: {
141907
+ number?: number;
141908
+ amount: number;
141909
+ due_date: string;
141910
+ /** Format: uri */
141911
+ payment_link_url?: string | null;
141912
+ }[];
141913
+ schedule?: {
141914
+ total_amount: number;
141915
+ count: number;
141916
+ first_due_date: string;
141917
+ };
141918
+ };
141919
+ };
141920
+ };
141921
+ responses: {
141922
+ /** @description The plan with its cuotas */
141923
+ 201: {
141924
+ headers: {
141925
+ [name: string]: unknown;
141926
+ };
141927
+ content: {
141928
+ /**
141929
+ * @example {
141930
+ * "id": "0192f0b2-0000-7000-8000-00000000c000",
141931
+ * "contact_id": "0192f0b2-0000-7000-8000-00000000a001",
141932
+ * "label": "Plan de cuotas",
141933
+ * "external_ref": "CONTRATO-2291",
141934
+ * "currency": "CLP",
141935
+ * "count": 6,
141936
+ * "total_amount": 510000,
141937
+ * "paid_amount": 85000,
141938
+ * "outstanding": 425000,
141939
+ * "status": "active",
141940
+ * "installments": [
141941
+ * {
141942
+ * "id": "0192f0b2-0000-7000-8000-00000000c001",
141943
+ * "plan_id": "0192f0b2-0000-7000-8000-00000000c000",
141944
+ * "contact_id": "0192f0b2-0000-7000-8000-00000000a001",
141945
+ * "number": 2,
141946
+ * "count": 6,
141947
+ * "amount": 85000,
141948
+ * "currency": "CLP",
141949
+ * "due_date": "2026-11-05",
141950
+ * "status": "overdue",
141951
+ * "ledger_state": "overdue",
141952
+ * "paid_amount": 0,
141953
+ * "outstanding": 85000,
141954
+ * "paid_at": null,
141955
+ * "days_overdue": 4,
141956
+ * "payment_link_url": "https://pagos.ejemplo.cl/c/8842"
141957
+ * }
141958
+ * ],
141959
+ * "created_at": "2026-10-05T14:00:00.000Z"
141960
+ * }
141961
+ */
141962
+ "application/json": {
141963
+ data?: unknown;
141964
+ };
141965
+ };
141966
+ };
141967
+ /** @description Validation error */
141968
+ 400: {
141969
+ headers: {
141970
+ [name: string]: unknown;
141971
+ };
141972
+ content: {
141973
+ "application/json": components["schemas"]["Error"];
141974
+ };
141975
+ };
141976
+ /** @description Unauthorized */
141977
+ 401: {
141978
+ headers: {
141979
+ [name: string]: unknown;
141980
+ };
141981
+ content: {
141982
+ "application/json": components["schemas"]["Error"];
141983
+ };
141984
+ };
141985
+ /** @description Forbidden */
141986
+ 403: {
141987
+ headers: {
141988
+ [name: string]: unknown;
141989
+ };
141990
+ content: {
141991
+ "application/json": components["schemas"]["Error"];
141992
+ };
141993
+ };
141994
+ /** @description Not found */
141995
+ 404: {
141996
+ headers: {
141997
+ [name: string]: unknown;
141998
+ };
141999
+ content: {
142000
+ "application/json": components["schemas"]["Error"];
142001
+ };
142002
+ };
142003
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
142004
+ 409: {
142005
+ headers: {
142006
+ [name: string]: unknown;
142007
+ };
142008
+ content: {
142009
+ "application/json": components["schemas"]["Error"];
142010
+ };
142011
+ };
142012
+ /** @description Rate limited */
142013
+ 429: {
142014
+ headers: {
142015
+ [name: string]: unknown;
142016
+ };
142017
+ content: {
142018
+ "application/json": components["schemas"]["Error"];
142019
+ };
142020
+ };
142021
+ };
142022
+ };
142023
+ delete?: never;
142024
+ options?: never;
142025
+ head?: never;
142026
+ patch?: never;
142027
+ trace?: never;
142028
+ };
142029
+ "/installment-plans/import": {
142030
+ parameters: {
142031
+ query?: never;
142032
+ header?: never;
142033
+ path?: never;
142034
+ cookie?: never;
142035
+ };
142036
+ get?: never;
142037
+ put?: never;
142038
+ /**
142039
+ * Import cuotas in bulk (JSON)
142040
+ * @description `payments:write`. One row per cuota (`external_ref`, `number`, `amount`, `due_date`, and the debtor as `contact_id` / `rut` / `phone` / `email` + `name`; optional `count`, `payment_link_url`, `label`, `paid_on`). Rows sharing an `external_ref` are one plan. **Idempotent on `external_ref`**: the same rows again change nothing; a new amount, date or link updates a cuota that is still owing; `paid_on` marks it paid; a paid cuota never moves. Up to 2000 rows. Row problems are listed in `errors` and do not stop the rest. Nothing here sends a message: a debtor who is not a contact yet is created silently (no `new_contact` trigger).
142041
+ */
142042
+ post: {
142043
+ parameters: {
142044
+ query?: never;
142045
+ header?: {
142046
+ /** @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. */
142047
+ "Idempotency-Key"?: string;
142048
+ };
142049
+ path?: never;
142050
+ cookie?: never;
142051
+ };
142052
+ requestBody?: {
142053
+ content: {
142054
+ /**
142055
+ * @example {
142056
+ * "rows": [
142057
+ * {
142058
+ * "external_ref": "CONTRATO-2291",
142059
+ * "number": 1,
142060
+ * "count": 6,
142061
+ * "amount": 85000,
142062
+ * "due_date": "2026-10-05",
142063
+ * "rut": "12.345.678-5",
142064
+ * "name": "Marta Rojas",
142065
+ * "paid_on": "2026-10-04"
142066
+ * },
142067
+ * {
142068
+ * "external_ref": "CONTRATO-2291",
142069
+ * "number": 2,
142070
+ * "amount": 85000,
142071
+ * "due_date": "2026-11-05",
142072
+ * "rut": "12.345.678-5"
142073
+ * }
142074
+ * ]
142075
+ * }
142076
+ */
142077
+ "application/json": {
142078
+ rows: {
142079
+ /** Format: uuid */
142080
+ contact_id?: string;
142081
+ name?: string;
142082
+ phone?: string;
142083
+ email?: string;
142084
+ rut?: string;
142085
+ external_ref: string;
142086
+ number: number;
142087
+ count?: number | null;
142088
+ amount: number;
142089
+ due_date: string;
142090
+ /** Format: uri */
142091
+ payment_link_url?: string | null;
142092
+ label?: string | null;
142093
+ paid_on?: string | null;
142094
+ }[];
142095
+ };
142096
+ };
142097
+ };
142098
+ responses: {
142099
+ /** @description What the import did */
142100
+ 200: {
142101
+ headers: {
142102
+ [name: string]: unknown;
142103
+ };
142104
+ content: {
142105
+ /**
142106
+ * @example {
142107
+ * "total_rows": 6,
142108
+ * "plans_created": 1,
142109
+ * "plans_updated": 0,
142110
+ * "installments_created": 6,
142111
+ * "installments_updated": 0,
142112
+ * "installments_unchanged": 0,
142113
+ * "marked_paid": 1,
142114
+ * "contacts_created": 1,
142115
+ * "errors": []
142116
+ * }
142117
+ */
142118
+ "application/json": {
142119
+ data?: unknown;
142120
+ meta?: {
142121
+ [key: string]: unknown;
142122
+ };
142123
+ };
142124
+ };
142125
+ };
142126
+ /** @description Validation error */
142127
+ 400: {
142128
+ headers: {
142129
+ [name: string]: unknown;
142130
+ };
142131
+ content: {
142132
+ "application/json": components["schemas"]["Error"];
142133
+ };
142134
+ };
142135
+ /** @description Unauthorized */
142136
+ 401: {
142137
+ headers: {
142138
+ [name: string]: unknown;
142139
+ };
142140
+ content: {
142141
+ "application/json": components["schemas"]["Error"];
142142
+ };
142143
+ };
142144
+ /** @description Forbidden */
142145
+ 403: {
142146
+ headers: {
142147
+ [name: string]: unknown;
142148
+ };
142149
+ content: {
142150
+ "application/json": components["schemas"]["Error"];
142151
+ };
142152
+ };
142153
+ /** @description Not found */
142154
+ 404: {
142155
+ headers: {
142156
+ [name: string]: unknown;
142157
+ };
142158
+ content: {
142159
+ "application/json": components["schemas"]["Error"];
142160
+ };
142161
+ };
142162
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
142163
+ 409: {
142164
+ headers: {
142165
+ [name: string]: unknown;
142166
+ };
142167
+ content: {
142168
+ "application/json": components["schemas"]["Error"];
142169
+ };
142170
+ };
142171
+ /** @description Rate limited */
142172
+ 429: {
142173
+ headers: {
142174
+ [name: string]: unknown;
142175
+ };
142176
+ content: {
142177
+ "application/json": components["schemas"]["Error"];
142178
+ };
142179
+ };
142180
+ };
142181
+ };
142182
+ delete?: never;
142183
+ options?: never;
142184
+ head?: never;
142185
+ patch?: never;
142186
+ trace?: never;
142187
+ };
142188
+ "/installment-plans/import-file": {
142189
+ parameters: {
142190
+ query?: never;
142191
+ header?: never;
142192
+ path?: never;
142193
+ cookie?: never;
142194
+ };
142195
+ get?: never;
142196
+ put?: never;
142197
+ /**
142198
+ * Import cuotas from a CSV file
142199
+ * @description `payments:write`. The same import as `POST /installment-plans/import`, from a CSV (`file`, up to 5 MB). Headers (Spanish or English): `external_ref`/`referencia`, `number`/`cuota`, `amount`/`monto`, `due_date`/`vencimiento`, and optional `count`, `rut`, `phone`/`telefono`, `email`/`correo`, `name`/`nombre`, `contact_id`, `payment_link_url`/`link_pago`, `label`, `paid_on`/`pagado_el`. Comma or semicolon separated; pesos as `$85.000`; dates as `2026-11-05` or `05/11/2026`. Nothing here sends a message: a debtor who is not a contact yet is created silently (no `new_contact` trigger).
142200
+ *
142201
+ * **Or a JSON body** (`application/json`) — what an MCP connector sends through `call_operation`, which cannot build multipart: `{ filename, content, content_encoding?, content_type? }` plus the operation's own form fields. `content` is UTF-8 text by default, or base64 when `content_encoding` is `"base64"` (images, PDF, audio, video). The same byte cap applies to the decoded bytes (413 above it); invalid base64 is a 400; the content type defaults from the filename extension.
142202
+ */
142203
+ post: {
142204
+ parameters: {
142205
+ query?: never;
142206
+ header?: {
142207
+ /** @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. */
142208
+ "Idempotency-Key"?: string;
142209
+ };
142210
+ path?: never;
142211
+ cookie?: never;
142212
+ };
142213
+ requestBody?: {
142214
+ content: {
142215
+ /**
142216
+ * @example {
142217
+ * "file": "(binary CSV part)"
142218
+ * }
142219
+ */
142220
+ "multipart/form-data": {
142221
+ file?: unknown;
142222
+ };
142223
+ /**
142224
+ * @example {
142225
+ * "filename": "cuotas.csv",
142226
+ * "content": "external_ref,number,amount,due_date,rut,name\nCONTRATO-2291,1,85000,2026-10-05,12.345.678-5,Marta Rojas"
142227
+ * }
142228
+ */
142229
+ "application/json": {
142230
+ /** @description File name with extension; the content type defaults from it. */
142231
+ filename: string;
142232
+ /** @description The file. UTF-8 text by default; base64 when `content_encoding` is "base64" (images, PDF, audio, video). */
142233
+ content: string;
142234
+ /**
142235
+ * @description `utf8` (default) for text, `base64` for binary files.
142236
+ * @enum {string}
142237
+ */
142238
+ content_encoding?: "utf8" | "base64";
142239
+ /** @description MIME type. Defaults from the extension (.png → image/png, …). */
142240
+ content_type?: string;
142241
+ };
142242
+ };
142243
+ };
142244
+ responses: {
142245
+ /** @description What the import did */
142246
+ 200: {
142247
+ headers: {
142248
+ [name: string]: unknown;
142249
+ };
142250
+ content: {
142251
+ /**
142252
+ * @example {
142253
+ * "total_rows": 6,
142254
+ * "plans_created": 1,
142255
+ * "plans_updated": 0,
142256
+ * "installments_created": 6,
142257
+ * "installments_updated": 0,
142258
+ * "installments_unchanged": 0,
142259
+ * "marked_paid": 1,
142260
+ * "contacts_created": 1,
142261
+ * "errors": []
142262
+ * }
142263
+ */
142264
+ "application/json": {
142265
+ data?: unknown;
142266
+ meta?: {
142267
+ [key: string]: unknown;
142268
+ };
142269
+ };
142270
+ };
142271
+ };
142272
+ /** @description Validation error */
142273
+ 400: {
142274
+ headers: {
142275
+ [name: string]: unknown;
142276
+ };
142277
+ content: {
142278
+ "application/json": components["schemas"]["Error"];
142279
+ };
142280
+ };
142281
+ /** @description Unauthorized */
142282
+ 401: {
142283
+ headers: {
142284
+ [name: string]: unknown;
142285
+ };
142286
+ content: {
142287
+ "application/json": components["schemas"]["Error"];
142288
+ };
142289
+ };
142290
+ /** @description Forbidden */
142291
+ 403: {
142292
+ headers: {
142293
+ [name: string]: unknown;
142294
+ };
142295
+ content: {
142296
+ "application/json": components["schemas"]["Error"];
142297
+ };
142298
+ };
142299
+ /** @description Not found */
142300
+ 404: {
142301
+ headers: {
142302
+ [name: string]: unknown;
142303
+ };
142304
+ content: {
142305
+ "application/json": components["schemas"]["Error"];
142306
+ };
142307
+ };
142308
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
142309
+ 409: {
142310
+ headers: {
142311
+ [name: string]: unknown;
142312
+ };
142313
+ content: {
142314
+ "application/json": components["schemas"]["Error"];
142315
+ };
142316
+ };
142317
+ /** @description Rate limited */
142318
+ 429: {
142319
+ headers: {
142320
+ [name: string]: unknown;
142321
+ };
142322
+ content: {
142323
+ "application/json": components["schemas"]["Error"];
142324
+ };
142325
+ };
142326
+ };
142327
+ };
142328
+ delete?: never;
142329
+ options?: never;
142330
+ head?: never;
142331
+ patch?: never;
142332
+ trace?: never;
142333
+ };
142334
+ "/installment-plans/{id}": {
142335
+ parameters: {
142336
+ query?: never;
142337
+ header?: never;
142338
+ path?: never;
142339
+ cookie?: never;
142340
+ };
142341
+ /**
142342
+ * Fetch one installment plan
142343
+ * @description `payments:read`. The plan with every cuota, its status and what is still owed.
142344
+ */
142345
+ get: {
142346
+ parameters: {
142347
+ query?: never;
142348
+ header?: never;
142349
+ path: {
142350
+ id: string;
142351
+ };
142352
+ cookie?: never;
142353
+ };
142354
+ requestBody?: never;
142355
+ responses: {
142356
+ /** @description The plan */
142357
+ 200: {
142358
+ headers: {
142359
+ [name: string]: unknown;
142360
+ };
142361
+ content: {
142362
+ /**
142363
+ * @example {
142364
+ * "id": "0192f0b2-0000-7000-8000-00000000c000",
142365
+ * "contact_id": "0192f0b2-0000-7000-8000-00000000a001",
142366
+ * "label": "Plan de cuotas",
142367
+ * "external_ref": "CONTRATO-2291",
142368
+ * "currency": "CLP",
142369
+ * "count": 6,
142370
+ * "total_amount": 510000,
142371
+ * "paid_amount": 85000,
142372
+ * "outstanding": 425000,
142373
+ * "status": "active",
142374
+ * "installments": [
142375
+ * {
142376
+ * "id": "0192f0b2-0000-7000-8000-00000000c001",
142377
+ * "plan_id": "0192f0b2-0000-7000-8000-00000000c000",
142378
+ * "contact_id": "0192f0b2-0000-7000-8000-00000000a001",
142379
+ * "number": 2,
142380
+ * "count": 6,
142381
+ * "amount": 85000,
142382
+ * "currency": "CLP",
142383
+ * "due_date": "2026-11-05",
142384
+ * "status": "overdue",
142385
+ * "ledger_state": "overdue",
142386
+ * "paid_amount": 0,
142387
+ * "outstanding": 85000,
142388
+ * "paid_at": null,
142389
+ * "days_overdue": 4,
142390
+ * "payment_link_url": "https://pagos.ejemplo.cl/c/8842"
142391
+ * }
142392
+ * ],
142393
+ * "created_at": "2026-10-05T14:00:00.000Z"
142394
+ * }
142395
+ */
142396
+ "application/json": {
142397
+ data?: unknown;
142398
+ meta?: {
142399
+ [key: string]: unknown;
142400
+ };
142401
+ };
142402
+ };
142403
+ };
142404
+ /** @description Validation error */
142405
+ 400: {
142406
+ headers: {
142407
+ [name: string]: unknown;
142408
+ };
142409
+ content: {
142410
+ "application/json": components["schemas"]["Error"];
142411
+ };
142412
+ };
142413
+ /** @description Unauthorized */
142414
+ 401: {
142415
+ headers: {
142416
+ [name: string]: unknown;
142417
+ };
142418
+ content: {
142419
+ "application/json": components["schemas"]["Error"];
142420
+ };
142421
+ };
142422
+ /** @description Forbidden */
142423
+ 403: {
142424
+ headers: {
142425
+ [name: string]: unknown;
142426
+ };
142427
+ content: {
142428
+ "application/json": components["schemas"]["Error"];
142429
+ };
142430
+ };
142431
+ /** @description Not found */
142432
+ 404: {
142433
+ headers: {
142434
+ [name: string]: unknown;
142435
+ };
142436
+ content: {
142437
+ "application/json": components["schemas"]["Error"];
142438
+ };
142439
+ };
142440
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
142441
+ 409: {
142442
+ headers: {
142443
+ [name: string]: unknown;
142444
+ };
142445
+ content: {
142446
+ "application/json": components["schemas"]["Error"];
142447
+ };
142448
+ };
142449
+ /** @description Rate limited */
142450
+ 429: {
142451
+ headers: {
142452
+ [name: string]: unknown;
142453
+ };
142454
+ content: {
142455
+ "application/json": components["schemas"]["Error"];
142456
+ };
142457
+ };
142458
+ };
142459
+ };
142460
+ put?: never;
142461
+ post?: never;
142462
+ delete?: never;
142463
+ options?: never;
142464
+ head?: never;
142465
+ /**
142466
+ * Rename an installment plan
142467
+ * @description `payments:write`. Changes the plan label.
142468
+ */
142469
+ patch: {
142470
+ parameters: {
142471
+ query?: never;
142472
+ header?: never;
142473
+ path: {
142474
+ id: string;
142475
+ };
142476
+ cookie?: never;
142477
+ };
142478
+ requestBody?: {
142479
+ content: {
142480
+ /**
142481
+ * @example {
142482
+ * "label": "Plan matrícula 2027"
142483
+ * }
142484
+ */
142485
+ "application/json": {
142486
+ label: string;
142487
+ };
142488
+ };
142489
+ };
142490
+ responses: {
142491
+ /** @description The plan */
142492
+ 200: {
142493
+ headers: {
142494
+ [name: string]: unknown;
142495
+ };
142496
+ content: {
142497
+ /**
142498
+ * @example {
142499
+ * "id": "0192f0b2-0000-7000-8000-00000000c000",
142500
+ * "contact_id": "0192f0b2-0000-7000-8000-00000000a001",
142501
+ * "label": "Plan de cuotas",
142502
+ * "external_ref": "CONTRATO-2291",
142503
+ * "currency": "CLP",
142504
+ * "count": 6,
142505
+ * "total_amount": 510000,
142506
+ * "paid_amount": 85000,
142507
+ * "outstanding": 425000,
142508
+ * "status": "active",
142509
+ * "installments": [
142510
+ * {
142511
+ * "id": "0192f0b2-0000-7000-8000-00000000c001",
142512
+ * "plan_id": "0192f0b2-0000-7000-8000-00000000c000",
142513
+ * "contact_id": "0192f0b2-0000-7000-8000-00000000a001",
142514
+ * "number": 2,
142515
+ * "count": 6,
142516
+ * "amount": 85000,
142517
+ * "currency": "CLP",
142518
+ * "due_date": "2026-11-05",
142519
+ * "status": "overdue",
142520
+ * "ledger_state": "overdue",
142521
+ * "paid_amount": 0,
142522
+ * "outstanding": 85000,
142523
+ * "paid_at": null,
142524
+ * "days_overdue": 4,
142525
+ * "payment_link_url": "https://pagos.ejemplo.cl/c/8842"
142526
+ * }
142527
+ * ],
142528
+ * "created_at": "2026-10-05T14:00:00.000Z"
142529
+ * }
142530
+ */
142531
+ "application/json": {
142532
+ data?: unknown;
142533
+ meta?: {
142534
+ [key: string]: unknown;
142535
+ };
142536
+ };
142537
+ };
142538
+ };
142539
+ /** @description Validation error */
142540
+ 400: {
142541
+ headers: {
142542
+ [name: string]: unknown;
142543
+ };
142544
+ content: {
142545
+ "application/json": components["schemas"]["Error"];
142546
+ };
142547
+ };
142548
+ /** @description Unauthorized */
142549
+ 401: {
142550
+ headers: {
142551
+ [name: string]: unknown;
142552
+ };
142553
+ content: {
142554
+ "application/json": components["schemas"]["Error"];
142555
+ };
142556
+ };
142557
+ /** @description Forbidden */
142558
+ 403: {
142559
+ headers: {
142560
+ [name: string]: unknown;
142561
+ };
142562
+ content: {
142563
+ "application/json": components["schemas"]["Error"];
142564
+ };
142565
+ };
142566
+ /** @description Not found */
142567
+ 404: {
142568
+ headers: {
142569
+ [name: string]: unknown;
142570
+ };
142571
+ content: {
142572
+ "application/json": components["schemas"]["Error"];
142573
+ };
142574
+ };
142575
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
142576
+ 409: {
142577
+ headers: {
142578
+ [name: string]: unknown;
142579
+ };
142580
+ content: {
142581
+ "application/json": components["schemas"]["Error"];
142582
+ };
142583
+ };
142584
+ /** @description Rate limited */
142585
+ 429: {
142586
+ headers: {
142587
+ [name: string]: unknown;
142588
+ };
142589
+ content: {
142590
+ "application/json": components["schemas"]["Error"];
142591
+ };
142592
+ };
142593
+ };
142594
+ };
142595
+ trace?: never;
142596
+ };
142597
+ "/installment-plans/{id}/cancel": {
142598
+ parameters: {
142599
+ query?: never;
142600
+ header?: never;
142601
+ path?: never;
142602
+ cookie?: never;
142603
+ };
142604
+ get?: never;
142605
+ put?: never;
142606
+ /**
142607
+ * Cancel an installment plan
142608
+ * @description `payments:write`. Cancels every cuota still owing (money already paid stays) and ends the person's collection sequence. Needs a `reason`.
142609
+ */
142610
+ post: {
142611
+ parameters: {
142612
+ query?: never;
142613
+ header?: {
142614
+ /** @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. */
142615
+ "Idempotency-Key"?: string;
142616
+ };
142617
+ path: {
142618
+ id: string;
142619
+ };
142620
+ cookie?: never;
142621
+ };
142622
+ requestBody?: {
142623
+ content: {
142624
+ /**
142625
+ * @example {
142626
+ * "reason": "Se refinanció la deuda"
142627
+ * }
142628
+ */
142629
+ "application/json": {
142630
+ reason: string;
142631
+ };
142632
+ };
142633
+ };
142634
+ responses: {
142635
+ /** @description The plan */
142636
+ 200: {
142637
+ headers: {
142638
+ [name: string]: unknown;
142639
+ };
142640
+ content: {
142641
+ /**
142642
+ * @example {
142643
+ * "id": "0192f0b2-0000-7000-8000-00000000c000",
142644
+ * "contact_id": "0192f0b2-0000-7000-8000-00000000a001",
142645
+ * "label": "Plan de cuotas",
142646
+ * "external_ref": "CONTRATO-2291",
142647
+ * "currency": "CLP",
142648
+ * "count": 6,
142649
+ * "total_amount": 510000,
142650
+ * "paid_amount": 85000,
142651
+ * "outstanding": 425000,
142652
+ * "status": "active",
142653
+ * "installments": [
142654
+ * {
142655
+ * "id": "0192f0b2-0000-7000-8000-00000000c001",
142656
+ * "plan_id": "0192f0b2-0000-7000-8000-00000000c000",
142657
+ * "contact_id": "0192f0b2-0000-7000-8000-00000000a001",
142658
+ * "number": 2,
142659
+ * "count": 6,
142660
+ * "amount": 85000,
142661
+ * "currency": "CLP",
142662
+ * "due_date": "2026-11-05",
142663
+ * "status": "overdue",
142664
+ * "ledger_state": "overdue",
142665
+ * "paid_amount": 0,
142666
+ * "outstanding": 85000,
142667
+ * "paid_at": null,
142668
+ * "days_overdue": 4,
142669
+ * "payment_link_url": "https://pagos.ejemplo.cl/c/8842"
142670
+ * }
142671
+ * ],
142672
+ * "created_at": "2026-10-05T14:00:00.000Z"
142673
+ * }
142674
+ */
142675
+ "application/json": {
142676
+ data?: unknown;
142677
+ meta?: {
142678
+ [key: string]: unknown;
142679
+ };
142680
+ };
142681
+ };
142682
+ };
142683
+ /** @description Validation error */
142684
+ 400: {
142685
+ headers: {
142686
+ [name: string]: unknown;
142687
+ };
142688
+ content: {
142689
+ "application/json": components["schemas"]["Error"];
142690
+ };
142691
+ };
142692
+ /** @description Unauthorized */
142693
+ 401: {
142694
+ headers: {
142695
+ [name: string]: unknown;
142696
+ };
142697
+ content: {
142698
+ "application/json": components["schemas"]["Error"];
142699
+ };
142700
+ };
142701
+ /** @description Forbidden */
142702
+ 403: {
142703
+ headers: {
142704
+ [name: string]: unknown;
142705
+ };
142706
+ content: {
142707
+ "application/json": components["schemas"]["Error"];
142708
+ };
142709
+ };
142710
+ /** @description Not found */
142711
+ 404: {
142712
+ headers: {
142713
+ [name: string]: unknown;
142714
+ };
142715
+ content: {
142716
+ "application/json": components["schemas"]["Error"];
142717
+ };
142718
+ };
142719
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
142720
+ 409: {
142721
+ headers: {
142722
+ [name: string]: unknown;
142723
+ };
142724
+ content: {
142725
+ "application/json": components["schemas"]["Error"];
142726
+ };
142727
+ };
142728
+ /** @description Rate limited */
142729
+ 429: {
142730
+ headers: {
142731
+ [name: string]: unknown;
142732
+ };
142733
+ content: {
142734
+ "application/json": components["schemas"]["Error"];
142735
+ };
142736
+ };
142737
+ };
142738
+ };
142739
+ delete?: never;
142740
+ options?: never;
142741
+ head?: never;
142742
+ patch?: never;
142743
+ trace?: never;
142744
+ };
142745
+ "/installments": {
142746
+ parameters: {
142747
+ query?: never;
142748
+ header?: never;
142749
+ path?: never;
142750
+ cookie?: never;
142751
+ };
142752
+ /**
142753
+ * List cuotas
142754
+ * @description `payments:read`. Cuotas across plans. `status` is `pending`, `paid`, `overdue` (past the due day and still owing) or `cancelled`; it is derived from payments, so filtering on it reads a bounded window of 500. Filter by `contact_id` or `plan_id`.
142755
+ */
142756
+ get: {
142757
+ parameters: {
142758
+ query?: {
142759
+ contact_id?: string;
142760
+ plan_id?: string;
142761
+ status?: "pending" | "paid" | "overdue" | "cancelled";
142762
+ limit?: number;
142763
+ offset?: number | null;
142764
+ };
142765
+ header?: never;
142766
+ path?: never;
142767
+ cookie?: never;
142768
+ };
142769
+ requestBody?: never;
142770
+ responses: {
142771
+ /** @description Cuotas */
142772
+ 200: {
142773
+ headers: {
142774
+ [name: string]: unknown;
142775
+ };
142776
+ content: {
142777
+ /**
142778
+ * @example [
142779
+ * {
142780
+ * "id": "0192f0b2-0000-7000-8000-00000000c001",
142781
+ * "plan_id": "0192f0b2-0000-7000-8000-00000000c000",
142782
+ * "contact_id": "0192f0b2-0000-7000-8000-00000000a001",
142783
+ * "number": 2,
142784
+ * "count": 6,
142785
+ * "amount": 85000,
142786
+ * "currency": "CLP",
142787
+ * "due_date": "2026-11-05",
142788
+ * "status": "overdue",
142789
+ * "ledger_state": "overdue",
142790
+ * "paid_amount": 0,
142791
+ * "outstanding": 85000,
142792
+ * "paid_at": null,
142793
+ * "days_overdue": 4,
142794
+ * "payment_link_url": "https://pagos.ejemplo.cl/c/8842"
142795
+ * }
142796
+ * ]
142797
+ */
142798
+ "application/json": {
142799
+ data?: unknown;
142800
+ meta?: {
142801
+ [key: string]: unknown;
142802
+ };
142803
+ };
142804
+ };
142805
+ };
142806
+ /** @description Validation error */
142807
+ 400: {
142808
+ headers: {
142809
+ [name: string]: unknown;
142810
+ };
142811
+ content: {
142812
+ "application/json": components["schemas"]["Error"];
142813
+ };
142814
+ };
142815
+ /** @description Unauthorized */
142816
+ 401: {
142817
+ headers: {
142818
+ [name: string]: unknown;
142819
+ };
142820
+ content: {
142821
+ "application/json": components["schemas"]["Error"];
142822
+ };
142823
+ };
142824
+ /** @description Forbidden */
142825
+ 403: {
142826
+ headers: {
142827
+ [name: string]: unknown;
142828
+ };
142829
+ content: {
142830
+ "application/json": components["schemas"]["Error"];
142831
+ };
142832
+ };
142833
+ /** @description Not found */
142834
+ 404: {
142835
+ headers: {
142836
+ [name: string]: unknown;
142837
+ };
142838
+ content: {
142839
+ "application/json": components["schemas"]["Error"];
142840
+ };
142841
+ };
142842
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
142843
+ 409: {
142844
+ headers: {
142845
+ [name: string]: unknown;
142846
+ };
142847
+ content: {
142848
+ "application/json": components["schemas"]["Error"];
142849
+ };
142850
+ };
142851
+ /** @description Rate limited */
142852
+ 429: {
142853
+ headers: {
142854
+ [name: string]: unknown;
142855
+ };
142856
+ content: {
142857
+ "application/json": components["schemas"]["Error"];
142858
+ };
142859
+ };
142860
+ };
142861
+ };
142862
+ put?: never;
142863
+ post?: never;
142864
+ delete?: never;
142865
+ options?: never;
142866
+ head?: never;
142867
+ patch?: never;
142868
+ trace?: never;
142869
+ };
142870
+ "/installments/{id}": {
142871
+ parameters: {
142872
+ query?: never;
142873
+ header?: never;
142874
+ path?: never;
142875
+ cookie?: never;
142876
+ };
142877
+ /**
142878
+ * Fetch one cuota
142879
+ * @description `payments:read`. One cuota with its status, what is owed and its payment link.
142880
+ */
142881
+ get: {
142882
+ parameters: {
142883
+ query?: never;
142884
+ header?: never;
142885
+ path: {
142886
+ id: string;
142887
+ };
142888
+ cookie?: never;
142889
+ };
142890
+ requestBody?: never;
142891
+ responses: {
142892
+ /** @description The cuota */
142893
+ 200: {
142894
+ headers: {
142895
+ [name: string]: unknown;
142896
+ };
142897
+ content: {
142898
+ /**
142899
+ * @example {
142900
+ * "id": "0192f0b2-0000-7000-8000-00000000c001",
142901
+ * "plan_id": "0192f0b2-0000-7000-8000-00000000c000",
142902
+ * "contact_id": "0192f0b2-0000-7000-8000-00000000a001",
142903
+ * "number": 2,
142904
+ * "count": 6,
142905
+ * "amount": 85000,
142906
+ * "currency": "CLP",
142907
+ * "due_date": "2026-11-05",
142908
+ * "status": "overdue",
142909
+ * "ledger_state": "overdue",
142910
+ * "paid_amount": 0,
142911
+ * "outstanding": 85000,
142912
+ * "paid_at": null,
142913
+ * "days_overdue": 4,
142914
+ * "payment_link_url": "https://pagos.ejemplo.cl/c/8842"
142915
+ * }
142916
+ */
142917
+ "application/json": {
142918
+ data?: unknown;
142919
+ meta?: {
142920
+ [key: string]: unknown;
142921
+ };
142922
+ };
142923
+ };
142924
+ };
142925
+ /** @description Validation error */
142926
+ 400: {
142927
+ headers: {
142928
+ [name: string]: unknown;
142929
+ };
142930
+ content: {
142931
+ "application/json": components["schemas"]["Error"];
142932
+ };
142933
+ };
142934
+ /** @description Unauthorized */
142935
+ 401: {
142936
+ headers: {
142937
+ [name: string]: unknown;
142938
+ };
142939
+ content: {
142940
+ "application/json": components["schemas"]["Error"];
142941
+ };
142942
+ };
142943
+ /** @description Forbidden */
142944
+ 403: {
142945
+ headers: {
142946
+ [name: string]: unknown;
142947
+ };
142948
+ content: {
142949
+ "application/json": components["schemas"]["Error"];
142950
+ };
142951
+ };
142952
+ /** @description Not found */
142953
+ 404: {
142954
+ headers: {
142955
+ [name: string]: unknown;
142956
+ };
142957
+ content: {
142958
+ "application/json": components["schemas"]["Error"];
142959
+ };
142960
+ };
142961
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
142962
+ 409: {
142963
+ headers: {
142964
+ [name: string]: unknown;
142965
+ };
142966
+ content: {
142967
+ "application/json": components["schemas"]["Error"];
142968
+ };
142969
+ };
142970
+ /** @description Rate limited */
142971
+ 429: {
142972
+ headers: {
142973
+ [name: string]: unknown;
142974
+ };
142975
+ content: {
142976
+ "application/json": components["schemas"]["Error"];
142977
+ };
142978
+ };
142979
+ };
142980
+ };
142981
+ put?: never;
142982
+ post?: never;
142983
+ delete?: never;
142984
+ options?: never;
142985
+ head?: never;
142986
+ /**
142987
+ * Change a cuota
142988
+ * @description `payments:write`. Amount, due date and/or the payment link. Amount and date only while the cuota is open; changes are audited with `reason`. `payment_link_url: null` removes the link.
142989
+ */
142990
+ patch: {
142991
+ parameters: {
142992
+ query?: never;
142993
+ header?: never;
142994
+ path: {
142995
+ id: string;
142996
+ };
142997
+ cookie?: never;
142998
+ };
142999
+ requestBody?: {
143000
+ content: {
143001
+ /**
143002
+ * @example {
143003
+ * "due_date": "2026-11-20",
143004
+ * "reason": "Pidió más plazo"
143005
+ * }
143006
+ */
143007
+ "application/json": {
143008
+ amount?: number;
143009
+ due_date?: string;
143010
+ /** Format: uri */
143011
+ payment_link_url?: string | null;
143012
+ reason?: string;
143013
+ };
143014
+ };
143015
+ };
143016
+ responses: {
143017
+ /** @description The cuota */
143018
+ 200: {
143019
+ headers: {
143020
+ [name: string]: unknown;
143021
+ };
143022
+ content: {
143023
+ /**
143024
+ * @example {
143025
+ * "id": "0192f0b2-0000-7000-8000-00000000c001",
143026
+ * "plan_id": "0192f0b2-0000-7000-8000-00000000c000",
143027
+ * "contact_id": "0192f0b2-0000-7000-8000-00000000a001",
143028
+ * "number": 2,
143029
+ * "count": 6,
143030
+ * "amount": 85000,
143031
+ * "currency": "CLP",
143032
+ * "due_date": "2026-11-05",
143033
+ * "status": "overdue",
143034
+ * "ledger_state": "overdue",
143035
+ * "paid_amount": 0,
143036
+ * "outstanding": 85000,
143037
+ * "paid_at": null,
143038
+ * "days_overdue": 4,
143039
+ * "payment_link_url": "https://pagos.ejemplo.cl/c/8842"
143040
+ * }
143041
+ */
143042
+ "application/json": {
143043
+ data?: unknown;
143044
+ meta?: {
143045
+ [key: string]: unknown;
143046
+ };
143047
+ };
143048
+ };
143049
+ };
143050
+ /** @description Validation error */
143051
+ 400: {
143052
+ headers: {
143053
+ [name: string]: unknown;
143054
+ };
143055
+ content: {
143056
+ "application/json": components["schemas"]["Error"];
143057
+ };
143058
+ };
143059
+ /** @description Unauthorized */
143060
+ 401: {
143061
+ headers: {
143062
+ [name: string]: unknown;
143063
+ };
143064
+ content: {
143065
+ "application/json": components["schemas"]["Error"];
143066
+ };
143067
+ };
143068
+ /** @description Forbidden */
143069
+ 403: {
143070
+ headers: {
143071
+ [name: string]: unknown;
143072
+ };
143073
+ content: {
143074
+ "application/json": components["schemas"]["Error"];
143075
+ };
143076
+ };
143077
+ /** @description Not found */
143078
+ 404: {
143079
+ headers: {
143080
+ [name: string]: unknown;
143081
+ };
143082
+ content: {
143083
+ "application/json": components["schemas"]["Error"];
143084
+ };
143085
+ };
143086
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
143087
+ 409: {
143088
+ headers: {
143089
+ [name: string]: unknown;
143090
+ };
143091
+ content: {
143092
+ "application/json": components["schemas"]["Error"];
143093
+ };
143094
+ };
143095
+ /** @description Rate limited */
143096
+ 429: {
143097
+ headers: {
143098
+ [name: string]: unknown;
143099
+ };
143100
+ content: {
143101
+ "application/json": components["schemas"]["Error"];
143102
+ };
143103
+ };
143104
+ };
143105
+ };
143106
+ trace?: never;
143107
+ };
143108
+ "/installments/{id}/mark-paid": {
143109
+ parameters: {
143110
+ query?: never;
143111
+ header?: never;
143112
+ path?: never;
143113
+ cookie?: never;
143114
+ };
143115
+ get?: never;
143116
+ put?: never;
143117
+ /**
143118
+ * Mark a cuota paid
143119
+ * @description `payments:write`. Records a payment for what is still owed on the cuota (`instrument` default `otro`, `paid_on` default today) and ends the person's collection sequence with the goal met. Already paid: nothing changes. A cancelled cuota answers 409.
143120
+ */
143121
+ post: {
143122
+ parameters: {
143123
+ query?: never;
143124
+ header?: {
143125
+ /** @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. */
143126
+ "Idempotency-Key"?: string;
143127
+ };
143128
+ path: {
143129
+ id: string;
143130
+ };
143131
+ cookie?: never;
143132
+ };
143133
+ requestBody?: {
143134
+ content: {
143135
+ /**
143136
+ * @example {
143137
+ * "paid_on": "2026-11-09",
143138
+ * "instrument": "transferencia"
143139
+ * }
143140
+ */
143141
+ "application/json": {
143142
+ paid_on?: string;
143143
+ /** @enum {string} */
143144
+ instrument?: "efectivo" | "transferencia" | "cheque" | "vale_vista" | "tarjeta" | "tarjeta_debito" | "tarjeta_credito" | "bono" | "otro" | "mercadopago" | "webpay" | "fintoc" | "flow" | "khipu" | "bancame";
143145
+ note?: string;
143146
+ };
143147
+ };
143148
+ };
143149
+ responses: {
143150
+ /** @description The cuota */
143151
+ 200: {
143152
+ headers: {
143153
+ [name: string]: unknown;
143154
+ };
143155
+ content: {
143156
+ /**
143157
+ * @example {
143158
+ * "id": "0192f0b2-0000-7000-8000-00000000c001",
143159
+ * "plan_id": "0192f0b2-0000-7000-8000-00000000c000",
143160
+ * "contact_id": "0192f0b2-0000-7000-8000-00000000a001",
143161
+ * "number": 2,
143162
+ * "count": 6,
143163
+ * "amount": 85000,
143164
+ * "currency": "CLP",
143165
+ * "due_date": "2026-11-05",
143166
+ * "status": "paid",
143167
+ * "ledger_state": "overdue",
143168
+ * "paid_amount": 0,
143169
+ * "outstanding": 85000,
143170
+ * "paid_at": null,
143171
+ * "days_overdue": 4,
143172
+ * "payment_link_url": "https://pagos.ejemplo.cl/c/8842"
143173
+ * }
143174
+ */
143175
+ "application/json": {
143176
+ data?: unknown;
143177
+ meta?: {
143178
+ [key: string]: unknown;
143179
+ };
143180
+ };
143181
+ };
143182
+ };
143183
+ /** @description Validation error */
143184
+ 400: {
143185
+ headers: {
143186
+ [name: string]: unknown;
143187
+ };
143188
+ content: {
143189
+ "application/json": components["schemas"]["Error"];
143190
+ };
143191
+ };
143192
+ /** @description Unauthorized */
143193
+ 401: {
143194
+ headers: {
143195
+ [name: string]: unknown;
143196
+ };
143197
+ content: {
143198
+ "application/json": components["schemas"]["Error"];
143199
+ };
143200
+ };
143201
+ /** @description Forbidden */
143202
+ 403: {
143203
+ headers: {
143204
+ [name: string]: unknown;
143205
+ };
143206
+ content: {
143207
+ "application/json": components["schemas"]["Error"];
143208
+ };
143209
+ };
143210
+ /** @description Not found */
143211
+ 404: {
143212
+ headers: {
143213
+ [name: string]: unknown;
143214
+ };
143215
+ content: {
143216
+ "application/json": components["schemas"]["Error"];
143217
+ };
143218
+ };
143219
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
143220
+ 409: {
143221
+ headers: {
143222
+ [name: string]: unknown;
143223
+ };
143224
+ content: {
143225
+ "application/json": components["schemas"]["Error"];
143226
+ };
143227
+ };
143228
+ /** @description Rate limited */
143229
+ 429: {
143230
+ headers: {
143231
+ [name: string]: unknown;
143232
+ };
143233
+ content: {
143234
+ "application/json": components["schemas"]["Error"];
143235
+ };
143236
+ };
143237
+ };
143238
+ };
143239
+ delete?: never;
143240
+ options?: never;
143241
+ head?: never;
143242
+ patch?: never;
143243
+ trace?: never;
143244
+ };
141737
143245
  "/payment-links/options": {
141738
143246
  parameters: {
141739
143247
  query?: never;
@@ -165236,6 +166744,7 @@ interface paths {
165236
166744
  * "label": "Agenda visita"
165237
166745
  * },
165238
166746
  * "agent_id": null,
166747
+ * "collection": false,
165239
166748
  * "priority": 4,
165240
166749
  * "situations": [],
165241
166750
  * "steps": [
@@ -165676,6 +167185,7 @@ interface paths {
165676
167185
  * "label": "Agenda visita"
165677
167186
  * },
165678
167187
  * "agent_id": null,
167188
+ * "collection": false,
165679
167189
  * "priority": 4,
165680
167190
  * "situations": [],
165681
167191
  * "steps": [
@@ -167088,6 +168598,7 @@ interface paths {
167088
168598
  * "label": "Agenda visita"
167089
168599
  * },
167090
168600
  * "agent_id": null,
168601
+ * "collection": false,
167091
168602
  * "priority": 4,
167092
168603
  * "situations": [],
167093
168604
  * "steps": [
@@ -167528,6 +169039,7 @@ interface paths {
167528
169039
  * "label": "Agenda visita"
167529
169040
  * },
167530
169041
  * "agent_id": null,
169042
+ * "collection": false,
167531
169043
  * "priority": 4,
167532
169044
  * "situations": [],
167533
169045
  * "steps": [
@@ -167872,7 +169384,7 @@ interface paths {
167872
169384
  put?: never;
167873
169385
  /**
167874
169386
  * Simulate what one customer will receive
167875
- * @description Walks «Si no responde» for ONE person: a real `contact_id` or a test `persona` (`has_whatsapp`, `has_email` optional, `opted_out`), from the moment our last message went out (`last_message_at`), with what the customer does (`behavior`: `never_replies`, `replies_after_step`; `pays` and `promises_date` are collections behaviors and are no-ops for sequences without payment steps). Returns the `timeline` (each step with the moment the ladder draws it, `planned_at`, and the moment the engine really sends it after contact hours and pacing, `shifted_at`, with `shift_reason`, a `preview` when a stored draft or approved template exists, and a `status`) and the real `end` reason: replied, end_of_sequence, marked_lost, no_fitting_approved_message, no_channel_left, message_limit_reached or opted_out. It is the same simulation `GET /followups/recontacto/plan` renders, so it follows the engine’s rules (contact hours from 9:00, the 24 h WhatsApp window, per-person limits, opt-out). Deterministic: no model call, nothing is sent or stored. `version` is `published` (default), `draft` (the open draft, `GET /sequences/{id}/draft`) or a version id (`GET /sequences/{id}/versions`). `builtin:si-no-responde` and custom sequences are simulable (a custom sequence walks its own steps through the same engine rules; steps timed before an appointment are listed in `notes`). Custom sequences with conditions, waits until and loops follow the scenario: `replies_after_step` → the `yes` branch of «¿Respondió?» (a reply ends the sequence only when its goal is a reply), `pays` → «¿Pagó?», `promises_date` → «Esperar hasta la fecha prometida» ends that day; `decisions` (`{step key or id: branch key}`) picks any condition’s branch, and «La IA decide» is never called here (without a decision it takes its first branch). The response then carries `path` (every step passed, the branch taken, loop laps) and timeline entries met again in a loop carry `iteration`. Requires `followups:read`.
169387
+ * @description Walks «Si no responde» for ONE person: a real `contact_id` or a test `persona` (`has_whatsapp`, `has_email` optional, `opted_out`), from the moment our last message went out (`last_message_at`), with what the customer does (`behavior`: `never_replies`, `replies_after_step`; `pays` and `promises_date` are collections behaviors and are no-ops for sequences without payment steps). AI call steps end as `call_outcomes` says (`{step_id: outcome}`, default `no_answer`; nothing is called and no model runs). Returns the `timeline` (each step with the moment the ladder draws it, `planned_at`, and the moment the engine really sends it after contact hours and pacing, `shifted_at`, with `shift_reason`, a `preview` when a stored draft or approved template exists, and a `status`) and the real `end` reason: replied, end_of_sequence, marked_lost, no_fitting_approved_message, no_channel_left, message_limit_reached or opted_out. It is the same simulation `GET /followups/recontacto/plan` renders, so it follows the engine’s rules (contact hours from 9:00, the 24 h WhatsApp window, per-person limits, opt-out). Deterministic: no model call, nothing is sent or stored. `version` is `published` (default), `draft` (the open draft, `GET /sequences/{id}/draft`) or a version id (`GET /sequences/{id}/versions`). `builtin:si-no-responde` and custom sequences are simulable (a custom sequence walks its own steps through the same engine rules; steps timed before an appointment are listed in `notes`). Custom sequences with conditions, waits until and loops follow the scenario: `replies_after_step` → the `yes` branch of «¿Respondió?» (a reply ends the sequence only when its goal is a reply), `pays` → «¿Pagó?», `promises_date` → «Esperar hasta la fecha prometida» ends that day; `decisions` (`{step key or id: branch key}`) picks any condition’s branch, and «La IA decide» is never called here (without a decision it takes its first branch). The response then carries `path` (every step passed, the branch taken, loop laps) and timeline entries met again in a loop carry `iteration`. Requires `followups:read`.
167876
169388
  */
167877
169389
  post: {
167878
169390
  parameters: {
@@ -172395,38 +173907,575 @@ interface paths {
172395
173907
  };
172396
173908
  };
172397
173909
  put?: never;
172398
- post?: never;
172399
- delete?: never;
172400
- options?: never;
172401
- head?: never;
172402
- patch?: never;
172403
- trace?: never;
172404
- };
172405
- "/sequences/{id}/draft/validation": {
172406
- parameters: {
172407
- query?: never;
172408
- header?: never;
172409
- path?: never;
172410
- cookie?: never;
172411
- };
173910
+ post?: never;
173911
+ delete?: never;
173912
+ options?: never;
173913
+ head?: never;
173914
+ patch?: never;
173915
+ trace?: never;
173916
+ };
173917
+ "/sequences/{id}/draft/validation": {
173918
+ parameters: {
173919
+ query?: never;
173920
+ header?: never;
173921
+ path?: never;
173922
+ cookie?: never;
173923
+ };
173924
+ /**
173925
+ * What blocks publishing the draft
173926
+ * @description Checks the open draft the way publishing does. `blockers` stop `POST /sequences/{id}/publish`; `warnings` do not. Each problem has a machine-readable `code`, the `step_id` it is about (null for the whole draft), a Spanish `message` and a `fix`: `kind` is `draft_template` (have the AI write the missing WhatsApp template: `POST /followups/recontacto/template-draft`), `connect_channel`, `request_review`, `remove_step`, `change_channel`, `pick_agent` or `contact_support`, with a `target` (the same vocabulary as notifications) when there is a screen for it. Blocker codes: `no_fitting_approved_template` (a WhatsApp step past the 24 h window with no approved template Vitrina can fill), `channel_not_connected` (WhatsApp, email, Instagram), `step_type_unavailable` (a channel the workspace cannot use yet, e.g. SMS), `agent_unavailable` (the chosen AI agent is no longer active), `agent_not_supported` (an agent set on «Al llegar» or «Avisos»), `review_required`. Warning codes: `instagram_past_24h`, `whatsapp_past_24h_without_template`. Steps that never send (mode `skip`, a situation switched off) are not checked. Never calls a model. 404 when there is no draft. Requires `followups:read`.
173927
+ */
173928
+ get: {
173929
+ parameters: {
173930
+ query?: {
173931
+ lang?: "es" | "en";
173932
+ };
173933
+ header?: never;
173934
+ path: {
173935
+ id: string;
173936
+ };
173937
+ cookie?: never;
173938
+ };
173939
+ requestBody?: never;
173940
+ responses: {
173941
+ /** @description The problems */
173942
+ 200: {
173943
+ headers: {
173944
+ [name: string]: unknown;
173945
+ };
173946
+ content: {
173947
+ /**
173948
+ * @example {
173949
+ * "data": {
173950
+ * "blockers": [
173951
+ * {
173952
+ * "code": "no_fitting_approved_template",
173953
+ * "step_id": "stalled-2",
173954
+ * "message": "Este paso escribe pasadas las 24 horas y para eso necesita una plantilla de WhatsApp aprobada. Todavía no hay ninguna que sirva.",
173955
+ * "fix": {
173956
+ * "kind": "draft_template",
173957
+ * "target": {
173958
+ * "kind": "page",
173959
+ * "page": "settings.templates"
173960
+ * }
173961
+ * }
173962
+ * }
173963
+ * ],
173964
+ * "warnings": [
173965
+ * {
173966
+ * "code": "instagram_past_24h",
173967
+ * "step_id": "stalled-3",
173968
+ * "message": "Instagram solo deja escribir dentro de las 24 horas desde el último mensaje del cliente. Este paso no se enviará pasado ese plazo.",
173969
+ * "fix": {
173970
+ * "kind": "change_channel"
173971
+ * }
173972
+ * }
173973
+ * ]
173974
+ * }
173975
+ * }
173976
+ */
173977
+ "application/json": {
173978
+ data: components["schemas"]["SequenceDraftValidation"];
173979
+ };
173980
+ };
173981
+ };
173982
+ /** @description Validation error */
173983
+ 400: {
173984
+ headers: {
173985
+ [name: string]: unknown;
173986
+ };
173987
+ content: {
173988
+ "application/json": components["schemas"]["Error"];
173989
+ };
173990
+ };
173991
+ /** @description Unauthorized */
173992
+ 401: {
173993
+ headers: {
173994
+ [name: string]: unknown;
173995
+ };
173996
+ content: {
173997
+ "application/json": components["schemas"]["Error"];
173998
+ };
173999
+ };
174000
+ /** @description Forbidden */
174001
+ 403: {
174002
+ headers: {
174003
+ [name: string]: unknown;
174004
+ };
174005
+ content: {
174006
+ "application/json": components["schemas"]["Error"];
174007
+ };
174008
+ };
174009
+ /** @description Not found */
174010
+ 404: {
174011
+ headers: {
174012
+ [name: string]: unknown;
174013
+ };
174014
+ content: {
174015
+ "application/json": components["schemas"]["Error"];
174016
+ };
174017
+ };
174018
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
174019
+ 409: {
174020
+ headers: {
174021
+ [name: string]: unknown;
174022
+ };
174023
+ content: {
174024
+ "application/json": components["schemas"]["Error"];
174025
+ };
174026
+ };
174027
+ /** @description Rate limited */
174028
+ 429: {
174029
+ headers: {
174030
+ [name: string]: unknown;
174031
+ };
174032
+ content: {
174033
+ "application/json": components["schemas"]["Error"];
174034
+ };
174035
+ };
174036
+ };
174037
+ };
174038
+ put?: never;
174039
+ post?: never;
174040
+ delete?: never;
174041
+ options?: never;
174042
+ head?: never;
174043
+ patch?: never;
174044
+ trace?: never;
174045
+ };
174046
+ "/sequences/collection-rules": {
174047
+ parameters: {
174048
+ query?: never;
174049
+ header?: never;
174050
+ path?: never;
174051
+ cookie?: never;
174052
+ };
174053
+ /**
174054
+ * Collection rules of the workspace
174055
+ * @description The days, hours and caps collection sequences obey on top of the shared guards (contact hours, per-person limits): `weekdays`, the `hours` window, `calls_per_day`, `calls_per_week`, `messages_per_week`, `min_spacing_hours` and `over_cap` (`skip` or `move`). The defaults are the limits of Ley 19.496 art. 37 (Ley 21.320) and CPC art. 59: Monday to Saturday except holidays, 08:00 to 20:00, one call per week, two messages per week at least 48 h apart. `ceilings` are those legal limits: a workspace may be stricter, never looser. `version` is 0 until the rules are saved. Requires `followups:read`.
174056
+ */
174057
+ get: {
174058
+ parameters: {
174059
+ query?: never;
174060
+ header?: never;
174061
+ path?: never;
174062
+ cookie?: never;
174063
+ };
174064
+ requestBody?: never;
174065
+ responses: {
174066
+ /** @description The rules */
174067
+ 200: {
174068
+ headers: {
174069
+ [name: string]: unknown;
174070
+ };
174071
+ content: {
174072
+ /**
174073
+ * @example {
174074
+ * "data": {
174075
+ * "rules": {
174076
+ * "weekdays": [
174077
+ * 1,
174078
+ * 2,
174079
+ * 3,
174080
+ * 4,
174081
+ * 5,
174082
+ * 6
174083
+ * ],
174084
+ * "hours": {
174085
+ * "start": "08:00",
174086
+ * "end": "20:00"
174087
+ * },
174088
+ * "skip_holidays": true,
174089
+ * "calls_per_day": 1,
174090
+ * "calls_per_week": 1,
174091
+ * "messages_per_week": 2,
174092
+ * "min_spacing_hours": 48,
174093
+ * "over_cap": "skip"
174094
+ * },
174095
+ * "version": 3,
174096
+ * "is_default": false,
174097
+ * "updated_at": "2027-03-02T14:20:00.000Z",
174098
+ * "updated_by": {
174099
+ * "kind": "user",
174100
+ * "id": "0192f0b2-0000-7000-8000-00000000a001"
174101
+ * },
174102
+ * "ceilings": {
174103
+ * "weekdays": [
174104
+ * 1,
174105
+ * 2,
174106
+ * 3,
174107
+ * 4,
174108
+ * 5,
174109
+ * 6
174110
+ * ],
174111
+ * "hours": {
174112
+ * "start": "08:00",
174113
+ * "end": "20:00"
174114
+ * },
174115
+ * "calls_per_day": 1,
174116
+ * "calls_per_week": 1,
174117
+ * "messages_per_week": 2,
174118
+ * "min_spacing_hours": 48
174119
+ * }
174120
+ * }
174121
+ * }
174122
+ */
174123
+ "application/json": {
174124
+ data: components["schemas"]["CollectionRulesView"];
174125
+ };
174126
+ };
174127
+ };
174128
+ /** @description Validation error */
174129
+ 400: {
174130
+ headers: {
174131
+ [name: string]: unknown;
174132
+ };
174133
+ content: {
174134
+ "application/json": components["schemas"]["Error"];
174135
+ };
174136
+ };
174137
+ /** @description Unauthorized */
174138
+ 401: {
174139
+ headers: {
174140
+ [name: string]: unknown;
174141
+ };
174142
+ content: {
174143
+ "application/json": components["schemas"]["Error"];
174144
+ };
174145
+ };
174146
+ /** @description Forbidden */
174147
+ 403: {
174148
+ headers: {
174149
+ [name: string]: unknown;
174150
+ };
174151
+ content: {
174152
+ "application/json": components["schemas"]["Error"];
174153
+ };
174154
+ };
174155
+ /** @description Not found */
174156
+ 404: {
174157
+ headers: {
174158
+ [name: string]: unknown;
174159
+ };
174160
+ content: {
174161
+ "application/json": components["schemas"]["Error"];
174162
+ };
174163
+ };
174164
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
174165
+ 409: {
174166
+ headers: {
174167
+ [name: string]: unknown;
174168
+ };
174169
+ content: {
174170
+ "application/json": components["schemas"]["Error"];
174171
+ };
174172
+ };
174173
+ /** @description Rate limited */
174174
+ 429: {
174175
+ headers: {
174176
+ [name: string]: unknown;
174177
+ };
174178
+ content: {
174179
+ "application/json": components["schemas"]["Error"];
174180
+ };
174181
+ };
174182
+ };
174183
+ };
174184
+ /**
174185
+ * Replace the collection rules
174186
+ * @description Replaces the rules (fields left out take the platform defaults). 422 `VALIDATION_ERROR` with `details.problems` when a value is looser than the law allows. A real change raises `version`, which makes every recorded legal review outdated: collection sequences need a new review before they publish again. Saving the rules already in force changes nothing. Requires `followups:write`.
174187
+ */
174188
+ put: {
174189
+ parameters: {
174190
+ query?: never;
174191
+ header?: never;
174192
+ path?: never;
174193
+ cookie?: never;
174194
+ };
174195
+ requestBody: {
174196
+ content: {
174197
+ /**
174198
+ * @example {
174199
+ * "messages_per_week": 1,
174200
+ * "hours": {
174201
+ * "start": "09:00",
174202
+ * "end": "19:00"
174203
+ * }
174204
+ * }
174205
+ */
174206
+ "application/json": components["schemas"]["CollectionRulesReplaceRequest"];
174207
+ };
174208
+ };
174209
+ responses: {
174210
+ /** @description The rules */
174211
+ 200: {
174212
+ headers: {
174213
+ [name: string]: unknown;
174214
+ };
174215
+ content: {
174216
+ /**
174217
+ * @example {
174218
+ * "data": {
174219
+ * "rules": {
174220
+ * "weekdays": [
174221
+ * 1,
174222
+ * 2,
174223
+ * 3,
174224
+ * 4,
174225
+ * 5,
174226
+ * 6
174227
+ * ],
174228
+ * "hours": {
174229
+ * "start": "09:00",
174230
+ * "end": "19:00"
174231
+ * },
174232
+ * "skip_holidays": true,
174233
+ * "calls_per_day": 1,
174234
+ * "calls_per_week": 1,
174235
+ * "messages_per_week": 1,
174236
+ * "min_spacing_hours": 48,
174237
+ * "over_cap": "skip"
174238
+ * },
174239
+ * "version": 3,
174240
+ * "is_default": false,
174241
+ * "updated_at": "2027-03-02T14:20:00.000Z",
174242
+ * "updated_by": {
174243
+ * "kind": "user",
174244
+ * "id": "0192f0b2-0000-7000-8000-00000000a001"
174245
+ * },
174246
+ * "ceilings": {
174247
+ * "weekdays": [
174248
+ * 1,
174249
+ * 2,
174250
+ * 3,
174251
+ * 4,
174252
+ * 5,
174253
+ * 6
174254
+ * ],
174255
+ * "hours": {
174256
+ * "start": "08:00",
174257
+ * "end": "20:00"
174258
+ * },
174259
+ * "calls_per_day": 1,
174260
+ * "calls_per_week": 1,
174261
+ * "messages_per_week": 2,
174262
+ * "min_spacing_hours": 48
174263
+ * }
174264
+ * }
174265
+ * }
174266
+ */
174267
+ "application/json": {
174268
+ data: components["schemas"]["CollectionRulesView"];
174269
+ };
174270
+ };
174271
+ };
174272
+ /** @description Validation error */
174273
+ 400: {
174274
+ headers: {
174275
+ [name: string]: unknown;
174276
+ };
174277
+ content: {
174278
+ "application/json": components["schemas"]["Error"];
174279
+ };
174280
+ };
174281
+ /** @description Unauthorized */
174282
+ 401: {
174283
+ headers: {
174284
+ [name: string]: unknown;
174285
+ };
174286
+ content: {
174287
+ "application/json": components["schemas"]["Error"];
174288
+ };
174289
+ };
174290
+ /** @description Forbidden */
174291
+ 403: {
174292
+ headers: {
174293
+ [name: string]: unknown;
174294
+ };
174295
+ content: {
174296
+ "application/json": components["schemas"]["Error"];
174297
+ };
174298
+ };
174299
+ /** @description Not found */
174300
+ 404: {
174301
+ headers: {
174302
+ [name: string]: unknown;
174303
+ };
174304
+ content: {
174305
+ "application/json": components["schemas"]["Error"];
174306
+ };
174307
+ };
174308
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
174309
+ 409: {
174310
+ headers: {
174311
+ [name: string]: unknown;
174312
+ };
174313
+ content: {
174314
+ "application/json": components["schemas"]["Error"];
174315
+ };
174316
+ };
174317
+ /** @description Rate limited */
174318
+ 429: {
174319
+ headers: {
174320
+ [name: string]: unknown;
174321
+ };
174322
+ content: {
174323
+ "application/json": components["schemas"]["Error"];
174324
+ };
174325
+ };
174326
+ };
174327
+ };
174328
+ post?: never;
174329
+ delete?: never;
174330
+ options?: never;
174331
+ head?: never;
174332
+ patch?: never;
174333
+ trace?: never;
174334
+ };
174335
+ "/sequences/{id}/legal-review": {
174336
+ parameters: {
174337
+ query?: never;
174338
+ header?: never;
174339
+ path?: never;
174340
+ cookie?: never;
174341
+ };
174342
+ /**
174343
+ * Where the legal review of a collection sequence stands
174344
+ * @description `status`: `not_required` (not a collection sequence), `missing`, `valid` (recorded against the current rules version) or `outdated` (the rules changed since). `review` is the newest recorded one. Publishing a collection sequence is refused with `review_required` unless the status is `valid`. Requires `followups:read`.
174345
+ */
174346
+ get: {
174347
+ parameters: {
174348
+ query?: never;
174349
+ header?: never;
174350
+ path: {
174351
+ id: string;
174352
+ };
174353
+ cookie?: never;
174354
+ };
174355
+ requestBody?: never;
174356
+ responses: {
174357
+ /** @description The review state */
174358
+ 200: {
174359
+ headers: {
174360
+ [name: string]: unknown;
174361
+ };
174362
+ content: {
174363
+ /**
174364
+ * @example {
174365
+ * "data": {
174366
+ * "sequence_id": "0192f0b2-0000-7000-8000-00000000c001",
174367
+ * "required": true,
174368
+ * "status": "valid",
174369
+ * "rules_version": 3,
174370
+ * "review": {
174371
+ * "id": "0192f0b2-0000-7000-8000-00000000d001",
174372
+ * "reviewer_member_id": "0192f0b2-0000-7000-8000-00000000a002",
174373
+ * "reviewed_on": "2027-03-02",
174374
+ * "note": "Revisado con la abogada del estudio",
174375
+ * "attachment_url": "https://docs.ejemplo.cl/opinion-legal.pdf",
174376
+ * "rules_version": 3,
174377
+ * "created_at": "2027-03-02T14:25:00.000Z",
174378
+ * "created_by": {
174379
+ * "kind": "user",
174380
+ * "id": "0192f0b2-0000-7000-8000-00000000a001"
174381
+ * }
174382
+ * }
174383
+ * }
174384
+ * }
174385
+ */
174386
+ "application/json": {
174387
+ data: components["schemas"]["SequenceLegalReview"];
174388
+ };
174389
+ };
174390
+ };
174391
+ /** @description Validation error */
174392
+ 400: {
174393
+ headers: {
174394
+ [name: string]: unknown;
174395
+ };
174396
+ content: {
174397
+ "application/json": components["schemas"]["Error"];
174398
+ };
174399
+ };
174400
+ /** @description Unauthorized */
174401
+ 401: {
174402
+ headers: {
174403
+ [name: string]: unknown;
174404
+ };
174405
+ content: {
174406
+ "application/json": components["schemas"]["Error"];
174407
+ };
174408
+ };
174409
+ /** @description Forbidden */
174410
+ 403: {
174411
+ headers: {
174412
+ [name: string]: unknown;
174413
+ };
174414
+ content: {
174415
+ "application/json": components["schemas"]["Error"];
174416
+ };
174417
+ };
174418
+ /** @description Not found */
174419
+ 404: {
174420
+ headers: {
174421
+ [name: string]: unknown;
174422
+ };
174423
+ content: {
174424
+ "application/json": components["schemas"]["Error"];
174425
+ };
174426
+ };
174427
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
174428
+ 409: {
174429
+ headers: {
174430
+ [name: string]: unknown;
174431
+ };
174432
+ content: {
174433
+ "application/json": components["schemas"]["Error"];
174434
+ };
174435
+ };
174436
+ /** @description Rate limited */
174437
+ 429: {
174438
+ headers: {
174439
+ [name: string]: unknown;
174440
+ };
174441
+ content: {
174442
+ "application/json": components["schemas"]["Error"];
174443
+ };
174444
+ };
174445
+ };
174446
+ };
174447
+ put?: never;
172412
174448
  /**
172413
- * What blocks publishing the draft
172414
- * @description Checks the open draft the way publishing does. `blockers` stop `POST /sequences/{id}/publish`; `warnings` do not. Each problem has a machine-readable `code`, the `step_id` it is about (null for the whole draft), a Spanish `message` and a `fix`: `kind` is `draft_template` (have the AI write the missing WhatsApp template: `POST /followups/recontacto/template-draft`), `connect_channel`, `request_review`, `remove_step`, `change_channel`, `pick_agent` or `contact_support`, with a `target` (the same vocabulary as notifications) when there is a screen for it. Blocker codes: `no_fitting_approved_template` (a WhatsApp step past the 24 h window with no approved template Vitrina can fill), `channel_not_connected` (WhatsApp, email, Instagram), `step_type_unavailable` (a channel the workspace cannot use yet, e.g. SMS), `agent_unavailable` (the chosen AI agent is no longer active), `agent_not_supported` (an agent set on «Al llegar» or «Avisos»), `review_required`. Warning codes: `instagram_past_24h`, `whatsapp_past_24h_without_template`. Steps that never send (mode `skip`, a situation switched off) are not checked. Never calls a model. 404 when there is no draft. Requires `followups:read`.
174449
+ * Record the legal review of a collection sequence
174450
+ * @description Records who reviewed the sequence and the rules (`reviewer_member_id`, `reviewed_on`, a `note` and/or an `attachment_url`) against the current rules version, which clears the `review_required` blocker. Append-only: the history is kept. 422 for a sequence that is not a collection sequence; 409 `rules_version_stale` when `rules_version` is no longer current. Requires `followups:write`.
172415
174451
  */
172416
- get: {
174452
+ post: {
172417
174453
  parameters: {
172418
- query?: {
172419
- lang?: "es" | "en";
174454
+ query?: never;
174455
+ header?: {
174456
+ /** @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. */
174457
+ "Idempotency-Key"?: string;
172420
174458
  };
172421
- header?: never;
172422
174459
  path: {
172423
174460
  id: string;
172424
174461
  };
172425
174462
  cookie?: never;
172426
174463
  };
172427
- requestBody?: never;
174464
+ requestBody: {
174465
+ content: {
174466
+ /**
174467
+ * @example {
174468
+ * "reviewer_member_id": "0192f0b2-0000-7000-8000-00000000a002",
174469
+ * "reviewed_on": "2027-03-02",
174470
+ * "note": "Revisado con la abogada del estudio",
174471
+ * "attachment_url": "https://docs.ejemplo.cl/opinion-legal.pdf"
174472
+ * }
174473
+ */
174474
+ "application/json": components["schemas"]["SequenceLegalReviewRequest"];
174475
+ };
174476
+ };
172428
174477
  responses: {
172429
- /** @description The problems */
174478
+ /** @description The review state */
172430
174479
  200: {
172431
174480
  headers: {
172432
174481
  [name: string]: unknown;
@@ -172435,35 +174484,28 @@ interface paths {
172435
174484
  /**
172436
174485
  * @example {
172437
174486
  * "data": {
172438
- * "blockers": [
172439
- * {
172440
- * "code": "no_fitting_approved_template",
172441
- * "step_id": "stalled-2",
172442
- * "message": "Este paso escribe pasadas las 24 horas y para eso necesita una plantilla de WhatsApp aprobada. Todavía no hay ninguna que sirva.",
172443
- * "fix": {
172444
- * "kind": "draft_template",
172445
- * "target": {
172446
- * "kind": "page",
172447
- * "page": "settings.templates"
172448
- * }
172449
- * }
172450
- * }
172451
- * ],
172452
- * "warnings": [
172453
- * {
172454
- * "code": "instagram_past_24h",
172455
- * "step_id": "stalled-3",
172456
- * "message": "Instagram solo deja escribir dentro de las 24 horas desde el último mensaje del cliente. Este paso no se enviará pasado ese plazo.",
172457
- * "fix": {
172458
- * "kind": "change_channel"
172459
- * }
174487
+ * "sequence_id": "0192f0b2-0000-7000-8000-00000000c001",
174488
+ * "required": true,
174489
+ * "status": "valid",
174490
+ * "rules_version": 3,
174491
+ * "review": {
174492
+ * "id": "0192f0b2-0000-7000-8000-00000000d001",
174493
+ * "reviewer_member_id": "0192f0b2-0000-7000-8000-00000000a002",
174494
+ * "reviewed_on": "2027-03-02",
174495
+ * "note": "Revisado con la abogada del estudio",
174496
+ * "attachment_url": "https://docs.ejemplo.cl/opinion-legal.pdf",
174497
+ * "rules_version": 3,
174498
+ * "created_at": "2027-03-02T14:25:00.000Z",
174499
+ * "created_by": {
174500
+ * "kind": "user",
174501
+ * "id": "0192f0b2-0000-7000-8000-00000000a001"
172460
174502
  * }
172461
- * ]
174503
+ * }
172462
174504
  * }
172463
174505
  * }
172464
174506
  */
172465
174507
  "application/json": {
172466
- data: components["schemas"]["SequenceDraftValidation"];
174508
+ data: components["schemas"]["SequenceLegalReview"];
172467
174509
  };
172468
174510
  };
172469
174511
  };
@@ -172523,8 +174565,6 @@ interface paths {
172523
174565
  };
172524
174566
  };
172525
174567
  };
172526
- put?: never;
172527
- post?: never;
172528
174568
  delete?: never;
172529
174569
  options?: never;
172530
174570
  head?: never;
@@ -175016,10 +177056,88 @@ interface paths {
175016
177056
  * "label": "Llamada de cobranza"
175017
177057
  * },
175018
177058
  * {
177059
+ * "situation": null,
177060
+ * "config_ref": null,
177061
+ * "key": "call-1-outcome",
177062
+ * "kind": "condition",
177063
+ * "position": 3,
177064
+ * "wait": {
177065
+ * "type": "duration",
177066
+ * "value": 0,
177067
+ * "unit": "hours",
177068
+ * "from": "previous_step",
177069
+ * "from_step": "step-2",
177070
+ * "hours": 0
177071
+ * },
177072
+ * "test": "call_outcome",
177073
+ * "ai_prompt": null,
177074
+ * "branches": [
177075
+ * {
177076
+ * "key": "promised_pay",
177077
+ * "label": "Prometió pagar",
177078
+ * "to": "promise-1-wait"
177079
+ * },
177080
+ * {
177081
+ * "key": "no_answer",
177082
+ * "label": "No contestó",
177083
+ * "to": "step-3"
177084
+ * }
177085
+ * ],
177086
+ * "default_branch": "no_answer",
177087
+ * "label": "¿Cómo salió la llamada?"
177088
+ * },
177089
+ * {
177090
+ * "situation": null,
177091
+ * "config_ref": null,
177092
+ * "key": "promise-1-wait",
177093
+ * "kind": "wait_until",
177094
+ * "position": 4,
177095
+ * "until": {
177096
+ * "kind": "date_field",
177097
+ * "field": "promised_date"
177098
+ * },
177099
+ * "timeout": {
177100
+ * "value": 14,
177101
+ * "unit": "days"
177102
+ * },
177103
+ * "label": "Esperar hasta la fecha prometida"
177104
+ * },
177105
+ * {
177106
+ * "situation": null,
177107
+ * "config_ref": null,
177108
+ * "key": "paid-1",
177109
+ * "kind": "condition",
177110
+ * "position": 5,
177111
+ * "wait": {
177112
+ * "type": "duration",
177113
+ * "value": 1,
177114
+ * "unit": "days",
177115
+ * "from": "previous_step",
177116
+ * "from_step": "promise-1-wait",
177117
+ * "hours": 24
177118
+ * },
177119
+ * "test": "paid",
177120
+ * "ai_prompt": null,
177121
+ * "branches": [
177122
+ * {
177123
+ * "key": "yes",
177124
+ * "label": "Sí",
177125
+ * "to": "end"
177126
+ * },
177127
+ * {
177128
+ * "key": "no",
177129
+ * "label": "No",
177130
+ * "to": "step-3"
177131
+ * }
177132
+ * ],
177133
+ * "default_branch": null,
177134
+ * "label": "¿Pagó?"
177135
+ * },
177136
+ * {
175019
177137
  * "key": "step-3",
175020
177138
  * "situation": null,
175021
177139
  * "kind": "message",
175022
- * "position": 3,
177140
+ * "position": 6,
175023
177141
  * "channel": "whatsapp",
175024
177142
  * "fallback_channel": null,
175025
177143
  * "wait": {
@@ -175042,7 +177160,7 @@ interface paths {
175042
177160
  * "key": "step-4",
175043
177161
  * "situation": null,
175044
177162
  * "kind": "message",
175045
- * "position": 4,
177163
+ * "position": 7,
175046
177164
  * "channel": "call",
175047
177165
  * "fallback_channel": null,
175048
177166
  * "wait": {
@@ -175062,10 +177180,88 @@ interface paths {
175062
177180
  * "label": "Segunda llamada"
175063
177181
  * },
175064
177182
  * {
177183
+ * "situation": null,
177184
+ * "config_ref": null,
177185
+ * "key": "call-2-outcome",
177186
+ * "kind": "condition",
177187
+ * "position": 8,
177188
+ * "wait": {
177189
+ * "type": "duration",
177190
+ * "value": 0,
177191
+ * "unit": "hours",
177192
+ * "from": "previous_step",
177193
+ * "from_step": "step-4",
177194
+ * "hours": 0
177195
+ * },
177196
+ * "test": "call_outcome",
177197
+ * "ai_prompt": null,
177198
+ * "branches": [
177199
+ * {
177200
+ * "key": "promised_pay",
177201
+ * "label": "Prometió pagar",
177202
+ * "to": "promise-2-wait"
177203
+ * },
177204
+ * {
177205
+ * "key": "no_answer",
177206
+ * "label": "No contestó",
177207
+ * "to": "step-5"
177208
+ * }
177209
+ * ],
177210
+ * "default_branch": "no_answer",
177211
+ * "label": "¿Cómo salió la llamada?"
177212
+ * },
177213
+ * {
177214
+ * "situation": null,
177215
+ * "config_ref": null,
177216
+ * "key": "promise-2-wait",
177217
+ * "kind": "wait_until",
177218
+ * "position": 9,
177219
+ * "until": {
177220
+ * "kind": "date_field",
177221
+ * "field": "promised_date"
177222
+ * },
177223
+ * "timeout": {
177224
+ * "value": 14,
177225
+ * "unit": "days"
177226
+ * },
177227
+ * "label": "Esperar hasta la fecha prometida"
177228
+ * },
177229
+ * {
177230
+ * "situation": null,
177231
+ * "config_ref": null,
177232
+ * "key": "paid-2",
177233
+ * "kind": "condition",
177234
+ * "position": 10,
177235
+ * "wait": {
177236
+ * "type": "duration",
177237
+ * "value": 1,
177238
+ * "unit": "days",
177239
+ * "from": "previous_step",
177240
+ * "from_step": "promise-2-wait",
177241
+ * "hours": 24
177242
+ * },
177243
+ * "test": "paid",
177244
+ * "ai_prompt": null,
177245
+ * "branches": [
177246
+ * {
177247
+ * "key": "yes",
177248
+ * "label": "Sí",
177249
+ * "to": "end"
177250
+ * },
177251
+ * {
177252
+ * "key": "no",
177253
+ * "label": "No",
177254
+ * "to": "step-5"
177255
+ * }
177256
+ * ],
177257
+ * "default_branch": null,
177258
+ * "label": "¿Pagó?"
177259
+ * },
177260
+ * {
175065
177261
  * "key": "step-5",
175066
177262
  * "situation": null,
175067
177263
  * "kind": "message",
175068
- * "position": 5,
177264
+ * "position": 11,
175069
177265
  * "channel": "email",
175070
177266
  * "fallback_channel": null,
175071
177267
  * "wait": {
@@ -281733,10 +283929,10 @@ interface components {
281733
283929
  } | null;
281734
283930
  at_hours: number | null;
281735
283931
  /**
281736
- * @description `replied` (the customer wrote since our last message), `paid` (unavailable until app#6456), `booked` (an appointment since entering), `ai_decides` (the sequence agent picks a branch; `default_branch` on failure). The fixed tests have exactly the branches `yes` and `no`.
283932
+ * @description `replied` (the customer wrote since our last message), `paid` (unavailable until app#6456), `booked` (an appointment since entering), `ai_decides` (the sequence agent picks a branch; `default_branch` on failure). `call_outcome` (how the latest AI call step ended: one branch per outcome answered | promised_pay | promised_visit | call_later | no_answer | do_not_contact, 2 to 6, the branch key is the outcome; `default_branch` for an outcome with no branch). The fixed tests (replied, paid, booked) have exactly the branches `yes` and `no`.
281737
283933
  * @enum {string}
281738
283934
  */
281739
- test: "replied" | "paid" | "booked" | "ai_decides";
283935
+ test: "replied" | "paid" | "booked" | "ai_decides" | "call_outcome";
281740
283936
  ai_prompt: string | null;
281741
283937
  branches: components["schemas"]["SequenceBranch"][];
281742
283938
  default_branch: string | null;
@@ -281922,13 +284118,22 @@ interface components {
281922
284118
  type: "event";
281923
284119
  /** @enum {string} */
281924
284120
  event: "lead_arrived" | "customer_went_quiet" | "customer_asked_reminder" | "stage_changed" | "quoted_not_booked" | "appointment_booked" | "signed_up_not_bought" | "installment_overdue";
281925
- filters: {
284121
+ filters: ({
281926
284122
  /** @description Custom sequences filter on `interest`, `source`, `stage` (stage id) or `tag` (tag name). */
281927
284123
  field: string;
281928
284124
  /** @enum {string} */
281929
284125
  op: "in";
281930
284126
  values: string[];
281931
- }[];
284127
+ } | {
284128
+ /**
284129
+ * @description Only for the `installment_overdue` entry: `days_overdue` (days past the due day) or `amount` (pesos still owed), at least `value`.
284130
+ * @enum {string}
284131
+ */
284132
+ field: "days_overdue" | "amount";
284133
+ /** @enum {string} */
284134
+ op: "gte";
284135
+ value: number;
284136
+ })[];
281932
284137
  } | {
281933
284138
  /** @enum {string} */
281934
284139
  type: "list";
@@ -281942,6 +284147,8 @@ interface components {
281942
284147
  };
281943
284148
  /** Format: uuid */
281944
284149
  agent_id: string | null;
284150
+ /** @description A collection sequence (Cobranza): it obeys the workspace’s collection rules (`GET /sequences/collection-rules`) and needs a recorded legal review to publish (`POST /sequences/{id}/legal-review`). True for the «Cobranza de cuotas» template, an entry of `installment_overdue` or a goal of `pays`. */
284151
+ collection: boolean;
281945
284152
  priority: number;
281946
284153
  situations: {
281947
284154
  key: string;
@@ -282004,6 +284211,11 @@ interface components {
282004
284211
  updated_at: string;
282005
284212
  } | null;
282006
284213
  };
284214
+ /**
284215
+ * @description AI call steps only: the outcome the scenario supplied (default no_answer).
284216
+ * @enum {string}
284217
+ */
284218
+ SequenceCallOutcome: "answered" | "promised_pay" | "promised_visit" | "call_later" | "no_answer" | "do_not_contact";
282007
284219
  SequenceSimulation: {
282008
284220
  timeline: {
282009
284221
  /** Format: uuid */
@@ -282016,16 +284228,22 @@ interface components {
282016
284228
  /** Format: date-time */
282017
284229
  shifted_at: string;
282018
284230
  /** @enum {string} */
282019
- shift_reason?: "outside_contact_hours" | "previous_late" | "unanswered_hold" | "agreed_reminder" | "min_gap" | "max_per_day" | "automated_gap" | "person_ceiling" | "appointment_soon" | "daily_cap";
284231
+ shift_reason?: "outside_contact_hours" | "previous_late" | "unanswered_hold" | "agreed_reminder" | "min_gap" | "max_per_day" | "automated_gap" | "person_ceiling" | "appointment_soon" | "daily_cap" | "non_collection_day" | "holiday" | "outside_collection_hours" | "min_spacing" | "calls_per_day" | "calls_per_week" | "messages_per_week";
284232
+ /**
284233
+ * @description Why the collection rules skipped the step (status `skipped_by_collection_rules`).
284234
+ * @enum {string}
284235
+ */
284236
+ skip_reason?: "non_collection_day" | "holiday" | "outside_collection_hours" | "min_spacing" | "calls_per_day" | "calls_per_week" | "messages_per_week";
282020
284237
  preview?: string;
284238
+ call_outcome?: components["schemas"]["SequenceCallOutcome"];
282021
284239
  /** @enum {string} */
282022
- status: "sends" | "awaits_approval" | "skipped_no_channel" | "skipped_no_template";
284240
+ status: "sends" | "awaits_approval" | "skipped_no_channel" | "skipped_no_template" | "skipped_by_collection_rules";
282023
284241
  /** @description Custom sequences: 2 on the first lap back through a loop, 3 on the next (absent = first pass). */
282024
284242
  iteration?: number;
282025
284243
  }[];
282026
284244
  end: {
282027
284245
  /** @enum {string} */
282028
- reason: "replied" | "end_of_sequence" | "marked_lost" | "no_fitting_approved_message" | "no_channel_left" | "message_limit_reached" | "opted_out";
284246
+ reason: "replied" | "paid" | "end_of_sequence" | "marked_lost" | "no_fitting_approved_message" | "no_channel_left" | "blocked_by_collection_rules" | "message_limit_reached" | "opted_out";
282029
284247
  /** Format: uuid */
282030
284248
  at_step?: string;
282031
284249
  /** Format: date-time */
@@ -282090,6 +284308,10 @@ interface components {
282090
284308
  };
282091
284309
  /** @description `published` (default), `draft` (the open draft) or a version id from `GET /sequences/{id}/versions`. */
282092
284310
  version?: string;
284311
+ /** @description AI call steps: how each call ends in this scenario, keyed by step id. A call step not named ends `no_answer`. Nothing is called and no model runs; `do_not_contact` ends the walk at that call. */
284312
+ call_outcomes?: {
284313
+ [key: string]: components["schemas"]["SequenceCallOutcome"] & unknown;
284314
+ };
282093
284315
  /** @description Custom sequences: the branch each condition takes, `{ <step key or step id>: <branch key> }`. «La IA decide» is never called in a simulation; without an entry it takes its first branch. Other conditions follow `behavior` unless listed here. */
282094
284316
  decisions?: {
282095
284317
  [key: string]: string;
@@ -282223,10 +284445,10 @@ interface components {
282223
284445
  hours: number;
282224
284446
  };
282225
284447
  /**
282226
- * @description `replied` (the customer wrote since our last message), `paid` (unavailable until app#6456), `booked` (an appointment since entering), `ai_decides` (the sequence agent picks a branch; `default_branch` on failure). The fixed tests have exactly the branches `yes` and `no`.
284448
+ * @description `replied` (the customer wrote since our last message), `paid` (unavailable until app#6456), `booked` (an appointment since entering), `ai_decides` (the sequence agent picks a branch; `default_branch` on failure). `call_outcome` (how the latest AI call step ended: one branch per outcome answered | promised_pay | promised_visit | call_later | no_answer | do_not_contact, 2 to 6, the branch key is the outcome; `default_branch` for an outcome with no branch). The fixed tests (replied, paid, booked) have exactly the branches `yes` and `no`.
282227
284449
  * @enum {string}
282228
284450
  */
282229
- test: "replied" | "paid" | "booked" | "ai_decides";
284451
+ test: "replied" | "paid" | "booked" | "ai_decides" | "call_outcome";
282230
284452
  /** @default null */
282231
284453
  ai_prompt: string | null;
282232
284454
  branches: components["schemas"]["SequenceBranch"][];
@@ -282272,13 +284494,22 @@ interface components {
282272
284494
  type: "event";
282273
284495
  /** @enum {string} */
282274
284496
  event: "lead_arrived" | "customer_went_quiet" | "customer_asked_reminder" | "stage_changed" | "quoted_not_booked" | "appointment_booked" | "signed_up_not_bought" | "installment_overdue";
282275
- filters: {
284497
+ filters: ({
282276
284498
  /** @description Custom sequences filter on `interest`, `source`, `stage` (stage id) or `tag` (tag name). */
282277
284499
  field: string;
282278
284500
  /** @enum {string} */
282279
284501
  op: "in";
282280
284502
  values: string[];
282281
- }[];
284503
+ } | {
284504
+ /**
284505
+ * @description Only for the `installment_overdue` entry: `days_overdue` (days past the due day) or `amount` (pesos still owed), at least `value`.
284506
+ * @enum {string}
284507
+ */
284508
+ field: "days_overdue" | "amount";
284509
+ /** @enum {string} */
284510
+ op: "gte";
284511
+ value: number;
284512
+ })[];
282282
284513
  } | {
282283
284514
  /** @enum {string} */
282284
284515
  type: "list";
@@ -282291,6 +284522,8 @@ interface components {
282291
284522
  };
282292
284523
  /** Format: uuid */
282293
284524
  agent_id: string | null;
284525
+ /** @description Mark the sequence as a collection sequence. Optional (false when left out); an entry of `installment_overdue` or a goal of `pays` makes it one anyway. */
284526
+ collection?: boolean;
282294
284527
  priority: number;
282295
284528
  situations: {
282296
284529
  key: string;
@@ -282466,6 +284699,105 @@ interface components {
282466
284699
  blockers: components["schemas"]["SequenceValidationProblem"][];
282467
284700
  warnings: components["schemas"]["SequenceValidationProblem"][];
282468
284701
  };
284702
+ CollectionRules: {
284703
+ /** @description Days collection may contact, ISO (1 = Monday … 7 = Sunday). Sunday is never allowed. */
284704
+ weekdays: number[];
284705
+ /** @description Local window (workspace time zone), start inclusive, end exclusive. */
284706
+ hours: {
284707
+ start: string;
284708
+ end: string;
284709
+ };
284710
+ /** @description National public holidays never allow a contact. Must be true. */
284711
+ skip_holidays: boolean;
284712
+ calls_per_day: number;
284713
+ calls_per_week: number;
284714
+ messages_per_week: number;
284715
+ min_spacing_hours: number;
284716
+ /**
284717
+ * @description `skip` drops a step that would go over a cap; `move` pushes it to the next week.
284718
+ * @enum {string}
284719
+ */
284720
+ over_cap: "skip" | "move";
284721
+ };
284722
+ CollectionRulesView: {
284723
+ rules: components["schemas"]["CollectionRules"];
284724
+ /** @description 0 = the platform defaults, never saved. Goes up on every real change; a legal review names the version it reviewed. */
284725
+ version: number;
284726
+ is_default: boolean;
284727
+ updated_at: string | null;
284728
+ updated_by: {
284729
+ kind: string | null;
284730
+ id: string | null;
284731
+ via?: string | null;
284732
+ } | null;
284733
+ ceilings: {
284734
+ weekdays: number[];
284735
+ hours: {
284736
+ start: string;
284737
+ end: string;
284738
+ };
284739
+ calls_per_day: number;
284740
+ calls_per_week: number;
284741
+ messages_per_week: number;
284742
+ min_spacing_hours: number;
284743
+ };
284744
+ };
284745
+ CollectionRulesReplaceRequest: {
284746
+ /** @description Days collection may contact, ISO (1 = Monday … 7 = Sunday). Sunday is never allowed. */
284747
+ weekdays?: number[];
284748
+ /** @description Local window (workspace time zone), start inclusive, end exclusive. */
284749
+ hours?: {
284750
+ start: string;
284751
+ end: string;
284752
+ };
284753
+ /** @description National public holidays never allow a contact. Must be true. */
284754
+ skip_holidays?: boolean;
284755
+ calls_per_day?: number;
284756
+ calls_per_week?: number;
284757
+ messages_per_week?: number;
284758
+ min_spacing_hours?: number;
284759
+ /**
284760
+ * @description `skip` drops a step that would go over a cap; `move` pushes it to the next week.
284761
+ * @enum {string}
284762
+ */
284763
+ over_cap?: "skip" | "move";
284764
+ };
284765
+ SequenceLegalReview: {
284766
+ /** Format: uuid */
284767
+ sequence_id: string;
284768
+ /** @description True for a collection sequence. */
284769
+ required: boolean;
284770
+ /** @enum {string} */
284771
+ status: "not_required" | "missing" | "valid" | "outdated";
284772
+ rules_version: number;
284773
+ review: {
284774
+ /** Format: uuid */
284775
+ id: string;
284776
+ /** Format: uuid */
284777
+ reviewer_member_id: string;
284778
+ reviewed_on: string;
284779
+ note: string | null;
284780
+ attachment_url: string | null;
284781
+ rules_version: number;
284782
+ created_at: string;
284783
+ created_by: {
284784
+ kind: string | null;
284785
+ id: string | null;
284786
+ via?: string | null;
284787
+ } | null;
284788
+ } | null;
284789
+ };
284790
+ SequenceLegalReviewRequest: {
284791
+ /** Format: uuid */
284792
+ reviewer_member_id: string;
284793
+ /** @description Day of the review (YYYY-MM-DD). Default today; not in the future. */
284794
+ reviewed_on?: string;
284795
+ note?: string | null;
284796
+ /** Format: uri */
284797
+ attachment_url?: string | null;
284798
+ /** @description The rules version the reviewer looked at. 409 `rules_version_stale` when the rules changed since; default the current version. */
284799
+ rules_version?: number;
284800
+ };
282469
284801
  SequencePublishResult: {
282470
284802
  /** Format: uuid */
282471
284803
  sequence_id: string;
@@ -282513,13 +284845,22 @@ interface components {
282513
284845
  type: "event";
282514
284846
  /** @enum {string} */
282515
284847
  event: "lead_arrived" | "customer_went_quiet" | "customer_asked_reminder" | "stage_changed" | "quoted_not_booked" | "appointment_booked" | "signed_up_not_bought" | "installment_overdue";
282516
- filters: {
284848
+ filters: ({
282517
284849
  /** @description Custom sequences filter on `interest`, `source`, `stage` (stage id) or `tag` (tag name). */
282518
284850
  field: string;
282519
284851
  /** @enum {string} */
282520
284852
  op: "in";
282521
284853
  values: string[];
282522
- }[];
284854
+ } | {
284855
+ /**
284856
+ * @description Only for the `installment_overdue` entry: `days_overdue` (days past the due day) or `amount` (pesos still owed), at least `value`.
284857
+ * @enum {string}
284858
+ */
284859
+ field: "days_overdue" | "amount";
284860
+ /** @enum {string} */
284861
+ op: "gte";
284862
+ value: number;
284863
+ })[];
282523
284864
  } | {
282524
284865
  /** @enum {string} */
282525
284866
  type: "list";
@@ -282532,7 +284873,7 @@ interface components {
282532
284873
  label: string;
282533
284874
  };
282534
284875
  channels: ("whatsapp" | "same_chat" | "instagram" | "email" | "call" | "sms")[];
282535
- steps: {
284876
+ steps: ({
282536
284877
  key: string;
282537
284878
  situation: string | null;
282538
284879
  /** @enum {string} */
@@ -282628,7 +284969,80 @@ interface components {
282628
284969
  /** @description Custom sequences: the step key (or `end`) this step goes to; absent/null = the next step by position. */
282629
284970
  next?: string | null;
282630
284971
  label: string;
282631
- }[];
284972
+ } | {
284973
+ key: string;
284974
+ situation: string | null;
284975
+ /** @enum {string} */
284976
+ kind: "condition";
284977
+ position: number;
284978
+ wait: {
284979
+ /** @enum {string} */
284980
+ type: "duration";
284981
+ value: number;
284982
+ /** @enum {string} */
284983
+ unit: "minutes" | "hours" | "days";
284984
+ /** @enum {string} */
284985
+ from: "previous_step" | "start";
284986
+ from_step: string | null;
284987
+ hours: number;
284988
+ } | {
284989
+ /** @enum {string} */
284990
+ type: "event";
284991
+ event: string;
284992
+ } | {
284993
+ /** @enum {string} */
284994
+ type: "agreed_time";
284995
+ } | {
284996
+ /** @enum {string} */
284997
+ type: "before_appointment";
284998
+ value: number;
284999
+ /** @enum {string} */
285000
+ unit: "minutes" | "hours" | "days";
285001
+ hours: number;
285002
+ };
285003
+ /**
285004
+ * @description `replied` (the customer wrote since our last message), `paid` (unavailable until app#6456), `booked` (an appointment since entering), `ai_decides` (the sequence agent picks a branch; `default_branch` on failure). `call_outcome` (how the latest AI call step ended: one branch per outcome answered | promised_pay | promised_visit | call_later | no_answer | do_not_contact, 2 to 6, the branch key is the outcome; `default_branch` for an outcome with no branch). The fixed tests (replied, paid, booked) have exactly the branches `yes` and `no`.
285005
+ * @enum {string}
285006
+ */
285007
+ test: "replied" | "paid" | "booked" | "ai_decides" | "call_outcome";
285008
+ /** @default null */
285009
+ ai_prompt: string | null;
285010
+ branches: components["schemas"]["SequenceBranch"][];
285011
+ /** @default null */
285012
+ default_branch: string | null;
285013
+ config_ref?: null;
285014
+ label: string;
285015
+ } | {
285016
+ key: string;
285017
+ situation: string | null;
285018
+ /** @enum {string} */
285019
+ kind: "wait_until";
285020
+ position: number;
285021
+ until: components["schemas"]["SequenceWaitUntil"];
285022
+ timeout: {
285023
+ value: number;
285024
+ /** @enum {string} */
285025
+ unit: "minutes" | "hours" | "days";
285026
+ };
285027
+ config_ref?: null;
285028
+ /** @description Custom sequences: the step key (or `end`) this step goes to; absent/null = the next step by position. */
285029
+ next?: string | null;
285030
+ label: string;
285031
+ } | {
285032
+ key: string;
285033
+ situation: string | null;
285034
+ /** @enum {string} */
285035
+ kind: "goto";
285036
+ position: number;
285037
+ target_step: string;
285038
+ /**
285039
+ * @description How many times one person takes this jump (default 2, at most 5).
285040
+ * @default 2
285041
+ */
285042
+ max_times: number;
285043
+ config_ref?: null;
285044
+ label: string;
285045
+ })[];
282632
285046
  };
282633
285047
  SequenceCreateResult: {
282634
285048
  sequence: components["schemas"]["Sequence"];
@@ -282647,13 +285061,22 @@ interface components {
282647
285061
  type: "event";
282648
285062
  /** @enum {string} */
282649
285063
  event: "lead_arrived" | "customer_went_quiet" | "customer_asked_reminder" | "stage_changed" | "quoted_not_booked" | "appointment_booked" | "signed_up_not_bought" | "installment_overdue";
282650
- filters: {
285064
+ filters: ({
282651
285065
  /** @description Custom sequences filter on `interest`, `source`, `stage` (stage id) or `tag` (tag name). */
282652
285066
  field: string;
282653
285067
  /** @enum {string} */
282654
285068
  op: "in";
282655
285069
  values: string[];
282656
- }[];
285070
+ } | {
285071
+ /**
285072
+ * @description Only for the `installment_overdue` entry: `days_overdue` (days past the due day) or `amount` (pesos still owed), at least `value`.
285073
+ * @enum {string}
285074
+ */
285075
+ field: "days_overdue" | "amount";
285076
+ /** @enum {string} */
285077
+ op: "gte";
285078
+ value: number;
285079
+ })[];
282657
285080
  } | {
282658
285081
  /** @enum {string} */
282659
285082
  type: "list";
@@ -282678,13 +285101,22 @@ interface components {
282678
285101
  type: "event";
282679
285102
  /** @enum {string} */
282680
285103
  event: "lead_arrived" | "customer_went_quiet" | "customer_asked_reminder" | "stage_changed" | "quoted_not_booked" | "appointment_booked" | "signed_up_not_bought" | "installment_overdue";
282681
- filters: {
285104
+ filters: ({
282682
285105
  /** @description Custom sequences filter on `interest`, `source`, `stage` (stage id) or `tag` (tag name). */
282683
285106
  field: string;
282684
285107
  /** @enum {string} */
282685
285108
  op: "in";
282686
285109
  values: string[];
282687
- }[];
285110
+ } | {
285111
+ /**
285112
+ * @description Only for the `installment_overdue` entry: `days_overdue` (days past the due day) or `amount` (pesos still owed), at least `value`.
285113
+ * @enum {string}
285114
+ */
285115
+ field: "days_overdue" | "amount";
285116
+ /** @enum {string} */
285117
+ op: "gte";
285118
+ value: number;
285119
+ })[];
282688
285120
  } | {
282689
285121
  /** @enum {string} */
282690
285122
  type: "list";