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

# Sandbox testing

> Fund test balances, exercise payment flows, and understand sandbox limitations

```python Python theme={null}
import os
from enum import Enum

class Environment(Enum):
    DEVELOPMENT = "development"
    TESTING = "testing"
    STAGING = "staging"
    PRODUCTION = "production"

class APIConfig:
    def __init__(self, env: Environment):
        self.environment = env
        self.base_url = self._get_base_url()
        self.api_key = os.getenv(f"HOP_API_KEY_{env.value.upper()}")
        self.secret = os.getenv(f"HOP_API_SECRET_{env.value.upper()}")
    
    def _get_base_url(self) -> str:
        urls = {
            Environment.DEVELOPMENT: "https://api.sbx.hopnow.io",
            Environment.TESTING: "https://api.sbx.hopnow.io",
            Environment.STAGING: "https://api.sbx.hopnow.io",
            Environment.PRODUCTION: "https://api.hopnow.io"
        }
        return urls[self.environment]
```

```javascript JavaScript theme={null}
```

```python Python theme={null}
import unittest
import hmac
import hashlib

class TestHMACSignature(unittest.TestCase):
    
    def setUp(self):
        self.secret = "test_secret_key_123"
    
    def test_post_request_signature(self):
        """Test HMAC signature for POST request"""
        method = "POST"
        path_and_query = "/v1/test"
        timestamp = "1640995200"
        nonce = "a1b2c3d4e5f678901234567890abcdef"
        body = '{"test":true}'
        
        expected_payload = f"{method}{path_and_query}{timestamp}{nonce}{body}"
        signature = self._create_signature(method, path_and_query, timestamp, nonce, body)
        
        self.assertEqual(
            expected_payload,
            'POST/v1/test1640995200a1b2c3d4e5f678901234567890abcdef{"test":true}'
        )
        self.assertEqual(
            signature,
            "91d30335d4bfdc5e0801f31de86e34e5ecc557aca551650f42141dd06eeb9953"
        )
    
    def test_get_request_signature(self):
        """Test HMAC signature for GET request with query string"""
        method = "GET"
        path_and_query = "/v1/customers/cus_123/accounts?page=1&size=10"
        timestamp = "1640995200"
        nonce = "00112233445566778899aabbccddeeff"
        body = ""
        
        signature = self._create_signature(method, path_and_query, timestamp, nonce, body)
        self.assertEqual(
            signature,
            "15decbbdf4fa8f2a26998e95a4c95f75bfa19cab74c8f2c2f08ff6ef191800b4"
        )
    
    def test_signature_consistency(self):
        """Test that same inputs produce same signature"""
        method = "POST"
        path_and_query = "/v1/test"
        timestamp = "1640995200"
        nonce = "a1b2c3d4e5f678901234567890abcdef"
        body = '{"test":true}'
        
        signature1 = self._create_signature(method, path_and_query, timestamp, nonce, body)
        signature2 = self._create_signature(method, path_and_query, timestamp, nonce, body)
        
        self.assertEqual(signature1, signature2)
    
    def _create_signature(self, method, path_and_query, timestamp, nonce, body):
        """Helper to create HMAC signature"""
        payload = f"{method.upper()}{path_and_query}{timestamp}{nonce}{body}"
        return hmac.new(
            self.secret.encode('utf-8'),
            payload.encode('utf-8'),
            hashlib.sha256
        ).hexdigest()

if __name__ == '__main__':
    unittest.main()
```

```javascript JavaScript theme={null}
```

Use the sandbox to test your integration before switching to production. For a complete payout example, follow [Quickstart](https://apidocs.hopnow.io/fx/quickstart.md).

## Environments

Use your sandbox API key, secret, and account IDs with the sandbox [base URL](https://apidocs.hopnow.io/fx/api-reference/introduction.md#base-url). Credentials and webhook endpoints are separate for each environment; a sandbox key cannot authenticate to production.

## What you can test

| Scenario | How to test it |
| - | - |
| Receive a deposit | [Simulate Payin](#simulating-a-deposit) credits a trading account or an active virtual account and emits `payin.received`. |
| Send a payout | Fund the balance, then use [Create Payout](https://apidocs.hopnow.io/fx/api-reference/payouts/create-payout.md). Sandbox payouts progress through `processing` to `completed` and emit `payout.completed`. |
| Transfer or convert funds | Fund the balance, then use the regular [transfer](https://apidocs.hopnow.io/fx/api-reference/transfers/create-transfer.md) or [FX](https://apidocs.hopnow.io/fx/flows/flow-4-convert-currency.md) flow. |
| Receive crypto on a test network | Use a sandbox wallet and test funds from the network's faucet. See [Crypto test networks](#crypto-test-networks). |

Register your webhook endpoint before creating test activity, and configure your receiver using [Webhook security](https://apidocs.hopnow.io/fx/webhooks/security.md).

## Simulating a deposit

[Simulate Payin](https://apidocs.hopnow.io/fx/api-reference/payin-simulations/simulate-payin.md) credits a balance without a bank transfer or an on-chain send. Send a signed `POST /v1/accounts/{account_id}/payin-simulations` with a UUID `Idempotency-Key` and `write` access on `payments`.

This request body funds the trading account:

```json theme={null}
{
  "deposit_destination": {"type": "trading_account"},
  "currency": "USD",
  "amount": "1000.00"
}
```

USD must be enabled for payins on the account; otherwise the request returns `422` `CURRENCY_NOT_ENABLED`. To fund a virtual account, use `{"type": "virtual_account", "virtual_account_id": "va_…"}` as the destination and match its currency.

The payin completes and emits a signed `payin.received` webhook. The credited balance can then fund payouts, transfers, or FX trades. This endpoint is unavailable in production.

## Crypto test networks

Crypto wallets in sandbox use test networks, funded from each network's public faucet:

| Network | `USDC` | `USDT` |
| - | :-: | :-: |
| `ethereum_sepolia` | ✓ | ✓, a test token rather than Tether's |
| `solana_devnet` | ✓ | |
| `tron_shasta` | | ✓ |

## Sandbox limitations

There is no simulation for payout failures or returns, deposit returns, or virtual account activation. Test your application's handling of those states with local fixtures. [Webhook events](https://apidocs.hopnow.io/fx/webhooks/events.md) documents which events Hop emits and the payloads your receiver must handle; do not assume every state change has a webhook.

## Signing

For offline signature checks, use the fixed [test vectors](https://apidocs.hopnow.io/fx/api-reference/authentication.md#test-vectors) alongside the signing examples in Authentication.


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