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

# Refinanciar uno o más contratos activos en uno nuevo

> Esta operación actúa como proxy de realizar-refinanciamento-trabalhador (Manual 008 v1.10 §3.1): abandona todos los contratos nombrados en listaContratosQuitadosTrabalhador y averba el nuevo contrato que los reemplaza, reservando margen hasta que se cierre el refinanciamiento. Cada contrato eliminado debe ser una averbação del tenant autenticado que la red reconoció; cualquier otra cosa es 404 antes de que se llame a la red; si ese contrato está actualmente activo en el registro del gobierno se deja a criterio de la red. Con garantía (temGarantias=true), el refinanciamento sólo podrá relacionarse 1:1 (regra fr, como máximo un contrato quitado) y deberá informar al menos uno de los tres valores de garantía (regra fi). Se requiere X-Idempotency.



## OpenAPI

````yaml es/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: >-
    Superficie OpenAPI 3.1 para Lerian Consignado — Dataprev. API cubre las
    credenciales y la configuración de red de tenant, el margen de los
    trabajadores, las subastas y ofertas de préstamos, el registro y el ciclo de
    vida de los contratos, la confirmación de desembolsos, la portabilidad, la
    refinanciación, la renegociación, las garantías de FGTS, la conciliación,
    los fondos, las asignaciones, el uso, el rendimiento y las suscripciones a
    eventos. El material secreto se escribe en el almacén secreto tenant y
    ninguna operación lo devuelve nunca.
  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: >-
      Custodia de credenciales de Dataprev y configuración pública del rail por
      tenant (carga, estado, rotación, revocación, código del solicitante y URL
      base del portal del trabajador)
    name: Credentials
  - description: >-
      Uso de la gateway del consignado en el ámbito del tenant: agregación de
      unidades facturables con precio por competencia
    name: Consignado Usage
  - description: >-
      Plano de control de suscripción al hub de streaming per-tenant (enumerar,
      crear, obtener, rotar, revocar y probar la entrega)
    name: Subscriptions
  - description: >-
      Superficie de rail de nómina Dataprev: lecturas de saldo y autorización
      FGTS, ejecución de garantía FGTS, suspensión de contrato, reactivación y
      cambios de términos, documentos de contrato propios de la red y lecturas
      bajo demanda de leilão solicitações, escriturações, repasses y
      terminaciones de empleo.
    name: Consignado Rail
  - description: >-
      Superficie de comando de red síncrona: las operaciones de un bancarizador
      sin que el prestamista conduzca sobre HTTP. Cada uno comparte su
      implementación de comando con el activador de evento de prestamista
      equivalente.
    name: Consignado Rail Commands
  - description: >-
      Confirmación de desembolso propiedad de la gateway: un banco cliente que
      registra el dinero que ya pagó a un trabajador. No cruza ninguna frontera
      gubernamental y no representa ninguna operación Dataprev.
    name: Consignado Disbursement
  - description: >
      Rendimiento de red Dataprev saliente de autoservicio per-tenant: lea y
      configure el requests-per-second propio de este tenant, incluida una pausa
      deliberada en cero
    name: Consignado Throughput
paths:
  /v1/consignado/contracts/{numero_contrato}/refinanciamento:
    post:
      tags:
        - Consignado Rail
      summary: Refinanciar uno o más contratos activos en uno nuevo
      description: >-
        Esta operación actúa como proxy de realizar-refinanciamento-trabalhador
        (Manual 008 v1.10 §3.1): abandona todos los contratos nombrados en
        listaContratosQuitadosTrabalhador y averba el nuevo contrato que los
        reemplaza, reservando margen hasta que se cierre el refinanciamiento.
        Cada contrato eliminado debe ser una averbação del tenant autenticado
        que la red reconoció; cualquier otra cosa es 404 antes de que se llame a
        la red; si ese contrato está actualmente activo en el registro del
        gobierno se deja a criterio de la red. Con garantía (temGarantias=true),
        el refinanciamento sólo podrá relacionarse 1:1 (regra fr, como máximo un
        contrato quitado) y deberá informar al menos uno de los tres valores de
        garantía (regra fi). Se requiere X-Idempotency.
      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

````