@lerianstudio/matcher-mcp 6.0.0-beta.2 → 6.0.0-beta.20

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.
@@ -247,78 +247,6 @@ components:
247
247
  - createdAt
248
248
  - updatedAt
249
249
  type: object
250
- AdminAssignPlanInputBody:
251
- additionalProperties: false
252
- properties:
253
- plan:
254
- description: "The plan code to assign. ONLY \"enterprise\" is accepted: self-serve plans are bought through checkout and converged from the live subscription's price, so assigning one here would be a payment-processor bypass the next processor delivery silently reverts. Any other code is refused with 409."
255
- maxLength: 64
256
- type: string
257
- required:
258
- - plan
259
- type: object
260
- AdminAssignPlanResult:
261
- additionalProperties: false
262
- properties:
263
- billingStatus:
264
- description: The commercial standing the workspace now holds. An enterprise contract is in good standing the moment it is signed, so this is always "active".
265
- type: string
266
- plan:
267
- description: The plan the workspace now holds.
268
- type: string
269
- slug:
270
- description: The workspace assigned.
271
- type: string
272
- required:
273
- - slug
274
- - plan
275
- - billingStatus
276
- type: object
277
- AdminWorkspaceBilling:
278
- additionalProperties: false
279
- properties:
280
- companyName:
281
- description: Legal name the workspace signed up with — the party the invoice is issued to.
282
- type: string
283
- email:
284
- description: Billing contact the invoice is sent to.
285
- type: string
286
- overageUncoveredCents:
287
- description: "Overage already incurred that the credit balance has not covered, in integer BRL cents — what this workspace owes, and the amount to invoice. It is a receivable and never a negative balance: a new billing period does NOT clear it, it survives a trial-to-paid conversion, and a credit purchase settles it. 0 when nothing is owed."
288
- format: int64
289
- type: integer
290
- slug:
291
- description: The workspace read.
292
- type: string
293
- taxIdStatus:
294
- description: "Whether the tax id could be read: \"available\" (on file, returned below), \"not_collected\" (the customer supplied none, or never reached checkout), or \"unavailable\" (the payment processor could not be asked — retry; this is NOT \"none supplied\")."
295
- type: string
296
- taxIdType:
297
- description: "Which Brazilian tax id is held: br_cpf (individual) or br_cnpj (company). Present only when taxIdStatus is \"available\"."
298
- type: string
299
- taxIdValue:
300
- description: The CPF/CNPJ as the customer entered it. Customer PII — present only when taxIdStatus is "available".
301
- type: string
302
- required:
303
- - slug
304
- - companyName
305
- - email
306
- - taxIdStatus
307
- - overageUncoveredCents
308
- type: object
309
- AdminWorkspaceResult:
310
- additionalProperties: false
311
- properties:
312
- action:
313
- description: "The action applied: \"suspended\" or \"reactivated\"."
314
- type: string
315
- slug:
316
- description: The workspace acted on.
317
- type: string
318
- required:
319
- - slug
320
- - action
321
- type: object
322
250
  AgeBucketDTO:
323
251
  additionalProperties: false
324
252
  properties:
@@ -1326,38 +1254,6 @@ components:
1326
1254
  required:
1327
1255
  - status
1328
1256
  type: object
1329
- CheckoutBody:
1330
- additionalProperties: false
1331
- properties:
1332
- interval:
1333
- description: "Billing interval: \"monthly\" or \"annual\". It selects the payment methods the session offers — monthly is card, annual is boleto and Pix."
1334
- examples:
1335
- - monthly
1336
- maxLength: 16
1337
- type: string
1338
- plan:
1339
- description: Plan code to subscribe to. Must be a self-serve plan in the price list.
1340
- examples:
1341
- - tier_1
1342
- maxLength: 64
1343
- type: string
1344
- required:
1345
- - plan
1346
- - interval
1347
- type: object
1348
- CheckoutSessionResponse:
1349
- additionalProperties: false
1350
- properties:
1351
- sessionId:
1352
- description: "Processor-side session identifier, for support and correlation. It activates nothing: activation happens only through the verified webhook."
1353
- type: string
1354
- url:
1355
- description: Hosted checkout URL. Redirect the browser here.
1356
- type: string
1357
- required:
1358
- - url
1359
- - sessionId
1360
- type: object
1361
1257
  CloneContextRequest:
1362
1258
  additionalProperties: false
1363
1259
  properties:
@@ -2621,75 +2517,6 @@ components:
2621
2517
  - credentialId
2622
2518
  - createdAt
2623
2519
  type: object
