Create a trading stream token
Returns a short-lived token for the real-time trading stream of all your organization’s trading accounts: every order, execution, position change, balance/equity update and rule violation, as it happens. New accounts are included automatically.
The stream is read-only. It accepts no trading commands.
Connect to the returned url with the token in the Authorization header:
TOKEN=$(curl -s -X POST "https://api.hyperprop.com/platform/v1/organization/trading-accounts/stream-token" \
-H "X-API-Key: hp_live_your_key_here" | jq -r .data.token)
websocat -H "Authorization: Bearer $TOKEN" wss://api.hyperprop.com/trade/org/stream
The first message is {"type": "Welcome", "organization_id": ..., "expires_at": ...}. Then each event arrives as one JSON message with a type: OrderSubmitted, OrderFilled (one per execution, with the trade), OrderCancelled, PositionUpdate, AccountUpdate (balance, equity, P&L, drawdown, status), RuleViolation and account Notification. Every event carries account_id. A Heartbeat arrives every 15 seconds.
Token lifetime: 15 minutes. Before it expires, request a new token and send {"action": "refresh", "token": "<new token>"} on the open connection (reply TokenRefreshed). Otherwise the connection closes with code 4001 and you reconnect with a new token. A revoked API key can’t get new tokens, so its connections end within one token lifetime.
Missed events: the stream does not replay. If your connection falls behind, you get {"type": "StreamGap", "dropped_events": n}; after a StreamGap or a reconnect, read current state from the trading account endpoints. A client that stops reading is disconnected (code 4008).
Limits: 5 open connections per organization per server; more are refused with HTTP 429. One connection carries all your accounts, so one or two are enough. Send {"action": "ping"} for a Pong.
Requires view permission on traders.
curl --request POST \
--url https://api.hyperprop.com/platform/v1/organization/trading-accounts/stream-token \
--header 'X-API-Key: <api-key>'import requests
url = "https://api.hyperprop.com/platform/v1/organization/trading-accounts/stream-token"
headers = {"X-API-Key": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'X-API-Key': '<api-key>'}};
fetch('https://api.hyperprop.com/platform/v1/organization/trading-accounts/stream-token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.hyperprop.com/platform/v1/organization/trading-accounts/stream-token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.hyperprop.com/platform/v1/organization/trading-accounts/stream-token"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("X-API-Key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.hyperprop.com/platform/v1/organization/trading-accounts/stream-token")
.header("X-API-Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.hyperprop.com/platform/v1/organization/trading-accounts/stream-token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6Im9yZ19zdHJlYW0ifQ.c2lnbmF0dXJl",
"expiresIn": 900,
"expiresAt": "2026-10-25T16:15:00.000Z",
"url": "wss://api.hyperprop.com/trade/org/stream"
}
}{
"success": false,
"statusCode": 401,
"error": "Unauthorized",
"message": "Authentication required",
"code": "UNAUTHORIZED"
}{
"success": false,
"statusCode": 403,
"error": "Forbidden",
"message": "This API key does not have admin permissions",
"code": "INSUFFICIENT_PERMISSIONS"
}{
"success": false,
"statusCode": 503,
"error": "Error",
"message": "The trading stream is not available right now",
"code": "STREAM_UNAVAILABLE"
}curl --request POST \
--url https://api.hyperprop.com/platform/v1/organization/trading-accounts/stream-token \
--header 'X-API-Key: <api-key>'import requests
url = "https://api.hyperprop.com/platform/v1/organization/trading-accounts/stream-token"
headers = {"X-API-Key": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'X-API-Key': '<api-key>'}};
fetch('https://api.hyperprop.com/platform/v1/organization/trading-accounts/stream-token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.hyperprop.com/platform/v1/organization/trading-accounts/stream-token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.hyperprop.com/platform/v1/organization/trading-accounts/stream-token"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("X-API-Key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.hyperprop.com/platform/v1/organization/trading-accounts/stream-token")
.header("X-API-Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.hyperprop.com/platform/v1/organization/trading-accounts/stream-token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6Im9yZ19zdHJlYW0ifQ.c2lnbmF0dXJl",
"expiresIn": 900,
"expiresAt": "2026-10-25T16:15:00.000Z",
"url": "wss://api.hyperprop.com/trade/org/stream"
}
}{
"success": false,
"statusCode": 401,
"error": "Unauthorized",
"message": "Authentication required",
"code": "UNAUTHORIZED"
}{
"success": false,
"statusCode": 403,
"error": "Forbidden",
"message": "This API key does not have admin permissions",
"code": "INSUFFICIENT_PERMISSIONS"
}{
"success": false,
"statusCode": 503,
"error": "Error",
"message": "The trading stream is not available right now",
"code": "STREAM_UNAVAILABLE"
}