> ## 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.

# List one contract's correction chain

> Lists every correction one contract carries, so an operator can prove WHAT was superseded, in which order, and which correction is current.

A contract nobody has had to correct answers 200 with an empty list, never 404. Having never been corrected is a normal state of a registered contract, and a miss there would read as "no such contract".

One contract can carry SEVERAL independent chains: one for its CCB and one per corrected payment. They are laid end to end rather than interleaved, each ordered root first and head last, because there is no order BETWEEN chains and publishing one would invent a fact. Each item names its own `correction_type` and `payment_reference`, which is what tells the chains apart.

`is_head` is declared by the server and answers "which correction is current". The head is the one correction nothing supersedes, which is a TOPOLOGICAL property: deriving it from a timestamp can name an already-superseded row, so it is derived here once instead of once per client.

`supersedes_event_id` is null on a first CCB correction, and that null MEANS the original contract-registration fact. It travels as null rather than being omitted, so a reader never has to tell "no such field" apart from "supersedes the original".

There is NO paging and no cursor. The chain's order is topological, and a keyset needs a position that survives the next append, which supersession links are not. The answer is bounded at 200 items instead, and reaching the bound is REPORTED through `truncated` rather than swallowed: a cut nobody is told about reads as a complete audit trail on the one surface whose purpose is proving what was corrected. `truncated` is also true when a chain link points at a correction this answer does not carry, which means the same thing to the reader.

Three columns of the stored row never leave: the client's own transport key, and the gateway's object key and version id. The published `resource_uri` is the only address a caller is given, and it is the same path the correction fact names.

It answers from a LOCAL table and never reaches the Dataprev rail. It answers 501 on a deployment that composed no correction family, which is a deployment posture rather than a wrong URL. The tenant is derived from the validated identity and is never read from the request.



## OpenAPI

````yaml /en/openapi/v3-current/consignado.yaml get /v1/consignado/contracts/{numero_contrato}/corrections
openapi: 3.1.0
info:
  contact:
    email: contact@lerian.studio
    name: Lerian Studio
    url: https://lerian.studio
  description: >-
    OpenAPI 3.1 surface for Lerian Consignado — Dataprev. The API covers tenant
    credentials and rail configuration, worker margin, loan auctions and bids,
    contract registration and lifecycle, disbursement confirmation, portability,
    refinancing, renegotiation, FGTS guarantees, reconciliation, funds,
    assignments, usage, throughput, and event subscriptions. Secret material is
    written to the tenant secret store and is never returned by any operation.
  license:
    name: Lerian Studio General License
  title: Lerian Consignado API
  version: v1.0.0
servers:
  - url: https://br-consignado-gw.sandbox.lerian.net
security:
  - BearerAuth: []
tags:
  - description: >-
      Per-tenant Dataprev credential custody and public rail configuration
      (upload, status, rotation, revoke, requester code, and worker portal base
      URL)
    name: Credentials
  - description: >-
      Tenant-scoped consignado gateway usage: priced billable-unit aggregation
      per competência
    name: Consignado Usage
  - description: >-
      Per-tenant streaming-hub subscription control-plane (list, create, get,
      rotate, revoke, and test delivery)
    name: Subscriptions
  - description: >-
      Dataprev payroll-rail surface: FGTS balance and authorization reads, the
      FGTS guarantee execution, contract suspension, reactivation and term
      changes, the rail's own contract documents, and the on-demand reads of
      leilão solicitações, escriturações, repasses and employment terminations
    name: Consignado Rail
  - description: >-
      Synchronous rail command surface: the operations a bancarizador without
      the lender drives over HTTP. Each shares its command implementation with
      the equivalent lender event trigger.
    name: Consignado Rail Commands
  - description: >-
      Gateway-owned disbursement confirmation: a client bank recording money it
      has ALREADY paid to a worker. It crosses no government boundary and
      proxies no Dataprev operation.
    name: Consignado Disbursement
  - description: >-
      Per-tenant self-service outbound Dataprev rail throughput: read and set
      this tenant's own requests-per-second, including a deliberate pause at
      zero
    name: Consignado Throughput