2624
- CreditLedgerEntry:
2625
- additionalProperties: false
2626
- properties:
2627
- amountCents:
2628
- description: "How much the balance moved, in integer BRL cents. SIGNED: positive for a purchase, negative for a debit, so the entries sum to the balance."
2629
- format: int64
2630
- type: integer
2631
- balanceAfterCents:
2632
- description: The balance this movement left behind, in integer BRL cents.
2633
- format: int64
2634
- type: integer
2635
- createdAt:
2636
- description: When the movement was recorded (UTC).
2637
- format: date-time
2638
- type: string
2639
- period:
2640
- description: The enforcement period a debit was taken FOR. Omitted on a purchase, which belongs to no period, and on a trial's lifetime debit, which has none.
2641
- format: date-time
2642
- type: string
2643
- reason:
2644
- description: "Why the balance moved: \"purchase\", \"overage_debit\", or \"overage_debit_shortfall\" (the debit could not be covered in full and took the balance to zero)."
2645
- type: string
2646
- stripePaymentId:
2647
- description: The payment behind a purchase, for support and correlation. Omitted on a debit, which charges nothing.
2648
- type: string
2649
- required:
2650
- - amountCents
2651
- - balanceAfterCents
2652
- - reason
2653
- - createdAt
2654
- type: object
2655
- CreditLedgerPage:
2656
- additionalProperties: false
2657
- properties:
2658
- entries:
2659
- description: Recorded movements of the prepaid overage balance, newest first, capped server-side.
2660
- items:
2661
- $ref: "#/components/schemas/CreditLedgerEntry"
2662
- type:
2663
- - array
2664
- - "null"
2665
- required:
2666
- - entries
2667
- type: object
2668
- CreditPurchaseBody:
2669
- additionalProperties: false
2670
- properties:
2671
- amountCents:
2672
- description: How much credit to buy, in integer cents (BRL). The minimum and maximum come from the price list.
2673
- examples:
2674
- - 50000
2675
- format: int64
2676
- type: integer
2677
- required:
2678
- - amountCents
2679
- type: object
2680
- CreditPurchaseResponse:
2681
- additionalProperties: false
2682
- properties:
2683
- sessionId:
2684
- description: "Processor-side session identifier, for support and correlation. It credits nothing: the balance moves only through the verified webhook."
2685
- type: string
2686
- url:
2687
- description: Hosted payment URL. Redirect the browser here.
2688
- type: string
2689
- required:
2690
- - url
2691
- - sessionId
2692
- type: object
2693
2520
  CurrencyExposureResponse:
2694
2521
  additionalProperties: false
2695
2522
  properties:
@@ -3157,12 +2984,13 @@ components:
3157
2984
  - BUSINESS_DECISION
3158
2985
  type: string
3159
2986
  resolutionType:
3160
- description: "How the exception was resolved: FORCE_MATCH (override match), ADJUST_ENTRY (monetary correction), MANUAL_MATCH (the manual match that paired it), AUTO_CONSUME (closed automatically when a run settled its transaction against a carried open item) or UNMATCH_WITHDRAWN (withdrawn by an un-match: the match that raised it, or the manual match that resolved it, was undone)"
2987
+ description: "How the exception was resolved: FORCE_MATCH (override match), ADJUST_ENTRY (monetary correction), MANUAL_MATCH (the manual match that paired it), AUTO_CONSUME (closed automatically when a run settled its transaction against a carried open item), AUTO_MATCH (closed automatically when a run matched its transaction, for a break whose reason only said its counterpart was missing or unusable: UNMATCHED, FX_RATE_UNAVAILABLE, MISSING_BASE_AMOUNT, MISSING_BASE_CURRENCY or SPLIT_INCOMPLETE) or UNMATCH_WITHDRAWN (withdrawn by an un-match: the match that raised it, or the match that resolved it, was undone)"
3161
2988
  enum:
3162
2989
  - FORCE_MATCH
3163
2990
  - ADJUST_ENTRY
3164
2991
  - MANUAL_MATCH
3165
2992
  - AUTO_CONSUME
2993
+ - AUTO_MATCH
3166
2994
  - UNMATCH_WITHDRAWN
3167
2995
  examples:
3168
2996
  - FORCE_MATCH
@@ -6171,15 +5999,6 @@ components:
6171
5999
  - createdAt
6172
6000
  - updatedAt
6173
6001
  type: object
6174
- PortalSessionResponse:
6175
- additionalProperties: false
6176
- properties:
6177
- url:
6178
- description: Hosted customer-portal URL. Redirect the browser here. It is short-lived and single-customer.
6179
- type: string
6180
- required:
6181
- - url
6182
- type: object
6183
6002
  ProcessCallbackRequest:
6184
6003
  additionalProperties: false
6185
6004
  properties:
@@ -7406,43 +7225,6 @@ components:
7406
7225
  - left
7407
7226
  - right
7408
7227
  type: object
7409
- SignupBody:
7410
- additionalProperties: false
7411
- properties:
7412
- acceptTos:
7413
- description: Must be true; acceptance is recorded with a timestamp.
7414
- type: boolean
7415
- companyName:
7416
- description: Company/organization name; a URL-safe slug is derived from it.
7417
- examples:
7418
- - Acme Payments
7419
- maxLength: 200
7420
- type: string
7421
- email:
7422
- description: Work email; disposable domains are rejected.
7423
- examples:
7424
- - founder@acme.com
7425
- maxLength: 254
7426
- type: string
7427
- password:
7428
- description: Account password; 12–72 characters with letters and digits. The 72-byte cap is bcrypt's input limit.
7429
- maxLength: 72
7430
- type: string
7431
- required:
7432
- - email
7433
- - password
7434
- - companyName
7435
- - acceptTos
7436
- type: object
7437
- SignupResponse:
7438
- additionalProperties: false
7439
- properties:
7440
- message:
7441
- description: Human-readable acknowledgement (identical for known and unknown emails).
7442
- type: string
7443
- required:
7444
- - message
7445
- type: object
7446
7228
  SimulateFeeItem:
7447
7229
  additionalProperties: false
7448
7230
  properties:
@@ -9035,29 +8817,6 @@ components:
9035
8817
  - adjustmentsApplied
9036
8818
  - outstandingVariance
9037
8819
  type: object
9038
- VerifyBody:
9039
- additionalProperties: false
9040
- properties:
9041
- token:
9042
- description: The verification token from the signup email link.
9043
- maxLength: 512
9044
- type: string
9045
- required:
9046
- - token
9047
- type: object
9048
- VerifyResponse:
9049
- additionalProperties: false
9050
- properties:
9051
- message:
9052
- description: Human-readable verification result.
9053
- type: string
9054
- slug:
9055
- description: Workspace handle (the company slug) whose setup is now under way. Empty when the link was already used or has expired.
9056
- type: string
9057
- required:
9058
- - message
9059
- - slug
9060
- type: object
9061
8820
  VersionBody:
