Skip to main content

How to use

Add the X-Sandbox-Scenario: <scenario> header to any cash-in or cash-out call. Without the header, the sandbox uses the success scenario by default.
Most scenarios control the asynchronous webhook: the HTTP response is 201 Created with status: PENDING, and the final result arrives via webhook. The exceptions are timeout and service_unavailable, which fail in the synchronous HTTP response.

Available scenarios

The canonical scenario values are: success, pending_long, rejected, returned, insufficient_funds, bad_clabe, timeout, service_unavailable.

Asynchronous result scenarios

Return 201 PENDING synchronously; the final state arrives via webhook within seconds.
*.returned events are delivered to the refund_in/refund_out webhook type (or all), not to cash_in/cash_out. To test the returned and bad_clabe scenarios, register those webhooks as well — see webhook types.

Synchronous error scenarios

Fail in the HTTP response itself — no webhook is sent.
Cash-in restrictions: insufficient_funds and bad_clabe do not apply to cash-in (there is no balance to debit, and the deposit CLABE is generated by the system). Sending either of them on a cash-in returns 400 with code SCENARIO_NOT_APPLICABLE.

Example: success webhook

success scenario on a cash-out — the cash_out webhook receives:

Example: rejection webhook

insufficient_funds scenario — the cash_out webhook receives:
With status: REJECTED, the receipt fields (reference, voucher) come back null — the SPEI network never confirmed the transaction. The full payload format is in the Webhooks Overview.

Restrictions

  • The X-Sandbox-Scenario header works exclusively on sandbox accounts.
  • Production accounts that send the header receive:

Best practices

  1. Test every scenario before going live — implement handling for all four statuses (LIQUIDATED, PENDING, REJECTED, RETURNED).
  2. Route by the event field*.settled, *.rejected, and *.returned require different actions in your system.
  3. Test with delay — use pending_long to verify that your system handles slow settlement gracefully.
  4. Idempotency — deduplicate by the x-event-id header; the same event may be redelivered.