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

# Import a contract already averbado outside this gateway

> Adopts a contract that is ALREADY averbado on the payroll rail — registered on the Dataprev portal by hand, by a previous provider, or carried in from a book you are migrating — so its recurring saldo devedor obligation (Manual 015 §2.2) exists here and its first M015 report is scheduled.

It does NOT averbate anything and it moves no money: the only call it makes to Dataprev is consultar-emprestimo-trabalhador (Manual 005 v1.13 §3.2.1), a read, under your own credential. Everything the obligation needs — the worker's CPF and matrícula, the employer inscription, the instalment count, the instalment amount and the first discount competência — is taken from that read. You send the contract number and, optionally, how many competências have already amortized; you never send worker or employer identifiers, and none come back.

Only a LIVE contract can be imported: situação 0 (Ativo), 7 (Contrato suspenso), 8 (Suspenso banco) or 17 (Contrato suspenso por antecipação de parcela). A suspension is not a closure — the deduction is still attached to the worker and the debt is still reportable. Situação 2, 3, 15 and 16 are closed and refused 422 whose detail names the código the registry published (`situacaoEmprestimo 3 não é vigente`) and nothing else — Dataprev's own descrição is never relayed into the body. Importing one would make this gateway file recurring reports about a debt the registry already ended. A read that carries no situação at all, no competência de início de desconto, or one that answers about a different contract number, is refused 422 the same way rather than guessed at.

The import is not idempotent in the ordinary sense: a contract this tenant already holds an obligation for is answered 409 CONTRACT_ALREADY_REGISTERED, with nothing changed and the parcelas_pagas you sent NOT applied. X-Idempotency is still required, and the transport middleware replays the answer of a duplicate request under the same key.



## OpenAPI

````yaml /en/openapi/v3-current/consignado.yaml post /v1/consignado/contracts/{numero_contrato}/import
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}/import:
    post:
      tags:
        - Consignado Rail Commands
      summary: Import a contract already averbado outside this gateway
      description: >-
        Adopts a contract that is ALREADY averbado on the payroll rail —
        registered on the Dataprev portal by hand, by a previous provider, or
        carried in from a book you are migrating — so its recurring saldo
        devedor obligation (Manual 015 §2.2) exists here and its first M015
        report is scheduled.


        It does NOT averbate anything and it moves no money: the only call it
        makes to Dataprev is consultar-emprestimo-trabalhador (Manual 005 v1.13
        §3.2.1), a read, under your own credential. Everything the obligation
        needs — the worker's CPF and matrícula, the employer inscription, the
        instalment count, the instalment amount and the first discount
        competência — is taken from that read. You send the contract number and,
        optionally, how many competências have already amortized; you never send
        worker or employer identifiers, and none come back.


        Only a LIVE contract can be imported: situação 0 (Ativo), 7 (Contrato
        suspenso), 8 (Suspenso banco) or 17 (Contrato suspenso por antecipação
        de parcela). A suspension is not a closure — the deduction is still
        attached to the worker and the debt is still reportable. Situação 2, 3,
        15 and 16 are closed and refused 422 whose detail names the código the
        registry published (`situacaoEmprestimo 3 não é vigente`) and nothing
        else — Dataprev's own descrição is never relayed into the body.
        Importing one would make this gateway file recurring reports about a
        debt the registry already ended. A read that carries no situação at all,
        no competência de início de desconto, or one that answers about a
        different contract number, is refused 422 the same way rather than
        guessed at.


        The import is not idempotent in the ordinary sense: a contract this
        tenant already holds an obligation for is answered 409
        CONTRACT_ALREADY_REGISTERED, with nothing changed and the parcelas_pagas
        you sent NOT applied. X-Idempotency is still required, and the transport
        middleware replays the answer of a duplicate request under the same key.
      operationId: importConsignadoContract
      parameters:
        - description: >-
            The contract number as the RAIL holds it (Manual 005 v1.13 §3.2.1
            p.13, 2..15 alphanumerics). It is the only identifier the import
            takes: everything else about the contract is read back from
            Dataprev.
          in: path
          name: numero_contrato
          required: true
          schema:
            description: >-
              The contract number as the RAIL holds it (Manual 005 v1.13 §3.2.1
              p.13, 2..15 alphanumerics). It is the only identifier the import
              takes: everything else about the contract is read back from
              Dataprev.
            examples:
              - '199971600000'
            maxLength: 15
            minLength: 2
            type: string
        - description: Required idempotency key. Absent is 422, never a generated default.
          in: header
          name: X-Idempotency
          required: true
          schema:
            description: >-
              Required idempotency key. Absent is 422, never a generated
              default.
            examples:
              - idem-import-1
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContractImportRequest'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractImportResponse'
          description: Created
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: >-
            A conflict with an obligation this contract already holds.
            CONTRACT_ALREADY_REGISTERED means this tenant's saldo devedor book
            already carries this contract, whether it was averbado through this
            gateway or imported earlier. It is definitive: nothing about the
            existing obligation was changed, and the parcelas_pagas sent with
            this request was not applied. Read the contract's saldo devedor
            instead of importing it again. DATAPREV_CREDENTIAL_REQUIRED means
            this tenant has no Dataprev credential in custody, so the gateway
            cannot act for it on the rail at all; it is definitive until the
            credential is provisioned, and retrying before that never succeeds.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity
        '500':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Internal Server Error
        default:
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Error
      security:
        - BearerAuth: []
