Configure the ledger counterparty of one provider in one ledger of a tenant
Sets the ledger account used as the counterparty of the postings of the operations of one provider of the tenant of the credentials you authenticate with, in the ledger named in the path, for one asset. A ledger with no configured counterparty uses @external/<asset>. The write and its history line are recorded in one transaction, with the actor, the instant, the previous and the new account, the reason and the trace. To go back to the default, write @external/<asset>.
VALIDATION. accountAlias must match its pattern, assetCode must be uppercase letters, and an alias in the default form must be exactly @external/ followed by assetCode; otherwise 400 PBP-0001, before any write. The ledger of the path must be a canonical UUID, in any case, and is kept in lower case; otherwise 400 PBP-0026. A provider not mounted on this installation is refused with 422 PBP-0702 reason PROVIDER_NOT_INSTALLED, and one not connected to the tenant with reason PROVIDER_NOT_CONNECTED. The account of any alias other than the default is then looked up in Midaz, in the ledger of the path, under the organization in X-Organization-Id, with the check every posting against it applies: absent there, 422 PBP-0702 reason ACCOUNT_NOT_FOUND; not of type external, compared exactly, ACCOUNT_NOT_EXTERNAL; not of the asset assetCode, ACCOUNT_ASSET_MISMATCH. Nothing is written on any refusal. Midaz unavailable answers 503 PBP-0008 and nothing is written, as does a connection that cannot be read. Midaz applies no balance floor to an external account, so postings run against the provider’s position; an ordinary account would have a customer’s funds debited instead. An account that stops passing that check after the write makes the posting fail with 503 PBP-0706, never sent to @external/<asset>. A write that repeats the account in effect (the default, with no configured counterparty) is refused with 422 PBP-0702 reason NO_CHANGE. A write made while a payment of that provider in that ledger waits for the ledger operation of its pending debit, or a settled boleto of theirs for that of its settlement credit, is refused with 422 PBP-0702 reason POSTINGS_IN_FLIGHT, nothing written; resend it under the same Idempotency-Key once the posting settles.
ONE COUNTERPARTY PER ORGANIZATION. Midaz accounting routes belong to the organization: the external leg of BOLETO_IN_DEBIT, PAYMENT_OUT_CREDIT and DARF_OUT_CREDIT names one account for every ledger of it, so an organization has one effective counterparty. A write of an account other than @external/<asset> lists the ledgers of the organization in X-Organization-Id in Midaz (Midaz unavailable answers 503 PBP-0008 and nothing is written) and is refused with 422 PBP-0702 reason LEDGER_COUNTERPARTY_CONFLICT, nothing written, when a row of another provider, in any ledger of the organization, or of the same provider, in another ledger, names an account other than @external/<asset> and other than the one written. A provider or a ledger with no row, or with a row of @external/<asset>, never conflicts: its postings are refused until the same account is written there too, so the writes of several providers and ledgers may go in any order. A write of @external/<asset> is never refused for a conflict; that provider’s postings are then refused until the organization’s accounting routes name the account in effect again.
Writes in the same organization and asset are serialized; one that cannot take its turn in time answers 503 PBP-0008, nothing written, and can be resent under the same Idempotency-Key.
OPTIMISTIC CONCURRENCY. version must be the current version of the (ledger, provider, asset) counterparty (0 when never configured), read with getLedgerCounterparty. A stale version is refused with 409 PBP-0705.
EFFECT. A posting of an operation uses the counterparty of the ledger and of the provider recorded on it, never the one of the provider currently on the route. A posting reads the counterparty each time it is presented, so one presented again after a change would carry the new account: while a posting of that provider in that ledger may still be presented again, the write is refused with 422 PBP-0702 reason POSTINGS_IN_FLIGHT. The commit or cancel of a reserve follows the original pending transaction in the ledger.
IDEMPOTENT under Idempotency-Key: a retry with the same key replays the stored 200. A missing or malformed key is refused with 400 PBP-0012.
WHO MAY CALL IT: provider-routes:configure; otherwise 403 PBP-0004.
Encabezados
Midaz organization that owns the ledger in the path. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. Used only to look the account of accountAlias up in that ledger; it does not select the tenant, which comes from the validated identity.
Parámetros de ruta
Midaz ledger whose counterparty is read or written, the same identifier the boleto and the payment record as their ledger. Each ledger has its own counterparty per provider and asset. Must be a canonical UUID (any case); otherwise 400 PBP-0026.
1 - 100"0199a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a6c"
Cuerpo
The asset, the account, the reason and the version read.
Alias of the ledger account, with the leading @. @external/ returns to the default and must name the assetCode of the request; any other value is the alias of an account created through the Midaz API, of a-zA-Z0-9@:_- only. Otherwise 400 PBP-0001.
2 - 100^(@external/[A-Z]{3,10}|@[A-Za-z0-9@:_-]{1,99})$"@siloc-a-liquidar"

