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

# Return a transfer

> Automatically return an inbound transfer to the sender when it doesn't match your business rules, using the Fintoc Transfers API and webhook events.

<Note>
  **Only available in Mexico**
</Note>

By the end of this guide, you can return an inbound transfer and handle the webhook events that report the result.

Use the [return transfer endpoint](/api/transfers-api/transfers/transfers-return) up to 90 days after the original inbound transfer. Base the return on your business logic. For example, return a transfer when you expect a specific amount but receive a different one.

<img src="https://mintcdn.com/fintoc-49b8bee8/SkvJJ-DZ5D4yC6tQ/images/e981759580e31e9b1bd63de2c1d7b25900ca1eab7dd8c749518d1024c7526241-image.png?fit=max&auto=format&n=SkvJJ-DZ5D4yC6tQ&q=85&s=75842010be852d338adab065c90b86f3" alt="" width="2182" height="1254" data-path="images/e981759580e31e9b1bd63de2c1d7b25900ca1eab7dd8c749518d1024c7526241-image.png" />

<br />

## Trigger the return

Call the [return transfer endpoint](/api/transfers-api/transfers/transfers-return) with the `transfer_id` and [`Fintoc-JWS-Signature`](/guides/transfers/transfers-setup/setting-up-jws-keys) header. The header contains a JSON Web Signature (JWS) for the request:

```bash curl theme={null}
curl --request POST \
     --url https://api.fintoc.com/v2/transfers/return \
     --header 'Authorization: sk_test_9c8d8CeyBTx1VcJzuDgpm4H-bywJCeSx' \
     --header 'Fintoc-JWS-Signature: CNMaYaDGU3ZhFV1ve6p3sAdYXhEklej8DVIAMqIWCkpNmT6Jp7iigcndXwH5q3WQFHiswgIQU5-_-4rV3jKGptCROmEyWPW8_elhYH1apzAyjOjyZ55ygv37xKHzIFhixzAwmXlAv4pfD4lVelYWVNOSN7REA0QJeCy2vKdqZ5cjqCXQ1lkQUlzOE7dpuNoAkhAhAJJ8HaamFKy7Gl7uwmqbIr-dVYv21d_9O7mO26n0gy3zWXD2nJDxU5Mzl2pZd8-sFvUr9Kmp_YkeRMh4bSe0fr1Uc_YgkjpmYUyu7kaxRWTbAdJ3GwqWFMUDiyfhHdzvZPZyU4VkWreimoydMA' \
     --header 'Idempotency-Key: 1ebfd86c-a75b-4606-872f-9f1cdd9724ca' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "transfer_id": "tr_2wlt3xRBaEstTGPezqIGXy6JUU8"
}
'
```

```javascript Node theme={null}
const transfer = await fintoc.v2.transfers.returnTransfer({
  transfer_id: "tr_2wlt3xRBaEstTGPezqIGXy6JUU8",
});
```

```python Python theme={null}
transfer = client.v2.transfers.return_transfer(
  transfer_id="tr_2wlt3xRBaEstTGPezqIGXy6JUU8"
)
```

```json Response theme={null}
{
  "id": "tr_2wlt3xRBaEstTGPezqIGXy6JUU8",
  "object": "transfer",
  "direction": "inbound",
  "status": "return_pending",
  "amount": 100000,
  "currency": "MXN",
  "mode": "test",
  "post_date": "2020-04-17T00:00:00.000Z",
  "transaction_date": "2020-04-17T05:12:41.462Z",
  "comment": "Electricity bill",
  "reference_id": "130824",
  "receipt_url": "https://api.fintoc.com/v2/transfers/tr_2wlt3xRBaEstTGPezqIGXy6JUU8/receipt",
  "tracking_key": "s2123423423324334",
  "return_reason": null,
  "account_number": {
    "id": "acno_Kasf91034gj1AD",
    "object": "account_number",
    "account_id": "acc_Lq7dP901xZgA2B",
    "description": "My payins",
    "number": "111111111111111111",
    "created_at": "2024-03-01T20:09:42.949787176Z",
    "mode": "test",
    "metadata": {
      "id_cliente": "12343212"
    }
  },
  "counterparty": {
    "holder_id": "AAA010101AAA",
    "holder_name": "Test Customer 1",
    "account_number": "000000000000000000",
    "type": "clabe",
    "institution": {
      "id": "40012",
      "name": "BBVA Mexico",
      "country": "mx"
    }
  }
}
```

After a successful request, the API returns a transfer with `status` set to `return_pending`. After Fintoc processes the return, `status` changes to `returned`.

## Handle the return result

Handle the following webhook events to track the outcome of a return:

| Event                            | Description                                                                                                                    |
| :------------------------------- | :----------------------------------------------------------------------------------------------------------------------------- |
| `transfer.inbound.returned`      | Fintoc returned the transfer. The `receipt_url` shows the original Comprobante Electrónico de Pago with the status `Devuelta`. |
| `transfer.inbound.return_failed` | Fintoc could not return the transfer. The transfer's `status` changes back to `succeeded`.                                     |

## Test the integration

Confirm your integration in `test` mode before going live. Trigger a return for a simulated inbound transfer and check that your webhook handler receives the expected event:

* For a successful return, expect the `transfer.inbound.returned` event and a transfer with `status` set to `returned`.
* For a failed return, expect the `transfer.inbound.return_failed` event and a transfer with `status` set to `succeeded`.

See [Test your integration](/guides/transfers/transfers-setup/test-your-integration) for the steps to simulate both scenarios.
