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

# Release a payroll loan by portability

> How your institution, as the origin institution, excludes at Dataprev through Lerian a payroll loan that the worker moved to another institution.

Exclude a contract from your institution after the worker moves it to another institution by portability.

> [!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 origin institution, which holds the contract until the exclusion.
* **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.

## Diagram

***

![Release a payroll loan by portability](https://mintcdn.com/lerian-49cb71fc/KypD0TIKUCqZ014J/images/en/d2/id-release-a-payroll-loan-by-portability.svg?fit=max\&auto=format\&n=KypD0TIKUCqZ014J\&q=85\&s=3f636a769a2343d800bf1d7369a2d23b)

## Steps

***

| # | From | To | Message | Lerian API | What happens |
| - | - | - | - | - | - |
| 1 | Your institution | Lerian | Lerian API | [`POST /v1/consignado/contracts/{numero_contrato}/portabilidade/exclusao`](https://docs.lerian.studio/en/reference/rails/consignado/excluir-consignado-portabilidade) | Send the exclusion with the número único of the portability, `numeroUnico`, and the code of the destination institution, `codigoProponente`. |
| 2 | Lerian | Dataprev | Dataprev API | | Lerian sends the exclusion by portability to Dataprev (Manual 008). |
| 3 | Dataprev | Lerian | Dataprev API | | Dataprev excludes the contract and returns the payroll month of the exclusion. |
| 4 | Lerian | Your institution | Lerian API | [`POST /v1/consignado/contracts/{numero_contrato}/portabilidade/exclusao`](https://docs.lerian.studio/en/reference/rails/consignado/excluir-consignado-portabilidade) | Lerian returns `competenciaExclusao` and the Dataprev operation hash. |
| 5 | Lerian | Your institution | Lerian API | Event `consignado.portabilidade.efetivada` | Lerian publishes that the contract left your institution. |

Your institution receives the número único and the destination institution outside Lerian. The contract must be a contract that Lerian holds for your institution: registered through Lerian, or imported with [`POST /v1/consignado/contracts/{numero_contrato}/import`](https://docs.lerian.studio/en/reference/rails/consignado/import-consignado-contract). Any other contract answers `404`, and Lerian does not call Dataprev.

The exclusion and the averbação by the destination institution can happen in either order. After Dataprev accepts the exclusion, Lerian sends a final outstanding balance of 0.00 for the contract.

When Dataprev refuses the exclusion with a code that Lerian recognizes, Lerian publishes `consignado.portabilidade.rejeitada`. If the answer does not arrive, do not send the command again under a new key. The code `RAIL_COMMAND_OUTCOME_UNRESOLVED` means that Lerian does not know the outcome yet. Read the command with [`GET /v1/consignado/rail-commands`](https://docs.lerian.studio/en/reference/rails/consignado/list-consignado-rail-commands).

## How you know it finished

***

The answer carries `competenciaExclusao`, and Lerian publishes `consignado.portabilidade.efetivada`.

## Related

***

* [Bring in a payroll loan by portability](https://docs.lerian.studio/en/diagrams/native-rails/bring-in-a-payroll-loan-by-portability.md)
* [Register a payroll loan](https://docs.lerian.studio/en/diagrams/native-rails/register-a-payroll-loan.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.