9062
8821
  additionalProperties: false
9063
8822
  properties:
@@ -9132,125 +8891,12 @@ components:
9132
8891
  - periodStart
9133
8892
  - periodEnd
9134
8893
  type: object
9135
- WorkspaceAuthConfig:
9136
- additionalProperties: false
9137
- properties:
9138
- clientId:
9139
- description: OAuth client id of the workspace's console application.
9140
- type: string
9141
- issuer:
9142
- description: Public base URL of the identity provider (the PKCE issuer).
9143
- type: string
9144
- organization:
9145
- description: Identity-provider organization name for the workspace.
9146
- type: string
9147
- required:
9148
- - clientId
9149
- - organization
9150
- - issuer
9151
- type: object
9152
- WorkspaceBilling:
9153
- additionalProperties: false
9154
- properties:
9155
- billingStatus:
9156
- description: "Commercial lifecycle: trialing, active, past_due, trial_expired (the free trial ran out of clock — the console stays readable and the upgrade path stays open), or suspended."
9157
- type: string
9158
- daysRemaining:
9159
- description: Whole days left in the trial (time axis), derived server-side. 0 when there is no trial or it has already ended.
9160
- format: int64
9161
- type: integer
9162
- expiryReason:
9163
- description: "Why the trial is over: \"\" (not expired), \"time\", \"volume\", or \"time_and_volume\"."
9164
- type: string
9165
- linesRemaining:
9166
- description: Free matched-line allotment left (volume axis), floored at 0. 0 when there is no trial or the allotment is spent.
9167
- format: int64
9168
- type: integer
9169
- matchedLineLimit:
9170
- description: Free-trial line ceiling the volume axis is measured against, read from the plan catalogue.
9171
- format: int64
9172
- type: integer
9173
- matchedLines:
9174
- description: "Lines consumed against the free-trial allotment (volume axis): distinct transactions matched, so a transaction re-matched under a different classification consumes one line and not two — the same figure the quota gate enforces on. Meaningful for a trialing or lapsed workspace; 0 for a paid plan."
9175
- format: int64
9176
- type: integer
9177
- maxCreditPurchaseCents:
9178
- description: Largest credit purchase the payment route accepts, in integer BRL cents.
9179
- format: int64
9180
- type: integer
9181
- minCreditPurchaseCents:
9182
- description: Smallest credit purchase the payment route accepts, in integer BRL cents.
9183
- format: int64
9184
- type: integer
9185
- monthlyLineAllowance:
9186
- description: Billable lines the plan includes per month, from the price list. Monthly on every plan regardless of billing interval. 0 when the plan is unmetered (see volumeUnmetered) or the stored plan code is not in the catalogue.
9187
- format: int64
9188
- type: integer
9189
- overageCreditBalanceCents:
9190
- description: Prepaid overage credit left, in integer BRL cents. Overage is debited from it daily; an exhausted balance blocks new matching, and unspent credit never expires.
9191
- format: int64
9192
- type: integer
9193
- overageRateCentsPerThousandLines:
9194
- description: What lines beyond the allowance cost, in integer BRL cents per THOUSAND lines (per-thousand because the entry rate is 0,4 cents a line and would truncate to zero). 0 when the plan is unmetered (see volumeUnmetered) or the stored plan code is not in the catalogue.
9195
- format: int64
9196
- type: integer
9197
- overageUncoveredCents:
9198
- description: "Overage already incurred that the credit balance has not covered, in integer BRL cents — what the workspace owes. It is a receivable and never a negative balance: a new billing period does NOT clear it, it survives a trial-to-paid conversion, and the next credit purchase settles it. 0 when nothing is owed."
9199
- format: int64
9200
- type: integer
9201
- plan:
9202
- description: Commercial plan the workspace is on ("free" or a paid tier).
9203
- type: string
9204
- provisioningFailed:
9205
- description: Whether setup has terminally failed. A failed setup is NOT retried — re-driving it cannot resolve the cause — and is distinguishable from one still in progress without reading logs.
9206
- type: boolean
9207
- provisioningState:
9208
- description: "Setup lifecycle of the workspace: \"provisioning\" (still being built), \"active\" (ready to use), or \"failed\" (setup will not complete on its own — we have been told)."
9209
- type: string
9210
- provisioningStep:
9211
- description: "The setup step that is owed: \"create_tenant\", \"associate_service\", \"migrate_tenant\", \"provision_console\", \"grant_admin\", or \"\" when nothing is owed. On a failed workspace this is the step it died on."
9212
- type: string
9213
- trialEndsAt:
9214
- description: When the free trial ends (UTC). Omitted for a paid plan that never trialed.
9215
- format: date-time
9216
- type: string
9217
- trialExpired:
9218
- description: Whether the trial is over on EITHER axis (time or volume), or the workspace is already suspended.
9219
- type: boolean
9220
- volumeUnmetered:
9221
- description: "Whether this plan is unmetered: its volume ceiling and its overage price are contractual (enterprise) rather than from the price list. When true, monthlyLineAllowance and overageRateCentsPerThousandLines are both 0 because no figure applies — do NOT render them as terms, and do not read the zero rate as free overage."
9222
- type: boolean
9223
- required:
9224
- - plan
9225
- - billingStatus
9226
- - daysRemaining
9227
- - matchedLines
9228
- - matchedLineLimit
9229
- - linesRemaining
9230
- - trialExpired
9231
- - expiryReason
9232
- - provisioningState
9233
- - provisioningStep
9234
- - provisioningFailed
9235
- - volumeUnmetered
9236
- - monthlyLineAllowance
9237
- - overageRateCentsPerThousandLines
9238
- - overageCreditBalanceCents
9239
- - overageUncoveredCents
9240
- - minCreditPurchaseCents
9241
- - maxCreditPurchaseCents
9242
- type: object
9243
8894
  securitySchemes:
