> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lerian.studio/llms.txt
> Use this file to discover all available pages before exploring further.

# Ledger routing coverage: scopes without a binding and transaction routes without the actions a TED takes

> Checks the ledger routing configuration of the institution (`tenant_policy/routing.ledger_bindings`) before a TED fails in the ledger. It reads the configuration once and lists every scope a TED posts on: `TED_OUT`, `P2P` and `TED_IN` in the emission ledger, then `TED_IN` and the seven `TED_IN_STRnnnn` types in the organization and ledger of each ISPB binding. The rows of those scopes show the organization and ledger ids of the ISPB binding.

For each scope, `binding` says if the configuration has a binding. A scope with `missing` is refused at posting time. For a `routes` binding, the transaction route is read in Midaz, and `missingActions` names the actions TED takes on that scope that the binding's operation routes lack.

- `TED_OUT` and `P2P` need `hold` on the source side, `commit` on both sides and `cancel` on the source side. A `bidirectional` destination needs `hold` too; a `destination` operation route is checked for `commit` only.
- `P2P` and every `TED_IN` type need `direct` on both sides: an internal transfer settles direct unless it is under review, and every inbound credit and the refund of a returned TED are posted direct.
- Every inbound type in the ledger of an ISPB binding needs `revert` on both sides, because a RETURN reverts the credit. Midaz accepts `revert` only on a bidirectional operation route.
- `TED_OUT` needs `revert` on both sides only when both of its operation routes are `bidirectional`. On a route that is not `bidirectional` the ledger refuses the revert of a fee refund, and TED posts the refund on the `TED_IN` routes instead. On `bidirectional` routes the revert is attempted, and without a `revert` entry the refund stays pending. The emission `TED_IN` is that refund and needs only `direct`, unless an ISPB binding uses the same ledger.

Midaz refuses an action that no operation route of the transaction route has with `0157`, and an action that the bound operation route lacks with `0117`. A missing `direct` or `hold` refuses the posting itself; a missing `commit`, `cancel` or `revert` is refused after the STR has already settled.

`routeCheck` is `not_found` when Midaz has no route by that id, `operation_route_not_in_route` when the binding names no source or no destination operation route, or names one that is not linked to the transaction route (the ledger then refuses every posting on that scope). An operation route linked as optional is part of the route and is checked like a required one, and `unavailable` when Midaz could not be read in time; check again later. `complete` is `true` only when no scope has any of these gaps. The check does not verify the account rules of the operation routes or the fee operation routes.

Without bindings (no configuration, `{}`, or an empty list), every TED posts without routes: the response gives the `documentState`, an empty `rows` and `complete: true`. That `complete` says nothing about a ledger that requires routes. Run this check right after you write the configuration, before the first TED posts on it, and again after each change to the routes in Midaz. Nothing is changed by this call.

When the configuration cannot be read or is invalid, or the organization or the emission `ledger_id` is not configured, the response is 503 `TED-0080`.



## OpenAPI

````yaml /pt/openapi/v3-current/ted-lerian.yaml get /v1/policy/ledger-routing/coverage
openapi: 3.1.0
info:
  description: >-
    API of **TED Lerian**, the interface over Lerian SPB. Your institution uses
    it to send TEDs, make internal transfers, track incoming TEDs, and operate
    returns, queues, and policy on its Midaz ledger. The [API
    overview](/pt/reference/interfaces/ted-lerian/ted-lerian-api-overview) gives
    the concepts, the roles, and the conventions.
  title: TED Lerian API
  version: v1.0.0
servers:
  - url: https://api.example.com
    description: >-
      Replace the example host with the URL provided during environment
      onboarding.
security:
  - BearerAuth: []
