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

# Receiving transfers

> Receive inbound transfers in real time on Fintoc's legacy v2023-11-15 Transfers API and reconcile payments against orders, invoices, or user accounts.

# 🇲🇽 Inbound transfers in Mexico

Receive and reconcile inbound transfers through Fintoc's Transfers API. Complete the setup guide before following these steps:

1. Find or create an `AccountNumber` using your **Secret key**. This object represents a standardized Mexican bank account number ([CLABE](https://es.wikipedia.org/wiki/CLABE)) for the Interbank Electronic Payment System (SPEI). When you sign in to the dashboard, you start with one **Default Account Number**.
2. Create a `WebhookEndpoint` to handle inbound transfer events.
3. Receive a transfer at the `AccountNumber` and get notified in real time.

The following diagram shows how Fintoc interacts with you and the counterparty that sends the inbound transfer.

<Frame>
  <img src="https://mintcdn.com/fintoc-49b8bee8/SkvJJ-DZ5D4yC6tQ/images/bfbff3c18083033f40b375c994f212d521f733b6f8ead999e479c8a2604ac88c-image.png?fit=max&auto=format&n=SkvJJ-DZ5D4yC6tQ&q=85&s=5e6b057bacb1157147a60297c8cb0f9f" width="2134" height="1124" data-path="images/bfbff3c18083033f40b375c994f212d521f733b6f8ead999e479c8a2604ac88c-image.png" />
</Frame>

<br />

## Step 1: Create an account number (SPEI CLABE)

An `AccountNumber` represents a SPEI CLABE. Assign an account number to a customer or order to reconcile inbound transfers with your records. For example, you can assign one account number to each customer to identify which customer sent a transfer. To learn more about account numbers, see the [data model](/v2023-11-15/guides/transfers/transfers-overview/v2-transfers-account-number-data-model).

### Attach metadata to your account number

When you create an account number, attach key-value data through `metadata`. For example, store your internal customer ID to associate the account number with a customer. Fintoc includes the metadata in each inbound transfer so you can reconcile the transfer with your records.

### Example

Use your test **Secret Key** and **Account ID** to create an `AccountNumber` from your backend. Attach the internal customer ID as `id_cliente`:

```bash theme={null}
curl --request POST \
     --url https://api.fintoc.com/v2/account_numbers \
     --header 'Authorization: sk_test_9c8d8CeyBTx1VcJzuDgpm4H' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "account_id": "acc_Lq7dP901xZgA2B",
  "metadata": {
   "id_cliente": "12343212"
   }
}
'
```

The response should look like this:

```json theme={null}
{
  "id": "acno_Kasf91034gj1AD",
  "object": "account_number",
  "description": "My payins",
  "number": "000000000000000000",
  "account_id": "acc_Lq7dP901xZgA2B",
  "created_at": "2024-03-01T20:09:42.949787176Z",
  "mode": "test",
  "metadata": {
    "id_cliente": "12343212"
  }
}
```

### Use an SDK

Use the Fintoc Python or Node SDK to create the account number:

```python Python theme={null}
account_number = client.v2.account_numbers.create(
    account_id="acc_M8sKf230BgHjD4",
    metadata={"id_cliente": "12343212"}
)
```

```javascript Node theme={null}
const accountNumber = await fintoc.v2.accountNumbers.create({
  account_id: 'acc_M8sKf230BgHjD4',
  metadata: {
    'id_cliente': '1234324',
  },
});
```

<br />

## Step 2: Create a webhook endpoint to handle inbound transfer events

When you receive an inbound transfer, Fintoc sends a `transfer.inbound.succeeded` event. Follow the [webhook guide](/v2023-11-15/guides/resources/webhooks-walkthrough) to create a webhook endpoint that receives and processes these events.

The `transfer.inbound.succeeded` event looks like this:

```json json theme={null}
{
  "id": "evt_a4xK32BanKWYn",
  "type": "transfer.inbound.succeeded",
  "object": "event",
  "data": {
    "id": "tr_jKaHD105H",
    "object": "transfer",  
    "direction": "inbound",
    "status": "succeeded",
    "amount": 2864,   
    "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://www.banxico.org.mx/cep/",
    "tracking_key": "s2123423423324334",
    "return_reason": null,
    "account_number": {
      "id": "acno_Kasf91034gj1AD",
      "object": "account_number",
      "account_id": "acc_Jas92lf9adg94ka",
      "description": "My payins",
      "number": "000000000000000000",
      "created_at": "2024-03-01T20:09:42.949787176Z",
      "mode": "test",
      "metadata": {
        "client_id": "12343212"
      }
    },
    "counterparty": {
      "holder_id": "AAAA010101AAA",
      "holder_name": "Test Customer 1",
      "account_number": "000000000000000000",
      "type": "clabe",  
      "institution": {
        "id": "40012",
        "name": "BBVA Mexico",
        "country": "mx" 
       }
     }
  },
  "created_at": "2020-04-22T21:10:19.254Z",
  "mode": "test"
}
```

## Step 3: Receive a transfer at your account number

After you create an account number and webhook endpoint, send a transfer to the account number. Use the resulting webhook event to reconcile the payment.

To test this flow in `test` mode, use the `/simulate/receive_transfer` endpoint to simulate an inbound transfer. The simulation follows the same flow as a real transfer to the specified account number. See the [test guide](/v2023-11-15/guides/transfers/test-your-integration) for simulation instructions.

# 🇨🇱 Inbound transfers in Chile

Receive and reconcile inbound transfers through Fintoc's Transfers API. Complete the setup guide before following these steps:

1. Create a `WebhookEndpoint` to handle inbound transfer events.
2. Receive a transfer in your `Account` and get notified in real time.

The following diagram shows how Fintoc interacts with you and the counterparty that sends the inbound transfer.

<Frame>
  <img src="https://mintcdn.com/fintoc-49b8bee8/YQmOnq8Zegydl6oL/images/1739789ad5079938ca7535937106a401d4a401a2106610dc98cde971fbb1ac61-image.png?fit=max&auto=format&n=YQmOnq8Zegydl6oL&q=85&s=dbade713008df9b4e563e86899d0f627" width="2182" height="1220" data-path="images/1739789ad5079938ca7535937106a401d4a401a2106610dc98cde971fbb1ac61-image.png" />
</Frame>

## Step 1: Create a webhook endpoint to handle inbound transfer events

When you receive an inbound transfer, Fintoc sends a `transfer.inbound.succeeded` event. Follow the [webhook guide](/v2023-11-15/guides/resources/webhooks-walkthrough) to create a webhook endpoint that receives and processes these events.

The `transfer.inbound.succeeded` event looks like this:

```json json theme={null}
{
  "id": "evt_a4xK32BanKWYn",
  "type": "transfer.inbound.succeeded",
  "object": "event",
  "data": {
    "id": "tr_jKaHD105H",
    "object": "transfer",  
    "direction": "inbound",
    "status": "succeeded",
    "amount": 2864,   
    "currency": "CLP", 
    "mode": "test",
    "post_date": "2020-04-17T00:00:00.000Z", 
    "transaction_date": "2020-04-17T05:12:41.462Z",
    "comment": "Electricity bill",
    "reference_id": null,
    "receipt_url": null,
    "tracking_key": null,
    "return_reason": null,
    "account_number": {
      "id": "acno_Kasf91034gj1AD",
      "object": "account_number",
      "account_id": "acc_Jas92lf9adg94ka",
      "description": "My payins",
      "number": "000000000000000000",
      "created_at": "2024-03-01T20:09:42.949787176Z",
      "mode": "test",
      "metadata": {
        "client_id": "12343212"
      }
    },
    "counterparty": {
      "holder_id": "00000000T",
      "holder_name": "Test Customer 1",
      "account_number": "000000000000000000",
      "type": "checking_account", 
      "code": "01", 
      "institution": {
        "id": "cl_banco_santander",
        "name": "Banco Santander",
        "country": "cl" 
       }
     }
  },
  "created_at": "2020-04-22T21:10:19.254Z",
  "mode": "test"
}
```

## Step 2: Receive a transfer at your account number

After you identify your `Account` and its `root_account_number`, add a webhook endpoint for notifications. Send a transfer to the account number, then use the resulting webhook event to reconcile the payment.

To test this flow in `test` mode, use the `/simulate/receive_transfer` endpoint to simulate an inbound transfer. The simulation follows the same flow as a real transfer to the specified account number. See the [test guide](/v2023-11-15/guides/transfers/test-your-integration) for simulation instructions.
