Sandbox
Test the whole integration against real prices and simulated fills, in the production pipeline, as a sandbox tenant.
What the sandbox is
The sandbox is the production pipeline with the execution layer simulated: live prices, real quote expiry, real idempotency and real settlement, with the fill produced locally instead of at a venue.
| Behaviour | Sandbox |
|---|---|
| Prices | Live upstream books, with real age and real freshness gating. |
| Quote expiry | Real, enforced server-side: 30 seconds by default, shorter on live and five-minute contracts. Read expiresAt. |
| Fill | Simulated, at the accepted price: at once for executionIntent simulate, and in the confirming call for a recorded intent. Rejected if the book moved past it. |
| Recorded intents | Filled the same way when you confirm the reserve, in that same call, then settled like any other fill. One that cannot fill at that moment is withdrawn instead, with a release instruction. |
| Partial fills | Never happens on its own, because the simulated venue never runs out of book. Arm one with POST /api/v1/sandbox/scenarios, below. |
| Positions | Real rows, real weighted averages. |
| Settlement | Real, when the upstream contract resolves. A position waits while a cash out on the same contract is still being confirmed, and a contract whose result is disputed upstream is not settled until the dispute ends: subscribe to market.disputed to be told. Cash movement is yours. |
| Fees | Parity’s fee is charged as live. The venue fee and the builder fee are not reserved, because the simulated venue charges neither, so a sandbox payout is better than the same trade live. Every sandbox buy quote carries liveEquivalent, the live figures; certify against those. |
| Webhook delivery | Signed deliveries to the endpoints your account team registers. The settlement feed is the authoritative record alongside it. |
| Order completion | No order.completed. A sandbox order is final when it fills: its order.filled carries final: true, and GET /api/v1/orders/{id} reads settlementState settled. Live, the market can close an order after its first fill, and order.completed then carries the final figures, so handle both. |
Swipe the table sideways for more columns.
Test users
There is no user provisioning call. Send any opaque id on X-Parity-User and the player is created on that first request.
# Two players, no setup step
curl ... -H "X-Parity-User: test-alice" ...
curl ... -H "X-Parity-User: test-bob" ...- Use a recognisable prefix so test identities are separable from real ones later.
- Parity stores only the opaque id, with no name or email, so it holds no personal data about your players.
- Positions and settlements are scoped to the pair of (operator, player), so two test users never see each other.
Test funds, and what they are for
A sandbox tenant has simulated money. Test funds arrive as a SANDBOX_CREDIT ledger movement from house equity, a real double-entry posting, and GET /api/v1/users/{id}/balance and GET /api/v1/users/{id}/ledger read it back.
They exist to be learned against, not integrated against
Those two endpoints, all three funding routes and the two test controls below answer 403 sandbox_only for a live operator. In production you own your customers' cash ledger and Parity returns the exact amounts to apply against it: operatorMoney, operatorExitMoney, settlementCredit.
So run your own wallet beside the sandbox: reserve authorizationAmount, apply actualDebit and releaseAmount, and compare your books with GET /api/v1/reconciliation. Your wallet is what will move cash in production.
Everything downstream (reserve, buy, fee, settlement, void refund) posts exactly as it would live, so a reconciliation built against the sandbox works in production.
Exercising the failure modes
Test the refusals, not only the happy path. Each of these can be reached in the sandbox.
| To produce | Do this |
|---|---|
409 quote_expired | Take a quote, wait past its expiresAt, submit it. |
409 quote_already_used | Submit one quote twice with two different clientOrderIds. The second refusal carries orderId, naming the order that spent it; your own clientOrderId finds nothing. |
200 idempotent replay | Submit the same clientOrderId twice. The second returns the first order. |
400 invalid_request | Send side: "Maybe". |
400 missing_user | Omit the X-Parity-User header. |
401 invalid_key | Send a bearer token that is not a key. |
404 market_not_found | Quote an outcome id that does not exist. |
422 stake_exceeds_stale_limit | Quote a large stake on a thinly-traded contract whose price has aged into the stale band. |
status: cancelled | Record an intent on a five-minute window, wait for the window to close, then confirm the reserve. The confirmation answers 200 with the order withdrawn and intent.cancellation carrying the release. |
Swipe the table sideways for more columns.
The sandbox is a tenant, not a mock
Sandbox is a mode stored on the operator, not a flag on a request, so no header can cross the boundary. Its trades are real rows written by the production code.
- A sandbox operator's keys start
pk_test_; a live operator's startsk_live_. - The mode gates the balance, ledger, funding and test-control routes. They answer
403 sandbox_onlyfor a live tenant, and every other path behaves identically in both. - A recorded intent (
executionIntent: "record_intent") fills here when its reserve is confirmed, byconfirm-reserveor byreserveReferenceon the order, and it settles when its market resolves. The confirming call returns the orderfilled(orpartially_filled, under an armed scenario), withoperatorMoneyto book. Live, a confirmed order waits atpending_venue_executionfor a few seconds until Parity's order lane sends it, inside your live caps, or withdraws it with its release when it may not go. See going live. - An intent that cannot fill at the moment its reserve is confirmed is withdrawn instead: its contract has closed or passed its trading cutoff, the price moved past the accepted price by more than the order's slippage, there is no book to fill against, the order is more than five minutes old, trading is paused, or the customer is suspended. The order comes back
cancelledandintent.cancellationcarries the release instruction, with anorder.cancelledwebhook. Release the hold. Confirming a reserve that was already confirmed changes nothing and fills nothing.
Testing failure and settlement paths
Two paths decide whether your integration moves money correctly. A partial fill is the only case where the debit differs from the authorization, and a settlement is the only case where money moves to your customer. Both depend on a venue and a clock you do not control.
Two sandbox-only endpoints let you rehearse them. They answer 403 sandbox_only for a live tenant and run the same order and settlement code as production.
A partial fill, on demand
Arm a scenario, then place an order exactly as you normally would.
# Consume $9.87 of the next order, whatever it authorizes
curl -X POST $PARITY_BASE/api/v1/sandbox/scenarios \
-H "Authorization: Bearer $PARITY_KEY" \
-H "Content-Type: application/json" \
-d '{"kind":"partial_fill","fillAmountMinor":987}'
# Then quote and submit a $25.00 order as usual. It comes back:
# "status": "partially_filled"
# "operatorMoney": {
# "authorizationAmount": "25.00",
# "actualDebit": "9.87",
# "releaseAmount": "15.13"
# }authorizationAmount = actualDebit + releaseAmount, exactly, in whole minor units. Book the debit, hand back the release. Give fillFraction instead of fillAmountMinor if a proportion suits your test better; give clientOrderId to arm one specific order instead of the next, which helps when tests run in parallel. Without it, the scenario applies to the next order you place of any kind, a sell included, and to a recorded intent when its reserve is confirmed. A scenario fires once and expires after an hour.
{
"scenarioId": "6f1d2c3b-…",
"kind": "partial_fill",
"fillFraction": null,
"fillAmount": "9.87",
"clientOrderId": null,
"expiresAt": "2026-08-21T05:43:40.000Z"
}POSTneedsorders:write. Send exactly one offillFraction(strictly between 0 and 1) orfillAmountMinor(whole minor units). Anything else is400 scenario_invalid; a body that is not JSON is400 invalid_json.GET /api/v1/sandbox/scenarios(orders:read) lists what is armed, unconsumed and unexpired as{ "scenarios": [ … ] }, each in the shape above. Add?disarm=<scenarioId>to remove one first; an unknown id is404 scenario_not_found.
A win, a loss, or a void
Resolve one of your own open positions and the ordinary settlement runs against it.
curl -X POST $PARITY_BASE/api/v1/sandbox/resolutions \
-H "Authorization: Bearer $PARITY_KEY" \
-H "Content-Type: application/json" \
-d '{"positionId":"5e0c2a91-…","resolution":"WIN"}'
# A settlement record appears on /api/v1/settlements carrying an exact
# settlementCredit (or voidCredit for a VOID). Book that figure.const response = await fetch(`${process.env.PARITY_BASE}/api/v1/sandbox/resolutions`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.PARITY_KEY}`,
'Content-Type': 'application/json',
},
body: '{"positionId":"5e0c2a91-…","resolution":"WIN"}',
});
console.log(response.status, await response.json());import os
import requests
response = requests.post(
f"{os.environ['PARITY_BASE']}/api/v1/sandbox/resolutions",
headers={
"Authorization": f"Bearer {os.environ['PARITY_KEY']}",
"Content-Type": "application/json",
},
data='{"positionId":"5e0c2a91-…","resolution":"WIN"}',
)
print(response.status_code, response.json())using var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post,
$"{Environment.GetEnvironmentVariable("PARITY_BASE")}/api/v1/sandbox/resolutions");
request.Headers.TryAddWithoutValidation("Authorization", $"Bearer {Environment.GetEnvironmentVariable("PARITY_KEY")}");
request.Content = new StringContent("""{"positionId":"5e0c2a91-…","resolution":"WIN"}""");
request.Content.Headers.Remove("Content-Type");
request.Content.Headers.TryAddWithoutValidation("Content-Type", "application/json");
var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");<?php
$ch = curl_init(getenv('PARITY_BASE') . '/api/v1/sandbox/resolutions');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('PARITY_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => '{"positionId":"5e0c2a91-…","resolution":"WIN"}',
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_RESPONSE_CODE), ' ', $response, PHP_EOL;{
"positionId": "5e0c2a91-…",
"resolution": "WIN",
"alreadyRequested": false, // true on a retry of the same outcome
"settled": true, // settled in this call, not left for the sweep
"reason": null // why not, when settled is false
}- Needs
settlements:readororders:write.resolutionis matched case-insensitively. - Refusals:
400 invalid_json(not JSON),400 invalid_body(positionIdorresolutionmissing or invalid),400 position_not_open(the position cannot be resolved),404 position_not_found(no such position of yours),409 resolution_conflict(already set to resolve differently), and403 sandbox_onlyon a live tenant.
WIN and LOSS are relative to the position's own side, so you need not work out whether a NO holder wins on a NO resolution. A VOID refunds according to the same money contract a real void would.
Retrying, which is the part worth testing hardest
Ask for the same resolution twice: the second call succeeds and there is still one settlement record, which is how a safe retry behaves. Ask for a different resolution and you get 409 resolution_conflict instead of a rewritten settlement.
When the call answers settled: false, the outcome is still recorded and reason says why it could not settle yet. Parity retries it on the next settlement pass, every few minutes, and the settlement record appears then. You can also send the same request again to retry at once.
These name a position, never a market
Markets are shared, so a forced outcome applies to one position of yours only, never to the market. Another tenant's position id answers 404, like an id that does not exist.
When the sandbox has nothing left to teach you
The move to a live key has its own page: Going live gives the sequence to work in, the checks to pass first, and what differs once the tenant is live. What you proved here about idempotency, recovery, settlement and errors carries over unchanged.