paths:
  /v1/consignado/contracts/{numero_contrato}/corrections:
    get:
      tags:
        - Consignado Corrections
      summary: List one contract's correction chain
      description: >-
        Lists every correction one contract carries, so an operator can prove
        WHAT was superseded, in which order, and which correction is current.


        A contract nobody has had to correct answers 200 with an empty list,
        never 404. Having never been corrected is a normal state of a registered
        contract, and a miss there would read as "no such contract".


        One contract can carry SEVERAL independent chains: one for its CCB and
        one per corrected payment. They are laid end to end rather than
        interleaved, each ordered root first and head last, because there is no
        order BETWEEN chains and publishing one would invent a fact. Each item
        names its own `correction_type` and `payment_reference`, which is what
        tells the chains apart.


        `is_head` is declared by the server and answers "which correction is
        current". The head is the one correction nothing supersedes, which is a
        TOPOLOGICAL property: deriving it from a timestamp can name an
        already-superseded row, so it is derived here once instead of once per
        client.


        `supersedes_event_id` is null on a first CCB correction, and that null
        MEANS the original contract-registration fact. It travels as null rather
        than being omitted, so a reader never has to tell "no such field" apart
        from "supersedes the original".


        There is NO paging and no cursor. The chain's order is topological, and
        a keyset needs a position that survives the next append, which
        supersession links are not. The answer is bounded at 200 items instead,
        and reaching the bound is REPORTED through `truncated` rather than
        swallowed: a cut nobody is told about reads as a complete audit trail on
        the one surface whose purpose is proving what was corrected. `truncated`
        is also true when a chain link points at a correction this answer does
        not carry, which means the same thing to the reader.


        Three columns of the stored row never leave: the client's own transport
        key, and the gateway's object key and version id. The published
        `resource_uri` is the only address a caller is given, and it is the same
        path the correction fact names.


        It answers from a LOCAL table and never reaches the Dataprev rail. It
        answers 501 on a deployment that composed no correction family, which is
        a deployment posture rather than a wrong URL. The tenant is derived from
        the validated identity and is never read from the request.
      operationId: listConsignadoContractCorrections
      parameters:
        - description: >-
            The rail contract number whose corrections to enumerate. Exact,
            control-free UTF-8, bounded in BYTES: 2..15, the same bound the
            intake enforces.
          in: path
          name: numero_contrato
          required: true
          schema:
            description: >-
              The rail contract number whose corrections to enumerate. Exact,
              control-free UTF-8, bounded in BYTES: 2..15, the same bound the
              intake enforces.
            examples:
              - 99999999999AN1
            maxLength: 15
            minLength: 2
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractCorrectionsChain'
          description: OK
        '401':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unauthorized
        '403':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Forbidden
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity
        '429':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Too Many Requests
        '500':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Internal Server Error
        '501':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Not Implemented
        '503':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Service Unavailable
      security:
        - BearerAuth: []
components:
  schemas:
    ContractCorrectionsChain:
      additionalProperties: false
      properties:
        items:
          items:
            $ref: '#/components/schemas/ContractCorrectionChainItem'
          type: array
        truncated:
          description: >-
            True when the item ceiling was reached or a chain link points
            outside this answer, so older corrections were not returned.
          examples:
            - false
          type: boolean
      required:
        - items
        - truncated
      type: object
    Detail:
      additionalProperties: false
      properties:
        code:
          description: >-
            Stable, machine-readable domain error code scoped to the emitting
            service (format: <SERVICE>-NNNN).
          examples:
            - ERR-0001
          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
    ContractCorrectionChainItem:
      additionalProperties: false
      properties:
        content_length:
          description: Size in bytes of the corrected resource.
          examples:
            - 184320
          format: int64
          type: integer
        content_type:
          description: Media type of the corrected resource.
          examples:
            - application/pdf
          type: string
        correction_id:
          description: >-
            The gateway's identity for this correction. It is also the published
            event id.
          examples:
            - 0192f1a0-0000-7000-8000-00000000c010
          type: string
        correction_type:
          description: What this correction corrects.
          enum:
            - ccb
            - disbursement
          examples:
            - disbursement
          type: string
        file_name:
          description: Original file name of the corrected resource.
          examples:
            - comprovante-pagamento.pdf
          type: string
        gateway_received_at:
          description: When the gateway took custody, at second resolution in UTC.
          examples:
            - '2026-08-14T09:12:33Z'
          format: date-time
          type: string
        is_head:
          description: True for the one correction in its chain that nothing supersedes.
          examples:
            - true
          type: boolean
        payment_reference:
          description: >-
            The payment this correction repairs. Null on a CCB correction,
            always present on a disbursement one.
          examples:
            - PIX-2026-08-14-000123
          type:
            - string
            - 'null'
        resource_digest_sha256:
          description: Lowercase hex SHA-256 the gateway computed over the corrected bytes.
          examples:
            - 3b1f2c9d5a47e08b6c1d4f2a8e7b0c93d6a51f84b2c7e903a1d5f6b8c2e4079a
          type: string
        resource_uri:
          description: >-
            Same-origin relative path serving the corrected resource under M2M
            bearer auth.
          examples:
            - >-
              /v1/consignado/contracts/99999999999AN1/corrections/0192f1a0-0000-7000-8000-00000000c010
          type: string
        source_authority:
          description: >-
            Who is authoritative for the corrected value. Always client on this
            gateway.
          examples:
            - client
          type: string
        supersedes_event_id:
          description: >-
            The event id this correction supersedes: the corrected disbursement
            confirmation, or the previous correction. Null on a first CCB
            correction, meaning the original contract fact.
          examples:
            - 0192f1a0-0000-7000-8000-00000000b7de
          type:
            - string
            - 'null'
      required:
        - correction_id
        - correction_type
        - payment_reference
        - source_authority
        - resource_uri
        - resource_digest_sha256
        - supersedes_event_id
        - file_name
        - content_type
        - content_length
        - gateway_received_at
        - is_head
      type: object
    ErrorDetail:
      additionalProperties: false
      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
      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
  securitySchemes:
    BearerAuth:
      bearerFormat: JWT
      description: JWT bearer token issued by the identity provider.
      scheme: bearer
      type: http

````