Authentication
One credential identifies the operator; one header identifies the player. Parity never authenticates an end user and holds no personal data about them.
Every partner request
Authorization: Bearer pk_test_... # sandbox. Live keys are sk_live_...
X-Parity-User: <your own id for this player>
Content-Type: application/json| Header | Required on | Meaning |
|---|---|---|
Authorization | Every /api/v1/* request | The operator credential. Bearer scheme only. |
X-Parity-User | POST /api/v1/quotes, POST /api/v1/orders, POST /api/v1/funding/deposit-address | Your opaque id for the player, and the only record Parity keeps of them. An earlier name for this header is still accepted on the same routes; send this one. |
Swipe the table sideways for more columns.
The funding route in that list is sandbox only and answers 403 sandbox_only for a live operator, along with the other funding routes, the /api/v1/sandbox/* test controls, GET /api/v1/users/{id}/balance and GET /api/v1/users/{id}/ledger. They use a balance held by Parity, which a live operator does not have because its customers' cash is on its own books. The scope lets a sandbox key reach them; it does not open them in production.
Two routes take no operator key because the browser calls them directly. GET /api/v1/images/{id} serves event artwork for an <img src>. GET /api/v1/stream/prices is an EventSource; it accepts an embed session token (not a key) and uses it only to choose whose offering policy filters the feed.
Missing the user header is a 400, not a 401
A request with a valid key and no X-Parity-User returns 400 missing_user: the credential is fine, the request is incomplete.
What X-Parity-User actually is
Parity does not authenticate end users or issue them credentials, and knows nothing else about them. You establish who the player is; the header carries your opaque id for them.
- A write creates the user on first use: the first quote or order for an id registers it. There is no separate “create player” call.
- A read never creates one. On the settlement register, the reconciliation feed and the two sandbox balance reads, an id that has never traded returns
404 unknown_userinstead of an empty page, so a mistyped id is not mistaken for a player with nothing. - The order and position lists are the exception. They apply
externalUserIdas a plain filter, so an unknown id returns an empty page there rather than a404. Check the id before concluding a player holds nothing. - Every read keys on your id, never on a Parity uuid, so you store one identifier per person.
- The id is scoped to your operator. Two partners may use the same string for different people with no collision.
How keys behave
- A key is shown once, when it is created. Parity stores a SHA-256 hash and a short non-secret prefix, so a key cannot be recovered.
- The prefix (the first 16 characters,
pk_test_XXXXXXXXorsk_live_XXXXXXXX) is safe to show in a dashboard or a log. It tells you which key to revoke and cannot authenticate anything. - Revocation is a timestamp, never a delete. A revoked key returns
401 revoked_keyand stays on the record. - An operator that is not active gets
403 operator_suspended, even with a valid key. Any status other than active gets this answer, not only a suspension. - An archived operator gets
403 operator_archivedon every request. - Parity issues your keys, and revokes them or changes their rate limits on request. Each key is shown once, when it is issued. No API key can create or manage another, so a leaked key cannot mint more.
- The prefixes are easy to search for, so secret scanners catch a committed key.
The prefix reports the mode; it does not decide it
Sandbox keys start pk_test_… and live keys sk_live_…. The tenant's mode, not the key string, decides whether a request is a sandbox request, so no key or parameter can reach the other environment.
| Response | Code | Meaning |
|---|---|---|
401 | missing_credentials | No Authorization header, or not a Bearer token. |
401 | invalid_key | The key is not recognised. |
401 | revoked_key | The key was revoked. |
403 | operator_suspended | The operator account is not active. |
403 | operator_not_permitted | Aggregators only: x-parity-operator names an operator this key may not act for. See below. |
Swipe the table sideways for more columns.
Scopes
Every /api/v1 route names the scope it needs, checked before the handler runs. A key without it gets 403 insufficient_scope with the needed scope in required. Two routes need more than one: POST /api/v1/embed-sessions and DELETE /api/v1/embed-sessions/{id} need markets:read, quotes:write and orders:write together, and answer with required and missing as arrays.
A few routes accept any one of several scopes: a customer's limits and status are read with orders:read or orders:write, and the statement and the audit trail with any read scope listed for them. Their refusal still names one scope in required, and lists every one that would pass in acceptedScopes.
An empty scope list grants nothing
A scope must be listed to be granted.
The table below is a summary. The complete, generated route-by-route scope list is on Rate limits, built from the OpenAPI document so it stays current.
| Scope | Routes it opens |
|---|---|
markets:read | GET /api/v1/events, GET /api/v1/events/{id}, GET /api/v1/categories, GET /api/v1/users/{id}/jurisdiction |
quotes:write | POST /api/v1/quotes |
orders:write | POST /api/v1/orders, POST /api/v1/orders/{id}/confirm-reserve, POST /api/v1/orders/{id}/cancel, PUT /api/v1/users/{id}/jurisdiction, every method of /api/v1/users/{id}/limits and /api/v1/users/{id}/status, POST /api/v1/embed-sessions and DELETE /api/v1/embed-sessions/{id} (with the two scopes above as well), and the sandbox-only scenario control |
orders:read | GET /api/v1/orders, GET /api/v1/orders/{id}, the confirmation, the reads of a customer's limits and status, the customer statement, the audit trail, and the sandbox-only scenario list |
positions:read | GET /api/v1/positions, GET /api/v1/positions/{id} |
settlements:read | GET /api/v1/settlements, GET /api/v1/settlements/positions, the customer statement, and the sandbox-only resolution control (which orders:write also reaches) |
ledger:read | GET /api/v1/reconciliation, GET /api/v1/reconciliation/feed, and the sandbox-only balance and movement reads |
funding:write | The sandbox-only funding routes. |
players:read | GET /api/v1/players/activity, GET /api/v1/players/{id}/activity: what your players viewed, priced and traded |
Swipe the table sideways for more columns.
A key minted without an explicit list gets the first eight scopes above. players:read is never granted by default: it is added when you ask for the player activity feed.
Scope is checked before the rate limit is consumed
Waiting does not fix a wrong scope, and spending quota on it would turn a 403 into a 429 on retry, which looks like a different bug. The order is key, then scope, then limit, then tenant mode.
Idempotency
Orders are idempotent on clientOrderId, scoped to the operator and the player. The guarantee comes from a unique index on (operator, user, clientOrderId), so two simultaneous requests produce one order.
POST /api/v1/orders { "quoteId": "...", "clientOrderId": "ticket-9031" }
→ 201 { ..., "idempotentReplay": false } first call, order created
POST /api/v1/orders { "quoteId": "...", "clientOrderId": "ticket-9031" }
→ 200 { ..., "idempotentReplay": true } same order returned- Derive the key from the reservation in your ledger (your ticket id), not from a clock or a random value per attempt. A retry must send the same string.
- A rejected order still uses up its
clientOrderId, so retrying a spent key cannot open a second live order.
Idempotency is keyed on clientOrderId
Idempotency comes from the resource, not an Idempotency-Key header: clientOrderId for placing an order, and the order itself for confirm-reserve and cancel. A second confirmation yields one executable order, and a second cancel replays the same cancellationId and the same releaseAmount. After a lost response, send the same request again. Reusing a clientOrderId for a different order is the only conflict: 409 idempotency_conflict.
Rate limits
Two per-minute limiters run on every /api/v1 route: one per key, and one per operator across every key it holds. Most responses, successes and refusals alike, carry RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset for the key. The quote and order routes carry them too. No header reports the tenant counter. Details are on Rate limits.
Embed sessions
Your API key is a server credential and must never reach a browser. To mount Parity Embed, exchange it on your server for a short-lived session for one customer. This section covers the credential; the full integration is on that page.
curl -X POST $PARITY_BASE/api/v1/embed-sessions \
-H "Authorization: Bearer $PARITY_KEY" \
-H "Content-Type: application/json" \
-d '{"externalUserId":"your-customer-id","returnOrigin":"https://your-app.example"}'
# → { "token": "pes1.…", "expiresAt": "…", "expiresInSeconds": 900, … }const response = await fetch(`${process.env.PARITY_BASE}/api/v1/embed-sessions`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.PARITY_KEY}`,
'Content-Type': 'application/json',
},
body: '{"externalUserId":"your-customer-id","returnOrigin":"https://your-app.example"}',
});
console.log(response.status, await response.json());import os
import requests
response = requests.post(
f"{os.environ['PARITY_BASE']}/api/v1/embed-sessions",
headers={
"Authorization": f"Bearer {os.environ['PARITY_KEY']}",
"Content-Type": "application/json",
},
data='{"externalUserId":"your-customer-id","returnOrigin":"https://your-app.example"}',
)
print(response.status_code, response.json())using var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post,
$"{Environment.GetEnvironmentVariable("PARITY_BASE")}/api/v1/embed-sessions");
request.Headers.TryAddWithoutValidation("Authorization", $"Bearer {Environment.GetEnvironmentVariable("PARITY_KEY")}");
request.Content = new StringContent("""{"externalUserId":"your-customer-id","returnOrigin":"https://your-app.example"}""");
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/embed-sessions');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('PARITY_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => '{"externalUserId":"your-customer-id","returnOrigin":"https://your-app.example"}',
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_RESPONSE_CODE), ' ', $response, PHP_EOL;Hand that token to the browser to mount the embed. It works for one operator and one customer only, and grants none of your API key's other powers.
- Needs
markets:read,quotes:writeandorders:writetogether, because a session can browse, quote and order and a key cannot grant more than it holds. A key missing one gets403 insufficient_scopenaming which. - Short-lived: 15 minutes by default, 60 seconds to 1 hour on request. Mint a new one instead of extending one.
- Header only: send
Authorization: Embed <token>. A token in a query string is refused, because query strings end up in logs, browser history and referrer headers. - Origin-bound: with
returnOrigin, the session works only from that origin. This stops a leaked token being used on another page, though not from a terminal. - Revocable: end a session with
DELETE /api/v1/embed-sessions/{id}, using thesessionIdthe mint returned, and its next request gets401 session_revoked. Sending it again returns200with the originalrevokedAt. To stop a customer in every session at once, suspend them (their sessions then get403 user_suspended).
Your offering policy governs the embed automatically
The session identifies you, so your offering policy applies to browsing, the live price stream, quoting, ordering and any market id entered by hand. A market you do not offer never reaches the browser. You have nothing to filter.
How requests are secured
- Requests to Parity are authenticated with your API key over TLS. Webhooks Parity sends you are signed; see Webhooks.
- The key is the whole credential: whoever presents it acts as you, from any address. Keep it in a secret manager on your servers.
- Call
/api/v1from your servers, not a browser. A browser reaches Parity through the embed, with an embed session.
With the SDK
The TypeScript client takes the key once and sets the player header for you, so the two identities cannot be mixed up.
import { ParityClient } from './parity-sdk'; // the client Parity provides
const parity = new ParityClient({
baseUrl: process.env.PARITY_BASE!,
apiKey: process.env.PARITY_KEY!, // pk_test_… in sandbox
});
// Catalogue reads need no player.
const events = await parity.listEvents({ category: 'economy', limit: 10 });
// Anything that trades is bound to YOUR id for the player.
const player = parity.forUser('user-4471');
const quote = await player.quoteBuy({ contractId, side: 'YES', stake: '50.00' });A missing scope surfaces as a typed InsufficientScopeError carrying required. See the SDK.
The public demo surface
/api/demo/quotes and /api/demo/orders take no credentials. They run the same pricing and order code as the partner routes, under a demo operator.
Read this
Do not build against /api/demo/*. It is unauthenticated and identifies a visitor by a cookie, not by a credential you hold.
Aggregators: one key, many operators
If you resell Parity to your own downstream operators, you hold one key and name which operator each request is for. Send x-parity-operator carrying that operator's id or its slug, alongside your usual x-parity-user. Omit it, or name your own id, and nothing changes: you are an ordinary direct tenant. In the SDK, pass operatorId to the client, or call forOperator(id) for a client per operator.
GET /api/v1/operators/children lists the operators your key may act for, with the id and slug to send and whether each one is actable now, so you never need the ids out of band.
To read every operator at once, add ?scope=children to GET /api/v1/orders, /positions or /settlements and leave x-parity-operator out: the list holds your own rows and your direct child operators' in your mode, and each row carries operatorId. Without it a read covers one operator, exactly as before.
A key may act for itself and for operators it is the direct parent of. Naming any other operator is 403 operator_not_permitted, and the refusal does not say whether that operator exists, so it cannot be used to discover other tenants. A downstream operator that is suspended or archived is refused with 403 operator_suspended or 403 operator_archived, even through your key.
Your key acts only for operators in its own mode: a sandbox key for sandbox operators, a live key for live ones. Naming an operator in the other mode is 403 mode_mismatch, so a test system holding your sandbox key can never reach a live operator's real money.
Each downstream operator is a full tenant with its own offering, limits, display currency, language, fees and reporting. The per-key rate limit is metered per acting operator, so one busy client cannot use another's budget. The tenant ceiling is counted against the operator holding the key, so all your downstream operators share it.
Webhooks, signing secrets and players stay per operator. One endpoint of yours can receive every downstream operator's events: ask Parity to switch on casino events for it, and every envelope names the operator it is for in operatorId (and you in parentOperatorId). Book each event against operatorId, never against the URL it arrived on, because two operators can have players with the same id. See Webhooks.
On the portal, a person with access to your account can read each of your downstream operators too, read only, with the pages their own role opens. Changing anything on a downstream operator still needs a grant on that operator.