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

# Bring in a payroll loan by portability

> How your institution answers a worker's portability request and registers the ported payroll loan at Dataprev through Lerian.

Answer a worker's portability request, then register the ported loan at your institution.

> [!NOTE]
>
> This flow is a suggested interpretation of the Dataprev manuals for Crédito do Trabalhador. The manuals prevail over this page. Your institution validates the flow and implements it on the Lerian APIs. See [how to read the diagrams](https://docs.lerian.studio/en/diagrams/introduction.md).

## Participants

***

* **Your institution.** The financial institution that takes the loan from the origin institution.
* **Lerian.** Lerian Consignado. It exchanges the requests with Dataprev, and exposes the API and the events your institution uses.
* **Dataprev.** Runs the Crédito do Trabalhador system: the portability requests and the registry of payroll loans.
* **Worker.** The employee who asks for portability proposals in the Carteira de Trabalho Digital app.

## Diagram

***

### Answer the portability request

![Bring in a payroll loan by portability: Answer the portability request](https://mintcdn.com/lerian-49cb71fc/KypD0TIKUCqZ014J/images/en/d2/id-bring-in-a-payroll-loan-by-portability-1.svg?fit=max\&auto=format\&n=KypD0TIKUCqZ014J\&q=85\&s=386eee8ccf35b077fe40bb6146175a4c)

| # | From | To | Message | Lerian API | What happens |
| - | - | - | - | - | - |
| 1 | Lerian | Dataprev | Dataprev API | | Lerian lists the open portability requests on a schedule (Manual 011). |
| 2 | Dataprev | Lerian | Dataprev API | | Dataprev returns the open requests. |
| 3 | Lerian | Your institution | Lerian API | Event `consignado.portability_proposal.received` | Lerian publishes each new request and its validity. |
| 4 | Your institution | Lerian | Lerian API | [`POST /v1/consignado/leilao/portabilidade/solicitacoes/{id_solicitacao_proposta}/propostas`](https://docs.lerian.studio/en/reference/rails/consignado/respond-consignado-portability-auction) | Send one proposal. Echo the validity of the request in `dataHoraValidadeSolicitacao`. |
| 5 | Lerian | Dataprev | Dataprev API | | Lerian includes the proposal at Dataprev (Manual 011). |
| 6 | Dataprev | Lerian | Dataprev API | | Dataprev answers the proposal. |
| 7 | Lerian | Your institution | Lerian API | [`POST /v1/consignado/leilao/portabilidade/solicitacoes/{id_solicitacao_proposta}/propostas`](https://docs.lerian.studio/en/reference/rails/consignado/respond-consignado-portability-auction) | Lerian returns the Dataprev answer. |
| 8 | Worker | Your institution | Proposal contact | | The worker reviews the proposals and can contact your institution directly. |

Lerian refuses a proposal after the validity of the request, before it calls Dataprev. A request that admits a second proposal, with and without FGTS collateral, takes two calls.

### Register the ported loan

![Bring in a payroll loan by portability: Register the ported loan](https://mintcdn.com/lerian-49cb71fc/-JdEHn8RRUgJwJCQ/images/en/d2/id-bring-in-a-payroll-loan-by-portability-2.svg?fit=max\&auto=format\&n=-JdEHn8RRUgJwJCQ\&q=85\&s=525e8efbf6cb2b01e335481ad9392b8b)

| # | From | To | Message | Lerian API | What happens |
| - | - | - | - | - | - |
| 1 | Your institution | Your institution | Internal step | | Obtain the número único of the portability, the NSU that comes from CIP. |
| 2 | Your institution | Lerian | Lerian API | [`POST /v1/consignado/portabilidade/{numero_unico}/averbacao`](https://docs.lerian.studio/en/reference/rails/consignado/averbar-consignado-portabilidade) | Send the averbação of the new contract. You choose `numeroContrato`: 2 to 15 letters or digits. Add `booking` to book the contract at Lender. |
| 3 | Lerian | Dataprev | Dataprev API | | Lerian sends the averbação by portability to Dataprev (Manual 008). |
| 4 | Dataprev | Lerian | Dataprev API | | Dataprev answers the averbação. |
| 5 | Lerian | Your institution | Lerian API | [`POST /v1/consignado/portabilidade/{numero_unico}/averbacao`](https://docs.lerian.studio/en/reference/rails/consignado/averbar-consignado-portabilidade) | Lerian returns the Dataprev answer. The contract now waits for its documentation. |
| 6 | Your institution | Lerian | Lerian API | [`POST /v1/consignado/contracts/{numero_contrato}/ccb-attachment`](https://docs.lerian.studio/en/reference/rails/consignado/attach-consignado-ccb) | Send the documentation under its own `X-Idempotency` key, as for any averbação. |
| 7 | Lerian | Dataprev | Dataprev API | | Lerian sends the contract information to Dataprev (Manual 004). |
| 8 | Dataprev | Lerian | Dataprev API | | Dataprev accepts the documentation. |
| 9 | Lerian | Your institution | Lerian API | [`POST /v1/consignado/contracts/{numero_contrato}/ccb-attachment`](https://docs.lerian.studio/en/reference/rails/consignado/attach-consignado-ccb) | The operation answers `confirmed`. |
| 10 | Your institution | Lerian | Lerian API | [`POST /v1/consignado/portabilidade/efetivacoes`](https://docs.lerian.studio/en/reference/rails/consignado/list-consignado-portabilidade-efetivacoes) | Read the status of the portability. Send the filters in the request body. |
| 11 | Lerian | Dataprev | Dataprev API | | Lerian reads the portability at Dataprev (Manual 008). |
| 12 | Dataprev | Lerian | Dataprev API | | Dataprev returns `classificadorSituacao`. |
| 13 | Lerian | Your institution | Lerian API | [`POST /v1/consignado/portabilidade/efetivacoes`](https://docs.lerian.studio/en/reference/rails/consignado/list-consignado-portabilidade-efetivacoes) | Lerian returns the status as Dataprev sent it. |

The exclusion at the origin institution must come first, with or without FGTS collateral. Dataprev refuses an averbação sent before the exclusion with rule `PT`, and one sent after the portability closed with rule `PW`. After either refusal, the contract number is free for a new averbação.

When you send `dataExclusaoOrigem`, Lerian refuses an averbação after the 20 calendar days that follow that date, before it calls Dataprev. Without it, Lerian skips only that check, and Dataprev judges the order and the window.

`classificadorSituacao` reads `0` open, `1` closed by deadline, `2` closed by averbação or `3` closed by a change of the número único.

An accepted averbação records the contract as waiting for its documentation, and starts the Lerian outstanding-balance reports. `GET /v1/consignado/contracts/{numero_contrato}/averbacao` reads `attachment_pending`. Lerian publishes no `consignado.averbacao.accepted` for it. The documentation follows the rules of [Register a payroll loan](https://docs.lerian.studio/en/diagrams/native-rails/register-a-payroll-loan.md).

For the `booking` fields and validation, see the [portability averbação](https://docs.lerian.studio/en/reference/rails/consignado/averbar-consignado-portabilidade.md).

With `booking`, `consignado.contract.registered` carries a `portability_in` block once Dataprev accepts the documentation. The block holds `origins[]`, `transferred_principal` and `effective_at`. Lerian sends it when the Dataprev status record of the portability shows exactly the booked origins. If the record shows another origin, or still lacks some 20 calendar days after the confirmed documentation, Lerian parks the contract and publishes no fact. Without `booking`, Lerian keeps the signed CCB and publishes no Lender fact.

A `503` or `500` answer with `X-Idempotency-Fenced: true` may have reached Dataprev. For a proposal, send the same body with the same `numeroProposta` under a new key, before the validity of the request. A `422` that names `SE` means that the first proposal reached Dataprev.

Lerian claims the `numeroContrato` before it calls Dataprev. While the outcome is open, a resend under a new key never submits the averbação again: it answers `409` `CLT-0007` while the first call may still run, then `503` `OUTCOME_UNKNOWN`. Lerian then reads the contract at Dataprev, and records it as accepted or frees the number. That read needs averbação recovery (`DATAPREV_AVERBACAO_RECOVERY_ENABLED`, off by default). A `numeroContrato` that your institution already holds answers `409` `CONTRACT_ALREADY_REGISTERED`, before Lerian calls Dataprev.

## How you know it finished

***

The documentation answers `confirmed`, and the status of the portability reads `2`.

## Related

***

* [Release a payroll loan by portability](https://docs.lerian.studio/en/diagrams/native-rails/release-a-payroll-loan-by-portability.md)
* [Answer a payroll loan request](https://docs.lerian.studio/en/diagrams/native-rails/answer-a-payroll-loan-request.md)
* [How Lerian Consignado works](https://docs.lerian.studio/en/rails/consignado/how-consignado-works.md)
* [Consignado events](https://docs.lerian.studio/en/reference/events/consignado.md)


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