> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mangopay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How Echo works

## Overview diagram

The diagram below gives an overview of how Echo works, focusing on the settlement of funds and reconciliation. The main sections of this guide are highlighted.

<img className="block dark:hidden" src="https://mintcdn.com/mangopay/1u-mSOKzKIcVv5Y0/images/diagram_echo_settlement_light.svg?fit=max&auto=format&n=1u-mSOKzKIcVv5Y0&q=85&s=42a18bf4d9ec1fa29bc2641c144b8124" width="1507" height="865" data-path="images/diagram_echo_settlement_light.svg" />

<img className="hidden dark:block" src="https://mintcdn.com/mangopay/1u-mSOKzKIcVv5Y0/images/diagram_echo_settlement_dark.svg?fit=max&auto=format&n=1u-mSOKzKIcVv5Y0&q=85&s=17b7f8b6005e860d85914f25bb28612b" width="1507" height="865" data-path="images/diagram_echo_settlement_dark.svg" />

## A. Declaration and capture

Your platform declares transactions as Intents, identified with the `ExternalProviderReference`.

Once created, an Intents' `Status` value is `AUTHORIZED` before being declared as `CAPTURED`. These Intents are not yet reconciled and the corresponding funds have not been received.

## B. Settlement file processing

When your platform uploads a [settlement file](/guides/echo/integration#send-settlement-files-to-manogpay) to Mangopay, the Echo system starts to parse the file.

Echo first checks that the file is valid (expected format, single currency, etc.). Once done, the `Status` becomes `CREATED`. If the file is not valid and the matching process cannot start, the `Status` becomes `FAILED` and the process stops for that file.

<Note>
  **Note – Settlement data must match intent data**

  It is critical that the data in the settlement fil matches the intents that you declared. If provider IDs or amounts are not matched then the reconciliation will fail.

  You can monitor this by checking the settlement file `Status` and using the dedicated endpoint to check any settlement errors, [GET View validation errors for a Settlement](/api-reference/settlements/view-settlement-validations).

  You need to address any failures, errors, or partially matched funds to prevent any delays in payouts to sellers.
</Note>

## C. Line matching

Once the file is validated, Echo proceeds to reconciliation.

Echo iterates through each transaction line of the file and attempts to match the  `ExternalProviderReference` to a corresponding unreconciled Intent declared previously.

### Fully successful matching

If a match is found for all lines, the Settlement `Status` changes to `PENDING_FUNDS_RECEPTION`.

At the same time, the associated Intent is updated:

* The `SettlementId` is linked in the Intent
* The `Status` of the Intent’s Capture becomes `SETTLED_NOT_PAID`
* The `Status` of any created Splits becomes `PENDING_FUNDS_RECEPTION`.

### Unsuccessful matching attempts

If a match is found for some lines of the file, the Settlement `Status` changes to `PARTIALLY_MATCHED`.

If no lines could be matched, the status becomes `UNMATCHED`.

In both `PARTIALLY_MATCHED` and `UNMATCHED` cases, no part of the Settlement is settled using any funds that may arrive on the Virtual Account.

These Settlements need to be re-uploaded so that they can be fully matched, using the [POST Update a Settlement and generate a new upload URL](/api-reference/settlements/update-settlement) endpoint.

## D. Funds reception

The final step is that Mangopay receives funds from your platform’s partner PSP to a dedicated Virtual Account and associated wallet.

When the system receives unallocated funds, it checks the amount with the oldest matched Settlement’s `ActualSettlementAmount`.

If the funds received are sufficient:

* The Settlement’s `Status` becomes `RECONCILED`
* The Intent’s Capture’s `Status` becomes `PAID`
* The `AvailableAmountToSplit` is populated with the received amount
* The Intent’s Splits become `AVAILABLE`

If the funds are not sufficient, the Settlement’s `Status` becomes `INSUFFICIENT_FUNDS`. These settlements remain unmatched and are retried when additional funds are received on the dedicated Virtual Account’s wallet.

So, when funds arrive on the virtual account, the system looks for the oldest Settlement that has a Status of `PENDING_FUNDS_RECEPTION` or `INSUFFICIENT_FUNDS` and settles it first, passing the object to `RECONCILED`.

## Settlement file state machine

The overall state machine for a Settlement object is below:

<div className="block dark:hidden">
  ```mermaid actions={true} theme={null}
  %%{
    init: {
      'theme': 'base',
      'themeVariables': {
        'primaryColor': '#FFFFFF',
        'primaryTextColor': '#2D0F37',
        'primaryBorderColor': '#2D0F37',
        'lineColor': '#2D0F37',
        'secondaryColor': '#FFFFFF',
        'tertiaryColor': '#FFFFFF',
        'fontSize': '16px',
        'fontFamily': 'Inter'
      }
    }
  }%%
  flowchart LR
      START(["start"])
      FAILED(["FAILED"])
      CANCELLED(["CANCELLED"])
      RECONCILED(["RECONCILED"])
      PENDING_UPLOAD["PENDING_UPLOAD"]
      UPLOADED["UPLOADED"]
      CREATED["CREATED"]
      PENDING_FUNDS_RECEPTION["PENDING_FUNDS_RECEPTION"]
      UNMATCHED["UNMATCHED"]
      PARTIALLY_MATCHED["PARTIALLY_MATCHED"]
      INSUFFICIENT_FUNDS["INSUFFICIENT_FUNDS"]

      START --> PENDING_UPLOAD
      PENDING_UPLOAD --> UPLOADED
      UPLOADED --> CREATED
      UPLOADED --> FAILED
      CREATED --> PENDING_FUNDS_RECEPTION
      CREATED --> UNMATCHED
      CREATED --> CANCELLED
      UNMATCHED --> PARTIALLY_MATCHED
      PENDING_FUNDS_RECEPTION --> RECONCILED
      PENDING_FUNDS_RECEPTION --> INSUFFICIENT_FUNDS
      INSUFFICIENT_FUNDS --> RECONCILED
      UNMATCHED --> CANCELLED
      PARTIALLY_MATCHED --> PENDING_FUNDS_RECEPTION
      PARTIALLY_MATCHED --> CANCELLED

      style START stroke-width:3.5px
      style FAILED stroke-width:3.5px
      style CANCELLED stroke-width:3.5px
      style RECONCILED stroke-width:3.5px
      style PENDING_UPLOAD stroke-width:3.5px
      style UPLOADED stroke-width:3.5px
      style CREATED stroke-width:3.5px
      style PENDING_FUNDS_RECEPTION stroke-width:3.5px
      style UNMATCHED stroke-width:3.5px
      style PARTIALLY_MATCHED stroke-width:3.5px
      style INSUFFICIENT_FUNDS stroke-width:3.5px
  ```
</div>

<div className="hidden dark:block">
  ```mermaid actions={true} theme={null}
  %%{
    init: {
      'theme': 'base',
      'themeVariables': {
        'primaryColor': "#090D0D",
        'primaryTextColor': "#FFFFFF",
        'primaryBorderColor': "#FFFFFF",
        'lineColor': "#FFFFFF",
        'secondaryColor': "#090D0D",
        'tertiaryColor': "#090D0D",
        'fontSize': '32px',
        'fontFamily': 'Inter'
      }
    }
  }%%
  flowchart LR
      START(["start"])
      FAILED(["FAILED"])
      CANCELLED(["CANCELLED"])
      RECONCILED(["RECONCILED"])
      PENDING_UPLOAD["PENDING_UPLOAD"]
      UPLOADED["UPLOADED"]
      CREATED["CREATED"]
      PENDING_FUNDS_RECEPTION["PENDING_FUNDS_RECEPTION"]
      UNMATCHED["UNMATCHED"]
      PARTIALLY_MATCHED["PARTIALLY_MATCHED"]
      INSUFFICIENT_FUNDS["INSUFFICIENT_FUNDS"]

      START --> PENDING_UPLOAD
      PENDING_UPLOAD --> UPLOADED
      UPLOADED --> CREATED
      UPLOADED --> FAILED
      CREATED --> PENDING_FUNDS_RECEPTION
      CREATED --> UNMATCHED
      CREATED --> CANCELLED
      UNMATCHED --> PARTIALLY_MATCHED
      PENDING_FUNDS_RECEPTION --> RECONCILED
      PENDING_FUNDS_RECEPTION --> INSUFFICIENT_FUNDS
      INSUFFICIENT_FUNDS --> RECONCILED
      UNMATCHED --> CANCELLED
      PARTIALLY_MATCHED --> PENDING_FUNDS_RECEPTION
      PARTIALLY_MATCHED --> CANCELLED

      style START stroke-width:3.5px
      style FAILED stroke-width:3.5px
      style CANCELLED stroke-width:3.5px
      style RECONCILED stroke-width:3.5px
      style PENDING_UPLOAD stroke-width:3.5px
      style UPLOADED stroke-width:3.5px
      style CREATED stroke-width:3.5px
      style PENDING_FUNDS_RECEPTION stroke-width:3.5px
      style UNMATCHED stroke-width:3.5px
      style PARTIALLY_MATCHED stroke-width:3.5px
      style INSUFFICIENT_FUNDS stroke-width:3.5px
  ```
</div>
