Complete reference for all Connect Trade REST and WebSocket endpoints. The interactive version is generated from the OpenAPI specification. REST base URL: https://api.connecttrade.com. Authenticate with credential headers or a platform/user Bearer token.
When authenticating with credentials, platform requests require the first two headers; user requests require all four. Access tokens are an alternative:
| Header | Description |
|---|---|
client-id | Your application's API client identifier, issued upon account approval. |
client-secret | Your application's API secret key, issued upon account approval. |
user-id | The identifier for an end user, provided by your application at user creation. |
user-secret | The secret token for the end user, returned by POST /users and stored by your application. |
Requests that operate at the platform level (user creation, listing users, and listing connections across the platform) require only client-id and client-secret. User-scoped requests require all four headers.
Authenticate requests with credential headers. Platform endpoints require client-id and client-secret. User endpoints also require user-id and user-secret. Each endpoint lists its required headers under Authorizations. Keep secrets on your server, never in a browser or mobile app. Server-to-server integrations do not need access tokens.
Optional: use access tokens when a browser or another front end calls Connect Trade directly. Your backend creates a short-lived token with credential headers and passes it to the intended front end. The front end uses Authorization: Bearer <token> or authenticates the Streaming Broker API with access_token, then asks your backend for a new token before expiry.
User tokens are scoped to one user's data and trading permissions. Platform tokens provide privileged multi-user access, suitable only for trusted admin applications, not ordinary end-user clients. Server-to-server integrations can keep using credential headers.
POST /auth/tokens/platform requires client-id and client-secret headers. Tokens are valid for 1 hour. The response contains access_token, UTC expires_at, and token_type (Bearer).
POST /auth/tokens/user requires all four credential headers and a JSON body with scopes: at least one of read (read user data) or trade (create, replace, cancel orders), with no duplicates. Tokens are valid for 15 minutes. The response contains access_token, expires_at, and granted scopes. Invalid scopes return 400.
{"scopes": ["read", "trade"]}
Tokens are created only with credential headers, never with another token. There are no refresh tokens: mint a new token before expiry. Multiple issued tokens can coexist; issuing another does not invalidate earlier tokens. Deleting a user immediately invalidates their tokens. Rotating a secret prevents minting with the old secret, but already-issued tokens remain valid until expiry. These tokens are distinct from the 24-hour market data tokens.
| Method | Endpoint | Description |
|---|---|---|
| POST | /users | Create a new user. Request body: user_id (string). Response: user_id, user-secret (shown once — store securely). |
| GET | /users | List all users associated with your platform credentials. |
| DELETE | /users/{user_id} | Delete a user and all their connections. Requires client-id and client-secret only. |
| Method | Endpoint | Description |
|---|---|---|
| POST | /connections | Create a brokerage connection (HTTP 201). Required fields: user-id, user-secret, type (trade or market_data), redirect_url. Response: authorization_url to display to the user. |
| GET | /connections | List a user's connections with optional ACTIVE or BROKEN status filtering. Repair broken connections using POST /connections/{connection_id}/repair. |
| POST | /connections/{connection_id}/repair | Generate a repair URL. Re-authenticate with the same broker, environment, and accounts to preserve connection identity and restore ACTIVE status. |
| GET | /platform/connections | List connections for all platform users. Requires only client-id and client-secret. Optional status filter (ACTIVE/BROKEN); sorted newest first. Cursor pagination: limit 1–1000 (default 100), and either next_cursor or prev_cursor. Returns required data, next_cursor, and prev_cursor. |
| DELETE | /connections/{connection_id} | Delete a brokerage connection and revoke its associated tokens. |
| GET | /connections/{connection_id}/token | Generate a short-lived access token (24-hour TTL) for the Streaming Market Data API. Only one token is active per connection at a time. |
Submit complex orders with POST /orders and complex_order_parameters. The order_class is separate from the execution type (MKT, LMT, STP, STPLMT). Omit complex_order_parameters for simple orders. Client order IDs (cl_order_id) are limited to 36 characters.
BRACKET: top-level fields define the entry. Both take_profit and stop_loss are required. When the entry fills, exits are placed on the reverse side; filling one cancels the other.OTO: top-level fields define the entry. Exactly one of take_profit or stop_loss is required; it is placed on the reverse side after the entry fills.OCO: no entry. Both take_profit and stop_loss are required. Top-level side applies to both: SELL protects a long position, BUY protects a short position. Filling one cancels the other. Omit top-level order_type, order_limit_price, and stop_price.Take profit requires order_limit_price and uses a limit order. Stop loss requires stop_price; adding order_limit_price makes it stop-limit. Broker/instrument combinations without support return 400 with UNSUPPORTED_ORDER_CLASS.
{"account_id":"ABC123","cl_order_id":"strat-42","broker":"TASTYTRADE","side":"BUY","instrument":"STK","symbol":"AAPL","order_qty":"10","order_type":"LMT","order_limit_price":"180.00","order_tif":"DAY","complex_order_parameters":{"order_class":"BRACKET","take_profit":{"order_limit_price":"195.00"},"stop_loss":{"stop_price":"172.00","order_limit_price":"171.50"}}}
REST order responses and brokerage streaming order updates include order_class, order_group_id, group_role, and parent_order_id. Simple orders use SIMPLE with null group fields. A complex create response also includes order_group. Group roles are ENTRY, TAKE_PROFIT, STOP_LOSS, OTHER. Parent IDs are null for entry and OCO orders.
Filter member orders with GET /orders?order_group_id={order_group_id}. Retrieve a group with GET /accounts/{account_id}/order-groups/{order_group_id}; request cancellation using DELETE on the same path. Group statuses are PENDING_ENTRY, ACTIVE, COMPLETED, CANCELLED, REJECTED, EXPIRED; each member also has its own normalized order status. Cancellation success confirms submission, not completed cancellation. Group cancellation returns 400 for unsupported functionality, 404 if missing, or 409 for a final state or broken connection.
Do not cancel group members individually: GROUP_LEG_NOT_CANCELLABLE requires cancelling the entire group. On an exit order only order_limit_price and stop_price can be modified. Brokers unable to replace a group member return GROUP_LEG_NOT_REPLACEABLE.
Find broken connections with GET /connections?status=BROKEN or GET /platform/connections?status=BROKEN. Request a repair URL using POST /connections/{connection_id}/repair with user credentials or a user access token.
The optional JSON request body accepts redirect_url and redirect_on_error_url, validated like connection creation. A 200 response returns the connection URL using the connection-creation response schema; it does not mean authentication has finished. Invalid data returns 400; a missing connection returns 404.
{"redirect_url": "https://example.com/callbacks/success", "redirect_on_error_url": "https://example.com/callbacks/error"}
The user must authenticate with the same broker and environment and select the same accounts. Successful repair preserves the existing connection_id and accounts and sets status to ACTIVE. The success redirect includes connection_id.
Failed repair leaves the connection unchanged. It redirects to redirect_on_error_url, or falls back to redirect_url, with error and error_details parameters (for example, connection_repair_failed for an account mismatch). With no applicable redirect URL, the user remains on Connect Trade. To change connected accounts, delete the connection and create a new one.
Creating, replacing, or cancelling orders through a broken connection returns 409 Conflict until the connection is repaired.
| Method | Endpoint | Description |
|---|---|---|
| GET | /accounts | List all brokerage accounts for a user. Filter by connection_id or broker. Returns account_id, account_number, institution_name, and broker. The account_id is required for most trading and account endpoints. |
| Method | Endpoint | Description |
|---|---|---|
| GET | /balances | Retrieve cash, buying power, margin, and equity values for connected accounts. Filter by account_id or connection_id. All numeric fields are returned as strings. |
| Method | Endpoint | Description |
|---|---|---|
| GET | /positions | Retrieve current holdings for connected accounts. Filter by account_id, connection_id, or comma-separated symbols (equities, options, crypto pairs, and futures). URL-encode crypto slashes as %2F when necessary. Positions include symbol, quantity, position_average_price, last_price, unrealized_pl, daily_pl, and total_pl; futures positions use instrument: "FUT". |
Futures position example (with response field names matching the position schema):
{
"connection_id": "be573d69-eaad-4ed9-b864-645d43eccd24",
"account_id": "9a091a87-c499-466c-9793-786d6b71ec93",
"user_id": "newuse011",
"account_number": "CCC992771",
"broker_position_id": "6JZ26",
"symbol": "6JZ25",
"quantity": "1.000000000",
"last_price": "0.006389500",
"position_average_price": "0.006389500",
"unrealized_pl": "-79868.750000000",
"daily_pl": "0",
"total_pl": "-79868.750000000",
"instrument": "FUT",
"system_time": "2025-01-01T12:00:00.000000Z"
}
| Method | Endpoint | Description |
|---|---|---|
| POST | /orders | Place an order (HTTP 201). Required: account_id, cl_order_id (unique per day), broker, side, order_type, order_tif, and symbol; instrument is optional. For limit orders: order_limit_price. For stop orders: stop_price. For multi-leg options: instrument = MLEG_OPT, legs array. A broken connection returns 409 Conflict. |
| GET | /orders | List orders. Filter by connection_id, account_id, broker, status, comma-separated symbols (including futures and crypto; URL-encode crypto slashes as %2F when needed), side, start_time, and end_time. Sort via field:direction using entry_time, last_modified_time, or last_exec_time. Pagination: limit (1–500, default 50), next_cursor, prev_cursor. |
| PATCH | /accounts/{account_id}/orders/{order_id} | Modify an open order. Required: new_cl_order_id, broker. Optional: order_qty, order_notional, order_limit_price, stop_price. Broken connections return 409 Conflict. |
| DELETE | /accounts/{account_id}/orders/{order_id} | Cancel an open order. Broken connections return 409 Conflict. |
| Code | Name | Description |
|---|---|---|
MKT | Market | Executes immediately at the current market price. |
LMT | Limit | Executes only at the specified price or better. Requires order_limit_price. |
STP | Stop | Becomes a market order when the stop price is reached. Requires stop_price. |
STPLMT | Stop-Limit | Becomes a limit order when the stop price is reached. Requires both stop_price and order_limit_price. |
| Code | Name | Description |
|---|---|---|
DAY | Day | Active until end of the regular trading session. |
GTC | Good Till Cancel | Active until filled or manually cancelled. |
IOC | Immediate or Cancel | Fill what is available immediately; cancel the remainder. |
FOK | Fill or Kill | Must fill the entire quantity immediately or cancel the whole order. |
OPEN | Market on Open | Executes at the opening auction price. |
CLOSE | Market on Close | Executes at the closing auction price. |
DAY+ | Day + Extended Hours | Active during both regular and extended trading hours for the session. |
GTC+ | GTC + Extended Hours | Active during regular and extended hours until filled or cancelled. |
| Status | Description |
|---|---|
pending | Submitted but not yet acknowledged by the broker. |
working | Active and waiting to be filled. |
partially_filled | Part of the order has been filled; remainder is still working. |
filled | Completely filled. Includes a fills array with per-execution quantity, price, and time. |
cancelled | Cancelled by request or expired. |
rejected | Rejected by the broker. Check broker_message for the reason. |
expired | Expired without being filled (e.g. DAY order past session close). |
replaced | Replaced by a modified version of the order. |
pending_cancel | Cancel request submitted but not yet confirmed. |
pending_replace | Modify request submitted but not yet confirmed. |
| Method | Endpoint | Description |
|---|---|---|
| GET | /transactions | Retrieve historical transaction activity. Filter by account_id, connection_id, start_date, and end_date. Returns transaction type, symbol, quantity, amount, and date. |
Base URL: wss://stream.connecttrade.com. Authenticate with client credentials or an access token within 30 seconds. Platform sessions share 10 sessions per client ID and support 500 users per session. User-token sessions support only their own user, with 5 sessions per user.
Authenticate within 30 seconds using client credentials or an access_token, never both. Client-credential and platform-token sessions subscribe to topics and explicitly subscribe to users. They share a cap of 10 sessions per client ID, with 500 users per session.
{"action": "authenticate", "access_token": "your-access-token"}
User-token sessions are locked to one user and automatically subscribe to that user. Subscribe to topics, but skip subscribe_user. The auth_success response includes user_id. Each user may have 5 concurrent sessions, separate from the client-ID cap. Subscribing another user fails with subscription_failed.
Tokens are checked only at authentication; sessions remain open after token expiry. Reconnect with a valid token and restore topic subscriptions; platform sessions also restore user subscriptions. Expired tokens return auth_error with Access token has expired; other invalid tokens return Invalid access token. Deleting the user sends an error and closes the socket with code 1008 and reason User deleted.
| Action | Direction | Description |
|---|---|---|
authenticate | Client → Server | Send client credentials or access_token (not both) within 30 seconds. |
subscribe | Client → Server | Subscribe to topics: orders, positions, or balances. |
subscribe_user | Client → Server | Subscribe a platform session to one user's updates. User-token sessions automatically subscribe to their own user. |
user_subscribed | Server → Client | Per-user subscription confirmation. |
unsubscribe_user | Client → Server | Release this session's subscription to one platform user. |
user_unsubscribed | Server → Client | Per-user unsubscription confirmation. |
orders | Server → Client | Pushed when an order changes for a subscribed user. |
positions | Server → Client | Pushed when positions change for a subscribed user. |
balances | Server → Client | Pushed when balances change for a subscribed user. |
Repeated subscriptions for the same session/user pair are no-ops. Exceeding 500 users on a platform session returns subscription_failed. Disconnect releases subscriptions; delivery continues until the last subscribing session leaves. Fetch initial snapshots via REST, then apply incremental updates. Reconnect with valid authentication, resubscribe to topics, and replay user subscriptions for platform sessions. User-token sessions automatically subscribe to their own user.
Base URL: wss://mdstream.connecttrade.com. Authenticated using a short-lived access token generated via GET /connections/{connection_id}/token. Tokens are valid for 24 hours. One token active per connection at a time. Connect from the user's browser using the token. All subscriptions for a connection must originate from the same IP address.
| Action | Channel | Description |
|---|---|---|
subscribe | quotes | Real-time Level 1 bid/ask quotes and last trade price for specified symbols. |
subscribe | trades | Real-time time and sales data. Optional session_filter for regular or extended hours. |
subscribe | bars | Real-time OHLCV candlestick bars. Configurable interval (e.g. 1m, 5m, 1h, 1d). Optional historical backfill. |
subscribe | depth | Real-time Level 2 order book. Configurable number of price levels. |
subscribe | options_chain | Real-time options chain data. Optional Greeks (delta, gamma, theta, vega, rho). |
snapshot | bars | Request a historical OHLCV snapshot without a persistent subscription. The response type is snapshot_response; bar timestamps are Unix nanoseconds for bar start time, status is c (closed) or o (open), and each bar includes ev: "b" and sym. |
list_subscriptions | — | List all active subscriptions for the current connection. |
unsubscribe | — | Cancel one or more active subscriptions by channel and symbol. |
Market-data symbols include crypto in BASE/QUOTE form and futures in [ROOT][M][YY] form, for example BTC/USD and ESU26. Bars accept case-sensitive intervals with units m, h, d, w, M, and y; 4h and 240m are equivalent.
Example futures streaming subscription:
{
"action": "subscribe",
"channel": "bars",
"symbol": "ESU26",
"interval": "4h",
"request_id": "unique-request-id"
}
A historical bars snapshot request returns type snapshot_response. Each bar has ts (bar start in Unix nanoseconds), st (c closed or o open), ev: "b", and sym.
{
"type": "snapshot_response",
"request_id": "unique-request-id",
"symbol": "AAPL",
"data_type": "bars",
"interval": "1m",
"start_time": "2025-06-30T09:30:00Z",
"end_time": "2025-06-30T16:00:00Z",
"data": [
{
"o": "200",
"h": "201",
"l": "199.5",
"c": "200.37",
"v": "1500",
"ts": "1751275800000000000",
"st": "c",
"ev": "b",
"sym": "AAPL"
}
]
}
| Code | Meaning |
|---|---|
| 200 | Success. |
| 201 | Connection or order created. |
| 400 | Bad Request — malformed request body, missing required fields, or invalid field value. |
| 401 | Unauthorized — invalid credentials, missing headers, or insufficient entitlements for the requested operation. |
| 404 | Not Found — the specified resource (user, connection, account, or order) does not exist. |
| 409 | Conflict — a duplicate resource or order operation through a BROKEN connection. Recover with POST /connections/{connection_id}/repair and complete broker authentication. |
| 422 | Validation Error — invalid status, cursor, or limit query parameter; next_cursor and prev_cursor are mutually exclusive. |
| 500 | Internal Server Error — an unexpected error occurred on the Connect Trade platform side. |
All error responses return JSON with a message field describing the error.
API documentation | Code cookbook (Python, JavaScript, Go, Rust) | OpenAPI specification (JSON)