# Euro365 Sports Odds API — integration brief for AI agents

> **You are an AI coding agent.** This file is the complete, self-contained specification for integrating the Euro365 Sports Odds API (live and pre-match odds, scores, settlements, a live match-tracker widget) into a customer's platform. Read it top to bottom, then build the integration in the order of the **Plan** section. Everything you need is here; the human-readable docs at https://api.euro365.bet/docs/ say the same things with more prose. Do not invent fields, endpoints or behaviours that are not in this file. Where the customer has not told you something (language, framework, database, which sports, REST polling vs WebSocket), **ask once, then proceed**. Never print, log or commit the API key.

Version: 2026-09-20. Canonical URL of this file: `https://api.euro365.bet/docs/agent.md`

---

## 0. What you are integrating

Euro365 is a B2B sports-data feed: **pre-match and live odds, scores and event data for 25+ sports**, one API key, consumed over REST, WebSocket, or a legacy RDSTN passthrough. Optional add-ons on the same key: a **Live Match Tracker widget** (iframe) and **Live TV streams**. Billing is prepaid credit drawn down per request (managed in the portal); a free **sandbox key** works on every endpoint.

The integration has four parts. Build them in this order:

1. **Event index** — sports, live and pre-match fixtures, kept fresh.
2. **Prices** — `GET /v1/odds` for the events on screen, decoded and rendered with suspension handling.
3. **Scores & real-time** — `/v1/scores` polling, or the WebSocket as a refresh trigger.
4. **Settlement** (if the customer accepts bets) — `/v1/settlements` after full time, under the binding Settlement Policy.

Optional: the tracker widget (`/widget`) and live streams (`/v1/streams`, `/v1/stream`).

---

## 1. Facts you must get right

| Item | Value |
|---|---|
| Base URL | `https://api.euro365.bet` |
| Auth | header `X-API-Key: <API_KEY>` on every request (equivalent fallback: `?api_key=` query param). WebSocket handshakes take `?api_key=` because browsers cannot set headers. Server-to-server only — **never ship the key in browser JavaScript or a mobile binary**; proxy from the backend. The only exceptions are the widget iframe `src` and `/ws-widget`, which are designed to carry the key in the URL. |
| Keys | Live keys `ek_…`; sandbox keys `ek_test_…`. Sandbox = same endpoints, identical responses, 60 requests/minute, no charge, no expiry, webhook callbacks carry `"sandbox": true`. Get both from https://api.euro365.bet/portal (sign up at `/portal?register=1`). |
| Envelope | success = HTTP 200 + `"success": true` + `"data"`. Errors = non-2xx + `{ "error": "<string>" }`. |
| Prices | integers = **decimal odds × 100** (`125` → 1.25, `1300` → 13.00). |
| Money / currency | none on the wire — this is a data feed, not a wallet. |
| Timestamps | `ts` fields are unix **milliseconds** unless the doc says seconds (`kickoff` and event `ts` = kickoff are unix **seconds**). |
| Rate limit | no rate limit while the key has credit (same unlimited rate and live speed on every plan; 1,000,000 req/min abuse guard). Only REST calls are charged (EUR 0.0002 each); WebSocket pushes are free and not counted. Credit at 0 → free tier, 10 req/min, data calls `402 {"error":"wallet_empty"}` until the next top-up. Sandbox keys: 60 req/min. Per key, 60 s bucket. `429` body: `{ "error": "Rate limit exceeded", "limit": 60, "window": "60s", "retry_after": 37 }` — sleep `retry_after` seconds, then retry. |
| WebSocket cap | **5 concurrent connections per key**. Extra handshakes are closed with `{"error":"Too many WebSocket connections for this API key"}`. Open connections from the backend and fan out yourself — never one per browser. |
| Batch limit | `/v1/odds` and `/v1/settlements` take at most **100 ids** per request. |

HTTP status meanings: `400` missing/malformed parameter · `401` invalid or disabled key · `403` key lacks a permission (widget / stream) · `404` unknown route (an unknown event id on `/v1/event` answers 200 with `success:false`, see 3.x) · `429` throttled (honour `retry_after`) · `500` server error (exponential backoff, report if persistent). `GET /health` (no auth) → `{ "status": "ok", "uptime": <seconds> }` is the liveness probe for your monitoring; `GET /v1/status` is the authenticated one with counters.

---

## 2. Identifiers

**Event id**: `s2-43.133873042` = `s2` (constant provider prefix) + `43` (source channel) + `.133873042` (**the canonical numeric id — unique and stable; the only part you truly need**). Inside an event's `map` the same id appears with a binding letter: `s2_l43.…` (live) or `s2_p43.…` (pre-match). Every endpoint that takes an id accepts the full key, the binding-prefixed key, or the bare numeric tail. Store the full key as returned; match on the numeric tail when in doubt.