components:
  schemas:
    ContractImportRequest:
      additionalProperties: false
      properties:
        parcelas_pagas:
          default: 0
          description: >-
            How many monthly competências of this contract have ALREADY
            amortized under whoever averbou it. It must lie between 0 and the
            contract's own total de parcelas as the rail reports it; anything
            outside that is refused 422. Leave it at 0 only for a contract that
            has genuinely not been discounted yet — a higher value than reality
            makes the first saldo devedor report understate the debt, and a
            lower one overstates it.
          examples:
            - 7
          format: int64
          minimum: 0
          type: integer
      type: object
    ContractImportResponse:
      additionalProperties: false
      properties:
        competencia_inicio_desconto:
          description: >-
            The first payroll competência the discount runs in, as the rail's
            verbatim AAAAMM literal.
          examples:
            - '202601'
          type: string
        numero_contrato:
          description: The contract that was imported.
          examples:
            - '199971600000'
          type: string
        numero_parcelas:
          description: >-
            The contract's total de parcelas, as the rail reports it. Read back,
            never supplied.
          examples:
            - 24
          format: int64
          type: integer
        origem:
          description: >-
            Always "importado" on this route — the provenance stamped on the
            obligation, distinguishing it forever from one this gateway averbou.
          enum:
            - importado
          examples:
            - importado
          type: string
        parcelas_pagas:
          description: >-
            The amortized count recorded on the obligation — the value sent with
            the request.
          examples:
            - 7
          format: int64
          type: integer
        saldo_devedor_dispatch_scheduled:
          description: >-
            Always true on a 201: the contract's first M015 saldo devedor report
            was scheduled durably alongside the obligation. It does NOT mean the
            report has been delivered to Dataprev — the outbox does that
            afterwards.
          examples:
            - true
          type: boolean
        situacao_emprestimo:
          description: >-
            The rail's own situação código for the contract at the moment it was
            imported (Manual 005 §3.2.2 p.17). Only 0, 7, 8 and 17 are
            importable.
          examples:
            - 0
          format: int64
          type: integer
        valor_parcela:
          description: >-
            The instalment, as the rail reports it, verbatim (BRL decimal
            string).
          examples:
            - '1116.31'
          type: string
      required:
        - numero_contrato
        - origem
        - numero_parcelas
        - valor_parcela
        - competencia_inicio_desconto
        - parcelas_pagas
        - situacao_emprestimo
        - saldo_devedor_dispatch_scheduled
      type: object
    Detail:
      additionalProperties: false
      properties:
        code:
          description: >-
            Stable, machine-readable product error code. One of the enumerated
            values: the CLT-NNNN catalog codes for the general refusal classes;
            the named command conflicts, which a client branches on to tell one
            conflict from another; and the four IDEMPOTENCY_* terminal refusals
            (422), which tell the client to reconcile the original request and
            never retry under a new key.
          enum:
            - AVERBACAO_ARTIFACT_CONFLICT
            - AVERBACAO_CLAIM_CONFLICT
            - BID_PROPOSAL_SLOT_TAKEN
            - BID_SOLICITACAO_TAKEN
            - CLT-0001
            - CLT-0002
            - CLT-0003
            - CLT-0004
            - CLT-0005
            - CLT-0006
            - CLT-0007
            - CLT-0008
            - CLT-0009
            - CLT-0010
            - CLT-0011
            - CONTRACT_ALREADY_REGISTERED
            - DATAPREV_CREDENTIAL_REQUIRED
            - EXCLUSION_AUTHORITY_CONFLICT
            - EXCLUSION_AUTHORITY_QUARANTINED
            - FGTS_EXECUTION_ALREADY_REFUSED
            - FGTS_EXECUTION_CONTRACT_TAKEN
            - FGTS_EXECUTION_OUTCOME_UNRESOLVED
            - FGTS_EXECUTION_PAYLOAD_MISMATCH
            - IDEMPOTENCY_OUTCOME_UNRECORDED
            - IDEMPOTENCY_RECORD_UNREADABLE
            - IDEMPOTENCY_REPLAY_UNAVAILABLE
            - IDEMPOTENCY_STATE_UNRECOGNISED
            - RAIL_COMMAND_ANSWER_NOT_RETAINED
            - RAIL_COMMAND_CLAIM_CONFLICT
            - REVERSAO_WINDOW_EXPIRED
          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
    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

````