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

# Refinance one or more active contracts into a new one

> Proxies realizar-refinanciamento-trabalhador (Manual 008 v1.10 §3.1): quits every contract named in listaContratosQuitadosTrabalhador and averbates the new contract that replaces them, reserving margin until the refinanciamento closes. Every quitado contract must be an averbação of the authenticated tenant that the rail acknowledged; anything else is 404 before the rail is called — whether that contract is currently ACTIVE on the government registry is left to the rail's own judgment. With garantia (temGarantias=true), the refinanciamento may only relate 1:1 (regra FR, at most one quitado contract) and must inform at least one of the three garantia values (regra FI). X-Idempotency is required.



## OpenAPI

````yaml en/openapi/v3-current/consignado.yaml post /v1/consignado/contracts/{numero_contrato}/refinanciamento
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://consignado.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}/refinanciamento:
    post:
      tags:
        - Consignado Rail
      summary: Refinance one or more active contracts into a new one
      description: >-
        Proxies realizar-refinanciamento-trabalhador (Manual 008 v1.10 §3.1):
        quits every contract named in listaContratosQuitadosTrabalhador and
        averbates the new contract that replaces them, reserving margin until
        the refinanciamento closes. Every quitado contract must be an averbação
        of the authenticated tenant that the rail acknowledged; anything else is
        404 before the rail is called — whether that contract is currently
        ACTIVE on the government registry is left to the rail's own judgment.
        With garantia (temGarantias=true), the refinanciamento may only relate
        1:1 (regra FR, at most one quitado contract) and must inform at least
        one of the three garantia values (regra FI). X-Idempotency is required.
      operationId: realizarConsignadoRefinanciamento
      parameters:
        - description: >-
            The NEW contract number, minted by the CLIENT — the rail mints
            nothing here.
          in: path
          name: numero_contrato
          required: true
          schema:
            description: >-
              The NEW contract number, minted by the CLIENT — the rail mints
              nothing here.
            examples:
              - 99999999999ARN1
            maxLength: 15
            minLength: 2
            type: string
        - description: >-
            Client-chosen idempotency key. REQUIRED: an absent key is 422, never
            a generated default.
          in: header
          name: X-Idempotency
          required: true
          schema:
            description: >-
              Client-chosen idempotency key. REQUIRED: an absent key is 422,
              never a generated default.
            examples:
              - idem-refinanciamento-0001
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RefinanciamentoBody'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RefinanciamentoOperationResponse'
          description: OK
        default:
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Error
      security:
        - BearerAuth: []