**Fixture identity contract (IDENTITY_V1, 2026-10-20).** (1) *Stable id*: `s<provider>-<channel>.<N>` where `N` is the upstream game number. The same `N` is used from the first pre-match listing through live play and after full time; the binding letter (`_p` / `_l`) appears only inside `map` keys, never in the id you store. Ids are never re-issued. (2) *Duplicates and canonical id*: upstream sometimes lists one match under several `N` (PSG–Barcelona 20 Oct 2026 under five). Rows are grouped on the exact tuple (home, away, kickoff ts, league_id, sport_id — GROUP_SPORT_V1: league ids are not a sport-unique namespace, 8 of 6,732 appear under more than one sport) and one member is pinned as `canonical_fixture_id`: the group's existing pin if there is exactly one; else the single member that already has grading history; else the lowest id. A pin is append-only — it is never moved silently. (3) *Exposure*: `/v1/settlements` (both envelopes), `/v1/scores` and the verify payload return `canonical_id` when the id you asked for is an alias, and `aliases[]` (the other members) on every member; alias chains are collapsed, an alias always points straight at the canonical; the alias index is rebuilt from every duplicate group and every recorder pin of the last 14 days (ALIAS_V3, 2026-10-21), so the outer `canonical_id` and `identity.canonical_id` are the same pin. **One resolver (CANON_RESOLVE_V1, 2026-10-28):** `/v1/settlements` (plain and `with_revision=1`), `/v1/fixtures`, the settlement intake and the in-play verdict store all resolve the canonical with the recorder's rule above (the group's pin when there is exactly one — also when the pinned listing's kickoff later moved out of the group; the member's own id for a `pin_split` / `history_split` group; else the single member with history; else the lowest id); the alias index is used only for ids the fixture table does not know yet. `identity.canonical_basis` names the rule (`group_pin` | `pin_split` | `history_split` | `history` | `lowest_id` | `alias_index` | `self`). Before this, plain settlements and `/v1/fixtures` could name a different canonical than the revision envelope (e.g. s9-99.765100278: self vs s9-99.764003529). Receipts and in-play `lock_id`s already issued are never re-bound or renamed. Any member id returns the same final score, the same market verdicts and the same revision number. (4) *Binding*: a fixture is bound to sport, competition (`league_id`), participants (home, away) and kickoff. Two meetings of the same teams at different kickoffs are different fixtures and are never aliased. (5) *Limits*: grouping is exact on the kickoff second — two listings of the same match whose kickoffs differ by seconds are not aliased; each id then settles on its own evidence, and a selection accepted under either id settles under that id. (6) *Conflicts and corrections*: if a group already carries grading history under more than one id (`history_split`) or more than one pin (`pin_split`), the recorder refuses to re-pin; each id keeps itself as canonical and settles independently; the conflict is logged for manual repair. There is no API signal for "alias X was re-pointed" because pins are not re-pointed; result changes are exposed only through `revision` / `correction` in `with_revision=1`. (6b) *Kickoff*: `kickoff_ts` is the start time upstream published when the listing was first catalogued; it is the grouping value and only moves while the match has not ended (KICKOFF_FOLLOW_V1 follows upstream changes within 6 h). When the live feed currently reports a different start time, the identity block adds `kickoff_ts_feed` (the current upstream value) and `kickoff_note`. A duplicate listing whose catalogued kickoff differs from the others is not aliased to them (limit 5); if both records already carry grading history they stay separate (conflict containment) and each answers its own final. (7) *Binding fields*: every `/v1/settlements` fixture (both envelopes) and `GET /v1/fixtures?ids=` carry an `identity` block `{fixture_id, sport_id, league_id, league_name, country, country_iso, home, away, kickoff_ts, canonical_id, canonical_basis, record_status, group_key}` (IDENTITY_BLOCK_V1 / FIXTURES_V1 2026-10-20). When the queried id is an alias, `kickoff_ts` is the canonical's and `requested_kickoff_ts`, `kickoff_delta_s` (canonical minus requested, seconds) and `kickoff_basis:"canonical"` describe the difference; they appear only when the canonical's own record was read (CANON_RESOLVE_V1 2026-10-28 — before, a missing canonical record produced a false `kickoff_delta_s: 0`). `country_iso` is an ISO 3166-1 alpha-2 code in upper case or `null` (COUNTRY_ISO_V1 2026-10-28: the stored upstream value is usually the sport name, e.g. "soccer", and is no longer passed through). (8) *Recovery after FT*: final score precedence is an ended row of any group member, then the durable verified history row of the canonical or any other group member (`score_source: "es_match_history:<id>"`; group-wide since 2026-10-28, as `/v1/fixtures` already did), then the queried id's own row, then the canonical's; a live row that outlived the canonical's full time is reported as `superseded_live_row` and ignored; markets come from the last non-empty live board (numeric market groups only — LASTBOARD_NUMERIC_V1), retained 48 h.

**Sport ids** (use wherever `sport=` is accepted; `GET /v1/sports` tells you which currently have events): 1 Soccer · 2 Basketball · 3 Baseball · 4 Ice Hockey · 5 Tennis · 6 Handball · 7 Volleyball · 9 Golf · 10 Boxing/MMA · 12 Rugby League · 13 Aussie Rules · 16 American Football · 17 Cycling · 20 Table Tennis · 21 Cricket · 22 Darts · 26 Waterpolo · 29 Futsal · 39 Lacrosse · 40 Formula 1 · 117 MMA · 190 Moto GP · 306 Bowling · 312 Rugby Union.

**Market and outcome ids** are integers resolved through `GET /v1/markets` (4,873 markets / 17,227 outcomes, refreshed hourly). Never hard-code names; a quick-glance soccer subset (verified against live `/v1/markets?sport=1` and `/v1/odds`, MKT_IDS_V1 2026-11-08): 1001 1x2 (outcomes 2001 `1` / 2002 `x` / 2003 `2`); 1005 Double Chance (2040 `1x` / 2041 `12` / 2042 `x2`); 1007 Both Teams To Score (2047 yes / 2048 no); 1009 Draw No Bet; 1018 Total Goals Over/Under (2081 over / 2082 under); 1019 Total Goals Odd/Even (2083 odd / 2084 even); 1004 Handicap (European, 3-way, line keys like `s1:0`); 1012 1st Half / Fulltime (HT/FT); 1014 1st Half 1x2; 1054 1st Half Total Goals Over/Under. Asian lines: 1011 Asian Handicap (2057 `1` / 2058 `2`); 1021 Total Goals Asian Over/Under (2087 over / 2088 under); 1015 1st Half Asian Handicap; 1020 1st Half Total Goals Asian Over/Under; 1060 2nd Half Asian Handicap; 1053 2nd Half Total Goals Asian Over/Under; 2417 / 2424 Asian Handicap Main Line full match / 1st half; 2418 / 2420 Home / Away Team Total Goals Asian Over/Under; 1313 / 1314 are the Extra Time versions. (Before 2026-11-08 this list wrongly gave 1005 Asian Handicap, 1007 O/U, 1019 BTTS, 1009 Double Chance, 1021 DNB, 1012 Correct Score, 1004 HT/FT.)

**Correct Score - Group Bet — market 1003265 (GROUP_CS_V1, 2026-11-08).** Football, prematch and live (regulation time). One market, line key `s`, one outcome per group of three correct scores; the outcome name lists the scores as `h:a / h:a / h:a` (home goals first) and the bet WINS when the regulation final score equals any of the three, otherwise LOSES. Outcome ids are stable: 70010417 `0:0 / 1:0 / 0:1`, 70010418 `0:1 / 0:2 / 0:3`, 70010419 `0:4 / 0:5 / 0:6`, 70010420 `1:0 / 2:0 / 3:0`, 70010421 `1:2 / 1:3 / 1:4`, 70010422 `2:1 / 3:1 / 4:1`, 70010423 `2:3 / 2:4 / 3:4`, 70010424 `3:2 / 4:2 / 4:3`, 70010425 `4:0 / 5:0 / 6:0` (70010426 `0:0 / 0:1 / 1:0` is a rare re-ordered upstream variant). Names come from `/v1/markets?sport=1` (market 1003265). Example `/v1/odds` fragment: `"1003265": {"s": {"70010420": [360, 0, null, 1794157565254], "70010422": [400, 0, null, 1794157565254]}}` = `1:0 / 2:0 / 3:0` at 3.60 and `2:1 / 3:1 / 4:1` at 4.00. Settlement: `/v1/settlements`, intake and `/v1/grade` grade it from the regulation score (a 2:1 final: 70010422 WIN, 70010420 LOSE); in-play preview only ever locks LOSE (once the running score has passed all three). Not the same market as dictionary 3156 "Correct Score Combined" (different groups, never published by the feed).

**Every event has a public deep-link** `https://api.euro365.bet/docs/explore?event=<id>` that reproduces every call for that match with a built-in demo key — use it in admin UIs, ticket links and support hand-offs.

---

## 3. Endpoints

### 3.1 `GET /v1/sports`
Sports that currently have events, with counts: `{ "success": true, "data": [ { "id": 1, "name": "Soccer", "live_count": 128, "prematch_count": 3142 }, … ] }`.

### 3.2 `GET /v1/live` and `GET /v1/prematch`
Query `sport=<id>` (optional). With `sport`, `data` is flat `{ "<eventId>": <event> }`; without it, `data` is grouped by sport id `{ "1": { "<eventId>": <event> }, "2": … }`. `/v1/live` also carries `ts`: unix ms at which our feed took its last live poll (a local time; it does not prove when the upstream source last changed its data). `/v1/prematch` does not carry it.

### 3.3 `GET /v1/event?id=<id>[&sport=<id>]`
One event across live and pre-match → `{ "success": true, "data": <event> }`; if the id is on neither board the answer is **HTTP 200** with `{ "success": false, "error": "Event not found" }` (always check `success`, not only the status); with `ids=` unknown ids are simply absent from `data`. Every event object also carries `"stream": true|false` here, whatever the plan.

### 3.4 Event object (same compact shape everywhere: REST, WebSocket, RDSTN)
```json
{ "s2-43.133874554": {
    "c": [66, "Georgia", 43, "ge"],          // country: [country_id, name, source_sport_id, iso2] — iso2 for flags
    "t": [570, "Erovnuli Liga", 2],           // tournament: [tournament_id, name, priority] — priority = ordering hint, NOT a sport id
    "g": 65,                                  // opaque display-bucket code
    "ts": 1779278400,                         // kickoff, unix SECONDS
    "h": "Meshakhte Tkibuli", "a": "Torpedo Kutaisi",   // home / away
    "co": 1091,                               // opaque ordering code
    "map": { "s2_l43.133874554": { "p": 0 } },// channel bindings; p = 0 available, non-zero locked
    "s": 0,                                   // score code, 0 = 0-0 / not started; use /v1/scores for live scores
    "ms": 0,                                  // match minute / status hint (optional, absent pre-match)
    "live": true, "sport": 1 } }
```
Map `c/t/h/a/ts/s/ms` to friendly names inside your adapter; the short keys keep WebSocket frames small.

### 3.5 `GET /v1/odds?ids=<id>[,<id>…]` — prices (max 100 ids)
```json
{ "success": true, "data": {
  "s2-43.133873042": {
    "1001": {                                   // market id
      "s": {                                    // line key
        "2001": [125, 0, null, 1779279999726],  // outcome id: [price×100, flags, special, ts_ms]
        "2002": [550, 0, null, 1779279999726],
        "2003": [1300, 0, null, 1779279999726] } },
    "1004": { "s0:3": { … } } } } }
```
Decoding rules — get these exactly right:
- Outcome tuple `[price, flags, special, ts]`: `price / 100` is the decimal odd; `flags !== 0` means **do not accept** (suspended / placeholder); `special` is the line value (`"-1.5"`, `"+0.5"`, `"2.5"`, or a scoreline `"2:1"`) auto-filled from the line key, `null` for plain markets; `ts` = last price change, unix ms.
- Line keys: `"s"` = the single/main line (1x2 1001, Double Chance 1005, BTTS 1007, DNB 1009, Odd/Even 1019); `"s<line>"` = handicap / total rungs (`"s+0.5"`, `"s-0.25"`, `"s2.5"`) — strip the leading `s` for the line value; `"s<home>:<away>"` = the head start of a 3-way European handicap (1004 Handicap, e.g. `"s1:0"` = home starts 1:0).
- Line objects carry outcomes only (DOCS_ODDS_SHAPE_V1, 2026-10-21: the current feed emits no line-level `s` status and no `ls` last-seen field; earlier versions of this page showed them). Freshness is the outcome tuple's own `ts`; suspension is the outcome's `flags`. A line object with no outcomes is a rung with no current prices — skip it.
- A market where every outcome's flag is non-zero (or, if ever present, line `s: 1`) is **suspended**: render greyed out and reject bets. Suspensions are common around goals / VAR / corners and usually clear within seconds.
- Rendering: `const [price, flags] = outcome; flags !== 0 ? renderLocked() : renderPrice((price/100).toFixed(2));`

### 3.6 `GET /v1/scores`
All known events (live and recently finished), keyed by event id: `home`, `away` (integers), `status` = `"live" | "ended" | "scheduled"`, `ts` (unix ms of the last feed write of this row — for live events it advances on every ~8 s poll, so it is an observation time, **not** a score-change time; track score stability yourself or use `inplay_final`), `kickoff` (unix seconds), and optionally `clock` (`"48:34"`), `ms` (elapsed minute), `period` (`"First Half"`, `"Second Half"`, `"Half Time"`, `"1st Set"`, `"Finished"`…), `match_length` (regulation minutes, e.g. 90), `injury_time` (derived elapsed overshoot past 45/90 — **not** the referee's announced board), `injury_time_announced` (the announced +N; present only for a limited set of covered soccer leagues). Cheaper than `/v1/live` when you only need the scoreboard.

**Extra time / penalties (ET_GUARD_V1, 2026-11-08).** Football and futsal: as soon as a match is beyond regulation (the source period says extra time / penalties, or the period list has 3+ segments) the score row in `/v1/scores`, `/v1/live`, `/v1/fixtures`, the in-play settlement preview and the widget keeps `home`/`away` = the REGULATION score (sum of the first two `periods` segments) and carries `full_home`/`full_away` = the aggregate including extra time (penalty shoot-out goals as the source counts them), `period` = `"Extra Time"` or `"Penalties"`, `beyond_regulation: true` and `score_basis` (`"periods[0]+periods[1]"`, or `"aggregate_unverified"` when the segments do not fit inside the aggregate). Example at 118' of a 2:2 match with one extra-time goal: `{"home":2,"away":2,"full_home":2,"full_away":3,"periods":"2:0;0:2;0:1","period":"Extra Time","beyond_regulation":true}`. No `injury_time` is reported in extra time. Ended rows keep the regulation score and also carry `beyond_regulation: true`. Odds: the source keeps the regulation market ids during extra time but prices them for extra time only (e.g. 1708 Correct Score at 1.20 for an extra-time 0:1), so from the end of regulation (including the break before extra time) every regulation-scope market is removed from the live board in `/v1/odds`; only markets whose name says extra time / penalties may stay. Regulation markets are graded from the regulation score after full time, as before.

**Actual kickoff (KICKOFF_ACTUAL_V1, 2026-10-22).** `kickoff` is the scheduled start (unix seconds) as published by the source. Live score rows also carry `kickoff_actual_ms` (unix ms) and `kickoff_actual_src`: `first_half` = football/futsal, derived from the match clock while the first half was running (the most reliable); `estimate_2h` = the match was first seen in the second half, so a 15-minute half-time break is assumed; `first_seen` = sports without a running match clock, the first time we saw the match live (an upper bound). A `first_half` value is never replaced by a weaker one. Missing = not established yet (e.g. a match first seen at half-time).
**Raw clock (CLOCK_RAW_V1, 2026-10-22).** `clock` is smoothed (it advances with wall time and catches up gradually after a source jump), and `clock_asof` is the time we WROTE the row, not the time the clock value was true. Live rows also carry `clock_raw` (the source's value, never interpolated) and `clock_read_ms` (unix ms of our FIRST read of that exact value). The source updates its clock only about every 4 s, so the value was published at most one read interval (~1.15 s) before `clock_read_ms`. For an exact running clock use `clock_raw + (now - clock_read_ms)` while the period runs.

**Instant score rows (EVENT_PUSH_V1, 2026-10-22).** A live score row is written the moment the source's per-match data changes (clock, score, periods), not on the next 1 s cycle; such rows carry `push: true`. A row is never replaced by an older read (`src_ms` only moves forward), and a live row never replaces an ended one. For the lowest delay read `/v1/scores?ids=...` (live read); the bulk answer is a shared snapshot rebuilt at most every 2 s.

**Period source (SRC_PERIOD_V1, 2026-10-23).** Football/futsal `period` (First Half / Halftime / Second Half) now follows the source's own period name, shown raw in `period_src` ("1st half", "Half-time", "2nd half"); `period_basis` is `source` when it came from that name and `derived` when the source sent none (then it is worked out from the periods count and clock). First-half stoppage time is `period` = First Half with a clock past 45:00 (e.g. 46:57) and `periods` holding ONE entry; the real break is `period` = Halftime, `periods` with TWO entries and the clock held at 45:00. Before this change stoppage time past 45:00 was wrongly labelled Halftime.

**Second-half start (SECOND_HALF_START_V1, 2026-10-22).** Football/futsal rows in the second half also carry `second_half_start_ms` (unix ms): when the second half actually kicked off, derived from the live clock (the source clock restarts at 45:00 / futsal 20:00), so it is independent of the half-time length. `estimate_2h` is only an estimate of the ORIGINAL kickoff, never of the second-half start. To run a live timer: first half `elapsed = now - kickoff_actual_ms`; half-time (`period` = Halftime) freeze at 45:00; second half `45:00 + (now - second_half_start_ms)`. Simplest and exact: show `clock` and advance it by `now - clock_asof`, re-syncing on every row.

**Score source (EVENT_FAST_LANE_V1, 2026-10-21).** Every live score row carries `src` and `src_ms`. `src:"event"` means the row was built from the source's per-match data, re-read for every live match about every 3-4 s. `src:"list"` means the source's live list, which the source regenerates only about every 10 s. `src_ms` is when we read that data (unix ms). `ts` remains the time we wrote the row. `ts - src_ms` is our own processing time; it does not include the source's own delay from the venue, which the source does not publish.

**Freshness (SCORES_SNAPSHOT_AT_V1, 2026-10-21).** `?ids=` reads each row live (`source:"live"`, `read_at_ms`). The bulk answer (no `ids`, optional `sport`) is a shared snapshot rebuilt at most every 2 s (`source:"snapshot"`, `snapshot_at_ms`, `read_at_ms`); its clock is interpolated when the snapshot is built. Both read the same stored row per id (an alias without its own row gets its canonical's), so for the same id the row with the newer `ts` is the current one; a bulk value can trail a targeted read by up to ~2 s plus the time between your two calls.

**Lifecycle (SCORES_RECONCILE_V1, 2026-10-20).** `/v1/scores` is the live view. A row is `live` while the feed writes it; a match that leaves the live list without a full-time flag keeps its last live row until the reconciler (every 60 s) replaces it with the group's final — `status:"ended"`, final `home/away`, `score_source` (`redis:<member>` or `es_match_history:<member>`), `canonical_id` when the row is an alias, and `superseded_live_row {home, away, ts, clock}` with the row it replaced — within ~11 minutes of the last live write. A live row with no final after 3 h carries `stale:true` + `stale_since`. Ended rows leave the hash 72 h after full time; the durable final is always `/v1/settlements` (or `/v1/fixtures`). A canonical id whose own live row never existed is answered through its aliases' rows (`canonical_id`/`aliases[]`).

### 3.7 `GET /v1/settlements?ids=<id>[,…]` (max 100; aliases `event_id`, `fixture_id`; optional `include_inplay=1`)
Deterministic win / lose / void / pending per outcome for **ended** events, from the final regulation-time score. Response per event: `fixture_id`, `status`, `score {home, away}`, `settled_at`, `coverage {covered, void, pending, markets}`, and `markets[mid].lines[lineKey].outcomes[oid] = { "name", "result": "win"|"lose"|"void"|"pending", "reason"? }`; the envelope carries `"version": "v1"` and `"policy_url"`. Each event carries `mode` = `"final"` or `"inplay"` when `include_inplay=1` (locked outcomes settle early; flippable markets like 1X2/DC/DNB/handicaps stay pending until FT). **In-play results are a provisional preview, not a payment authorisation**: on a live fixture `settlement_status` stays `pending` (binding rule §1a: leave the bet open, retry after FT), only lines currently on the live odds board are returned, and a locked result can revert (VAR, abandonment). Pay only from the `mode: "final"` response after full time, regardless of when the bet was placed; placement phase is not part of the rule. **Timeout-closed fixtures (STALE_SETTLE_STATUS_V1, 2026-10-28):** a fixture with no verified final whose record was closed by the 8 h timeout answers, with or without `include_inplay` / `inplay_final`, `status:"ended_unverified"`, `completion:"timeout_unverified"`, `settlement_status:"unresolved_no_evidence"` (do not settle, do not refund), `score:null`, `last_score` and `note` — the same state as `/v1/fixtures`. Before, its frozen last live row was served as `status:"live"` / `"event has not ended"`.
**Definitive in-play settlement — `inplay_final=1` (INPLAY_FINAL_V1, football phase 1, Settlement Plus).** Adds an `inplay_final` block to every live football fixture: `engine` (`inplay-final-1.1.4`), `confirmation_basis` (text of the observer-v2 rule below), `sport_supported`, `score`, `score_confirmed` / `confirm_in_s` (a score must stand unchanged 120 s before it locks anything), `half_time {home, away, final}`, `locked[]`, `corrections[]`, `locked_count`, `stands:true`. Each `locked[]` entry (`market_id`, `market`, `line`, `line_key`, `outcome_id`, `outcome`, `result` win/lose/void, `basis` full_match|first_half, `locked_at`, `score_at_lock`) is **payable before full time** and is never withdrawn: evaluated on a fixed line ladder (not only lines on the live board), persisted 72 h, stands if the match is later abandoned, and a later score reversal is reported as `disputed:true` + `corrections[]` instead of flipping it. Locked in-play: totals O/U (half, whole, Asian quarter), team totals, BTTS, correct score (lose), team exact goals (lose), clean sheet, goal bands (lose), HT/FT (HT part wrong); first-half markets lock on the running 1H score and settle completely once the half-time score is final. Never locked in-play: 1x2, DC, DNB, handicaps, combos, full-match odd/even, stat and scorer markets. Other sports: `sport_supported:false`. Quarter lines are emitted only when both halves of the leg are decided (never as a partial win/lose). Regulation score only: beyond 90 minutes the score is re-derived from the first two period segments (`beyond_regulation`, `aggregate_score`, `score_basis`); an extra-time goal never locks a regulation market. Confirmation = observed + stable (OBSERVER_V2): the engine's own per-fixture observation record, sampled every 5 s from the fixtures present in the latest upstream read, where an observation counts only when the feed wrote a NEW score row (write timestamp advanced; re-sampling a frozen snapshot is not evidence); `seen` = write time of the latest observation, `since` = first observation of the current score in a continuous run (gaps > 90 s or a score change restart it); confirmed iff `seen` ≤ 90 s old AND `seen − since` ≥ 120 s (`observation {seen, seen_age_s, since, stable_s, observations}`, `observed`, `score_stable`, `not_confirmed_reason`); the global heartbeat and the sampling clock are not evidence; observation records are namespaced by observer version so an upgrade never inherits a window. Each stored verdict carries the rule actually used: `confirmation_rule: "legacy-score-ts"` (engine 1.0.0–1.0.4, score.ts rule, 3,988 verdicts on 11 fixtures locked before the 1.1.0 process start 2026-10-20 16:52 UTC) or `"observer-v1"` (1.1.0–1.1.1, 625 verdicts on 3 fixtures; counted re-sampling as observation, no window restart after absence) or `"observer-v2"` (1.1.2+; the 261 verdicts locked under 1.1.2 predate the per-verdict observation record, their fresh windows were verified from start-time captures, see the published history note). Cache reconciliation on every read: cache entries absent from Postgres are committed first-writer-wins even when the fixture is partly populated (`storage.migrated_from_cache`); committed rows are never overwritten, disagreeing cache copies are reported in `storage.cache_disagreements`; nothing is dropped. Identity: `lock_id` = `<canonical fixture id>:<market_id>|<line_key>|<outcome_id>`, `revision:1` (immutable), `scope:"regulation"`, `score_ts` (feed row ts at lock time, audit only), `confirmation_rule`, `engine` and `observation {seen, since, observations, stable_s, observer_version}` stored on the entry at lock time (provenance and justifying observation persisted, never inferred). Persistence (commit-before-return): a verdict is returned only after Postgres committed it, first writer wins, every caller returns what it reads back (concurrent requests get identical sets); Redis is a never-overwritten read cache (clearing it cannot change a result); `storage {source, durable}`; Postgres unavailable → no new verdict (`storage_error`, `new_locks:0`), cached verdicts served with `stands:false` = advisory; `stands:true` only for durably stored verdicts; `new_locks` = committed rows the caller had not seen at its read (informational, may repeat under exact simultaneity). Full-time response: same block with `final:true`, per entry `final_result` + `agrees`; a disagreement is `disputed:true` + `corrections[]` (`stage` live|final) while `result` stays the binding verdict (never settle the leg twice). Without the `settlements_plus` permission the call returns 403. **Combinable with `with_revision=1` (INPLAY_WITH_REV_V1, 2026-10-28):** each `fixtures[]` entry then carries the same `inplay_final` block and the envelope `inplay_final: true` (before, the flag was silently ignored in that combination). **Timeout-closed fixtures:** the block carries `fixture_completion:"timeout_unverified"`, `final:true`, `evidence:"none"`, no new verdicts are locked, and verdicts committed while the match was observed live are returned as stored (they stand per §8). Binding rules: policy §8 (engine tag inplay-final-1.1.4).
**Revision envelope — `with_revision=1` (Settlement Plus).** Replaces the per-event object with `fixtures[]`: `fixture_id` (as queried), `canonical_id` / `aliases[]` (IDENTITY_V1), `revision` (monotonic per canonical; a new revision is written on every state change of the fixture including the full-time transition — FT_BUMP_V1 2026-10-20), `result_asof_ms`, `source`, `engine_version`, `selections[]` (`market_id`, `line_key`, `outcome_id`, `verdict` WIN/LOSE/VOID/pending, `settlement_status`, `settled_at_ms`, optional `reason`, optional `correction {prior_verdict, prior_revision, first_revised_at_ms}`). `revision=<n>` pins a historical read. Once a revision's verdicts are materialised they never change on re-read. When no market board is retained for the fixture nothing can be graded: the fixture then carries `verdicts_pending: "no_market_board"` with an empty `selections[]` and is materialised on a later read once a board is available (NO_FREEZE_EMPTY_V1 2026-10-20). `fixture_status: "no_current_score"` (REV_CONTINUITY_V1, 2026-10-21) means no current score row exists but the fixture has stored revisions: the response is the latest stored revision exactly as stored (same `revision`, `result_asof_ms`, `source`, `engine_version`, `selections`), nothing recomputed. `fixture_status: "unresolved_no_evidence"` with `revision: null` now only means the fixture is known but has neither a score nor any stored revision. **Timeout-closed fixtures (STALE_REV_NOFREEZE_V1, 2026-10-28):** a fixture whose record was closed by the 8 h timeout with no verified final in its group answers `fixture_status:"ended_unverified"`, `completion:"timeout_unverified"`, `last_score` (last value seen, not a final) and `selections: []`; nothing is graded or frozen for it, and a verified final arriving later is written as a new revision and graded normally. The timeout close itself is recorded as an `ended_unverified` state (before 2026-10-28 it was recorded as "ended" and the first read froze an empty verdict map on it; the 19 affected fixtures received a `source:"correction"` revision on 2026-10-28 — earlier revisions are unchanged and still readable with `revision=<n>`).
Pay-out mapping: `win` → pay at the offered price · `lose` → keep the stake · `void` → refund the stake (price 1.00; `reason` says push / suspended at last read / Asian quarter line) · `pending` → the engine cannot resolve it from the final score alone (`reason` explains) — settle client-side or wait for V2/V3.
V1 covers full-time score-derivable markets (1X2, DC, DNB, totals, Asian totals, odd/even, BTTS, correct score, European and whole/half Asian handicaps, team totals, 1X2+BTTS and 1X2+totals combos). Pending in V1: half markets, HT/FT, corners/cards/shots and other stat markets, scorer markets.
**Binding policy** (https://api.euro365.bet/docs/#settlement-policy): regulation time only unless the market name says otherwise; whole-line totals and European handicaps push on a tie; Asian quarter lines are void in V1; DNB voids on a draw; suspension flags on the last odds snapshot no longer void outcomes of an ended event with a final score (changed 2026-10-20, engine 1.1.0; reported as `coverage.suspended_at_last_read`); abandoned / cancelled / replayed matches void; an ended event with no score voids everything; late score corrections re-run settlement, so **re-poll at least once 30 minutes after FT**; disputes go to the operator with event id, market id, outcome id and expected result — never silently override the engine.

### 3.7b `GET /v1/fixtures?ids=<id>[,…]` (max 100; FIXTURES_V1, 2026-10-20)
Identity and lifecycle of any fixture id, ended or not (`/v1/event` drops ended events). Per id: `fixture_id`, `canonical_id` (when the id is an alias), `aliases[]`, `identity {sport_id, league_id, league_name, country, country_iso, home, away, kickoff_ts, canonical_id, canonical_basis, group_key}` (plus `requested_kickoff_ts` / `kickoff_delta_s` / `kickoff_basis` for an alias, as in §2 (7)), `status` (`ended` / `live` / `scheduled` / `unknown`), `score {home, away}` (the final for ended fixtures — taken from the canonical or any sibling's ended record, `score_source` names it; the live row otherwise, with `score_ts_ms`), `periods`, `ended_at_ms`, and `superseded_live_row` when a live row of the queried id outlived the full time. Ids unknown to both the fixture table and the live score hash are listed in `missing[]`. **Timeout-closed records (TIMEOUT_UNVERIFIED_V1, 2026-10-21):** a match that never delivers full-time evidence (no feed full-time flag, no fallback results match) is closed by our recorder 8 h after kickoff; such a record answers `status:"ended_unverified"`, `completion:"timeout_unverified"`, `score:null` and `last_score` (the last value seen, not a final). It is never used as a final by `/v1/settlements` (the record stays unresolved) or by the score reconciler, and the fallback results source keeps retrying it; a verified final later replaces it. Any valid key.

### 3.7c `POST /v1/grade` · `POST /v1/grade/register` · `GET /v1/grade/coupon-status` (Settlement Plus)
`POST /v1/grade {legs:[{event_id, market_id, market_name, outcome_name, odds, line?}]}` grades bet legs with the central grader (sport-aware: football/futsal/hockey regulation vs full-time scope per market, basketball incl. overtime, hockey regulation markets, set sports tennis/table tennis/volleyball/badminton on sets, games/points and per-set scores; `format` and `completion` are returned, the match format is verified from the tournament name and an unverifiable format answers `pending` with an `unverified` reason). Each leg verdict carries `source`: `"grader"` (our engine) or `"sportapi"` (the provider's own settlement of a mirrored coupon, when one exists).
**`POST /v1/grade/register` places real money.** Every distinct registered leg is mirrored as one real single coupon on **our** partner account at the provider (configured stake, currently 0.01 USD per leg, our cost; it can be lost or paid out there and placement pauses when that account's balance is exhausted). It never touches your euro365 credit beyond the ordinary per-call charge and never places anything on an account of yours. Register only legs you actually accepted. **Non-wagering modes (REGISTER_SANDBOX_V1, 2026-10-21):** a sandbox key (`ek_test_…`) never places a coupon and answers `mode:"sandbox"`; any key may send `dry_run:true` to validate the payload without placing (`mode:"dry_run"`). `GET /v1/grade/coupon-status` shows env, stake, queue, open coupons and the partner balance. Requires the `settlements_plus` permission.

### 3.7d Non-wagering settlement intake — `POST /v1/settlements/intake` · `GET /v1/settlements/intake` (INTAKE_V1, 2026-10-21, Settlement Plus)
**Places nothing anywhere.** `POST {selections:[{ref, fixture_id, market_id, outcome_id, line_key? | line?}]}` (max 200) stores each accepted selection under your key (idempotent on `ref`; a re-post replaces it, `replaced:true`) and acknowledges it: `accepted[] {ref, intake_id, fixture_id, canonical_id, market_id, outcome_id, line_key, line, received_at_ms}`, `rejected[] {ref, error}`, `placed_coupons: 0`. Use the `line_key` exactly as `/v1/odds` and `with_revision=1` show it (`s` for lines without a handicap/total, `s2.5`, `s0.0` …) or pass `line` as a number and it is matched numerically on read. `GET ?refs=a,b` (max 100) · `?fixture_id=<id>` · `?since=<ms>` returns per stored selection the verdict taken byte-for-byte from the fixture's revision envelope: `match` (`matched` | `not_on_board` — the retained board has no such market/line, the selection is never graded by guesswork | `no_market_board` | `awaiting_final` — the fixture has not ended yet; intake carries no in-play verdicts, they appear after full time (INTAKE_AWAIT_FINAL_V1 2026-10-21; before that a live selection wrongly answered `not_on_board`) | `fixture_unknown` | `read_failed` — retry), `verdict`, `settlement_status`, `settled_at_ms`, `reason`, `correction {prior_verdict, prior_revision, first_revised_at_ms}` when a result changed, plus `revision`, `result_asof_ms`, `engine_version`, `identity`. Re-read to pick up corrections; `revision` tells you whether anything moved. **Alias continuity (contract `intake-1.1`, 2026-10-21):** a receipt is bound to the `fixture_id` it was submitted with and never re-bound to another market or outcome. Every read resolves that id through the settlement envelope at read time, so `canonical_id` and `identity.canonical_id` always come from one snapshot; `canonical_id_at_receipt` keeps the canonical recorded at POST and `canonical_changed:true` signals that the pin moved since (typically a duplicate listing that was not yet in the alias index — rebuilt every 5 min — when you posted). The `match` value also includes `awaiting_final` (fixture not ended) and `read_failed` (retry). **Final-score grading off the board (contract `intake-1.2`, INTAKE_OFFBOARD_V1 2026-10-24):** a selection on an ENDED **football** fixture whose market had left the retained board before full time (the board kept at the end holds only late markets such as Next Goal) is now graded from the confirmed final score with the same settlement engine: `match:"matched"`, `grade_basis:"final_score"`, plus `final_score {home, away}`, `score_source` (the group member or `es_match_history:<id>` the final came from) and `settled_at_ms` = the final's time. Board-graded rows carry `grade_basis:"retained_board"`. Only confirmed finals count (never a `stale_timeout` ending), regulation only (a final with more than two periods, i.e. extra time, stays pending), and markets the final score cannot decide (half-time, corners/cards, statistics) keep `not_on_board` / `pending`. Other sports are NOT graded off the board (their scores are sets/legs/points) and keep `not_on_board`. Stored receipts recover on the next read; no resubmission. **Change detection: `receipt_revision` (contract `intake-1.3`, INTAKE_RCPT_REV_V1 2026-10-24):** `revision` / `result_asof_ms` belong to the FIXTURE's revision envelope and do not move when only the intake's grading of your receipt changes (a `final_score` grade, or its withdrawal). Every intake row therefore carries `receipt_revision` — stored per receipt, strictly increasing, bumped whenever the returned (`match`, `verdict`, `settlement_status`, `grade_basis`) changes — and `receipt_changed_at_ms` (when that change was recorded). When a terminal verdict (WIN/LOSE/VOID) was replaced, `receipt_correction {prior_verdict, prior_receipt_revision, changed_at_ms}` is present. `read_failed` rows never move it. Use `receipt_revision` as the authoritative change signal for intake rows; `revision` stays the envelope's. Counters were backfilled for the 2026-10-24 events (final-score grading at 10:10:45 UTC → 2; the withdrawal at 10:14:20 UTC → 3 with `receipt_correction`); other receipts start at 1 on their first read. **Timeout-closed fixtures (contract `intake-1.4`, STALE_REV_NOFREEZE_V1 2026-10-28):** a receipt on a fixture closed by the 8 h timeout without a verified final answers `match:"awaiting_final"`, `verdict:"pending"`, `fixture_status:"ended_unverified"`, `completion:"timeout_unverified"`, `last_score` — never `not_on_board` (before, such receipts were labelled `not_on_board` because an empty verdict map had been frozen on the timeout revision); it is graded when a verified final arrives. The canonical recorded at POST uses the same resolver as the envelope (CANON_RESOLVE_V1); stored receipts are never re-bound. This is the intake to use when your side must not trigger provider coupons; `/v1/grade/register` is the only call that places a coupon. **SportAPI settlement authority (contract `intake-1.5`, SA_INTAKE_VERDICT_V1 2026-11-16):** both the retained-board and the final-score (offboard) paths now consult SportAPI's coupon settlement before the local grader. When SportAPI has a settled verdict for a receipt's `(fixture_id, market_id, outcome_id, line)` tuple (because that leg had ever been placed as a mirrored coupon by `/v1/grade/register` or any other caller), that verdict replaces the engine's result and the response carries `source:"sportapi"` with `reason` holding SportAPI's `settlement_reason_code` wrapped in a short phrase (for example `"SportAPI settlement REMOTE_WIN at 2:1"`, `"SportAPI settlement MARKET_PUSH"`, `"SportAPI settlement AUTOMATIC_SETTLEMENT"`). Legs SportAPI has not placed as a coupon fall through to the existing engine unchanged and carry `source:"grader"`; `pending` rows have no `source` field. `grade_basis` is unchanged by this — a SportAPI-sourced row that came through the retained board still carries `grade_basis:"retained_board"`, an off-board row still carries `grade_basis:"final_score"` — so stored verdict archives, `receipt_revision` counters, idempotency and alias continuity all keep the same semantics; this only strengthens the WIN/LOSE/VOID decision itself with the authoritative provider result. The same authority rule has driven `/v1/grade` since 2026-09-28 (SA_AUTHORITY_V1); `/v1/settlements/intake` was the remaining Settlement Plus endpoint that had not yet consulted it. No change to request shape or to the POST path (the POST still places nothing). **Archive SportAPI evidence and intake-POST mirror (contract `intake-1.6`, SA_EVIDENCE_V1 + SA_INTAKE_MIRROR_V1 2026-11-16):** when the committed verdict is `source:"sportapi"`, the archive snapshot row in `es_settlement_intake_snapshots` now carries a new `sa_evidence` block with `coupon_code`, `settlement_reason_code`, `sv_r`, `calculate_score`, `calculate_score_periods`, `legkey` and `sv_at_ms`. Old snapshot rows are untouched (`tr_snap_immutable` remains enforced); new rows carry `sa_evidence` only when SportAPI supplied the verdict. Grader-sourced rows have no `sa_evidence` key. Separately, the POST path now has an optional intake-mirror step: when `SPLUS_SA_MIRROR_V1=1` and the caller's client key matches `SPLUS_SA_MIRROR_CLIENT_KEY` (if set, else global), each accepted selection is mirrored to the SportAPI Coupon API (`sa-coupon.registerLegs`) fire-and-forget, so subsequent GETs can serve the SportAPI-settled verdict. Mirror is idempotent per `splus_coupon_placements` (PG) + `sa:cpn:bl:` (redis), so retries are safe; a mirror failure never fails the intake accept (the stored selection + 200 response are unchanged). **Archive for retained-SA rows, truthful mirror status in POST, fail-closed scope, upper-case retained verdict (contract `intake-1.7`, INTAKE_RETAINED_ARCHIVE_V1 + SA_INTAKE_MIRROR_RESPONSE_V1 + SA_INTAKE_MIRROR_SCOPE_V1 2026-11-16):** (a) the retained-board SportAPI path (LIVE/HT settlement) now writes the same append-only archive row as the final-score path — `_buildIntakeSnapshot` accepts `grade_basis:"retained_board"` when `source:"sportapi"` AND `sa_evidence` is present, so the verdict → `receipt_revision` → `es_settlement_intake_snapshots` chain is traceable for LIVE/HT too (`writer:"settlement-intake-retained-sa"`, `ended_at_ms` = `sa_evidence.sv_at_ms`); grader-only retained rows remain unarchived (unchanged). (b) the POST response now carries a `mirror {enabled, scope, queued, scope_reason}` block and `placed_coupons` equals the number of legs actually queued; when the mirror is active the `note` reads "selections stored for grading; N leg(s) queued for SportAPI Coupon mirror (scope=customer_88, idempotent via splus_coupon_placements)" instead of the earlier "nothing is placed with any provider" — the response is truthful about what the server did. (c) mirror scope is fail-closed: a missing/empty `SPLUS_SA_MIRROR_CLIENT_KEY` broadcasts to no one (previously it broadcast to every client), AND the request's client key must also match a hardcoded customer allow-list (currently customer 88's key hash only), so a misconfigured env cannot enable the mirror for anyone else. (d) retained-board SA casing is now identical to the offboard path: the retained-board SA block maps `sv.r ∈ {win,lose,push,void,half_win,half_loss}` to UPPERCASE WIN/LOSE/PUSH/VOID/HALF_WIN/HALF_LOSS before `receiptResult.normalize` (receipt-result passes `verdict` through verbatim, so previously the lowercase would have propagated into `rcpt_state` for new retained-SA rows — now fixed).

### 3.7e `/v1/verify-selections` identity echo (VERIFY_IDENTITY_V2, 2026-10-22)
Each selection's `event` carries `requested_event_id` (the id you sent) and, when the lookup used another member of the duplicate group, `canonical_id`. `event.identity` = `{ requested: {event_id, sport_id, league_id, league_name, home, away, kickoff_ts, pinned_canonical_id}, canonical: {…same fields…} (only when different), group_key: [home, away, kickoff_ts, league_id, sport_id], same_group, verified_from, same_match, cross_source, source_mapping }`. `same_group` stays strict: it compares the whole `group_key` including `league_id`. `same_match` (VERIFY_IDENTITY_V2) answers the softer "is this the same real-world fixture?" — it compares `(home, away, kickoff_ts, sport_id)` only and ignores `league_id`, so cross-source twins (same match catalogued under a different source's league namespace) register as `true`. `cross_source` is `true` when the requested id and the canonical come from different source channels and would otherwise look like different fixtures. `source_mapping[]` lists every group member as `{event_id, source, league_id, league_name}` so an integrator can see the full alias set at a glance. **`source_mapping` is informational — it does NOT by itself authorize ticket acceptance.** Ticket acceptance still requires successful odds / market / line / outcome / price / state validation; accept `event.canonical_id ≠ requested_event_id` only when `same_group` is `true` (strict) or `same_match` is `true` (soft, cross-source twin — league id drift is expected and benign).

### 3.7f Interim operational guidance for `/v1/settlements?inplay_final=1` (INTERIM_OPS_V1, 2026-11-08)
This is **operational, not contractual**. The API contract itself permits up to 100 ids per `/v1/settlements` request. Under current server behaviour (PIT per-fixture loop budget `SETTLE_LOOP_BUDGET_MS=8000`, Sofascore enrichment budget `SETTLE_ENRICH_BUDGET_MS=2500`, plus scores + serialization), **inplay_final=1 batches larger than ~8 ids may approach a 12-second wall-clock under concurrent load**. Until the server is proven stable under larger batches:

- **Recommended batch size**: `≤ 8` fixture ids per `/v1/settlements?include_inplay=1&inplay_final=1`. Larger batches still return a correct response but with less latency margin.
- **Recommended client-side deadline**: `≥ 15 s` (R1 loop ceiling 8 s + enrich 2.5 s + scores typically ≤ 1 s + serialization + network + generous variance).
- **Retry behaviour on timeout or 5xx**: idempotent exponential backoff (e.g. 2 s, 4 s, 8 s) with a 3-retry ceiling. `/v1/settlements` reads are safe to retry — the response is derived from durable state (scores, locks). `/v1/settlements/intake` POST is idempotent on `(client_key, ref)` — a retry of the same `ref` does not create a duplicate receipt.
- **Incomplete-response handling**: a successful response always has `success: true` and a populated `data` object. A `success: false` body, an empty body, or a 5xx is a **retryable transient failure**; never treat it as "no locks exist" — poll again. Never retry a terminal verdict path as a write; our server-side LIVE locks are already durable in Postgres, so a repeated read merely re-fetches the same committed state.
- **Response-body completion**: this release adds a `[settle-empty]` detector that logs any socket closed before response headers. Future releases will progressively tighten the empty-200 surface. Report any empty-200 occurrences with the request id (`X-Request-Id` response header) for correlation.
- **`_loop_budget` field**: when the server activates its per-fixture budget (currently `SETTLE_LOOP_BUDGET_MS=8000`), response carries `_loop_budget: {ms, hits}` at the envelope level and `_loop_budget_hit: true` on any fixture that returned its durable lock-only fallback rather than a full retained-board grading. **Durable LIVE locks are still served under budget hits** — the fallback prefers evidence over completeness. If a fixture is marked `_loop_budget_hit`, the caller may re-poll to get the full retained-board grading as well.

These limits reflect present operational state, not the permanent API shape. They will be revisited as server stability under larger batches improves.

### 3.8 `GET /v1/status`
`{ "success": true, "live_events": 312, "prematch_events": 9874, "last_update": 1747300000000 }` — cheap authenticated liveness probe. `last_update` is the local time of our last live write (FRESHNESS_WORDING_V1, 2026-10-21): it shows that our feed is writing, not how recent the upstream data is.

### 3.9 `GET /v1/markets` and `GET /v1/market-groups` — dictionaries (cache these)
`/v1/markets` → `data.markets { mid: name }`, `data.outcomes { oid: name }`, `data.codes { mid: rawUpstreamCode }` (≈720 markets), and with `nested=1` `data.markets_full { mid: { name, code?, groups?, outcomes } }`. Params: `sport=<id>` (soccer ≈ 550 markets instead of 4,873), `nested=0|1`, `groups=0|1` (needs `sport`), `lang=<code>`. Emits a weak `ETag`; send `If-None-Match` and handle `304`.
`/v1/market-groups?sport=<id>[&lang=]` → `data.prematch[]` and `data.live[]` tab buckets `{ key, name, markets: [mid…] }` (Main, Goals, Halves / Periods, Teams, Interval, …) — drives the tab strip on an event page. Omitting `sport` returns every sport keyed by id (heavy; do it once at startup).
Show `markets[mid]` (or `markets_full[mid].name`) to users; `codes[mid]` is for badges/debugging. An id missing from the dictionary (rare) renders as `Market <id>` — tell support.

### 3.10 Localization — `lang=` on `/v1/markets`, `/v1/market-groups` (and settlement outcome names)
24 codes: `en de it fr es sq me tr el sr zh pt ru da sv bn bg pl ro cs hu sk nl et`; unknown → `en`; untranslated phrases fall back to English. Team names, competitions, ids, scores and prices are never translated. Cache one dictionary per language (ETag works with `lang`).

### 3.11 Live TV (add-on; key needs the `stream` permission)
`GET /v1/streams` → `{ "events": { "<eventId>": { "ch", "name" } }, "tournaments": { … } }` — poll ≈ once a minute to mark matches with a 📺.
`GET /v1/stream?id=<eventId>[&ttl=60..3600]` → signed, short-lived (`expires_at`, unix seconds, ≈15 min) `embed_url` (ready player: `<iframe src="{embed_url}" allow="autoplay; fullscreen" allowfullscreen>`), `ws_url` (raw MPEG-TS over WebSocket, mpegts.js) and `hls_url`. Call it **from the backend after your own viewer gate** (logged-in, funded or has a bet), then hand the URL to the browser; request a fresh one when the user reopens the match. `"available": false` (HTTP 200) = no stream; `503` = relay at capacity.

---

## 4. Real-time

### 4.1 `wss://api.euro365.bet/ws?api_key=<key>` — event list push (no prices)
On connect: `{ "type": "snapshot", "ts", "live": { id: event }, "prematch": { id: event } }` — the full catalogue, so no REST is needed to bootstrap the index. Then `{ "type": "live_update", "ts", "data": { id: event } }` about once per second. **Frames carry events, not prices** — treat each `live_update` as "refresh now" and re-call `GET /v1/odds?ids=<visible batch>`. Server pings every 30 s; reply with pong (standard clients do) or be dropped in ≈60 s. Reconnect with backoff (≈2 s) and re-consume the snapshot. Max 5 connections per key.

Loop: open WS → render fixtures from the snapshot → pick the ids on screen → `/v1/odds?ids=…` → on every `live_update`, re-call `/v1/odds` for the same batch. Polling `/v1/odds` every 1–2 s without the WS gives the same result with more bandwidth.

### 4.2 `wss://api.euro365.bet/pt-ws?api_key=<key>&protocol=v2` — live odds delta relay
Text frames with fields separated by the `0x1F` unit-separator byte: `INFO\x1FPUB` (ready), then `P\x1F<channel>\x1F<json>`. Channels: `evt:<sportId>` (map `{ eventId: event }` — snapshot on connect, then add/change/delete deltas) and `odds:<sportId>:<eventId>` (map `{ marketId: marketObject }` — **full-market replacements, apply by overwrite**). No subscribe step; every active live event is pushed. The connect snapshot replays only the last ≈10 s of odds frames, so **seed base prices from `/v1/event` + `/v1/odds`, then apply relay frames on top**. Answers ping with pong; reconnect with exponential backoff 1 s → 30 s (a fresh snapshot follows, no manual resync). `GET /pt-relay/health` (no auth) reports `upstream_ready`, `downstream_clients`, etc.
```js
const SEP = '\x1F';
ws.on('message', raw => { const [type, channel, body] = String(raw).split(SEP);
  if (type === 'P') applyFrame(channel, JSON.parse(body)); });
```
Use `/ws` when you need the event list and are happy to fetch prices; use `/pt-ws` when you need sub-second price deltas. Without `protocol=v2` the relay uses a legacy channel naming — always pass it.

---

## 5. Live Match Tracker widget (add-on; key needs the `widget` permission)
- `GET /widget?event_id=<id>&api_key=<key>` returns an HTML page to embed: `<iframe src="https://api.euro365.bet/widget?event_id=s2-43.133873042&api_key=YOUR_KEY" width="480" height="600" frameborder="0" style="border-radius:12px;overflow:hidden"></iframe>`. It opens its own `/ws-widget` connection and falls back to polling. Errors: `400` missing `event_id`, `401` bad key, `403` no widget permission. **Pitch version** (`pitch=` query param): `pitch=v1` (default for most keys) = our 2D/CSS pitch whose ball follows the real ball position / live situation — fully customizable (theme, colors, header, pitch photo, modules); `pitch=v2` = SportAPI's 3D live WebGL pitch, Live Streams add-on required (football only, only on domains enabled for 3D for the key — falls back to `v1` by itself when not covered); `pitch=v3` (TRACKER_V3_V1, 2026-11-20) = TifoSports Betradar LMT Plus, served through our `/sa/lmt` wrapper so the browser only ever sees `api.euro365.bet` as the iframe origin. V3 covers football + basketball + ice-hockey + handball + volleyball (~85–100% on those sports); falls back silently when TF has no `has_tracker=true` for the match. V3 defaults to a dark palette; override with `theme=light` on the widget URL. V3 appearance beyond `theme` is controlled by Betradar — not customizable via our params. V3 is gated per customer: add `tf_widget` to `permissions`, add your customer id to `sa:config.tracker_v3_clients`, or set the `TF_WIDGET` note on your api key. `/widget-data` takes the same `pitch` and answers `"pitch": "v1"|"v2"|"v3"` with the version actually served.
- `GET /widget-events` (header auth) → `{ "count", "data": { "<eventId>": { "h", "a", "sport", "score": "1:0", "timer", "period", "status", "event_types": [...] } } }` — only events with tracker data; use it to populate a match picker.
- `GET /widget-data?event_id=<id>[&pitch=v1|v2|v3]` → one snapshot: `home_name`, `away_name`, `home_score`, `away_score`, `period`, `status`, `timer` (seconds), `ts`, `xy [x,y]` (ball, 0–1, x=0 home goal / x=1 away goal), `situation` (e.g. `"Away Dangerous Attack"`, `"Home Ball Safe"`, `"Home Corner"`), `corner`/`yelc`/`redc` (`"H:A"`), `stats {"Attacks":[h,a],…}`, `sc {"GOAL":[h,a],"CORNER":[h,a],…}`, `timeline [{type,min,team,text}]`, `pitch` (`"v1"`|`"v2"`|`"v3"`, the version served), and the add-on URL for your own iframe: `sa3d` (signed `/sa/tracker` URL) on `v2`, `lmt` (signed `/sa/lmt` URL) on `v3`. For TF-enabled customers the response also carries a `tf: { event_id, source, stats, periods, has_tracker, tracker_url (our /sa/lmt URL), age_ms, fresh, score, state, clock }` block. Missing fields are omitted; a non-live id yields `{ "error": "Event not found or not live" }` with HTTP **200**.
- `wss://api.euro365.bet/ws-widget?api_key=<key>&event_id=<id>[,<id>…]` or `?mode=all` → `{ "type": "connected", … }` once, then `{ "type": "tracker", "event_id", … }` (same fields as `/widget-data`) on every change; one initial frame per subscribed event. Client messages: `{ "action": "subscribe"|"unsubscribe", "event_id": "id1,id2" }`, `{ "action": "subscribe_all" }`. Close codes `4001` invalid key, `4003` missing permission.
- **Sports covered by the tracker (TRACKER_BB_TEN_V1, 2026-11-09):** football (and futsal), basketball (sport 2) and tennis (sport 5). The `/widget` page picks a pitch, a basketball court or a tennis court from the event's sport, with the same customization params. Basketball and tennis frames add `"sport": "basketball"|"tennis"` (football frames are unchanged and have no `sport` field). Other sports get score, period and stats only. Volleyball is not covered yet.
  - **Common fields on basketball and tennis frames:** `situation` (`"Home 2 Points"`, `"Away Serve"` …), `situation_code` (raw `<team><code>`), `situation_team` (`home`|`away`|`null`), `situation_ts` (ms), `situation_info` (event parameter, e.g. free throw `"1:2"`), and `period_number` (quarter or set). `ball_player` is never set for these sports, because the source parameter is not a player name.
  - **Basketball:** `xy [x,y]` is the real ball position (0-1, x=1 = the basket home attacks), dropped 20 s after the last position. `situation` is one of: In Possession, Attack, Rebound, 1/2/3 Points, Free Throw / Free Throw Scored / Free Throw Missed, Missed Shot, Foul, Timeout, End of Quarter, Half Time, Overtime, 1st-4th Quarter, Match Complete. `home_score`/`away_score` are points, and `sc` carries `Q1`…`Q4` quarter scores. `clock { seconds, display "MM:SS", running, direction "down"|"up", ts }` is the period clock as on the scoreboard; it only advances while `running` is true and freezes when play stops. `clock_running` (bool) is the same flag. `timer` is elapsed game seconds from the source, no longer extrapolated.
  - **Tennis:** no running clock (`timer` is `0`, `clock_running` is `false`). `tennis { server, serve "first"|"second"|null, points ["30","40"], sets [[6,4],[3,5]], set, tie_break, break_point {team,count}|null, last_point {team,type,ts} }`. `situation` is one of: Serve / Second Serve, Point, Fault, Double Fault, Ace, Break Point, Game, Tie-break, End of Set, Rain Delay, Match Complete. `home_score`/`away_score` are sets won. There is no `xy`.
  - `/widget-events` entries now also carry `has_tracker`, `live_tracker` (true when the frame has `xy` or `situation`) and `tracker_sport` (`basketball`|`tennis`).
- Customization: query params on `/widget` (or saved per key in the portal customizer; query wins): `theme=dark|light`, `accent`/`accent2` (hex, no `#`), `hide=stats,timeline,pitch,corners`, `layout=portrait|landscape`, `hstyle=classic|modern|compact|minimal|bold|scoreboard|neon|split|stacked|broadcast`, `hbg`, `radius`, `font` (URL-encoded), `home_logo`/`away_logo`, `stadium`, `bg`, `blogo`/`bbg`/`bsize`, `sport`, `sim=1`, `pm=1&home=&away=&league=&kick=` (pre-match card).

---

## 6. RDSTN (legacy — only when porting an existing RDSTN backend)
`POST /rdstn` with `X-API-Key`, JSON body = array of `[op, args]`; response = parallel array. Ops `ga`/`gf`/`g`/`go` take `[key, …]`; `sl` / `sp` return live / pre-match sport lists. Keys: `bm{N}_el{sportId}` live events, `bm{N}_ep{sportId}` pre-match events, `bm{N}_sl`, `bm{N}_sp`, `bm{N}_{eventId}` market config. Example `[["ga",["bm1_el1"]]]` → `[ { "bm1_el1": { eventId: event, … } } ]`. New code uses REST/WebSocket.

---

## 7. Plan — do this, in this order

1. **Config**: `EURO365_API_KEY` (secret), `EURO365_BASE_URL=https://api.euro365.bet`. Start with the customer's **sandbox key** (`ek_test_…`); switch the env var to the live key at the end — no code change.
2. **Client**: one server-side HTTP client that sets `X-API-Key`, checks `success`, maps `error` strings to exceptions, honours `429 retry_after`, retries `5xx` with exponential backoff, and batches ids in groups of ≤100.
3. **Dictionaries at startup**: `/v1/markets?sport=N&nested=1` and `/v1/market-groups?sport=N` for each sport the customer offers (or everything once); cache with ETag / `If-None-Match`; refresh hourly. One copy per `lang` the UI shows.
4. **Event index**: `/v1/sports` (per minute) → `/v1/live?sport=N` (every 2–5 s) and `/v1/prematch?sport=N` (less often) into your store, keyed by the full event id; keep the numeric tail as a secondary key. Or open `/ws` from the backend (≤5 connections per key) and feed the store from `snapshot` + `live_update`.
5. **Prices**: for the events currently rendered, `/v1/odds?ids=<batch>` every 1–2 s (or on each `live_update`); decode tuples per §3.5, treat non-zero flags and `s: 1` as locked, build tabs from `/v1/market-groups`, names from `/v1/markets`. For sub-second deltas add `/pt-ws` with `protocol=v2` on top of a REST-seeded base.
6. **Scores**: `/v1/scores` every 5–10 s for the scoreboard column (`status`, `home`, `away`, `clock`/`ms`, `period`, `injury_time`).
7. **Settlement** (only if bets are accepted): when an event's `status` becomes `"ended"`, call `/v1/settlements?ids=…`, apply win/lose/void per §3.7 with the offered price you stored at bet time, leave `pending` outcomes open, and re-poll once ≥30 min after FT for corrections. Never overwrite an engine result without a dispute.
8. **Optional**: tracker widget on the event page (§5); Live TV behind your own viewer gate (§3.11).
9. **Self-test** (sandbox key): assert (a) `/v1/status` and `/health` answer; (b) an event from `/v1/live` resolves via `/v1/event` with the full key, the `s2_l…` binding and the bare numeric tail; (c) every price renders as `price/100` with two decimals and a flagged outcome renders locked; (d) a `429` sleeps `retry_after` and recovers; (e) with the WS open, a `live_update` triggers exactly one `/v1/odds` batch call; (f) never more than 5 WS connections; (g) for a finished match, `/v1/settlements` results map to payouts and `void` refunds at 1.00.

## 8. Gotchas that break real integrations
- Reading odds from the `/ws` frames → there are none; the WS is the refresh trigger, `/v1/odds` is the price source.
- Rendering `price` without dividing by 100, or accepting an outcome whose `flags !== 0`.
- Treating `"s<home>:<away>"` line keys as numeric lines, or reading `special` on the bare `"s"` key (it is `null`).
- Mixing seconds and milliseconds: `kickoff` and event `ts` are seconds; price/score/frame `ts` are milliseconds.
- Opening one WebSocket per browser session → the 6th handshake is refused. Fan out from the backend.
- Passing more than 100 ids to `/v1/odds` / `/v1/settlements`.
- Hard-coding market or outcome names, or the sport list — fetch the dictionaries and `/v1/sports`.
- Putting the API key in front-end code (except the widget iframe `src` / `/ws-widget`, which are built for it).
- Settling on the score at kickoff+90 without checking `status === "ended"`, or never re-polling for corrections.
- Connecting to `/pt-ws` without `protocol=v2` and then parsing channel names that do not match this brief.

---

Human docs: https://api.euro365.bet/docs/ · Match explorer: https://api.euro365.bet/docs/explore · Portal (keys, sandbox, credit, widget customizer): https://api.euro365.bet/portal · Support: through the portal.
