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

# Move objects and trigger events in sandbox

> Put sandbox objects in the status you need to test, and read the errors if a call fails

Sandbox, Lead's test system, has two v2 calls that production doesn't: one moves an object you created to a status you name, and one triggers an event that would come from outside Lead. This page has both calls, their rules, and the errors they return. You need them as soon as a test creates something that would move on its own in production. A funding is one example: in production, Lead moves it to `posted` when the money reaches your account number. In sandbox nothing moves by itself, so you move your own objects between statuses and trigger what other banks would do. To get credentials and make your first call, see [Set up sandbox](https://docs.lead.bank/v2/get-started/sandbox/setup.md).

On v1, sandbox has a separate endpoint for each event, listed on [Sandbox Setup](https://docs.lead.bank/get-started/sandbox.md). v2 replaces them with at most one call of each kind per product, and the move call lets you name the status you want instead of only taking the next one.

## Advance and simulate calls

Both calls take the product's name as `{domain}` in the path, such as `fundings` or `card_network_settlements`:

| Call | What it does | Path | Response |
| - | - | - | - |
| Advance | Moves one of your own objects to the status you name in `next_status`, the way Lead would in production | `POST /v2/simulate/{domain}/{id}/advance`, for example [Simulate Advance Funding](https://docs.lead.bank/api-reference/endpoint/simulation/simulate-advance-a-funding-v2.md) | `200` with an empty object |
| Simulate | Triggers the event you name in `scenario`, something that comes from outside Lead, like a card network settling your program's card spend | `POST /v2/simulate/{domain}`, for example [Simulate a Card Network Settlement](https://docs.lead.bank/api-reference/endpoint/simulation/simulate-a-network-settlement-v2.md) | `200` with an empty object |

Both calls are under `/v2/simulate`, which marks them as sandbox-only, so on this page "simulate" means the second call only. Neither returns the object itself. To see what changed, retrieve the object, or wait for its webhook where the status sends one, as you would in production.

## Rules for both calls

* A new object stays in its first status until you move it. Each advance call makes one supported transition. The product's Test and go live page lists the transitions.
* What sandbox can do is listed as endpoints and `scenario` values in the API reference, under Simulations (for example [Simulate Advance Funding](https://docs.lead.bank/api-reference/endpoint/simulation/simulate-advance-a-funding-v2.md)).
* To cancel or return a payment, call the same endpoint you'd call in production. The simulate call is only for what another bank or a network does.
* Send an `Idempotency-Key` header on every call under `/v2/simulate`, whether or not the endpoint's reference page marks it required. See [Idempotency](https://docs.lead.bank/api-reference/using-the-api/idempotency-v2.md).
* Calls under `/v2/simulate` work only in sandbox. In production they return `404`. Keep them out of production code.

## Test and go live pages

A Test and go live page lists the statuses you can move a product's objects to, the events you can trigger, and a test run in order.

| Product | Page |
| - | - |
| Fundings | [Test and go live with fundings](https://docs.lead.bank/v2/products/fundings/test-and-go-live.md) |

For other products, see the API reference, for example [Simulate a Card Network Settlement](https://docs.lead.bank/api-reference/endpoint/simulation/simulate-a-network-settlement-v2.md). The Note at the top of each product's pages says whether the product is in sandbox yet.

## Errors

Every error uses the v2 error body. The top-level `code` tells you the kind of problem, and `errors`, when it's present, lists each specific one. For which fields you can build on, see [Errors](https://docs.lead.bank/api-reference/using-the-api/errors-v2.md).

| Status | What happened | What to do |
| - | - | - |
| `400` | The body isn't valid JSON, or a required `Idempotency-Key` header is missing. | Fix the request and resend it. |
| `403` | The token is missing, expired, or doesn't have the product's scope, or the call came from an address that isn't on your IP allowlist. | Get a new token with the right scope. If the address is the problem, call from one on your allowlist. See [Authentication](https://docs.lead.bank/api-reference/using-the-api/authentication.md). |
| `404` | No object with that ID exists in your program, or you called `/v2/simulate` in production. | Check that the ID came from sandbox, and that you're calling the sandbox base URL. |
| `409` | Another request with the same `Idempotency-Key` is still being processed. | Wait, then retry with the same key. |
| `422` | The object can't move to `next_status` from its current status, it can't take that `scenario`, a field is missing or invalid, or the `Idempotency-Key` was already used with a different request. | Read `errors`. If the object's status is the problem, retrieve it and check `status` before you retry. If the key is the problem, send a new key. |

For every v2 error code, see [Errors](https://docs.lead.bank/api-reference/using-the-api/errors-v2.md).

## Related

* [Set up sandbox](https://docs.lead.bank/v2/get-started/sandbox/setup.md): your first token, your first call, and webhook checks
* [Environments and testing](https://docs.lead.bank/v2/get-started/sandbox/environments-and-testing.md): how sandbox and production differ, and what sandbox simulates
* [Test and go live with fundings](https://docs.lead.bank/v2/products/fundings/test-and-go-live.md): the funding advance call and a full test run
* [Errors](https://docs.lead.bank/api-reference/using-the-api/errors-v2.md): every v2 error code, with the error body fields
* [Idempotency](https://docs.lead.bank/api-reference/using-the-api/idempotency-v2.md): how the `Idempotency-Key` header works on v2 requests
