# Test mode (/docs/test-mode)

> Pre-release: the public API is not live yet and has no base URL. Routes and fields are in the OpenAPI contract, at /openapi.yaml.

Run the whole integration, from the QR code to the webhook, without moving money.

Test mode is a complete, isolated environment: the same API and the same webhooks as live, with a simulated bank in place of the real one. It exists from the first version of the API.

## How to use it [#how-to-use-it]

Use a key with the `sk_test_` prefix. There is no separate URL and no parameter: the key decides the environment. The operations that exist only in test mode ask the key for the `charges:write` scope. See [Authentication](/docs/authentication).

## What is the same as live [#what-is-the-same-as-live]

- Routes, fields, validation and errors.
- The life of a charge: it starts as `pending` and becomes `paid` or `expired`, and a `paid` charge can be refunded or disputed.
- Refunds: the same rules, with the simulated bank returning the amount at once. See [Refunds](/docs/refunds).
- Webhooks: the same events, the same signature, the same retries.

## What exists only in test mode [#what-exists-only-in-test-mode]

**Simulating a payment.** There is no real payer in test mode, so one operation, available only with a test key, tells the simulated bank to pay a charge: `simulatePayment` in the [OpenAPI contract](/openapi.yaml). It answers `202`, and from there everything follows the real path: shortly after, the charge becomes `paid`, the event is recorded, and the signed webhook reaches your destination.

- Read the charge again, or wait for the webhook, to see it `paid`. The `202` only says that the simulated bank registered the payment.
- Simulating again on a charge that is already paid changes nothing.
- A charge that already expired cannot be paid: the answer is `409` with the `charge_not_payable` code.
- With a live key this route does not exist: the answer is `404` with the `not_found` code.

## Simulating a dispute [#simulating-a-dispute]

No payer disputes a PIX in test mode either, so three operations, available only with a test key, play the part of the banks. Each answers `202`, and from there everything follows the real path: shortly after, the charge changes, the event is recorded, and the signed webhook reaches your destination. See [Disputes](/docs/disputes).

| Operation in the contract | What the simulated bank does | The charge becomes |
|---|---|---|
| `simulateDispute` | Holds the amount of a `paid` charge, as if the payer had disputed it | `disputed` |
| `simulateDisputeWon` | Refuses the open dispute | `paid` again |
| `simulateDisputeLost` | Accepts the open dispute and sends the amount back to the payer | `refunded` |

- Read the charge again, or wait for the webhook, before the next step: the outcome can only be simulated once the charge is `disputed`.
- A charge that is not `paid`, or whose payment has nothing left to dispute, answers `409` with the `charge_not_disputable` code.
- Deciding a charge that has no open dispute answers `409` with the `charge_not_disputed` code.
- With a live key these routes do not exist: the answer is `404` with the `not_found` code.

## The path of an integration [#the-path-of-an-integration]

1. Create a charge with a test key.
2. Simulate its payment.
3. Read the charge and check that it is `paid`.
4. Receive the webhook on your server and verify its signature.

All four steps are plain HTTP.

## Isolation [#isolation]

Test data and live data never mix. A charge created with a test key cannot be read with a live key, and the reverse is also true: the request gets `404`.