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

# Environments

> How sandbox and production work, and what to check before going live.

Tanda has one base URL for both environments:

```bash theme={null}
https://api.tandapay.io
```

Your keys decide the environment. A token minted with sandbox keys works in sandbox; a token minted with production keys moves real money.

| | Sandbox | Production |
| :- | :- | :- |
| Keys | Sandbox public key + API key | Production public key + API key |
| Money | Simulated; nothing reaches M-PESA, Airtel or banks | Real |
| Outcomes | Set by the [test values](https://api.tandapay.io/guides/testing.md) you send | Set by the customer and the network |
| Webhooks | Sent to your sandbox webhook URL | Sent to your production webhook URL |
| [Simulate webhook](https://api.tandapay.io/api-reference/endpoint/simulate-webhook.md) | Available | Not available |

> [!NOTE]
>
> Simulate webhook is the one endpoint with a different path: `/api/sandbox/b2b/utilities/simulate-webhook`.

Set both webhook URLs in the dashboard under **Webhooks**. [Get user](https://api.tandapay.io/api-reference/endpoint/get-user.md) returns them as `sandboxWebhookUrl` and `webhookUrl`.

## Rules for both environments

* **Unique `externalReference`.** Use a new value for every new transaction. If a request times out and you don't know whether it arrived, resend it with the **same** value: Tanda rejects a reused reference with `409 DUPLICATE_EXTERNAL_REFERENCE`, so you can't charge or pay twice.
* **Only `successful` means money moved.** `pending` means the customer or network hasn't finished. Don't release value until you see `successful`.
* **Confirm before you fulfil.** For anything you can't undo, check the transaction with [Get transaction](https://api.tandapay.io/api-reference/endpoint/get-transaction.md) after the webhook.
* **Keep keys apart.** Don't use production keys in tests, or test with real customers' details.

## Going live

**1. Test success and failure in sandbox**

Run every method you'll use, collections and payouts, through both outcomes using the [sandbox test values](https://api.tandapay.io/guides/testing.md).

**2. Verify webhook signatures**

Reject any webhook that doesn't carry your secret. See [Verify webhooks](https://api.tandapay.io/guides/webhooks/verify-signatures.md).

**3. Set your production webhook URL**

Make sure it's reachable over HTTPS and returns `2xx` quickly.

**4. Swap your keys**

Replace the sandbox public key and API key with production ones. The URL doesn't change.


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