> ## Documentation Index
> Fetch the complete documentation index at: https://rain-sandbox-trial.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# MXN Offramps

> Enable users to offramp crypto to MXN using payment routes with SPEI transfers.

<Info>
  **Endpoint Migration**

  The `/v1/automations` endpoints have been renamed to `/v1/payment-routes`. The old `/v1/automations` paths remain available as deprecated aliases during migration. Update your integrations to use `/v1/payment-routes` as the deprecated endpoints will be removed in a future release.
</Info>

MXN offramps follow the same flow as standard [offramps](/docs/offramps), but with MXN as the destination currency and SPEI as the rail. This guide covers only the differences. Refer to the [offramps guide](/docs/offramps) for the full integration flow, managing payment routes, webhooks, and settlement details.

## Differences from USD offramps

### Step 1: create a payment account

Before creating an MXN offramp payment route, register the beneficiary's Mexican bank account as a payment account. The key difference is using `mxn` as the currency, `mx_spei` as the rail, and providing a `clabeNumber` instead of `accountNumber` and `routingNumber`.

#### Request

```bash theme={null}
curl -X POST https://api.rain.xyz/v1/payment-accounts \
  -H "Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "externalFiatAccount",
    "userId": "11111111-1111-1111-1111-111111111111",
    "nickname": "Juan SPEI Account",
    "externalFiatAccount": {
      "currency": "mxn",
      "rail": "mx_spei",
      "thirdParty": true,
      "beneficiaryFirstName": "Juan",
      "beneficiaryLastName": "Perez",
      "beneficiaryType": "individual",
      "clabeNumber": "032180000118359719"
    }
  }'
```

#### Response

```json theme={null}
{
  "id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
  "type": "externalFiatAccount",
  "nickname": "Juan SPEI Account",
  "userId": "11111111-1111-1111-1111-111111111111",
  "externalFiatAccount": {
    "currency": "mxn",
    "rail": "mx_spei",
    "thirdParty": true,
    "beneficiaryFirstName": "Juan",
    "beneficiaryLastName": "Perez",
    "beneficiaryType": "individual",
    "clabeNumber": "032180000118359719"
  },
  "createdAt": "2025-01-15T10:30:00Z"
}
```

#### Required fields for MXN/SPEI

| Field             | Required |
| ----------------- | -------- |
| `clabeNumber`     | Required |
| `beneficiaryType` | Required |

<Info>
  **Beneficiary type and name fields**

  Set `beneficiaryType` to either `individual` or `business`. The name fields you must provide depend on this value:

  * **Individual:** provide `beneficiaryFirstName` and `beneficiaryLastName`.
  * **Business:** provide `beneficiaryBusinessName`.
</Info>

<Info>
  Unlike USD payment accounts, MXN/SPEI accounts only require a `clabeNumber`
  (18-digit CLABE) and `beneficiaryType`. They don't need `accountNumber`,
  `routingNumber`, `bankAccountType`, `beneficiaryAddress`, `bankName`, or
  `bankAddress`.
</Info>

### Step 2: create an offramp payment route

Once you have a payment account, create the offramp payment route. The request and response follow the same structure as the [standard offramp](/docs/offramps#step-2-create-an-offramp-payment-route), with MXN as the destination:

```bash theme={null}
curl -X POST https://api.rain.xyz/v1/payment-routes \
  -H "Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "userId": "11111111-1111-1111-1111-111111111111",
    "source": {
      "currency": "usdc",
      "rail": "base"
    },
    "destination": {
      "currency": "mxn",
      "rail": "mx_spei",
      "address": {
        "type": "paymentAccount",
        "id": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
      }
    },
    "refundAddress": "0x1234567890abcdef1234567890abcdef12345678"
  }'
```

#### Response

```json theme={null}
{
  "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "userId": "11111111-1111-1111-1111-111111111111",
  "status": "active",
  "source": {
    "currency": "usdc",
    "rail": "base"
  },
  "destination": {
    "currency": "mxn",
    "rail": "mx_spei",
    "address": {
      "type": "paymentAccount",
      "id": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
    }
  },
  "refundAddress": "0x1234567890abcdef1234567890abcdef12345678",
  "depositAddress": {
    "type": "onchain",
    "address": "0xabcdef1234567890abcdef1234567890abcdef12"
  },
  "createdAt": "2025-01-15T10:30:00Z",
  "updatedAt": "2025-01-15T10:30:00Z"
}
```

Once the payment route is active, sending stablecoin to the `depositAddress` triggers a conversion and SPEI transfer of MXN to the user's bank account.

<Info>
  MXN payment routes can't be updated after creation. To change one, delete the
  route and create a new one.
</Info>