9244
8895
  BearerAuth:
9245
8896
  bearerFormat: JWT
9246
8897
  description: JWT bearer token issued by the identity provider.
9247
8898
  scheme: bearer
9248
8899
  type: http
9249
- BillingWebhookSignature:
9250
- description: Timestamped HMAC-SHA256 over the raw request body under the configured signing secret, proving an inbound billing event originated from the payment processor and is inside its tolerance window.
9251
- in: header
9252
- name: Stripe-Signature
9253
- type: apiKey
9254
8900
  CallbackToken:
9255
8901
  description: Opaque bearer token authenticating an external system's inbound exception callback.
9256
8902
  in: header
@@ -9278,15 +8924,19 @@ info:
9278
8924
 
9279
8925
  A retry must repeat the original request. On an ordinary route the body is part of what identifies it, so a completed key re-sent with a DIFFERENT body is refused with 422 and nothing is applied — send the correction under a new key. The two file routes (`POST /v1/imports/contexts/{contextId}/sources/{sourceId}/upload` and the matching `/preview`) consume their body as a live stream and cannot re-read it, so there the key itself is the identity under that method and path: a completed key re-sent replays the first answer whatever file the retry carries.
9280
8926
 
9281
- A key is ONE attempt. A refusal the request earned is recorded like any other answer, and every resend under that key replays it for the retention window — a caller that wants to correct its request mints a new key. Three answers do NOT spend the key, because none of them is an answer to the request itself: a 429 from the rate limiter, a 402 from the volume quota, and a 502 with code `MTCH-0513`, where the dispatch target answered and DECLINED before anything was created there. Every other 5xx HOLDS the key, including that code's near neighbour, the dispatch whose outcome could not be confirmed (502, code `MTCH-0514`), whose exception may already exist in the target system: the outcome was not recorded, so every resend under that key is refused 409 `MTCH-0022` and nothing is sent again. Deliberately attempting such an operation again therefore requires a NEW key.
8927
+ A key is ONE attempt. A refusal the request earned is recorded like any other answer, and every resend under that key replays it for the retention window — a caller that wants to correct its request mints a new key. Two answers do NOT spend the key, because neither is an answer to the request itself: a 429 from the rate limiter and a 502 with code `MTCH-0513`, where the dispatch target answered and DECLINED before anything was created there. Every other 5xx HOLDS the key, including that code's near neighbour, the dispatch whose outcome could not be confirmed (502, code `MTCH-0514`), whose exception may already exist in the target system: the outcome was not recorded, so every resend under that key is refused 409 `MTCH-0022` and nothing is sent again. Deliberately attempting such an operation again therefore requires a NEW key.
9282
8928
 
9283
8929
  `X-Idempotency-Fenced` rides every response whose outcome the guard could not receipt, a 2xx included. `true` means the hold landed: the key still protects the operation and every resend under it is refused 409. Only `false` means a resend would EXECUTE — the answer in hand may already have applied and the key no longer protects it, so check whether the first attempt took effect before sending anything again.
9284
8930
 
9285
8931
  `MTCH-0022` is the one code for a 409 saying an earlier attempt under this key already ran: it may already have applied and nothing is run again under that key, so keep the key and check the outcome before sending anything. Every other 409 refuses the request itself.
9286
8932
 
9287
- Two bounds close the contract. A response larger than about 1 MB is delivered to its caller in full, but it is not stored for replay: a duplicate under the same key is answered 409 `MTCH-0022` instead of replayed. And an over-sized body is refused with 413 and spends nothing. On every route but one the service-wide request body limit refuses it before the key is read. The streaming upload (`POST /v1/imports/contexts/{contextId}/sources/{sourceId}/upload`) is exempt from that limit: the key is read first and ingestion enforces its own upload limit inside the handler, so its 413 is a fourth answer that releases the key, and a smaller file may be re-sent under it.
8933
+ Two bounds close the contract. A response larger than about 1 MB is delivered to its caller in full, but it is not stored for replay: a duplicate under the same key is answered 409 `MTCH-0022` instead of replayed. And an over-sized body is refused with 413 and spends nothing. On every route but one the service-wide request body limit refuses it before the key is read. The streaming upload (`POST /v1/imports/contexts/{contextId}/sources/{sourceId}/upload`) is exempt from that limit: the key is read first and ingestion enforces its own upload limit inside the handler, so its 413 is a third answer that releases the key, and a smaller file may be re-sent under it.
9288
8934
 
9289
8935
  Secret mints are another, sharper exception. `POST /v1/discovery/aggregator-connections/{id}/connect-token`, `POST /v1/discovery/webhooks/tokens`, `POST /v1/exceptions/callbacks/credentials` and `POST /v1/exceptions/callbacks/credentials/{credentialId}/rotate` each return a raw credential exactly ONCE, and storing that answer would keep the secret re-readable for the life of the key — so those four routes IGNORE the idempotency header entirely. Nothing is stored, nothing is replayed, and `X-Idempotency-Replayed` is never sent on them. A retry under the same key MINTS AGAIN and leaves a second live credential behind, so treat a mint as non-idempotent: read the first attempt's response rather than resending it. A surplus callback credential or aggregator webhook token shows in its list operation (metadata only, never the secret) and is revoked through its own operation.
