API Reference
Read and withdraw funds from a bookmaker account via an active session. This page covers two endpoints:
POST /v3/balance. Synchronous -
returns the balance directly in the response body.POST /v3/withdraw_balance.
Async - returns HTTP 200 with status: "pending" + a
correlation_id, same contract as the other v3 endpoints.Base URL: https://api.b337.ai
Both endpoints require API key authentication:
X-API-Key: YOUR_API_KEYContent-Type: application/jsonUnlike the other v3 endpoints (/v3/place_bet, /v3/withdraw_balance,
/v3/price_check), Get Balance is synchronous - it does not return
a pending envelope + correlation_id. The server reads the balance straight from the
Redis cache and returns it inline, typically in ~tens of milliseconds.
The balance cache is kept warm - it is eagerly seeded from the stored account balance when a
session starts and refreshed on every session heartbeat. Treat the response
as the final answer: do not poll /api/bet_status for this endpoint.
| Field | Type | Required | Description |
|---|---|---|---|
session_id | string (UUID) | Yes | Active session ID to read the balance for |
| Field | Type | Description |
|---|---|---|
balance | number | Total account balance (cash + bonus) |
bonus_balance | number | Portion of the balance held as bonus / promo funds |
withdrawable_balance | number | Cash available to withdraw right now. Accounts that have not reported it yet return balance here |
success | bool | false when no balance is available (see below) |
timestamp | string | Server time of this response (ISO 8601). It is not when the balance was read |
If the session has not reported a balance and none is stored, the call still
answers 200, with no balance fields:
Check success before reading balance; retry shortly or restart the session.
400 - session_id is required401 - Invalid API key403 - Session is not active (the session is not yours, or not running)404 - Session not found500 - Internal server errorInitiate a withdrawal from a bookmaker account via an active session. The
endpoint is async - it returns in ~100ms with a correlation_id and
the actual bookie withdrawal runs in the background. Retrieve the final
result by polling /api/bet_status or by registering a webhook
callback_url.
This uses the same async contract as POST /v3/place_bet. If you've
already wired up polling/webhooks for place_bet, the withdraw flow is a
drop-in: same status states, same callback shape, same polling endpoint.
Withdrawals are supported on nearly every bookmaker - all the major AU books
and every brand on their shared platforms. The exceptions, where withdrawals
are not supported yet: PlayUp, NextBet, Picklebet, BoostBet, 123bet,
BetPinnacle, GRSBet, LaserBet, Multis and MyBet (and Betfair - withdraw on
Betfair itself). On those, the submit still answers normally with a
correlation_id, and the result comes back as a clean refusal - nothing is
sent to the bookmaker:
Withdraw on the bookmaker's own site or app for those; support for the remaining bookmakers is added as each is built.
There is no destination parameter - the request carries only a session and an amount, and the money can only land on a withdrawal option already saved and verified on the bookmaker account. A withdrawal can never add a new destination. If the account has more than one saved option, the bookmaker's default is used:
Multiple saved options never cause a failure - the withdrawal simply goes to the default. To control which account receives withdrawals, make it the primary (or only) saved option on the bookmaker's own website.
| Field | Type | Required | Description |
|---|---|---|---|
session_id | string (UUID) | Yes | Active session ID to withdraw from |
amount | number | Yes | Positive decimal amount to withdraw |
callback_url | string | No | If set, the result is POSTed to this URL when ready. Must be http:// or https:// and its host must resolve only to public IP addresses, otherwise 400. If absent, poll for the result. |
status is always literal "pending" on submission. timeout_at is
~5 minutes from submitted_at - cap your polling at that time.
If callback_url registration fails, the field comes back as null -
fall back to polling in that case. (A sandbox sample of this route returns
202.)
POST /api/bet_status with the correlation_id until status flips off
pending.
Response:
When status === "completed", the result field is the bookie payload -
the same shape the legacy sync endpoint used to return inline. Poll every
~2-3 seconds; stop when status is not pending.
status values:
pending - withdrawal is in flight, keep polling.completed - withdrawal finished, read result.timeout - server gave up waiting for the client. Treat as a transient failure.unknown - correlation_id expired (over 90 minutes since submission).The polling endpoint is named
/api/bet_statusfor historical reasons - it works for any correlation_id (place_bet, withdraw_balance, price_check).
Provide callback_url in the original request and the result will be POSTed
to your URL when ready.
Requirements: your URL must be reachable from api.b337.ai, resolve only
to public IP addresses, and respond 2xx within 10 seconds. Redirects are
not followed: a 3xx answer counts as a failed delivery.
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)
Signature verification and retry semantics (3 attempts in total, waiting 1s then 4s between them) are identical to place_bet. See the Async API (v3) guide for the verification snippet.
The bookie result inside statuses[0].result (or the webhook's result
field) has the following shape:
| Field | Type | Description |
|---|---|---|
success | bool | Whether the withdrawal was accepted by the bookie |
message | string | Human-readable status / error message |
withdrawal_id | string | Bookie-side reference for the withdrawal (when available) |
amount | number | Amount requested |
status | string | pending | completed | failed - the bookie's own state for the withdrawal (separate from the async job state) |
bookie | string | Bookie identifier |
400 - session_id or amount missing/invalid, or callback_url is not a public http(s) URL401 - Invalid API key403 - Invalid session_id or session does not belong to user404 - Session not found410 - you called a retired withdraw route; use /v3/withdraw_balance500 - Internal server error503 - PC is not online. Please ensure the client is running.Errors come back as {"detail": "..."}.