Saxo OpenAPI POST /port/v1/balances/subscriptions
Sets up a streaming subscription on a balance and returns a first snapshot of it.
Risk warning: CFDs and spread bets are complex instruments and come with a high risk of losing money rapidly due to leverage. You can lose money on these products, and each provider publishes its own loss figure under FCA rules. You should consider whether you understand how they work and whether you can afford to take the high risk of losing your money. Automated and API trading can amplify losses through bugs, connectivity failures and runaway orders.
Read on Saxo's own reference page on 12 Oct 2026: method, path, parameters and response fields. Needs an open WebSocket connection with the same ContextId. Updates after the first snapshot arrive on that connection, not in the reply to this call. Remove the subscription when you are done with it. Saxo lists the permission needed as Subscribe.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
| Content-Typerequired | header | string | Send application/json on a request with a body. |
| ContextIdrequired | body | string | Id of your streaming connection: letters, digits, dash and underscore, up to 50 characters. |
| ReferenceIdrequired | body | string | Your own id for this subscription, up to 50 characters. It cannot start with an underscore. |
| Arguments | body | object | BalanceRequest: the client, account group or account whose balance to follow. |
| RefreshRate | body | integer | Shortest time in milliseconds between updates. It cannot go below the rate in your service agreement. |
| Format | body | string | Media type of the streamed updates: application/json or application/x-protobuf. |
| ReplaceReferenceId | body | string | Reference id of an existing subscription that this one replaces. |
Authentication headers
| Name | Type | Description |
|---|---|---|
| Authorizationrequired | string | OAuth 2.0 bearer access token. In SIM you can use a 24 hour token from the Saxo developer portal. Placeholder only: never paste a real token into this site. |
Request
Written from the method, path and parameters recorded on this page, against the demo host. Not executed against a live or demo account. Credentials are read from environment variables on your own machine and are never entered on this site. The request builder writes these same snippets, from the same record.
This call takes a request body. The samples send it as JSON with a Content-Type of application/json (in Python, passing json= sets that header) and a placeholder for each of the 2 body fields the record marks as required. Each placeholder has to be replaced with a real value before the request can succeed.
Python
# Set SAXO_SIM_TOKEN as an environment variable first. Never paste real values into code.
# Replace each {placeholder}, "..." and 0 with a real value before running.
# Optional and not shown: body fields Arguments, RefreshRate, Format, ReplaceReferenceId.
import os
import requests
BASE_URL = "https://gateway.saxobank.com/sim/openapi" # the demo host
headers = {
"Authorization": "Bearer " + os.environ["SAXO_SIM_TOKEN"],
"Content-Type": "application/json",
}
body = {"ContextId": "...", "ReferenceId": "..."}
resp = requests.post(BASE_URL + "/port/v1/balances/subscriptions", headers=headers, json=body, timeout=10)
resp.raise_for_status()
print(resp.json())JavaScript
// Set SAXO_SIM_TOKEN as an environment variable first. Never paste real values into code.
// Replace each {placeholder}, "..." and 0 with a real value before running.
// Optional and not shown: body fields Arguments, RefreshRate, Format, ReplaceReferenceId.
// Run as a module, for example a .mjs file, on a Node version that has fetch built in.
const BASE_URL = "https://gateway.saxobank.com/sim/openapi"; // the demo host
const res = await fetch(BASE_URL + "/port/v1/balances/subscriptions", {
method: "POST",
headers: {
"Authorization": "Bearer " + process.env.SAXO_SIM_TOKEN,
"Content-Type": "application/json",
},
body: JSON.stringify({"ContextId": "...", "ReferenceId": "..."}),
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
console.log(await res.json());curl
# Set SAXO_SIM_TOKEN as an environment variable first. Never paste real values into code.
# Replace each {placeholder}, "..." and 0 with a real value before running.
# Optional and not shown: body fields Arguments, RefreshRate, Format, ReplaceReferenceId.
curl -X POST "https://gateway.saxobank.com/sim/openapi/port/v1/balances/subscriptions" \
-H "Authorization: Bearer $SAXO_SIM_TOKEN" \
-H "Content-Type: application/json" \
-d '{"ContextId": "...", "ReferenceId": "..."}'Response
A mock response. The values are invented, so check field names against the official reference.
{
"_mock": true,
"ContextId": "MOCKCONTEXT01",
"ReferenceId": "MOCKREF01",
"RefreshRate": 1000,
"InactivityTimeout": 30,
"Format": "application/json",
"State": "Active",
"Snapshot": {
"CashBalance": 10000,
"CashAvailableForTrading": 9900
}
}Limits that apply at Saxo OpenAPI
| Limit | Value | Scope | Source |
|---|---|---|---|
| Headline limit | 120/min per session, per service group | session | developer.saxochecked |
Saxo API errors you may meet
- HTTP 409 (duplicate order)HTTP 409. An identical order was sent within a rolling 15 second window and was rejected.
- HTTP 426HTTP 426. Upgrade Required.
- HTTP 429HTTP 429. Rate limit exceeded: 120 requests per minute per session per service group, 1 order per second per session, or 10,000,000 per day per app.
- ActiveFollowerCannotDoManualTradeHTTP 400. Opening or closing a position is not allowed on an active strategy account.
- AlgoOrderTimeBeforeExchangeOpenHTTP 400. An algo order parameter carries a time before the exchange opens.
- AmountBelowMinimumLotSizeHTTP 400. The order size is below the exchange's minimum lot size.
All Saxo API error codes, including 137 more not listed here.