Embed the Predictions tab
The turnkey integration: an iframe, one server endpoint, and a message listener. Parity draws the markets, the ticket and the positions; you keep the customer, the wallet and the brand. Most operators are live in days.
Embed or Headless?
Parity comes in two shapes. To add a Predictions tab to an existing casino, sportsbook or wallet, use Embed, described on this page. To build your own trading UI, use Headless, described in the rest of these docs.
| Parity Embed (recommended) | Parity Headless | |
|---|---|---|
| What you ship | an <iframe> and one server endpoint | your own UI over the API and the stream |
| Who draws the market list, ticket and positions | Parity | you |
| Server work | mint an embed session; reserve, confirm and release against your ledger | everything Embed does, plus catalogue, pricing, quoting and position rendering |
| Price feed | Parity opens it inside the frame | you open it, or you poll |
| Typical time to first order | days | weeks |
| Best for | casinos and sportsbooks adding a vertical | operators and fintechs with a trading UI already |
Swipe the table sideways for more columns.
The money architecture below is the same for both.
Sample app: a working casino in about 300 lines
A runnable casino backend and page with its own wallet. It mints the session, answers the frame, reserves and confirms each order, closes holds, credits each settlement once and verifies webhooks. No dependencies, Node 20 or later, sandbox keys only. Download sample-app.zip
The money architecture, before any code
You own your customers' only cash ledger
There is no Parity player balance. Players fund and cash out with you: Parity has no deposit or withdrawal screen and no “transfer to Predictions” step. Parity never holds a player's funds and has no route that pays one out. You tell Parity only whether a reserve against your balance succeeded.
A worked example
A customer has $100 with you and stakes $25 on a contract.
- Parity returns a quote whose
operatorMoney.authorizationAmountis"25.00". - You reserve $25 in your ledger. The customer sees
$75 availableand$25 reserved. Their total is still $100, on your books. - You tell Parity the reserve succeeded. Only success or failure crosses.
- If you cannot reserve it, you decline. Parity shows an insufficient-funds state, records no fill and sends nothing to a venue.
| Parity owns | Parity never owns |
|---|---|
| Catalogue, live pricing, quote, order, routing, fills, positions, cashout, settlement, fees, reconciliation, and the exact money instructions you apply | Player deposits, withdrawals, the general cash balance, the casino wallet, the customer account, KYC, support |
Swipe the table sideways for more columns.
Every amount Parity returns is an exact decimal string to apply as given. Do not recompute one from a price and a quantity, or your books and Parity's can disagree. Partial fills and exits are on The money contract.
How the pieces fit
YOUR PAGE (browser) PARITY
┌───────────────────────────┐
│ your header │
├───────────────────────────┤ GET /embed/predictions?operator=…
│ <iframe> ───────────────────────────▶ the Predictions surface
│ Parity draws │ GET /api/v1/stream/prices (SSE)
│ markets · ticket · │◀────────────── live prices, filtered by
│ positions │ your offering policy
├───────────────────────────┤
│ your bottom nav │
└───────────────────────────┘
│ ▲
│ │ postMessage: NO MONEY IN EITHER DIRECTION
▼ │
YOUR SERVER
POST /api/v1/embed-sessions mint a browser-safe token
POST /api/v1/quotes (optional) price it yourself
POST /api/v1/orders record a durable intent
POST /api/v1/orders/{id}/confirm-reserve "the funds are held"
POST /api/v1/orders/{id}/cancel release instruction
GET /api/v1/orders?… recoveryYou build a server endpoint that mints a session, a message listener on the page that holds the iframe, and the reserve and release wiring into your wallet. Parity builds everything inside the frame.
Provisioning
Parity provisions your tenant first. Send us the following and you receive two things back.
| You give Parity | Why it is needed |
|---|---|
Your operator slug preference, e.g. acme-casino | It is the ?operator= value in the iframe URL: lower case letters, digits and hyphens, at most 63 characters. Public, and it grants nothing: it selects your operator's frame policy, stored theme, language, region and display currency. |
| Every origin that will frame the embed | scheme://host[:port]. No path, no trailing slash, no wildcard, at most 100. Include staging. Parity registers them on your operator's embed settings; an unregistered origin cannot render the frame at all, and it cannot exchange messages with it either. |
| Your offering policy: which categories and venues you may carry | Applied server-side to the catalogue, the stream and the quote path. A market you are not offered is never sent, not sent-and-hidden. |
| Your region, and your default language | The region orders the board (which markets lead) and selects region-scoped offering rules. The language is the one the frame speaks when the iframe URL does not name one. Both are stored on your operator, so no parameter is needed on every placement. |
| Your presentation: mode, accent colour, corner radius, density | The only branding knobs the frame has. There is no font or logo setting for an operator: the frame inherits your page around it rather than re-drawing your brand. Each can also be set per placement on the iframe URL. |
Swipe the table sideways for more columns.
| Parity gives you | Notes |
|---|---|
| An API key | Scoped markets:read + quotes:write + orders:write. An embed session can browse, quote and order, so the key that mints one must be able to do all three itself. Keep it on your server. Parity turns the embed on for your operator at the same time; until it is on, the frame renders “Predictions are not available here yet.” |
| Your host | Configure it as an environment variable. A key does not encode which host it belongs to; hard-coding it is how a staging integration ends up pointed at production. |
Swipe the table sideways for more columns.
Keep the API key out of the browser
It is a permanent, operator-wide credential: anyone who reads your bundle could act for every customer. POST /api/v1/embed-sessions exchanges it for a token that expires in minutes and acts as one customer only.
1. Mint a session, server-side
POST /api/v1/embed-sessions
Authorization: Bearer <your Parity API key>
Content-Type: application/json
{
"externalUserId": "acme-user-1234",
"returnOrigin": "https://acme.example",
"ttlSeconds": 900,
"locale": "en",
"region": "us",
"jurisdiction": { "country": "MT" }
}The body is strict. An unknown field is refused with 400 invalid_request instead of being dropped, so a typo cannot mint a session configured differently from what you sent. detail names the field.
| Field | Required | Meaning |
|---|---|---|
externalUserId | yes | Your id for a customer you have already authenticated. 1 to 200 characters. Parity never authenticates end users and stores no other identifier. The same string under two operators is two different people. |
returnOrigin | no, but send it | The origin that will call the embed API with this token. Must be https (loopback http is accepted for local development) with no credentials; a path is dropped and only scheme://host[:port] is kept. It binds the session's API calls to that Origin; it does not decide who may frame the page, which is your operator's registered origin list. A session without it is usable from any page that obtains the token. |
ttlSeconds | no | An integer from 60 to 3600; default 900. A value outside the range is refused, not clamped. See Session renewal. |
locale | no | A BCP-47 shaped tag, at most 35 characters. The frame renders this customer in it: en, es, pt or hr, with a regional tag read by its language (pt-BR is pt). Any other language leaves the frame on your placement and operator settings. See Presentation. |
region | no | One of global, ar, br, mx, cl, co, pe, us, eu, hr, lower case exactly. Anything else is 400 invalid_region. It is a merchandising hook, not a jurisdiction: it orders the board this customer sees, so the markets that matter to them lead. |
jurisdiction | no | Where you say this customer is: { country, subdivision? }, an ISO 3166-1 alpha-2 country and optionally the part of an ISO 3166-2 code after the hyphen (NY). Recorded against the customer, not the session, so it outlives the token. It is what decides a jurisdiction-enforced offering; see Jurisdiction. |
theme | no | At most 32 keys; a key up to 64 characters, a value a string (up to 256), number or boolean. Stored, echoed and never a permission. The frame applies mode, accent, radius and density from it, with the same values and validation as the presentation parameters; other keys are stored and ignored. |
Swipe the table sideways for more columns.
{
"sessionId": "52dad6af-…",
"token": "pes1.<keyId>.<secret>.<mac>",
"tokenType": "embed_session",
"expiresAt": "2026-08-22T23:19:54.624Z",
"expiresInSeconds": 900,
"operatorId": "50516095-…",
"externalUserId": "acme-user-1234",
"origin": "https://acme.example",
"locale": "en",
"region": "us",
"jurisdiction": { "country": "MT", "subdivision": null },
"theme": {},
"usage": "Send as `Authorization: Embed <token>` on /api/embed/*. Never in a URL or a cookie."
}locale, region and jurisdiction are echoed as stored, and are null when not sent. theme is {} when none was sent.
The token is returned once
Only a SHA-256 of its secret is stored, so it cannot be recovered. If you lose it, mint another.
Your endpoint
Wrap the call in one route on your server that authenticates your customer with your own session, then mints. Apart from the wallet wiring, this is the only server work Embed needs.
// POST /api/parity/embed-session (on YOUR backend)
export async function POST(request: Request) {
const user = await requireSignedInUser(request); // YOUR auth, not ours
const res = await fetch(`${process.env.PARITY_HOST}/api/v1/embed-sessions`, {
method: 'POST',
headers: {
// Server-side only. This key must never be reachable from the browser.
authorization: `Bearer ${process.env.PARITY_API_KEY}`,
'content-type': 'application/json',
},
body: JSON.stringify({
externalUserId: user.id,
returnOrigin: process.env.PUBLIC_ORIGIN, // https://acme.example
ttlSeconds: 900,
}),
});
if (!res.ok) return Response.json({ error: 'session_unavailable' }, { status: 502 });
const { token, expiresAt } = await res.json();
// Return ONLY these two fields. Never proxy the whole body: it echoes your
// operatorId and the session id, and your page needs neither.
return Response.json({ token, expiresAt });
}| Refusal | What it means |
|---|---|
403 insufficient_scope | Your key is missing one of markets:read, quotes:write and orders:write. required and missing in the body name which. |
400 invalid_json | The body is not JSON. |
400 invalid_request | A field failed validation, or the body carries a field this route does not know. detail lists each problem with its path. |
400 invalid_origin | returnOrigin is unparsable, is not https (http is accepted for loopback only), or carries credentials. A path is dropped, not refused. It is checked at mint time so a bad origin fails here, not later as a session that refuses every browser request with no server-side clue. |
400 invalid_region | region is not one of the ten listed above. The match is exact and lower case, so US is refused and us is not. |
503 embed_unavailable | Embed sessions are temporarily unavailable on our side. Retry later; nothing about your request needs to change. |
500 internal_error | The session could not be minted. Safe to retry: nothing usable was issued. |
Swipe the table sideways for more columns.
2. Mount the iframe
<iframe
src="https://<your-parity-host>/embed/predictions?operator=acme-casino"
title="Predictions"
style="width:100%;height:100%;border:0"
></iframe>?operator=acme-casino is public and grants nothing. It selects your operator's frame policy and presentation defaults; all quote, order and position data requires the session token in a header. To open one market directly, frame /embed/predictions/{id}?operator=acme-casino with the event id from the catalogue.
Never put the token in the URL
Every Parity embed surface refuses ?token=. A token in a query string ends up in access logs, referrer headers, analytics and browser history for its whole lifetime.
Allowed origins
The embed document can only be framed from an origin registered against your operator. Its Content-Security-Policy lists every registered origin in frame-ancestors, and an operator with none gets frame-ancestors 'none', so the browser refuses to render the frame anywhere else. The list is per operator, not per session, and Parity changes it for you when your domain changes. The session's returnOrigin is a separate check on the frame's API calls.
- Format is
scheme://host[:port]. No path, no trailing slash, no wildcard, no scheme-less value. A new or changed origin must behttps;httpis accepted only forlocalhost,127.0.0.1,*.localhostand*.test. Anhttporigin registered before this rule keeps working until it is replaced. - Up to ten origins are supported. Register staging before you need it.
- The same list decides who the frame talks to. It sends
parity.session.requiredto each registered origin (never to'*'), acceptsparity.sessiononly from one of them, and from then on posts only to the origin that answered. - An operator with no registered origin cannot be framed. That fails visibly instead of silently allowing every origin.
Sizing: give the iframe your actual content pane
Build this first. Parity cannot know your nav height, whether you have a bottom bar or whether your header collapses on scroll, so give the frame the pane you would give any other screen. Parity handles scrolling inside it.
/*
The pane is what is left after YOUR chrome. Parity fills it and scrolls
inside it: one scroll context, no nested scrollbars, no page-level jump
when the player opens a market.
*/
.app {
display: grid;
grid-template-rows: auto 1fr auto; /* header · pane · bottom nav */
height: 100dvh; /* dynamic: survives the mobile URL bar */
overflow: hidden; /* the PAGE never scrolls; the pane does */
}
.app__header { height: 56px; }
.app__nav { height: 64px; }
.app__pane {
min-height: 0; /* without this a grid row refuses to shrink and the
iframe pushes the nav off-screen on small phones */
overflow: hidden;
}
.app__pane iframe {
display: block;
width: 100%;
height: 100%;
border: 0;
}- Prefer
100dvhto100vh. On mobile Safari and Chrome,100vhis the viewport with the URL bar hidden, so your bottom nav sits under the browser chrome until the user scrolls.dvhtracks the visible pane. - The pane is not the viewport. Subtract your chrome with a grid row as above, or with
height: calc(100dvh - 56px - 64px). - Keep
min-height: 0on the pane. A grid or flex item defaults tomin-height: autoand will not shrink below its content, so a long market list pushes your navigation off screen. - Do not add
-webkit-overflow-scrolling: touch, and setoverflow: hiddenon the page. Two stacked scroll contexts are the most common embed complaint, caused by the host page scrolling behind the frame.
Optional: auto-height
Add sizing=auto to the iframe URL and the embed emits parity.height_changed with a pixel height when its content grows or shrinks by 24 pixels or more, at most once per animation frame. Without sizing=auto (the default is pane) the message is never sent. Resize the iframe from it when the embed is a short block inside a long page.
if (data.type === 'parity.height_changed') {
iframe.style.height = `${data.height}px`;
}Not for a Predictions tab
A market list is thousands of pixels tall, so auto-height produces a very tall iframe: your header scrolls away, your bottom nav becomes unreachable, the page re-lays out on every price tick and the scroll position jumps as rows appear. Parity also cannot keep the ticket in view. Use auto-height for a small surface and the application pane for a Predictions tab.
Content Security Policy
If your page sends a CSP, it must allow the frame. Parity sets frame-ancestors on its own response; the two policies must agree or the frame stays blank.
Content-Security-Policy: frame-src https://<your-parity-host>;frame-src, notchild-src. If you support older browsers, send both.- You do not need a
connect-srcentry for Parity. The document inside the frame opens the price stream under Parity's own policy. - If a proxy, WAF or CDN sits in front of your page, confirm it passes
text/event-streamthrough unbuffered. A buffering proxy delivers prices in late batches.
Presentation: theme, language and region
Every presentation setting has a stored default on your operator and can be overridden per placement on the iframe URL. The URL wins, then your stored setting, then Parity's default. A value that fails validation falls back rather than erroring.
| Parameter | Values | Default |
|---|---|---|
mode | light, dark, inherit | inherit (no mode is forced) |
accent | #rgb or #rrggbb; URL-encode the # as %23 | none |
radius | sharp, soft, round | soft |
density | comfortable, compact | comfortable |
locale | en, es, pt, hr | see below |
region | global, ar, br, mx, cl, co, pe, us, eu, hr | see below |
sizing | pane, auto (auto-height) | pane |
Swipe the table sideways for more columns.
<iframe
src="https://<your-parity-host>/embed/predictions?operator=acme-casino&mode=dark&accent=%2300c2a8&density=compact&locale=es®ion=mx"
title="Predictions"></iframe>- These parameters are carried on every link inside the frame, so a player who opens a market keeps the same presentation.
- Branding is these four settings: mode, accent, radius and density. There is no font or logo setting. The accent's text colour is chosen automatically for contrast.
- Language is exactly one of
en,es,pt,hr. The match is exact:pt-BRis notptand falls through. The frame uses the first of:?locale=, the session'slocale, your operator's configured primary language, the language stored in your embed theme, then the browser'sAccept-Language. - Region orders the board so the markets your customers care about come first. The frame uses
?region=, then the session'sregion, then your operator's stored region, then a default. - Currency has no URL parameter. Stakes are shown in your operator's display currency, converted only through a peg or a recorded rate; see The money contract.
- Per customer, the session's
locale,regionandthemeapply as soon as the frame holds the token. Precedence is the iframe URL, then the session, then your stored settings. Language and region are rendered on our side, so the frame reloads once to apply them; the theme applies in place. parity.themefrom your page changes the theme at any time without a reload, and overrides every other source. See the message contract.
The board and layout versions
The frame draws Parity's own Predictions board: the category bar, a left rail, top moments, the markets grid, event pages and the sports lobby, filtered by your offering policy and in your theme. How the board is laid out is a named layout version, set on its own for each kind of frame.
- There are two versions.
classic-2025is the plain board every frame drew before versions existed.predictions-2026-10is Parity's Predictions board.latestalways means the newest, todaypredictions-2026-10. - Until you go live, your frame follows
latestand moves with each release, unless Parity has already pinned it for you. On the day you go live, Parity pins your frame to the version it draws, and from then on it changes only when you approve. - If your offering is decided by jurisdiction, the standard frame draws the plain board and its jurisdiction panel, whatever the layout version.
- Colours and theme stay adjustable in any version, and every security, money and data fix applies to every version.
- On the latest layout the category bar ends in a search icon. It searches the category on screen through your offering policy, and needs nothing from your page.
- Parity can send you a signed preview link that opens your frame in another layout version for a week, without changing what your players see. An unsigned or expired link shows your current layout.
- No layout version carries combos. Combos would reach a frame only as a new version, and never a frame pinned to an earlier one. See Combos (optional).
3. Hand the token to the frame
An iframe loads with a plain GET, which cannot carry an Authorization header; a cookie would expose a trading API to CSRF, and a query string leaks. So the frame carries no credential and asks your page for one with parity.session.required. Answering it is the minimum working integration.
const PARITY = 'https://<your-parity-host>';
const frame = document.querySelector('iframe');
window.addEventListener('message', async (event) => {
// ORIGIN FIRST, before the payload is even looked at. An unrecognised
// sender should cost one string compare, not a parse of whatever they sent.
if (event.origin !== PARITY) return;
const message = event.data;
if (!message || message.protocol !== 'parity.embed.v1') return;
if (message.type === 'parity.session.required') {
// YOUR endpoint from step 1. The API key stays on your server.
const res = await fetch('/api/parity/embed-session', { method: 'POST' });
const { token, expiresAt } = await res.json();
frame.contentWindow.postMessage(
{ protocol: 'parity.embed.v1', type: 'parity.session', token, expiresAt },
PARITY, // an explicit target origin. NEVER '*'.
);
}
});reasonisinitialon mount andexpiredwhen the held token stopped working (an expiry, a revocation or any other refusal of the token). Both are answered the same way: mint a fresh token and reply. The protocol type also namesrejected; handle every reason the same way. Anexpiredrequest is always preceded byparity.session.expired, so a page that wants its own reconnecting state has a moment to show it.- Answer straight away.
parity.readyis sent only after the frame accepts aparity.session, so a page that waits forreadybefore answering waits forever. - Send a fresh token. A token equal to the one the frame just had refused is ignored, and the frame stays in its reconnecting state until a different one arrives. Replacement requests are throttled to one every 5 seconds.
- Never post to
'*', which sends the customer's session token to any page that is listening. parity.sessionmay also carrycapabilities, a list of what your page handles beyond the minimum.order.cancelsays you answerparity.order.cancel_requested, and gives the customer a withdraw action on an order that has not traded. Without it the frame offers none.- Do not store the token in
localStorage, a cookie or the URL. InlocalStorageit outlives its session and every script on your page can read it.
The message contract
No monetary value crosses postMessage, in either direction
The order messages carry identifiers only: no stake, authorization or release amount.
Anything your page reads from a message event can be changed in the customer's devtools, so the browser must never be the source of a debit. Your page learns that an order was requested, and your server gets the authoritative authorizationAmount from its own Parity call.
Parity → your page
| Message | Payload | What to do |
|---|---|---|
parity.session.required | { reason: initial | expired } | Required. Mint a token and reply parity.session. Sent to every registered origin until one answers. |
parity.ready | { protocol, capabilities } | The frame accepted your token and is live. Sent once, after the first valid parity.session. Hide your loading skeleton; never gate your token reply on it. capabilities lists what the frame handles, including theme and navigate. |
parity.market.opened | { contractId, title } | Analytics, deep links, your own breadcrumb. Optional. |
parity.quote.created | { quoteId, contractId, side, stake, expiresAt } | The player is looking at a priced ticket. Optional; useful for telemetry. |
parity.order.requested | { requestId, quoteId, clientOrderId } | Required to take orders. Go to your server. See the order flow. |
parity.height_changed | { height } | Only with sizing=auto on the iframe URL. See auto-height. |
parity.session.expired | { at } | The held token was refused: it ran out, you ended it, or it was refused for any other reason a fresh token fixes. Sent once per token, immediately before parity.session.required. Show a reconnecting state if you want one. |
parity.error | { code, message } | A failure the customer can see. code is one of order_no_answer (your page did not answer an order request within 20 seconds), order_unreadable (you accepted and the frame could not read the order back) or session_refused (the session is refused for a reason a new token does not fix, such as a suspended customer). message is a fixed sentence for the code. Log it, or show your own help. |
parity.order.cancel_requested | { requestId, orderId } | Only when you declared order.cancel. The customer withdrew an order that has not traded. Cancel it from your server with POST /api/v1/orders/{id}/cancel and apply the release it returns; the frame reads the result back from Parity. See Cancellation and release. |
Swipe the table sideways for more columns.
One name per event
The protocol type also lists parity.session_expired, an alias of parity.session.expired kept so listeners typed against it still compile. The frame sends the dotted name only; treat the two as the same event.
Your page → Parity
| Message | Payload | When |
|---|---|---|
parity.session | { token, expiresAt?, capabilities? } | In answer to parity.session.required. |
parity.order.accepted | { requestId, orderId } | Your server reserved the funds and confirmed the reserve with Parity. requestId echoes the one from parity.order.requested. |
parity.order.declined | { requestId, reason, message? } | You could not. reason is one of insufficient_funds · unavailable · rejected. |
parity.theme | { mode?, accent?, radius?, density? } | Any time. Restyles the frame in place, with the values listed under Presentation. A field outside its set is ignored and the rest still apply; successive messages add up. |
parity.navigate | { to, contractId? } | Any time. to: "markets" shows the board; to: "market" opens the market whose contractId you received in parity.market.opened. to: "orders" is accepted and moves nothing, because order history belongs to your own account pages. Ignored while an order request is waiting for your answer. |
Swipe the table sideways for more columns.
requestId matches a reply to its request. Echo it exactly; a reply with an unknown requestId is dropped so it cannot answer the wrong ticket.
- A
parity.order.acceptedwithout anorderIdis ignored. The frame then reads the order back from Parity and shows itsoperatorMoney.authorizationAmount; the acceptance is only trusted once that read succeeds. - The frame keeps reading the order for about 20 seconds until it stops moving. An order that fills, as a sandbox order does when you confirm its reserve, is shown as a placed trade with what it returns if it wins; one refused or withdrawn says so. Each state comes from the read, never from your message.
- A
reasonoutside the three is shown asrejected.messageis your own words to your customer, rendered as plain text and cut at 200 characters. - If neither answer arrives within 20 seconds, the ticket shows a no-answer error. Your server may still complete the order; recover it by
clientOrderId, as in Failure and recovery. - Only messages from your registered origins are read, and once one of them has answered the handshake, only that one. That applies to every inbound message, including
parity.themeandparity.navigate. parity.navigatenames a destination and never carries an address. The frame builds the path itself, so it can only ever move within the frame.
Every message carries protocol: "parity.embed.v1". Filter on it, because your window also receives messages from devtools, analytics SDKs and payment widgets. Within a version, fields may be added but are never changed.
4. Live prices
GET /api/v1/stream/prices?contracts=ctr_a,ctr_b
Authorization: Embed <token>
Accept: text/event-stream- One connection per page, however many contracts it watches. Parity handles fan-out: a thousand browsers on one contract cost one upstream subscription.
- Frames are
hello(what you are subscribed to, and what was refused),snapshot(everything; safe to replace state with),update(only what changed; patch, never replace),heartbeat,status(the feed went stale or recovered),revoked(contracts withdrawn from a live connection) anderror. - Filtered by your offering policy before delivery. A market you may not offer is refused in
helloand its prices are never sent. - Contract ids are opaque
ctr_…. No venue name appears anywhere on this wire. - Each frame carries an
id:;EventSourcereplays it asLast-Event-IDon reconnect, so continuity is a browser feature rather than code you write.
Here the session token decides only whose offering policy applies. A connection with no credential gets the public catalogue. A connection with a refused credential is closed, not downgraded to anonymous, which would show a revoked session more than it saw while valid.
What the frame calls, and how it is refused
The frame calls these with the session token; you do not. They are listed so your monitoring and support team can read a refusal a player reports.
- The token travels as
Authorization: Embed <token>, or in theX-Parity-Embed-Sessionheader (an earlier name for that header is still read). ABeareroperator key is not accepted here. - If the session carries a
returnOrigin, a request'sOriginmust equal it. The frame's own same-origin calls, and requests with noOrigin, pass. - Rate limit: 300 requests a minute per session, and every session also counts against your operator's per-minute budget, the same one your API key draws on (see Rate limits). Over either, the answer is
429 rate_limitedwithRateLimit-*andRetry-Afterheaders.
| Status | Code | Meaning |
|---|---|---|
| 401 | missing_session | No token, or a Bearer key was sent instead. |
| 401 | token_in_query | A ?token= was sent. Refused on every embed surface. |
| 401 | malformed_token | Not the pes1 token shape. |
| 401 | invalid_token | The signature does not verify. |
| 401 | unknown_session | No such session. |
| 401 | session_expired | Past expiresAt. The frame asks you for a new one. |
| 401 | session_revoked | The session was revoked. |
| 403 | operator_suspended | Your operator is suspended. |
| 403 | operator_archived | Your operator is archived. |
| 403 | user_suspended | This customer is suspended. |
| 403 | origin_mismatch | The Origin is not the session returnOrigin. |
| 429 | rate_limited | Over the per-session or per-operator budget. |
| 503 | signing_unavailable | Embed signing is not configured. Ours. |
Swipe the table sideways for more columns.
Jurisdiction
Where your offering depends on where the customer is, Parity decides from the jurisdiction you assert, never from an IP address. Assert it with jurisdiction when you mint the session, or with PUT /api/v1/users/{id}/jurisdiction; either records it against the customer.
- If your tenant's jurisdiction rule is enforced, a customer whose asserted jurisdiction you are not offered in sees a panel explaining that predictions are not available where they are (with the country's flag when one is known) instead of the board, and the catalogue, quote and order paths refuse on the server regardless of what the frame shows.
- If the rule is not enforced, the assertion is stored and nothing is blocked by it.
- The frame also records the country of the player's IP address as evidence for your own review. It never blocks, allows or changes anything.
5. The order flow, end to end
This sequence moves money. Each step ensures you never hold a customer's reserve without being able to tell whether Parity has an executable order.
player taps BUY inside the frame
│
├─▶ embed → your page parity.order.requested { requestId, quoteId, clientOrderId }
│ (no money in this message)
│
│ YOUR SERVER
│ 1. POST /api/v1/orders { quoteId, clientOrderId, externalUserId,
│ executionIntent: "record_intent" }
│ → orderId, state reserve_pending, transmissionState not_transmitted
│ → operatorMoney.authorizationAmount ← the AUTHORITATIVE amount
│
│ 2. reserve authorizationAmount in YOUR ledger
│ ├─ cannot? → POST /api/v1/orders/{orderId}/cancel and decline
│ └─ held? → continue
│
│ 3. POST /api/v1/orders/{orderId}/confirm-reserve
│ → state pending_venue_execution (sandbox: filled, at the accepted price)
│
├─◀ your page → embed parity.order.accepted { requestId, orderId }
│ or parity.order.declined { requestId, reason }
▼
the frame renders the confirmed ticket, or an insufficient-funds stateStep 1: record a durable intent
POST /api/v1/orders
Authorization: Bearer <your Parity API key>
X-Parity-User: acme-user-1234
{
"quoteId": "qt_…",
"clientOrderId": "your-own-idempotency-key",
"executionIntent": "record_intent"
}The response carries a stable Parity orderId, status reserve_pending, transmissionState not_transmitted, and operatorMoney. Reserve operatorMoney.authorizationAmount from this server-side call, never from a browser message.
reserve_pending cannot execute
The state machine has no transition from reserve_pending to submitted, so no worker or retry can send an order until you confirm the funds are held.
clientOrderId is your id and the idempotency key. Derive it from the reservation in your ledger, not from a clock or a random value, so it survives a crash that loses our response. Re-POSTing the same id returns the same order with idempotentReplay: true, enforced by a unique index on (operator, user, clientOrderId).
Step 2: reserve, in your ledger
This step is yours alone. Move authorizationAmount from available to reserved on the customer's balance. If it does not fit, cancel and decline the order; an insufficient balance is a normal outcome, not an error.
Step 3: confirm the reserve
POST /api/v1/orders/ord_…/confirm-reserve
Authorization: Bearer <your Parity API key>
{ "reserveReference": "your-own-hold-id" }The order becomes pending_venue_execution and then moves to submitted and filled. reserveReference is optional, stored and never interpreted: it is your half of the audit trail.
In the sandbox this call fills the order on the simulated venue at the accepted price, so it returns filled, and the position settles when its market resolves. One that cannot fill at that moment (its contract has closed, or the price moved past the accepted price) comes back cancelled with the release instruction on intent.cancellation. A live order rests at pending_venue_execution for 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.
It is idempotent. Resend a call that timed out: the same confirmation twice returns 200 with idempotentReplay: true and one executable order, never a conflict.
It refuses with 409 a cancelled order, or one not awaiting a reserve (already at a venue, filled or rejected), so a 200 always means your hold backs a live order.
Step 4: answer the frame
if (message.type === 'parity.order.requested') {
const { requestId, quoteId, clientOrderId } = message;
// Your server does steps 1-3 and answers with a verdict, never an amount.
const res = await fetch('/api/parity/order', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ quoteId, clientOrderId }),
});
const result = await res.json();
frame.contentWindow.postMessage(
result.ok
? { protocol: 'parity.embed.v1', type: 'parity.order.accepted',
requestId, orderId: result.orderId }
: { protocol: 'parity.embed.v1', type: 'parity.order.declined',
requestId, reason: result.reason }, // insufficient_funds | unavailable | rejected
PARITY,
);
}| reason | Use it when | What the player sees |
|---|---|---|
insufficient_funds | the reserve did not fit the available balance | an insufficient-funds state, with your own top-up affordance outside the frame |
unavailable | your wallet, ledger or Parity call was unreachable, or Parity refused the order in a way a fresh quote can clear (see the next table) | a retryable error whose Try again starts over on a fresh quote |
rejected | your own rules said no: limits, self-exclusion, jurisdiction, risk | a terminal refusal, not a retry prompt |
Swipe the table sideways for more columns.
A decline creates nothing
After a decline there is no fill, no position and nothing sent to a venue. A filled ticket after a failed reserve would be a position with no cash behind it.
When Parity refuses step 1
POST /api/v1/orders can itself be refused. Nothing is reserved on a refusal, so answer the frame with the reason that matches what the player can do next:
| Parity answers step 1 with | Answer the frame with | What the player gets |
|---|---|---|
409 quote_expired, price_moved, price_unverified, price_stale or line_not_available; 422 market_unavailable; 503 trading_paused or live_execution_unavailable | unavailable | “Unable to submit order right now”, or your message, with Try again. Try again drops the refused quote, asks Parity for a fresh one and, once the player confirms the new price, sends a new parity.order.requested with a new requestId, quoteId and clientOrderId. |
403 over_wager_limit, over_period_limit, over_order_limit, user_suspended or market_not_offered | rejected | A terminal refusal with no Try again. Say why in message, in the player's language. |
503 order_in_progress | no answer yet | Wait for Retry-After, resend the identical request (same quoteId and clientOrderId) and answer once it resolves. After 20 seconds without an answer the frame shows a no-answer error; its Try again repeats the same requestId, quoteId and clientOrderId, which your server must treat as the same order. |
Swipe the table sideways for more columns.
Any other refusal points at the integration rather than the market: decline it with unavailable and look the code up in Errors.
Up or down windows: spend the quote at once
On an up or down crypto contract (5 minute, 15 minute and 4 hour series) a quote stands for 5 seconds and is never re-priced. Call POST /api/v1/orders as soon as parity.order.requested arrives, before any slower work of your own.
A quote_expired or price_moved there is an ordinary outcome on a contract that moves this fast, not a fault. Decline with unavailable, never rejected, so the player's Try again takes a fresh quote.
6. Cancellation and release
{
"cancellation": {
"cancellationId": "cxl_…",
"currency": "USD",
"authorizationAmount": "25.00",
"actualDebit": "0.00",
"releaseAmount": "25.00",
"reason": "player cancelled",
"issuedAt": "2026-08-22T23:19:54.624Z",
"idempotentReplay": false
}
}authorizationAmount = actualDebit + releaseAmountexactly. Every figure is an exact integer of minor units rendered as a decimal string, andreleaseAmountis a subtraction.actualDebitis"0.00"on a cancellation. A cancelled order spent nothing, so everything comes back.- Cancelling twice returns the same
cancellationIdwithidempotentReplay: true. Key your release on that id and you release exactly once, even if the first response was lost.
When the customer withdraws in the frame: if your page declared order.cancel on parity.session, an order that has not traded shows a withdraw action. Pressing it sends parity.order.cancel_requested { requestId, orderId }; your server calls this endpoint for that orderId and applies the release. The frame reads the order back from Parity and shows it withdrawn once it is cancelled. If it is not cancelled within about 20 seconds, the customer is told the withdrawal is unconfirmed, never that it happened.
If transmissionState is unknown, do not release
A 409 with transmissionState: "unknown" means Parity asked a venue and got no answer, so the order may or may not be live. Releasing now could return money that backs a real position, and nothing would flag it later.
Keep holding the authorization. Reconciliation resolves it, and the order's operatorMoney then says what to apply. unknown never resolves to released on its own.
A 409 carrying transmissionState: "resolved" is the other refusal: the order is filled or rejected, its money is already decided, and operatorMoney on the order says what to do with it.
7. Failure and recovery
Every step recovers from an id Parity already holds.
| What failed | What to do |
|---|---|
| The POST /orders timed out | Resend it with the same clientOrderId. The unique index replays the original order rather than opening a second. |
| The confirm-reserve timed out | Resend it, or read the order back. A confirmation of an already-confirmed order returns 200, not an error a retrying integration would treat as fatal. |
| The cancel timed out | Resend it. The instruction was issued once and is replayed verbatim: same id, same amount. |
| You lost the response entirely | GET /api/v1/orders?externalUserId=…&clientOrderId=…. It reports reserve_pending or pending_venue_execution while the order waits, or the state it has since reached, such as filled, rejected or cancelled. Act on its settlementState. |
| The page reloaded mid-order | Nothing is lost. The order is durable on Parity's side and the reserve is durable on yours; the frame re-mounts, asks for a session, and reads the order back. |
You received 409 quote_already_used | The quote was spent by an order carrying a different clientOrderId. The body names that orderId; a resend of yours would have replayed as a 200 instead, so this is not a case a retry can reach. |
Swipe the table sideways for more columns.
Never release on an unknown. A timeout is not a rejection: hold the authorization and resolve it by reading the order.
8. Session renewal
- Default TTL is 900 seconds, minimum 60, maximum an hour. A token held by a browser is protected by its short life, not by secrecy.
- On expiry the embed sends
parity.session.expiredand thenparity.session.requiredwithreason: "expired", at the moment a request is refused. Mint and reply, with the same handler you already wrote. The frame also checks its session once a minute and just afterexpiresAt, so an idle frame asks in time too. - The frame does not renew ahead of time: the
expiresAtyou pass withparity.sessionis not read. If you want no visible reconnect, send a freshparity.sessionbefore the old token expires; the frame takes the newer token. - A refused token is never retried. The embed asks you for a new one, so an expiry costs one round trip, not a reconnect loop.
- Keep session lifetimes short. To stop a customer at once, suspend them from your operator portal: suspension is checked on every request, so the session's next request is refused with
user_suspended. - Mint per customer session, not per page view, and only when needed: an unused token is a live credential with no purpose.
End a session early
sessionId the mint returned.{
"sessionId": "52dad6af-…",
"revoked": true,
"revokedAt": "2026-08-22T23:19:54.624Z",
"idempotentReplay": false
}- Call it when your own session for the customer ends: sign-out, self-exclusion, or a token you believe has leaked. The frame's next request with the token is refused
401 session_revoked, and your page receivesparity.session.expiredandparity.session.required. Your server decides whether to mint a replacement. - Revoking ends that one session immediately. To stop a player, your server should also stop minting sessions for them, so the frame's request for a replacement is refused on your side.
- It needs the same scopes as minting:
markets:read,quotes:writeandorders:write. A key missing any of them gets403 insufficient_scopenaming the ones missing. - Idempotent: ending an ended session returns
200with the originalrevokedAtandidempotentReplay: true. Resend freely. - A session id belonging to another operator is
404 unknown_session, the same answer as an id that never existed. Every revocation is recorded in your audit trail with the API key that made it.
9. Settlement
Settlement works the same in Embed and Headless. The frame cannot do it for you, because crediting a winner is a movement in your ledger.
- Poll
GET /api/v1/settlements. Each record carries the exact figure:operatorMoney.settlementCreditfor a winner,operatorMoney.voidCreditfor a cancelled market, fee included. - Every record is safe to apply twice: key on the settlement
id. - Stop on
hasMore, not on the cursor. The last page still returns a cursor (a watermark to resume from), sowhile (nextCursor)never ends. GET /api/v1/reconciliationis the verdict on whether your books and ours agree, andGET /api/v1/reconciliation/feedis the totally-ordered fact stream behind it.
Details are on Settlement and Reconciliation. How an order executes, and how the sandbox differs, is on How Parity works.
Before you go live
- The API key is server-side only. Search your bundle for its prefix to confirm.
- Every production and staging origin is registered, and your CSP names
frame-src. - The iframe gets your real content pane, with
100dvhandmin-height: 0, and the host page does not scroll behind it. parity.session.requiredis answered for every reason,initialandexpiredincluded, without waiting forparity.ready.- The region you send, on the session and on the URL, is lower case and one of the ten listed; the language is
en,es,ptorhr. - If your offering is jurisdiction-enforced, every session carries the customer's
jurisdiction. clientOrderIdcomes from your ledger, not a clock, and a replayed POST is handled as success.- A failed reserve declines with
insufficient_fundsand never with a fabricated accept. - A cancel is keyed on
cancellationId, andtransmissionState: "unknown"holds rather than releases. - Settlement polling stops on
hasMore, and credits are keyed on the settlement id. - You have worked through Going live, which covers what to prove before the key changes.