CLAUDE.mdepks — self-contained for any AI assistant. Base URL: https://api.b337.ai.<paste-your-api-key-here> placeholder./v3/place_bet is async.200 with status: "pending" in ~100 ms and a correlation_id.POST /api/bet_status with {"correlation_ids": [ … ]} until status leaves pending — completed (the outcome is in result), timeout or unknown. Keep polling until timeout_at, which is at least 5 minutes after submit. Or provide callback_url and the API will POST the signed result to you (no webhook fires on a timeout).Core Concepts
/v3/place_bet is the new recommended way to place bets. It returns immediately
(~100 ms) with a correlation_id and decouples your script from the actual
bookie wait, so you no longer get 30s timeouts when a bookie is slow.
A synchronous place-bet call holds the HTTP connection open
while the server places the bet on the bookie (/v2/place_bet is retired and
now answers 410 Gone). Slow bookies cause:
/v3/place_bet fixes all of this by returning a correlation_id
in ~100 ms. You then either poll for the result or have it POSTed back to
your URL when ready.
POST /v3/place_bet
Headers:
X-API-Key: YOUR_API_KEYContent-Type: application/jsonThe same bet body the retired /v2/place_bet took (that route now answers
410 Gone). Plus these optional fields:
| Field | Type | Required | Description |
|---|---|---|---|
callback_url | string | No | If provided, the result is POSTed to this URL when the bet completes. Must be http:// or https:// and its host must resolve to public IPs only (private, loopback and link-local addresses are refused with 400). Redirects are not followed. If absent, you poll for the result instead. |
trace_id | string | No | Your own identifier, max 200 characters. Echoed back unchanged on the submit response, the /api/bet_status poll, and the webhook body (plus a Bet-Trace-Id header). |
idempotency_key | string | No | 1-200 characters. Makes a blind retry a no-op: a re-send with the same key within 48 hours returns {"status": "pending", "correlation_id", "session_id", "idempotent_replay": true} with the original correlation_id and places nothing. A duplicate that arrives while the first request is still being accepted gets 409 - poll /api/bet_status. Scoped to your API key. |
pk | string | No | Racing only. The canonical race key ({track}/{num}/{type}/{country}/{date}). Preferred over track/race_num/race_type/date; the server targets that exact race at the session's bookie. Falls back to the track fields if the pk is unknown, so it is safe to send both. |
market_ref | string | No | Sports only. Bet a market that has no canonical name yet by its slug from GET /v3/markets. Requires site_event_id. Fails closed: missing site_event_id 400, unknown slug 404, a selection with no id to place by 422. |
source | string | No | Free-form label for your own bookkeeping, max 200 characters. |
tags | string[] | No | Up to 10 labels, each ≤50 characters, for splitting bet performance by your own strategies/sources. Echoed on the submit response and the /api/bet_status poll, stored on the bet (rejected bets included), and filterable on the dashboard's API page (Bet Tag filter). |
tipster | string | No | Tipster name (1-42 characters). Shortcut over tags: stored as a tipster:<name> tag (counts toward the 10-tag cap) and surfaced on the dashboard's API Sports page as the Tipster filter + CSV column. |
bet_type | string | No | Besides the promo values (non_promo / bonus), the tracking labels standard, hedge, middle and arb are accepted (middles/arbs normalise to the singular): stored as a bet_type:<label> tag while the bet is placed and charged as a normal cash bet. Powers the API Sports page's Standard / Hedge / Middle / Arb Bets filter + CSV column, so those legs can be split out when reviewing EV performance. |
Supported categories: racing, sports, multi (single, SRM, SGM, parlay),
and betfair (direct Exchange BACK/LAY, incl. BSP — see
Place Bet → Betfair).
Stacked SRMs now have a dedicated v3 endpoint -
POST /v3/stacked_srm - with the
same async contract as this one.
The real endpoint answers HTTP 200 with this envelope. (Sandbox samples for
unpaid keys answer 202 with the same shape.)
status is always "pending" at this point. Use the correlation_id to
fetch the actual bet result via either delivery option below.
POST /api/bet_status with the correlation_id until status flips from
pending to completed (or timeout).
Response:
When status === "completed", read the result field. result.success
is whether the bet placed; the bookie receipt (bet_id, odds, stake,
error) sits on result itself. On a failure, read
result.outcome_code (a machine-readable reason such as
odds_below_target or market_not_carried), not success alone:
placement_uncertain and duplicate_bet mean the bet may already be on, so
never re-send those. placement_uncertain can also come with
success: true and confirmed_bet: false: the bookie is holding the bet
for review (Ladbrokes / Neds "Processing") and may still reject it, so treat
it as not yet confirmed.
status values:
pending - bet is in flight, keep polling.completed - bet finished, read result.timeout - server gave up waiting for the client. The bet may still have placed late, so only re-send with the same idempotency_key (a replay places nothing).unknown - correlation_id expired (over 90 minutes since submission).Provide callback_url in the original /v3/place_bet request and the result
will be POSTed to your URL when ready. Use this if you already run an HTTP server.
Requirements: your URL must be reachable from api.b337.ai, resolve to
public IP addresses only, and respond 2xx within 10 seconds. A 3xx
redirect is not followed and the delivery is abandoned (poll instead).
Inbound POST shape:
POST {your callback_url}
Headers:
Content-Type: application/json
Bet-Correlation-Id: {correlation_id}
Bet-Signature: sha256=<HMAC-SHA256(api_key, body)>
Bet-Trace-Id: {trace_id} (only when you sent a trace_id)
Header rename: as of 2026-05-14 these headers are
Bet-SignatureandBet-Correlation-Id- previouslyX-Bet337-SignatureandX-Bet337-Correlation-Id. The "X-" prefix was dropped per RFC 6648 and the "Bet337" namespace removed for whitelabel-friendliness. Header values are unchanged. If you have existing handlers reading the old names, update the lookup - verification logic itself doesn't change.
result is exactly the same client payload you would read from
statuses[0].result on a completed /api/bet_status poll, so one parser
handles both. status is always "completed" on a webhook.
Verifying the signature (Python):
Delivery is tried 3 times in total, waiting 1s and then 4s between
attempts. After that the delivery is dead-lettered server-side; you
can still recover the result by polling /api/bet_status with the
correlation_id for up to 90 minutes.
These come back on the submit itself; nothing was dispatched. Bodies are
{"detail": "..."}.
| Status | When | What to do |
|---|---|---|
400 | Bad body (missing field, callback_url not a public http(s) URL, trace_id/source over 200 chars, bad idempotency_key) | Fix the request |
403 | Betting is not enabled on this account., or the session isn't yours / isn't active | Check your plan and session |
404 | Session not found, or a market_ref slug that doesn't exist | Fix the id |
409 | Same idempotency_key while the first request is still being accepted | Poll /api/bet_status |
410 | You called /v2/place_bet | Use /v3/place_bet |
422 | Validation failure, a sports bet on a racing-only bookie, or a market_ref with no id to place by | Fix the request |
429 | Back-off: the bookie kept refusing this account on this SGM event (or this bet365 sports selection), so we did not send it | Wait Retry-After seconds for that account and selection; others are unaffected |
/v2/place_bet now answers 410 Gone. Change the URL and read result
from the poll response instead of the direct response.
| Aspect | v2 sync (/v2/place_bet, retired) | v3 async (/v3/place_bet) |
|---|---|---|
| Returns | 410 Gone | {correlation_id, …} in ~100ms |
| Timeouts | - | Decoupled; HTTP request never times out on the bet itself |
| Retrieving result | - | Poll /api/bet_status or webhook |
| Payload shape | - | Same bet body (plus optional callback_url, trace_id, idempotency_key, ...) |
stacked_srm | - | /v3/stacked_srm (same async contract) |
betfair | - | Supported (BACK/LAY + BSP) |
Once you read statuses[0].result from /api/bet_status: result.success
is placed/not, and the bookie receipt (bet_id, odds, stake) sits on
result itself.
while loop, so this should be very rare.