tags:
  - description: >-
      Outgoing TEDs and internal transfers: fee quote, creation, query,
      timeline, and cancellation. Every integration starts here.
    name: Transfers
  - description: >-
      Incoming TEDs from other institutions: query, timeline, and operator
      actions (full return and manual review resolution).
    name: Incoming Transfers
  - description: >-
      STR participant list, to resolve COMPE code ↔ ISPB and validate the
      destination bank before you create a transfer.
    name: Participants
  - description: >-
      Back office: operations queue, inconsistency findings between the ledger
      and the STR, reviews of rail facts, held returns, and manual unblock with
      evidence.
    name: Reconciliation
  - description: >-
      Operations dashboard: daily aggregates, regulatory deadlines (30/60/60
      min), and the closing balance that the STR reported.
    name: Operations
  - description: >-
      Institution configuration (editor): operating window and cut-off, usage
      limits, holiday calendar, and ISPB → organization bindings.
    name: Policy
paths:
  /v1/policy/ledger-routing/coverage:
    get:
      tags:
        - Policy
      summary: >-
        Ledger routing coverage: scopes without a binding and transaction routes
        without the actions a TED takes
      description: >-
        Checks the ledger routing configuration of the institution
        (`tenant_policy/routing.ledger_bindings`) before a TED fails in the
        ledger. It reads the configuration once and lists every scope a TED
        posts on: `TED_OUT`, `P2P` and `TED_IN` in the emission ledger, then
        `TED_IN` and the seven `TED_IN_STRnnnn` types in the organization and
        ledger of each ISPB binding. The rows of those scopes show the
        organization and ledger ids of the ISPB binding.


        For each scope, `binding` says if the configuration has a binding. A
        scope with `missing` is refused at posting time. For a `routes` binding,
        the transaction route is read in Midaz, and `missingActions` names the
        actions TED takes on that scope that the binding's operation routes
        lack.


        - `TED_OUT` and `P2P` need `hold` on the source side, `commit` on both
        sides and `cancel` on the source side. A `bidirectional` destination
        needs `hold` too; a `destination` operation route is checked for
        `commit` only.

        - `P2P` and every `TED_IN` type need `direct` on both sides: an internal
        transfer settles direct unless it is under review, and every inbound
        credit and the refund of a returned TED are posted direct.

        - Every inbound type in the ledger of an ISPB binding needs `revert` on
        both sides, because a RETURN reverts the credit. Midaz accepts `revert`
        only on a bidirectional operation route.

        - `TED_OUT` needs `revert` on both sides only when both of its operation
        routes are `bidirectional`. On a route that is not `bidirectional` the
        ledger refuses the revert of a fee refund, and TED posts the refund on
        the `TED_IN` routes instead. On `bidirectional` routes the revert is
        attempted, and without a `revert` entry the refund stays pending. The
        emission `TED_IN` is that refund and needs only `direct`, unless an ISPB
        binding uses the same ledger.


        Midaz refuses an action that no operation route of the transaction route
        has with `0157`, and an action that the bound operation route lacks with
        `0117`. A missing `direct` or `hold` refuses the posting itself; a
        missing `commit`, `cancel` or `revert` is refused after the STR has
        already settled.


        `routeCheck` is `not_found` when Midaz has no route by that id,
        `operation_route_not_in_route` when the binding names no source or no
        destination operation route, or names one that is not linked to the
        transaction route (the ledger then refuses every posting on that scope).
        An operation route linked as optional is part of the route and is
        checked like a required one, and `unavailable` when Midaz could not be
        read in time; check again later. `complete` is `true` only when no scope
        has any of these gaps. The check does not verify the account rules of
        the operation routes or the fee operation routes.


        Without bindings (no configuration, `{}`, or an empty list), every TED
        posts without routes: the response gives the `documentState`, an empty
        `rows` and `complete: true`. That `complete` says nothing about a ledger
        that requires routes. Run this check right after you write the
        configuration, before the first TED posts on it, and again after each
        change to the routes in Midaz. Nothing is changed by this call.


        When the configuration cannot be read or is invalid, or the organization
        or the emission `ledger_id` is not configured, the response is 503
        `TED-0080`.
      operationId: getLedgerRoutingCoverage
      parameters:
        - $ref: '#/components/parameters/XRequestId'
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LedgerRoutingCoverageBody'
          description: >-
            Coverage report of the ledger routing configuration. Read
            `complete`, then each scope in `rows`.
          headers:
            X-Request-Id:
              $ref: '#/components/headers/XRequestId'
        '401':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: 'Not authenticated: token missing, invalid, or expired (`TED-0070`).'
          headers:
            X-Request-Id:
              $ref: '#/components/headers/XRequestId'
        '403':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: >-
            No permission: the token's role does not authorize this action
            (`TED-0071`).
          headers:
            X-Request-Id:
              $ref: '#/components/headers/XRequestId'
        '500':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: >-
            Unexpected failure (`TED-9000`). If it continues, contact support
            and give the `X-Request-Id` of the response.
          headers:
            X-Request-Id:
              $ref: '#/components/headers/XRequestId'
        '503':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: >-
            The ledger routing configuration cannot be read or is invalid, or
            the organization or the emission `ledger_id` is not configured
            (`TED-0080`).
          headers:
            X-Request-Id:
              $ref: '#/components/headers/XRequestId'
