🇲🇽 BitPays Mexico API — MXN
Collect and disburse in Mexico over SPEI transfer to a CLABE. The contract is identical to every other BitPays market — one base URL, one bearer token, the same webhook envelope. Only the currency, method and checkout differ.
At a glance
| Country code | MX |
|---|---|
| Currency | MXN (MX$) |
| Methods | BANK |
| Rail | SPEI transfer to a CLABE |
| Amounts | Whole pesos, integer — 2500 means MXN 2500. Decimals are rejected. |
| Limits | Integer only — decimals are rejected. Platform range 20–100,000 MXN per order; per-merchant limits may be lower. |
Environments
| Production | https://api.bitpays.live |
|---|---|
| Staging (pre-production) | https://api.staging.bitpays.live |
| Path prefix | /v1 on every endpoint |
| Content type | application/json |
Staging is not a sandbox. Staging is a pre-production environment connected to live payment channels. Transactions initiated in staging may move real money. Do not use staging for test payments or payouts.
Staging has its own database and its own API keys; production keys do not work there. Treat every staging transaction as real money unless BitPays has confirmed in writing that your staging account is routed to the simulated channel described below.
Simulated channel (only when enabled for your staging account)
BitPays can route a staging account to a simulated channel. It is not on by default and
is configured per account — ask support whether it applies to yours before relying on it. When it
is in use for Mexico, no request leaves the platform: the simulated channel returns the placeholder CLABE 000000000000000018; no transfer is needed because the outcome follows the amount convention below.
On that simulated channel the result is chosen by the last two digits of the whole amount, so every branch is reproducible on demand:
| Amount ends in | Result | Use it to test |
|---|---|---|
…11 | failed | Failure handling and the payment.failed webhook |
…22 | stays pending | Timeout / expiry handling and polling |
| anything else | success | The happy path and the payment.success webhook |
Webhooks are not simulated separately: the platform status pipeline drives the transition, so the simulated channel exercises your real webhook endpoint and signature verification.
Authentication
Exchange your API keys for a bearer token, then send it on every request. Tokens last 1 hour.
curl -s -X POST https://api.bitpays.live/v1/auth/token \
-H 'Content-Type: application/json' \
-d '{"client_id":"YOUR_CLIENT_ID","client_secret":"YOUR_CLIENT_SECRET"}'
Create a payment
Send an X-Idempotency-Key on every create. Retrying with the same key returns the
original order instead of creating a second one.
curl -s -X POST https://api.bitpays.live/v1/payin/create \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-H 'X-Idempotency-Key: mx-order-1001' \
-d '{
"merchant_order_id": "ORDER-1001",
"amount": 2500,
"currency": "MXN",
"method": "BANK",
"customer": { "name": "Test Customer", "email": "test@example.com" },
"return_url": "https://your-site.com/thanks"
}'
The Mexico checkout
The cashier shows the CLABE, the beneficiary name and the exact amount. The customer transfers via SPEI from their own bank app and BitPays confirms on the provider callback.
Payment status
curl -s https://api.bitpays.live/v1/payin/status/ORDER_ID \
-H 'Authorization: Bearer $TOKEN'
Treat the webhook as the source of truth and this endpoint as reconciliation. Never mark an order paid because a checkout page or a payment app merely opened.
Webhooks
BitPays POSTs a signed JSON envelope to your configured URL on every final state
(payment.success, payment.failed, payout.success,
payout.failed). Verify the HMAC signature header before trusting the body, respond
2xx quickly, and make your handler idempotent on delivery_id — retries
use exponential backoff.
Payouts
curl -s -X POST https://api.bitpays.live/v1/payout/create \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-H 'X-Idempotency-Key: mx-payout-1001' \
-d '{
"merchant_payout_id": "PO-1001",
"amount": 100,
"currency": "MXN",
"method": "BANK",
"beneficiary": { "name": "Jane Doe", "account_number": "ACCOUNT_NUMBER" }
}'
Payout availability for Mexico depends on your contract — confirm with support before building against it.
Order statuses
| Status | Meaning |
|---|---|
created | Order accepted, customer has not paid |
pending | Awaiting the customer or the rail |
processing | The provider is settling it |
success | Paid and confirmed — safe to fulfil |
failed | Not paid |
expired | The payment window elapsed |
Errors & limits
Every error returns a JSON body with success: false, a stable
code and a human message. Branch on code, never on the
message text.
Retry only on 5xx. A 4xx says the request or the account configuration has
to change first, so retrying it unchanged will fail the same way every time.
| HTTP | code | What it means |
|---|---|---|
| 422 | INVALID_REQUEST | Validation failed. details holds the messages per field, and issues[] gives a machine-readable code for each one. |
| 422 | ROUTE_NOT_CONFIGURED | No payment route is enabled on your account for this currency and method. Permanent until support enables that market — do not retry. |
| 422 | AMOUNT_OUTSIDE_LIMITS | No available channel accepts this amount. Try a different amount. |
| 403 | PAYIN_DISABLED | Collections are switched off for your account. |
| 409 | DUPLICATE_ORDER | That merchant_order_id already exists. |
| 409 | IDEMPOTENCY_CONFLICT | The same X-Idempotency-Key was reused with a different body. |
| 503 | PAYMENT_TEMPORARILY_UNAVAILABLE | Every channel for this request is down or at capacity. Retry shortly — this is not a decline. |
| 503 | PROVIDER_ERROR and similar | The upstream bank or acquirer rejected the attempt. See reason below. |
When a create fails at the provider, the response carries what we know, so you do not have to open a ticket to find out why:
reason | The upstream rejection, in plain text, with credentials removed. Present only when the provider told us something useful. |
|---|---|
order_id | The order we created and then marked FAILED. Quote this to support, or read it back from the status endpoint. |
merchant_order_id | Your own reference for the same order. |
retryable | true when the failure looked transient. Absent when we could not tell. |
Rate limits apply per IP, and you should whitelist your server IP before going live in production.
Amount limits
Three things bound an amount, in this order:
| Currency band | A wide sanity range per currency. For MXN the API rejects anything outside it with AMOUNT_BELOW_MINIMUM or AMOUNT_ABOVE_MAXIMUM. |
|---|---|
| Your account limits | The per-merchant minimum and maximum set for you. This is the one that usually applies — ask support to change it. |
| Channel limits | Each payment channel has its own range. If an amount falls outside every available channel you get 422 AMOUNT_OUTSIDE_LIMITS. |
Full multi-country reference: /docs