components:
  schemas:
    RefinanciamentoBody:
      additionalProperties: false
      properties:
        cnpjOperador:
          description: >-
            CNPJ of the operator (correspondent, cooperado or similar)
            responsible for the operation. Optional, Texto since v1.7.
          examples:
            - '12345678000199'
          maxLength: 14
          type: string
        codigoInscricaoEmpregador:
          description: 'Employer inscription type: 1 CNPJ, 2 CPF.'
          examples:
            - '1'
          pattern: ^[12]$
          type: string
        competenciaInicioDesconto:
          description: Payroll competência of the first deduction, yyyyMM. Optional.
          examples:
            - '202507'
          pattern: ^[0-9]{6}$
          type: string
        cpfTrabalhador:
          description: Worker CPF, 11 digits.
          examples:
            - '99999999999'
          maxLength: 11
          minLength: 11
          pattern: ^[0-9]{11}$
          type: string
        dataFimContrato:
          description: End date of the new consignado contract, RFC 3339 UTC.
          examples:
            - '2027-07-10T00:00:00Z'
          format: date-time
          type: string
        dataInicioContrato:
          description: Start date of the new consignado contract, RFC 3339 UTC.
          examples:
            - '2025-06-11T00:00:00Z'
          format: date-time
          type: string
        dataPrimeiroDesconto:
          description: Date of the first payroll deduction, RFC 3339 UTC.
          examples:
            - '2025-07-10T00:00:00Z'
          format: date-time
          type: string
        listaContratosQuitadosTrabalhador:
          description: >-
            Every contract this refinanciamento quits. Each must be an active
            averbação of the authenticated tenant — 'active' is the government
            registry's own judgment, which this gateway does not locally track.
          examples:
            - - numeroContrato: 99999999999AR1
          items:
            $ref: '#/components/schemas/RefinanciamentoContratoQuitado'
          minItems: 1
          type:
            - array
            - 'null'
        matricula:
          description: Matrícula assigned to the worker by the employer.
          examples:
            - 99999999999-A
          maxLength: 30
          type: string
        nomeTrabalhador:
          description: Worker's full name.
          examples:
            - Trabalhador 99999999999
          maxLength: 90
          type: string
        numeroInscricaoEmpregador:
          description: >-
            Employer inscription number, Texto since Manual 008 v1.7 (the
            mirrored Swagger still types this int64).
          examples:
            - '99999999999881'
          maxLength: 14
          type: string
        numeroParcelas:
          description: >-
            Number of instalments of the new contract, capped at the manual's
            own 3-digit field width (Manual 008 §3.1.1 p.10).
          examples:
            - 24
          format: int64
          maximum: 999
          minimum: 1
          type: integer
        percVerbaRescisoriaGarantia:
          description: Percentage of severance pay pledged as collateral, 0 to 35%.
          examples:
            - '15'
          maxLength: 13
          pattern: ^[0-9]+(\.[0-9]{1,2})?$
          type: string
        temGarantias:
          description: >-
            Whether FGTS collateral secures the new contract. When true, exactly
            one contract may be named in lista_contratos_quitados_trabalhador
            (regra FR) and at least one of the three garantia values below must
            be informed (regra FI).
          examples:
            - true
          type: boolean
        valorCETAnual:
          description: valorCETAnual — Custo Efetivo Total, annual percent decimal string.
          examples:
            - '7.26'
          maxLength: 13
          pattern: ^[0-9]+(\.[0-9]{1,2})?$
          type: string
        valorCETMensal:
          description: >-
            valorCETMensal — Custo Efetivo Total, monthly percent decimal
            string.
          examples:
            - '0.59'
          maxLength: 13
          pattern: ^[0-9]+(\.[0-9]{1,2})?$
          type: string
        valorEmprestimo:
          description: >-
            valorEmprestimo — the new contract's principal (decimal string,
            BRL).
          examples:
            - '9018.54'
          maxLength: 13
          pattern: ^[0-9]+(\.[0-9]{1,2})?$
          type: string
        valorIOF:
          description: valorIOF — the IOF charged, in reais (decimal string, BRL).
          examples:
            - '94.95'
          maxLength: 13
          pattern: ^[0-9]+(\.[0-9]{1,2})?$
          type: string
        valorMultaRescisoriaGarantiaFgts:
          description: >-
            FGTS termination-fine collateral, up to 100% of the 40% fine
            (decimal string, BRL). Optional individually.
          examples:
            - '300.00'
          maxLength: 13
          pattern: ^[0-9]+(\.[0-9]{1,2})?$
          type: string
        valorPago:
          description: >-
            valorPago — settlement amount paid to quit the original contracts
            (decimal string, BRL).
          examples:
            - '6114.50'
          maxLength: 13
          pattern: ^[0-9]+(\.[0-9]{1,2})?$
          type: string
        valorParcela:
          description: >-
            valorParcela — the new contract's instalment amount (decimal string,
            BRL).
          examples:
            - '400.00'
          maxLength: 13
          pattern: ^[0-9]+(\.[0-9]{1,2})?$
          type: string
        valorSaldoDisponivelGarantiaFgts:
          description: >-
            FGTS balance pledged as collateral (decimal string, BRL). Optional
            individually; at least one of the three garantia values is required
            when temGarantias is true.
          examples:
            - '600.00'
          maxLength: 13
          pattern: ^[0-9]+(\.[0-9]{1,2})?$
          type: string
        valorTaxaAnual:
          description: valorTaxaAnual — annual interest rate, percent decimal string.
          examples:
            - '6.17'
          maxLength: 13
          pattern: ^[0-9]+(\.[0-9]{1,2})?$
          type: string
        valorTaxaMensal:
          description: valorTaxaMensal — monthly interest rate, percent decimal string.
          examples:
            - '0.5'
          maxLength: 13
          pattern: ^[0-9]+(\.[0-9]{1,2})?$
          type: string
        valorTroco:
          description: >-
            valorTroco — amount delivered to the client after settling the
            quitados contracts (decimal string, BRL).
          examples:
            - '2809.09'
          maxLength: 13
          pattern: ^[0-9]+(\.[0-9]{1,2})?$
          type: string
      required:
        - cpfTrabalhador
        - matricula
        - nomeTrabalhador
        - codigoInscricaoEmpregador
        - numeroInscricaoEmpregador
        - dataInicioContrato
        - dataFimContrato
        - dataPrimeiroDesconto
        - numeroParcelas
        - valorEmprestimo
        - valorParcela
        - valorIOF
        - valorPago
        - valorTroco
        - valorTaxaAnual
        - valorTaxaMensal
        - valorCETAnual
        - valorCETMensal
        - listaContratosQuitadosTrabalhador
        - temGarantias
      type: object
    RefinanciamentoOperationResponse:
      additionalProperties: false
      properties:
        competenciaInicioDesconto:
          description: Payroll competência of the first deduction, yyyyMM.
          examples:
            - '202507'
          type: string
        hashOperacao:
          description: The rail's own identity for this operation.
          examples:
            - '34006311'
          type: string
        listaContratosQuitadosTrabalhador:
          description: >-
            Every contract the rail confirmed as quitado by this
            refinanciamento.
          examples:
            - - numeroContrato: 99999999999AR1
          items:
            $ref: '#/components/schemas/RefinanciamentoContratoQuitado'
          type:
            - array
            - 'null'
        mensagem:
          description: The rail's own message.
          examples:
            - Refinanciamento realizado com sucesso
          type: string
        numeroContrato:
          description: The new contract's number, as confirmed by the rail.
          examples:
            - 99999999999ARN1
          type: string
      required:
        - mensagem
        - numeroContrato
        - competenciaInicioDesconto
        - hashOperacao
        - listaContratosQuitadosTrabalhador
      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
    RefinanciamentoContratoQuitado:
      additionalProperties: false
      properties:
        numeroContrato:
          description: >-
            Contract number being quit by this refinanciamento. Must be an
            averbação of the authenticated tenant that the rail acknowledged.
          examples:
            - 99999999999AR1
          maxLength: 15
          minLength: 2
          type: string
      required:
        - numeroContrato
      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

````