8936
+
8937
+ ## Refusals
8938
+
8939
+ An authorization refusal is answered with an `application/problem+json` document carrying a code, title and sentence. On every `/v1` route Matcher first checks a token that parses: on a multi-tenant deployment a token with no tenant claim is refused 403 `MTCH-0004`, and a malformed tenant claim or a missing `sub` is refused 401 `MTCH-0003`. The authorization layer then answers with its own codes: 401 `AUT-0006` (no bearer token) or `AUT-0007` (token expired, invalid or malformed); 401 `AUT-1009` or `AUT-1010` (the credential's partner is suspended or outside its validity period); 403 `AUT-1020` (the credential may not perform the `resource:action` the detail names); 403 `AUT-1016`, `AUT-1017`, `AUT-1018` or `AUT-1019` (the partner the request was made on behalf of belongs to another tenant, is suspended, is no longer valid, or may not perform it); 503 `AUT-0033` (the Access Manager did not decide the request) and 504 `AUT-1021` (it did not answer in time). Nothing ran on either 5xx: retry the same request, under the same idempotency key. A code the Access Manager answered itself, such as 403 `AUT-0021` (caller address not on the tenant allowlist), is relayed as code, title and detail at its status.
9290
8940
  license:
9291
8941
  name: Lerian Studio General License
9292
8942
  title: Matcher Reconciliation API
@@ -9340,169 +8990,6 @@ paths:
9340
8990
  summary: Readiness check
9341
8991
  tags:
9342
8992
  - Health
9343
- /v1/admin/workspaces/{slug}/billing:
9344
- get:
9345
- description: "Returns what a human needs to issue this workspace's NFS-e by hand: the legal name, the billing contact, the CPF/CNPJ the customer supplied at checkout — read through from the payment processor on demand, never stored on this side — and the standing unpaid overage the invoice is for, in integer BRL cents. That amount is a receivable, not a negative balance: a new billing period does not clear it and it survives a trial-to-paid conversion, so what an operator reads here is what the customer still owes. taxIdStatus distinguishes \"available\" from \"not_collected\" (the customer supplied none) and \"unavailable\" (the processor could not be asked), so an unreachable processor degrades to a stated answer instead of an error and is never mistaken for a customer with no tax id. The tax id is customer PII and is returned ONLY here, to an operator gated by the workspace admin action; it is never logged or traced. The target slug comes from the URL path: this is a backoffice operation, NOT a tenant-scoped route. An unknown workspace returns 404. Errors use RFC 9457 problem+json."
9346
- operationId: admin-workspace-billing
9347
- parameters:
9348
- - description: Slug of the workspace to act on.
9349
- in: path
9350
- name: slug
9351
- required: true
9352
- schema:
9353
- description: Slug of the workspace to act on.
9354
- maxLength: 255
9355
- type: string
9356
- responses:
9357
- "200":
9358
- content:
9359
- application/json:
9360
- schema:
9361
- $ref: "#/components/schemas/AdminWorkspaceBilling"
9362
- description: OK
9363
- default:
9364
- content:
9365
- application/problem+json:
9366
- schema:
9367
- $ref: "#/components/schemas/Detail"
9368
- description: Error
9369
- security:
9370
- - BearerAuth: []
9371
- summary: Read a workspace's invoicing identification (backoffice)
9372
- tags:
9373
- - Onboarding
9374
- /v1/admin/workspaces/{slug}/plan:
9375
- put:
9376
- description: "Puts a workspace on the contractual enterprise plan: persists plan=enterprise and billing_status=active together, then evicts the billing edge-gate and volume-resolver caches so the contractual ceiling applies immediately. ONLY \"enterprise\" is accepted. This is not a generic set-plan operation: self-serve plans are bought through hosted checkout and converged from the live subscription's price, so assigning one by hand would be a payment-processor bypass that the next processor delivery silently reverts — any other plan code returns 409. It REFUSES a workspace whose subscription the payment processor could still bill (409): the operator cancels there first, where the proration and refund decision gets human eyes, and this route never moves processor money. That refusal covers every subscription that is not permanently over — one awaiting card authentication or one that is paused is not charging today and resumes tomorrow, and it would revert this plan the moment it does; only a cancelled or expired subscription is assignable over. If the processor cannot be asked, the request is refused as retryable (503) rather than allowed through. A suspended workspace is refused (409) because this operation moves no access posture — reactivate it first, and the write is compare-and-swapped on the status read, so a suspension landing mid-request is refused rather than reversed. There is no reverse: removing the enterprise plan is not offered. The target slug comes from the URL path (backoffice operation, workspace admin action). An unknown workspace returns 404. Errors use RFC 9457 problem+json. Every refusal on this route carries its own product code, because the sentence of a 503 is scrubbed before it leaves the process and the code is then the whole answer: 409 MTCH-0803 (a subscription the processor can still bill — cancel it there first), 409 MTCH-0804 (a plan code other than enterprise), 409 MTCH-0805 (the workspace's billing status does not allow the change — reload it), 503 MTCH-0802 (the processor could not be asked — retry) and 503 MTCH-0801 (no payment processor is configured on this deployment — NO retry clears it; the lever is configuration). MTCH-0805 is the same code the suspend and reactivate routes answer for a refused billing-status transition."
9377
- operationId: admin-assign-workspace-plan
9378
- parameters:
9379
- - description: Slug of the workspace to assign the plan to.
9380
- in: path
9381
- name: slug
9382
- required: true
9383
- schema:
9384
- description: Slug of the workspace to assign the plan to.
9385
- maxLength: 255
9386
- type: string
9387
- requestBody:
9388
- content:
9389
- application/json:
9390
- schema:
9391
- $ref: "#/components/schemas/AdminAssignPlanInputBody"
9392
- required: true
9393
- responses:
9394
- "200":
9395
- content:
9396
- application/json:
9397
- schema:
9398
- $ref: "#/components/schemas/AdminAssignPlanResult"
9399
- description: OK
9400
- default:
9401
- content:
9402
- application/problem+json:
9403
- schema:
9404
- $ref: "#/components/schemas/Detail"
9405
- description: Error
9406
- security:
9407
- - BearerAuth: []
9408
- summary: Assign the enterprise plan to a workspace (backoffice)
9409
- tags:
9410
- - Onboarding
9411
- /v1/admin/workspaces/{slug}/reactivate:
9412
- put:
9413
- description: "Restores a suspended workspace: persists billing_status=active, re-enables interactive console login at the IdP, reactivates the tenant at the Tenant Manager (best-effort), and evicts the billing edge-gate cache. The target slug comes from the URL path (backoffice operation, workspace admin action). Idempotent. Errors use RFC 9457 problem+json."
9414
- operationId: admin-reactivate-workspace
9415
- parameters:
9416
- - description: Slug of the workspace to act on.
9417
- in: path
9418
- name: slug
9419
- required: true
9420
- schema:
9421
- description: Slug of the workspace to act on.
9422
- maxLength: 255
9423
- type: string
9424
- responses:
9425
- "200":
9426
- content:
9427
- application/json:
9428
- schema:
9429
- $ref: "#/components/schemas/AdminWorkspaceResult"
9430
- description: OK
9431
- default:
9432
- content:
9433
- application/problem+json:
9434
- schema:
9435
- $ref: "#/components/schemas/Detail"
9436
- description: Error
9437
- security:
9438
- - BearerAuth: []
9439
- summary: Reactivate a suspended workspace (backoffice)
9440
- tags:
9441
- - Onboarding
9442
- /v1/admin/workspaces/{slug}/suspend:
9443
- put:
9444
- description: "Suspends a workspace's commercial access: persists billing_status=suspended (source of truth), cuts interactive console login at the IdP, suspends the tenant's matcher service association at the Tenant Manager (best-effort), and evicts the billing edge-gate cache so API traffic is cut within the gate TTL. The target slug comes from the URL path: this is a backoffice operation gated by the workspace admin action, NOT a tenant-scoped route — the operator acts across workspaces. Idempotent. Errors use RFC 9457 problem+json."
9445
- operationId: admin-suspend-workspace
9446
- parameters:
9447
- - description: Slug of the workspace to act on.
9448
- in: path
9449
- name: slug
9450
- required: true
9451
- schema:
9452
- description: Slug of the workspace to act on.
9453
- maxLength: 255
9454
- type: string
9455
- responses:
9456
- "200":
9457
- content:
9458
- application/json:
9459
- schema:
9460
- $ref: "#/components/schemas/AdminWorkspaceResult"
9461
- description: OK
9462
- default:
9463
- content:
9464
- application/problem+json:
9465
- schema:
9466
- $ref: "#/components/schemas/Detail"
9467
- description: Error
9468
- security:
9469
- - BearerAuth: []
9470
- summary: Suspend a workspace (backoffice)
9471
- tags:
9472
- - Onboarding
9473
- /v1/billing/webhook:
9474
- post:
9475
- description: "Receives a signed billing event from the payment processor and applies it to the workspace's commercial state. This route carries NO operator JWT and no tenant identifier of any kind: a processor event has no tenant until its customer id is resolved server-side. Authentication is the Stripe-Signature signature over the RAW request body, verified inside the processor's own tolerance window. It is fail-closed on configuration — with no signing secret configured every event is rejected, and there is no value that means accept anything. Delivery is idempotent by the processor's event id: a redelivery of an event already applied returns a quiet 200 and changes nothing, an event still being applied elsewhere returns 503 so the processor retries, and an event id reused with a DIFFERENT body is a 409 rather than an acknowledgement. A processing failure returns 5xx and never records the event as applied, so the processor's retry reclaims it. Errors use the RFC 9457 application/problem+json contract and never echo the signature, the secret or the body. The divergent-replay conflict carries its own product code, 409 MTCH-0811."
9476
- operationId: receiveBillingWebhook
9477
- parameters:
9478
- - description: The processor's signature over the raw body, verified inside the processor's own tolerance window.
9479
- in: header
9480
- name: Stripe-Signature
9481
- schema:
9482
- description: The processor's signature over the raw body, verified inside the processor's own tolerance window.
9483
- type: string
9484
- requestBody:
9485
- content:
9486
- application/octet-stream:
9487
- schema:
9488
- contentMediaType: application/octet-stream
9489
- format: binary
9490
- type: string
9491
- required: true
9492
- responses:
9493
- "200":
9494
- description: OK
9495
- default:
9496
- content:
9497
- application/problem+json:
9498
- schema:
9499
- $ref: "#/components/schemas/Detail"
9500
- description: Error
9501
- security:
9502
- - BillingWebhookSignature: []
9503
- summary: Receive a payment-processor billing event
9504
- tags:
9505
- - Onboarding
9506
8993
  /v1/contexts:
9507
8994
  get:
9508
8995
  description: Returns a cursor-paginated list of reconciliation contexts, optionally filtered by type and status.
@@ -17175,219 +16662,6 @@ paths:
17175
16662
  summary: Export variance report
17176
16663
  tags:
17177
16664
  - Reporting
17178
- /v1/signup:
17179
- post:
17180
- description: "Starts self-service onboarding. This is a PUBLIC, anonymous, pre-tenant route: it carries no operator JWT and creates no account yet. It validates the payload (email, password policy, company name, and mandatory Terms of Service acceptance) and stores a pending record whose TTL is the whole expiry mechanism. A company name whose derived slug is reserved (e.g. admin, api, www) is rejected with a 400 application/problem+json error. To prevent account enumeration, an email that is already registered or pending returns the SAME 202 response as a new one; a repeat signup for a still-pending email re-sends the verification email, throttled per address. The route is rate-limited per client IP. All errors use the RFC 9457 application/problem+json contract."
17181
- operationId: signup
17182
- requestBody:
17183
- content:
17184
- application/json:
17185
- schema:
17186
- $ref: "#/components/schemas/SignupBody"
17187
- required: true
17188
- responses:
17189
- "202":
17190
- content:
17191
- application/json:
17192
- schema:
17193
- $ref: "#/components/schemas/SignupResponse"
17194
- description: Accepted
17195
- default:
17196
- content:
17197
- application/problem+json:
17198
- schema:
17199
- $ref: "#/components/schemas/Detail"
17200
- description: Error
17201
- security: []
17202
- summary: Create a self-service signup
17203
- tags:
17204
- - Onboarding
17205
- /v1/signup/verify:
17206
- post:
17207
- description: "Completes email verification and starts self-service onboarding. This is a PUBLIC, anonymous, pre-tenant route: it exchanges the emailed verification token for a workspace whose setup is now under way, and returns the workspace handle. It does NOT wait for setup to finish — creating the environment includes a schema migration whose duration the server does not control, so a background worker drives it to completion and the response comes back immediately. It is idempotent: a repeat call records nothing new, and a token that no longer resolves (already used or expired) returns the same 200 response. The route is rate-limited per client IP. Its two conflicts carry their own product codes, and they are not the same answer: 409 MTCH-0812 (the workspace already exists and MAY be the caller's own — sign in, or sign up under another company name) and 409 MTCH-0813 (the name belongs to another account — only a different company name clears it)."
17208
- operationId: signup-verify
17209
- requestBody:
17210
- content:
17211
- application/json:
17212
- schema:
17213
- $ref: "#/components/schemas/VerifyBody"
17214
- required: true
17215
- responses:
17216
- "200":
17217
- content:
17218
- application/json:
17219
- schema:
17220
- $ref: "#/components/schemas/VerifyResponse"
17221
- description: OK
17222
- default:
17223
- content:
17224
- application/problem+json:
17225
- schema:
17226
- $ref: "#/components/schemas/Detail"
17227
- description: Error
17228
- security: []
17229
- summary: Verify a self-service signup
17230
- tags:
17231
- - Onboarding
17232
- /v1/workspace/billing:
17233
- get:
17234
- description: "Returns the authenticated tenant's own commercial state: its plan, billing status, and BOTH trial axes — the time axis (trial deadline + whole days remaining) and the volume axis (matched lines consumed, the free-tier ceiling, and lines remaining) — plus the unified trial-expiry verdict (whether the trial is over and why), all derived server-side. The tenant is resolved from the JWT tenant-slug claim — this endpoint never accepts a tenant identifier in the request and can only read the caller's own workspace. A tenant with no self-serve workspace record (the default/system tenant, or an unknown slug) returns 404. Errors use the RFC 9457 application/problem+json contract."
17235
- operationId: workspace-billing
17236
- responses:
17237
- "200":
17238
- content:
17239
- application/json:
17240
- schema:
17241
- $ref: "#/components/schemas/WorkspaceBilling"
17242
- description: OK
17243
- default:
17244
- content:
17245
- application/problem+json:
17246
- schema:
17247
- $ref: "#/components/schemas/Detail"
17248
- description: Error
17249
- security:
17250
- - BearerAuth: []
17251
- summary: Read the current workspace's commercial state
17252
- tags:
17253
- - Onboarding
17254
- /v1/workspace/billing-portal:
17255
- post:
17256
- description: "Opens the payment processor's hosted customer portal for the AUTHENTICATED tenant's own workspace and returns the URL to redirect the browser to. Card update, invoice history and cancellation live there, not here; cancellation takes effect at the end of the period already paid for. Errors use the RFC 9457 application/problem+json contract. Its two refusals carry their own product codes: 409 MTCH-0806 (plan set by contract, so there is no self-serve subscription to manage) and 409 MTCH-0810 (no billing account yet — subscribe first)."
17257
- operationId: workspace-billing-portal
17258
- responses:
17259
- "200":
17260
- content:
17261
- application/json:
17262
- schema:
17263
- $ref: "#/components/schemas/PortalSessionResponse"
17264
- description: OK
17265
- default:
17266
- content:
17267
- application/problem+json:
17268
- schema:
17269
- $ref: "#/components/schemas/Detail"
17270
- description: Error
17271
- security:
17272
- - BearerAuth: []
17273
- summary: Open the customer billing portal for the current workspace
17274
- tags:
17275
- - Onboarding
17276
- /v1/workspace/checkout:
17277
- post:
17278
- description: "Opens a hosted checkout session that subscribes the AUTHENTICATED tenant's own workspace to a self-serve plan, and returns the URL to redirect the browser to. The workspace is resolved from the JWT tenant-slug claim: this endpoint never accepts a tenant identifier in the body, path, query or headers, and the session is bound to the caller's tenant. The billing interval selects the payment methods — monthly is card, annual is boleto and Pix — so a session is never created with an instrument the amount cannot clear. A plan that is not self-serve, an unknown plan or interval, and a workspace that already has a subscription are all refused before the processor is called. The return URLs carry no activation-bearing parameter: the plan is activated only by the verified webhook, and the return page reads the resulting state from GET /v1/workspace/billing. Errors use the RFC 9457 application/problem+json contract. Each refusal carries its own product code so a client never has to read the sentence: 409 MTCH-0806 (plan set by contract), 409 MTCH-0807 (already subscribed), 409 MTCH-0808 (a checkout is open for a different plan or interval), 409 MTCH-0809 (a checkout is being opened right now — retry), 422 MTCH-0814 (the plan is not sold self-serve) and 400 MTCH-0001 (unknown plan or interval)."
17279
- operationId: workspace-checkout
17280
- requestBody:
17281
- content:
17282
- application/json:
17283
- schema:
17284
- $ref: "#/components/schemas/CheckoutBody"
17285
- required: true
17286
- responses:
17287
- "200":
17288
- content:
17289
- application/json:
17290
- schema:
17291
- $ref: "#/components/schemas/CheckoutSessionResponse"
17292
- description: OK
17293
- default:
17294
- content:
17295
- application/problem+json:
17296
- schema:
17297
- $ref: "#/components/schemas/Detail"
17298
- description: Error
17299
- security:
17300
- - BearerAuth: []
17301
- summary: Open a subscription checkout for the current workspace
17302
- tags:
17303
- - Onboarding
17304
- /v1/workspace/credit-ledger:
17305
- get:
17306
- description: "Returns the AUTHENTICATED tenant's own prepaid overage-credit movements, newest first: every purchase and every daily overage debit, each with its signed amount, the balance it left behind, and why it happened. The daily debit only does its job if the customer can see it — a balance that moves with no readable explanation is money nobody can reconcile. The workspace is resolved from the JWT tenant-slug claim: this endpoint never accepts a tenant identifier in the request and can only read the caller's own movements. The result is capped server-side and has no pagination. A tenant with no self-serve workspace record returns 404. Errors use the RFC 9457 application/problem+json contract."
17307
- operationId: workspace-credit-ledger
17308
- responses:
17309
- "200":
17310
- content:
17311
- application/json:
17312
- schema:
17313
- $ref: "#/components/schemas/CreditLedgerPage"
17314
- description: OK
17315
- default:
17316
- content:
17317
- application/problem+json:
17318
- schema:
17319
- $ref: "#/components/schemas/Detail"
17320
- description: Error
17321
- security:
17322
- - BearerAuth: []
17323
- summary: Read the current workspace's prepaid-credit movements
17324
- tags:
17325
- - Onboarding
17326
- /v1/workspace/credit-purchase:
17327
- post:
17328
- description: "Opens a ONE-OFF hosted payment session that buys prepaid overage credit for the AUTHENTICATED tenant's own workspace, and returns the URL to redirect the browser to. It is never a subscription. The workspace is resolved from the JWT tenant-slug claim: this endpoint never accepts a tenant identifier in the body, path, query or headers. Any workspace on a self-serve plan may buy — trialing, lapsed, monthly or annual — because the customer who has run out of allowance is the one being told to buy. A workspace on a CONTRACTUAL plan is refused with 409: its volume is not metered, so prepaid overage credit buys it nothing. Payment is by CARD on every plan, including annual: the instrument that funds overage credit is deliberately not the subscription's instrument, and the card is saved for future CREDIT purchases only. An amount outside the price list's minimum and maximum is refused before the processor is called. The credit balance moves ONLY when the processor confirms the payment through the verified webhook — never on the return page and never in this response. Errors use the RFC 9457 application/problem+json contract. Its two refusals carry their own product codes: 422 MTCH-0815 (the amount is outside the purchasable range) and 409 MTCH-0806 (plan set by contract, so volume is not metered and credit buys nothing)."
17329
- operationId: workspace-credit-purchase
17330
- requestBody:
17331
- content:
17332
- application/json:
17333
- schema:
17334
- $ref: "#/components/schemas/CreditPurchaseBody"
17335
- required: true
17336
- responses:
17337
- "200":
17338
- content:
17339
- application/json:
17340
- schema:
17341
- $ref: "#/components/schemas/CreditPurchaseResponse"
17342
- description: OK
17343
- default:
17344
- content:
17345
- application/problem+json:
17346
- schema:
17347
- $ref: "#/components/schemas/Detail"
17348
- description: Error
17349
- security:
17350
- - BearerAuth: []
17351
- summary: Buy prepaid overage credit for the current workspace
17352
- tags:
17353
- - Onboarding
17354
- /v1/workspaces/{slug}/auth-config:
17355
- get:
17356
- description: "Resolves the minimum a browser needs to start a PKCE login for a workspace: the console OAuth client id, the identity-provider organization, and the public issuer URL. This is a PUBLIC, anonymous, read-only, pre-tenant route: it carries no operator JWT and returns nothing about the account, its owner, or its lifecycle. It answers only for ACTIVE workspaces; a nonexistent, still-provisioning, or suspended workspace returns an IDENTICAL 404 (no enumeration of lifecycle state). The response is briefly cacheable and the route is rate-limited per client IP. Errors use the RFC 9457 application/problem+json contract."
17357
- operationId: workspace-auth-config
17358
- parameters:
17359
- - description: Workspace slug as typed on the login screen.
17360
- in: path
17361
- name: slug
17362
- required: true
17363
- schema:
17364
- description: Workspace slug as typed on the login screen.
17365
- examples:
17366
- - acme
17367
- maxLength: 63
17368
- type: string
17369
- responses:
17370
- "200":
17371
- content:
17372
- application/json:
17373
- schema:
17374
- $ref: "#/components/schemas/WorkspaceAuthConfig"
17375
- description: OK
17376
- headers:
17377
- Cache-Control:
17378
- schema:
17379
- description: Short public cache lifetime for the login config.
17380
- type: string
17381
- default:
17382
- content:
17383
- application/problem+json:
17384
- schema:
17385
- $ref: "#/components/schemas/Detail"
17386
- description: Error
17387
- security: []
17388
- summary: Resolve a workspace's public login configuration
17389
- tags:
17390
- - Onboarding
17391
16665
  /version:
17392
16666
  get:
17393
16667
  description: Returns the service build version (from the VERSION environment variable, default 0.0.0) and the server UTC timestamp.