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

# Testing

> Test deposits and flows in the sandbox environment using the mock trade endpoint.

## Mock trade (sandbox only)

In **sandbox** (`X-Breet-Env: sandbox`), you can simulate an incoming deposit without sending real crypto. This lets you:

* Test webhooks and notification flows end-to-end
* Verify auto-settlement and payout logic
* Exercise your app against the same trade lifecycle as production

## How it works

1. You already have at least one wallet address (from [Generate Wallet Address](https://docs.breet.io/api-reference/crypto-wallet/generate-wallet-address.md) or [Fetch Wallet Addresses](https://docs.breet.io/api-reference/crypto-wallet/fetch-wallet-addresses.md)).
2. You send a `POST /trades/sell/mock-trade` request with:
   * **walletAddress** — the deposit address to credit
   * **asset** — must match that wallet's asset (e.g. `TRX_TEST`)
   * **amountInUSD**, **cryptoReceived** — amounts for the mock deposit
   * **reference**, **txHash** — unique identifiers for the mock transaction
   * **scenario** *(optional)* — the webhook outcome you want to exercise. See [Scenarios](#scenarios) below.
3. The API enqueues the trade as if it had been received from the blockchain. Your webhooks and any downstream flows (e.g. auto-settlement) run as they would for a real deposit.

## Example request

Full request and response details: [Mock a trade (POST /trades/sell/mock-trade)](https://docs.breet.io/api-reference/testing/mock-a-trade-non-production-only.md).

Minimal body (required fields only):

```json theme={null}
{
  "walletAddress": "TV8dNYYBgL3xLbQcJLMBNavY4gYNqPF8Jv",
  "asset": "TRX_TEST",
  "amountInUSD": 50,
  "cryptoReceived": 500,
  "reference": "mock-ref-550e8400-e29b-41d4-a716-446655440000",
  "txHash": "0xmock550e8400e29b41d4a716446655440000"
}
```

With optional fields:

```json theme={null}
{
  "walletAddress": "TV8dNYYBgL3xLbQcJLMBNavY4gYNqPF8Jv",
  "asset": "TRX_TEST",
  "amountInUSD": 100,
  "cryptoReceived": 1000,
  "reference": "mock-ref-660e8400-e29b-41d4-a716-446655440001",
  "txHash": "0xmock660e8400e29b41d4a716446655440001",
  "sourceAddress": "TSource1234567890AbCdEfGhIjKlMnOpQr",
  "confirmations": 12
}
```

## cURL example

```bash theme={null}
curl -X POST "https://api.breet.io/v1/trades/sell/mock-trade" \
  -H "x-app-id: YOUR_APP_ID" \
  -H "x-app-secret: YOUR_APP_SECRET" \
  -H "X-Breet-Env: sandbox" \
  -H "Content-Type: application/json" \
  -d '{
    "walletAddress": "TV8dNYYBgL3xLbQcJLMBNavY4gYNqPF8Jv",
    "asset": "TRX_TEST",
    "amountInUSD": 50,
    "cryptoReceived": 500,
    "reference": "mock-ref-550e8400-e29b-41d4-a716-446655440000",
    "txHash": "0xmock550e8400e29b41d4a716446655440000"
  }'
```

## Responses

| Status | Meaning |
| - | - |
| **200** | Mock trade accepted; processing runs asynchronously (same as a real deposit). |
| **403** | Mock trade is not allowed — you are in production or not using `X-Breet-Env: sandbox`. |
| **404** | No wallet found for the given `walletAddress` and `asset`. Ensure the address exists and matches the asset (e.g. from [Fetch Wallet Addresses](https://docs.breet.io/api-reference/crypto-wallet/fetch-wallet-addresses.md)). |
| **422** | Validation error (e.g. missing required field, invalid asset). Check the response body for details. |

After a successful request, you can confirm the trade and related webhooks in your dashboard and via your webhook endpoint.

## Scenarios

In sandbox you can pass an optional `scenario` field on the mock-trade body to drive the deposit down a specific webhook path. If `scenario` is omitted, the deposit follows the happy path and ends credited.

| `scenario` | What it simulates |
| - | - |
| `completed` | Happy path. Webhook: `trade.pending` → `trade.completed`. |
| `confirming` | Deposit stays pending, waiting for more confirmations. Webhook: `trade.pending` only. Useful for testing your pending-state UI. |
| `below_minimum` | Deposit is flagged for being under the asset's minimum. Webhook: `trade.pending` → `trade.flagged` with `balanceRemaining`. Requires your `amountInUSD` to actually be below the asset minimum. |
| `failed_on_chain` | On-chain transaction fails to confirm. Webhook: `trade.pending` → `trade.deleted` with `reason: failed_on_chain`. |
| `under_review` | Compliance review holds the deposit and then rejects it. Webhook: `trade.flagged` (`subStatus: under_review`) → `trade.deleted` with `reason: rejected_after_review`. |
| `kyt_hold` | AML screening flags the deposit. Webhook: `trade.pending` → `trade.flagged` (`subStatus: under_review`) with a populated `kyt` object. |

### Example

```json theme={null}
{
  "walletAddress": "TV8dNYYBgL3xLbQcJLMBNavY4gYNqPF8Jv",
  "asset": "TRX_TEST",
  "amountInUSD": 50,
  "cryptoReceived": 500,
  "reference": "mock-ref-under-review-001",
  "txHash": "0xmockunderreview001",
  "scenario": "under_review"
}
```

## Simulating withdrawal statuses (sandbox only)

In **sandbox** (`X-Breet-Env: sandbox`), the `amount` you submit on a withdrawal request decides the final status, so you can exercise each branch of the [withdrawal lifecycle](https://docs.breet.io/withdrawals.md) — `reversed`, `processing`, and `completed`.

### Amount-based rules

Find the row for the currency you're withdrawing in. To trigger a `reversed` withdrawal, send any `amount` at or below the value in the first column. To make it stop at `processing`, send the exact value in the second column. Any other `amount` will go straight through to `completed`.

| Currency | `reversed` when `amount` ≤ | `processing` when `amount` = | `completed` otherwise |
| - | - | - | - |
| NGN | `5,000` | `10,000` | any other amount |
| GHS | `10` | `100` | any other amount |
| USD | `15` | `50` | any other amount |

* **At or below the failure threshold** → `withdrawal.pending` → `withdrawal.reversed`. Use this to test refund handling.
* **Exactly the pending threshold** → `withdrawal.pending` → `withdrawal.processing`. The withdrawal stops at `processing` so you can test how your system handles a long-running processing state.
* **Any other amount** → `withdrawal.pending` → `withdrawal.completed`. Standard happy path.

These rules are scoped to sandbox only. In production, withdrawals run through the normal flow and the final status reflects the actual outcome.

### Nothing reaches the blockchain

Sandbox withdrawals are simulated end to end. No funds move and nothing is broadcast to any chain.

> [!WARNING]
>
> The `txHash` on a completed sandbox withdrawal is synthetic. It will not resolve on any block explorer. Do not build checks that expect to find it on-chain.

UTXO fee quotes are the one exception. [`POST /payments/estimate-network-fee`](https://docs.breet.io/api-reference/withdrawals/estimate-network-fee) returns a real estimate in sandbox, priced against the testnet chain, so you can exercise the full quote-then-withdraw flow.

### Use testnet destination addresses

In sandbox, `walletAddress` must be a **testnet** address for the chain you are withdrawing on. A mainnet address is rejected as an invalid wallet address, and the reverse holds in production.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.