components:
  parameters:
    XRequestId:
      description: >-
        Correlation identifier of this request (UUID). Optional: when you omit
        it, or when the value is not a well-formed UUID, the platform creates a
        UUID and returns it in the X-Request-Id header of the response. The
        resolved identifier goes to the logs, spans, and audit events of this
        request. Keep it to open a support ticket.
      in: header
      name: X-Request-Id
      schema:
        format: uuid
        type: string
  schemas:
    LedgerRoutingCoverageBody:
      additionalProperties: false
      description: >-
        Coverage of the ledger routing configuration: every scope a TED posts
        on, its binding, and the actions its transaction route lacks.
      properties:
        complete:
          description: >-
            True when no scope has a missing binding, a missing action, or a
            route check other than ok. With no rows (a document without
            bindings) it says nothing about a ledger that requires routes.
          type: boolean
        documentRevision:
          description: >-
            Revision of the bindings document read; 0 while the default is in
            force.
          format: int64
          type: integer
        documentState:
          description: >-
            State of the bindings document. Without bindings (absent, sentinel
            or empty) every TED posts without routes, and the report lists no
            scope.
          enum:
            - absent
            - sentinel
            - empty
            - bindings
          type: string
        rows:
          description: >-
            Every scope a TED posts on: TED_OUT, P2P and TED_IN in the emission
            ledger, then TED_IN and the seven TED_IN_STRnnnn types in the
            organization and ledger of each ISPB binding, whose ids the rows
            show.
          items:
            $ref: '#/components/schemas/LedgerRoutingCoverageRowDTO'
          type: array
      required:
        - documentState
        - documentRevision
        - complete
        - rows
      type: object
    Detail:
      additionalProperties: true
      description: >-
        Standard error body (RFC 9457, `application/problem+json`) for every
        `/v1` operation. Use `code` (TED-NNNN) to handle the error in code,
        `detail` for the readable message, and `errors` for the invalid fields
        of a 422. The `X-Request-Id` of the response identifies the occurrence
        for support.
      properties:
        code:
          description: >-
            Stable, machine-readable domain error code scoped to the emitting
            service (format: <SERVICE>-NNNN).
          type: string
        detail:
          description: >-
            A human-readable explanation specific to this occurrence of the
            problem.
          examples:
            - Property foo is required but is missing.
          type: string
        errors:
          description: Optional list of individual error details
          items:
            $ref: '#/components/schemas/ErrorDetail'
          type:
            - array
            - 'null'
        instance:
          description: >-
            A URI reference that identifies the specific occurrence of the
            problem.
          examples:
            - https://example.com/error-log/abc123
          format: uri
          type: string
        status:
          description: HTTP status code
          examples:
            - 400
          format: int64
          type: integer
        title:
          description: >-
            A short, human-readable summary of the problem type. This value
            should not change between occurrences of the error.
          examples:
            - Bad Request
          type: string
        type:
          default: about:blank
          description: A URI reference to human-readable documentation for the error.
          examples:
            - https://example.com/errors/example
          format: uri
          type: string
        upstream:
          $ref: '#/components/schemas/Upstream'
          description: >-
            RFC 9457 extension member: the error a proxied third-party provider
            reported. Absent unless the emitting service explicitly surfaced
            one.
      type: object
    LedgerRoutingCoverageRowDTO:
      additionalProperties: false
      description: >-
        One scope (organization, ledger, transfer type) a TED posts on, with its
        binding and the check of its transaction route in Midaz.
      properties:
        binding:
          description: >-
            Binding of the scope: routes (posts with the transaction route
            below), omit (posts without routes), or missing (no binding; the
            posting is refused).
          enum:
            - routes
            - omit
            - missing
          type: string
        ledgerId:
          description: Ledger (Midaz) of the scope.
          format: uuid
          type: string
        missingActions:
          description: >-
            Actions TED takes on this scope that the binding's operation routes
            lack. direct (both sides) for P2P and every TED_IN type; hold
            (source side, and a bidirectional destination), commit (both sides)
            and cancel (source side) for TED_OUT and P2P; revert (both sides,
            each bidirectional) for every inbound type of an ISPB binding's
            ledger, which a RETURN reverts, and for TED_OUT when both of its
            operation routes are bidirectional, since a fee refund then reverts
            it with no fallback. Midaz refuses a missing action with 0157.
          items:
            type: string
          type:
            - array
            - 'null'
        organizationId:
          description: Organization (Midaz) of the scope.
          format: uuid
          type: string
        routeCheck:
          description: >-
            Read of the transaction route in Midaz, for a routes binding: ok,
            not_found (Midaz has no route by this id), unavailable (Midaz could
            not be read in time; check again), or operation_route_not_in_route
            (the binding names no source or no destination operation route, or
            names one that is not linked to this route, as a required or an
            optional link).
          enum:
            - ok
            - not_found
            - unavailable
            - operation_route_not_in_route
          type: string
        transactionRouteId:
          description: Transaction route (Midaz) of a routes binding.
          format: uuid
          type: string
        transferType:
          description: 'Transfer type of the scope: TED_OUT, P2P, TED_IN or TED_IN_STRnnnn.'
          examples:
            - TED_OUT
          type: string
      required:
        - organizationId
        - ledgerId
        - transferType
        - binding
      type: object
    ErrorDetail:
      additionalProperties: false
      description: >-
        An invalid field inside a validation error: where it is (`location`),
        what is wrong (`message`), and the value received.
      properties:
        location:
          description: >-
            Where the error occurred, e.g. 'body.items[3].tags' or
            'path.thing-id'
          type: string
        message:
          description: Error message text
          type: string
        value:
          description: The value at the given location
      type: object
    Upstream:
      additionalProperties: false
      description: >-
        Error reported by an upstream system (ledger or rail), when the service
        chooses to expose it. Absent in most errors.
      properties:
        code:
          description: The upstream provider's own error code, verbatim.
          examples:
            - E4001
          type: string
        message:
          description: >-
            The upstream provider's own error message, verbatim (bounded, never
            its raw response body).
          examples:
            - account not found at provider
          type: string
      type: object
  headers:
    XRequestId:
      description: >-
        Echo of the request X-Request-Id: the value that the client sent, or the
        UUID that the platform generated when the client sent none. Present in
        every response, success or error.
      schema:
        format: uuid
        type: string
  securitySchemes:
    BearerAuth:
      bearerFormat: JWT
      description: >-
        JWT token that the Lerian Access Manager issues for your institution.
        Send it in `Authorization: Bearer <token>` on every call (except the
        public health probes). The tenant never comes from the body, the query,
        or the path. Each operation requires a role with the matching permission
        (see the API overview). Without it, 403 `TED-0071`. Missing, invalid, or
        expired token: 401 `TED-0070`.
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.