# CrossTrade API — Complete Reference for AI Agents Generated from the live OpenAPI spec. This file describes the CrossTrade REST API surface as published at app.crosstrade.io. --- ## Base URL All endpoints are rooted at `https://app.crosstrade.io`. Note: the path prefix is `/v1/api/...` — there is **no** `/api/...` route. If you guess `/api/order`, `/api/orders`, or `/api/v1/...` you will get a 404. ## Authentication Every request must carry a Bearer token: ``` Authorization: Bearer ``` Tokens are issued from https://app.crosstrade.io/user/my-account and require an active Pro subscription. ## Rate limits - 180 requests / minute per user, shared across HTTP and WebSocket. - 20-request burst allowance on top of that. - Per-endpoint egress caps apply to bulk endpoints (bars, executions). ## Response shape Every successful response carries `"success": true`. Errors carry `"success": false` plus an `"error"` string (machine-readable code) and an optional `"detail"` (human-readable). Some endpoints add `"warning"` for non-fatal edge cases (e.g. flatten with no positions). ```json {"success": true, "data": ...} {"success": false, "error": "invalid_account", "detail": "Account Sim999 not found"} ``` ## Instrument format Wherever an `instrument` parameter is accepted, all of these resolve: - `"ES 03-26"` — full dated form (always works) - `"ES"` — root symbol, resolves to current front month - `"ES1!"` — TradingView continuous format - `"ESH26"` — CME code format ## Common gotchas - Endpoints are **PascalCase RPC names** mapped to **REST paths**: `PlaceOrder` → `POST /v1/api/accounts/{account}/orders/place`. Don't invent /api/orders. - Path parameters live in the URL; everything else for POST/PUT goes in a JSON body. No form-encoding. - The user must have NinjaTrader running with the CrossTrade add-on connected — otherwise calls return `{"success": false, "error": "..."}` with HTTP 408. - `account` values are case-insensitive on input but echoed in canonical case. --- ## Endpoints ### Accounts #### `GET /v1/api/accounts` Get Accounts **Example:** ```bash curl -H "Authorization: Bearer $XTRADE_TOKEN" "https://app.crosstrade.io/v1/api/accounts" ``` --- #### `GET /v1/api/accounts/snapshot` Get Accounts Summary **Example:** ```bash curl -H "Authorization: Bearer $XTRADE_TOKEN" "https://app.crosstrade.io/v1/api/accounts/snapshot" ``` --- #### `GET /v1/api/accounts/{account}` Get Account **Path parameters:** - `account` (required) — Account name (e.g., "Sim101") **Example:** ```bash curl -H "Authorization: Bearer $XTRADE_TOKEN" "https://app.crosstrade.io/v1/api/accounts/Sim101" ``` --- #### `GET /v1/api/accounts/{account}/position` Get Position by Account + Instrument (instrument URL-encoded) **Path parameters:** - `account` (required) — Account name (e.g., "Sim101") **Query parameters:** - `instrument` (required) **Example:** ```bash curl -H "Authorization: Bearer $XTRADE_TOKEN" "https://app.crosstrade.io/v1/api/accounts/Sim101/position" ``` --- #### `GET /v1/api/accounts/{account}/quote` Get Quote **Query parameters:** - `instrument` (required) - `root` (required) - `showRollover` (optional) **Example:** ```bash curl -H "Authorization: Bearer $XTRADE_TOKEN" "https://app.crosstrade.io/v1/api/accounts/{account}/quote" ``` --- #### `GET /v1/api/accounts/{account}/watermarks` Get Watermarks (per-account high/low water marks) **Path parameters:** - `account` (required) — Account name (e.g., "Sim101") **Example:** ```bash curl -H "Authorization: Bearer $XTRADE_TOKEN" "https://app.crosstrade.io/v1/api/accounts/Sim101/watermarks" ``` --- ### Executions #### `GET /v1/api/accounts/{account}/executions` Get Executions by Account **Path parameters:** - `account` (required) — Account name (e.g., "Sim101") **Query parameters:** - `lookbackTime` (optional) **Example:** ```bash curl -H "Authorization: Bearer $XTRADE_TOKEN" "https://app.crosstrade.io/v1/api/accounts/Sim101/executions" ``` --- #### `GET /v1/api/accounts/{account}/executions/{id}` Get Execution by ID **Path parameters:** - `account` (required) — Account name (e.g., "Sim101") - `id` (required) — Resource ID **Example:** ```bash curl -H "Authorization: Bearer $XTRADE_TOKEN" "https://app.crosstrade.io/v1/api/accounts/Sim101/executions/Sim101" ``` --- #### `GET /v1/api/executions/order/{orderId}` Get Executions by Order ID (matches both current and original/initial order ID) **Path parameters:** - `orderId` (required) — Order ID **Example:** ```bash curl -H "Authorization: Bearer $XTRADE_TOKEN" "https://app.crosstrade.io/v1/api/executions/order/Sim101" ``` --- ### General #### `GET /v1/api/atm-templates` Get All ATM Templates **Example:** ```bash curl -H "Authorization: Bearer $XTRADE_TOKEN" "https://app.crosstrade.io/v1/api/atm-templates" ``` --- ### Market Data #### `POST /v1/api/market/bars` Get historical bars **Request body:** ```json { "daysBack": 1, "dividendAdjust": true, "from": "", "instrument": "ES 03-26", "limit": 1, "mergePolicy": "", "period": 1, "periodType": "", "splitAdjust": true, "to": "" } ``` **Body fields:** - `daysBack` (integer, (optional)) - `dividendAdjust` (boolean, (optional)) - `from` (string, (optional)) - `instrument` (string, (required)) - `limit` (integer, (optional)) - `mergePolicy` (string, (optional)) - `period` (integer, (optional)) - `periodType` (string, (optional)) - `splitAdjust` (boolean, (optional)) - `to` (string, (optional)) **Example:** ```bash curl -X POST -H "Authorization: Bearer $XTRADE_TOKEN" \ -H "Content-Type: application/json" \ -d '{"daysBack": 1, "dividendAdjust": true, "from": "", "instrument": "ES 03-26", "limit": 1, "mergePolicy": "", "period": 1, "periodType": "", "splitAdjust": true, "to": ""}' \ "https://app.crosstrade.io/v1/api/market/bars" ``` --- #### `GET /v1/api/market/info` Get Market Info **Query parameters:** - `instrument` (required) - `root` (required) **Example:** ```bash curl -H "Authorization: Bearer $XTRADE_TOKEN" "https://app.crosstrade.io/v1/api/market/info" ``` --- #### `GET /v1/api/market/quote` Get Quote **Query parameters:** - `instrument` (required) - `root` (required) - `showRollover` (optional) **Example:** ```bash curl -H "Authorization: Bearer $XTRADE_TOKEN" "https://app.crosstrade.io/v1/api/market/quote" ``` --- ### Orders #### `GET /v1/api/accounts/{account}/orders` List Active/Orders in Account **Path parameters:** - `account` (required) — Account name (e.g., "Sim101") **Query parameters:** - `activeOnly` (optional) **Example:** ```bash curl -H "Authorization: Bearer $XTRADE_TOKEN" "https://app.crosstrade.io/v1/api/accounts/Sim101/orders" ``` --- #### `POST /v1/api/accounts/{account}/orders/cancel` Cancel Orders by Account + Instrument **Path parameters:** - `account` (required) — Account name (e.g., "Sim101") **Request body:** ```json { "force": true, "instrument": "ES 03-26", "strategyTag": "" } ``` **Body fields:** - `force` (boolean, (optional)) - `instrument` (string, (optional)) - `strategyTag` (string, (optional)) **Example:** ```bash curl -X POST -H "Authorization: Bearer $XTRADE_TOKEN" \ -H "Content-Type: application/json" \ -d '{"force": true, "instrument": "ES 03-26", "strategyTag": ""}' \ "https://app.crosstrade.io/v1/api/accounts/Sim101/orders/cancel" ``` --- #### `POST /v1/api/accounts/{account}/orders/cancel_and_bracket` Cancel existing orders and immediately place new OCO Bracket (TP/SL) **Path parameters:** - `account` (required) — Account name (e.g., "Sim101") **Request body:** ```json { "action": "Buy", "delayMs": 1, "force": true, "instrument": "ES 03-26", "ocoId": "", "quantity": 1, "stopLoss": 0, "strategyTag": "", "takeProfit": 0 } ``` **Body fields:** - `action` (string, (required)) - `delayMs` (integer, (optional)) - `force` (boolean, (optional)) - `instrument` (string, (required)) - `ocoId` (string, (optional)) - `quantity` (integer, (required)) - `stopLoss` (number, (optional)) - `strategyTag` (string, (optional)) - `takeProfit` (number, (optional)) **Example:** ```bash curl -X POST -H "Authorization: Bearer $XTRADE_TOKEN" \ -H "Content-Type: application/json" \ -d '{"action": "Buy", "delayMs": 1, "force": true, "instrument": "ES 03-26", "ocoId": "", "quantity": 1, "stopLoss": 0, "strategyTag": "", "takeProfit": 0}' \ "https://app.crosstrade.io/v1/api/accounts/Sim101/orders/cancel_and_bracket" ``` --- #### `POST /v1/api/accounts/{account}/orders/flatplace` Flat Place Order **Path parameters:** - `account` (required) — Account name (e.g., "Sim101") **Request body:** ```json { "action": "Buy", "force": true, "instrument": "ES 03-26", "quantity": 1, "strategyTag": "" } ``` **Body fields:** - `action` (string, (optional)) - `force` (boolean, (optional)) - `instrument` (string, (optional)) - `quantity` (integer, (optional)) - `strategyTag` (string, (optional)) **Example:** ```bash curl -X POST -H "Authorization: Bearer $XTRADE_TOKEN" \ -H "Content-Type: application/json" \ -d '{"action": "Buy", "force": true, "instrument": "ES 03-26", "quantity": 1, "strategyTag": ""}' \ "https://app.crosstrade.io/v1/api/accounts/Sim101/orders/flatplace" ``` --- #### `POST /v1/api/accounts/{account}/orders/place` Place Order **Path parameters:** - `account` (required) — Account name (e.g., "Sim101") **Request body:** ```json { "action": "Buy", "force": true, "instrument": "ES 03-26", "limitPrice": 0, "maxPositions": 1, "ocoId": "", "orderId": "", "orderType": "", "quantity": 1, "requireMarketPosition": "", "smartOptions": {}, "stopPrice": 0, "strategy": "", "strategyTag": "", "targetQuantity": 1, "timeInForce": "" } ``` **Body fields:** - `action` (string, (required)) - `force` (boolean, (optional)) - `instrument` (string, (required)) - `limitPrice` (number, (optional)) - `maxPositions` (integer, (optional)) - `ocoId` (string, (optional)) - `orderId` (string, (optional)) - `orderType` (string, (required)) - `quantity` (integer, (required)) - `requireMarketPosition` (string, (optional)) - `smartOptions` (object, (optional)) - `stopPrice` (number, (optional)) - `strategy` (string, (optional)) - `strategyTag` (string, (optional)) - `targetQuantity` (integer, (optional)) - `timeInForce` (string, (required)) **Example:** ```bash curl -X POST -H "Authorization: Bearer $XTRADE_TOKEN" \ -H "Content-Type: application/json" \ -d '{"action": "Buy", "force": true, "instrument": "ES 03-26", "limitPrice": 0, "maxPositions": 1, "ocoId": "", "orderId": "", "orderType": "", "quantity": 1, "requireMarketPosition": "", "smartOptions": {}, "stopPrice": 0, "strategy": "", "strategyTag": "", "targetQuantity": 1, "timeInForce": ""}' \ "https://app.crosstrade.io/v1/api/accounts/Sim101/orders/place" ``` --- #### `GET /v1/api/accounts/{account}/orders/{id}` Get Order by ID **Path parameters:** - `account` (required) — Account name (e.g., "Sim101") - `id` (required) — Resource ID **Example:** ```bash curl -H "Authorization: Bearer $XTRADE_TOKEN" "https://app.crosstrade.io/v1/api/accounts/Sim101/orders/Sim101" ``` --- #### `POST /v1/api/accounts/{account}/orders/{id}/cancel` Cancel Order by ID **Path parameters:** - `account` (required) — Account name (e.g., "Sim101") - `id` (required) — Resource ID **Example:** ```bash curl -X POST -H "Authorization: Bearer $XTRADE_TOKEN" \ -H "Content-Type: application/json" \ "https://app.crosstrade.io/v1/api/accounts/Sim101/orders/Sim101/cancel" ``` --- #### `PUT /v1/api/accounts/{account}/orders/{id}/change` Change Order **Path parameters:** - `account` (required) — Account name (e.g., "Sim101") - `id` (required) — Resource ID **Request body:** ```json { "force": true, "limitPrice": 0, "orderId": "", "quantity": 1, "stopPrice": 0, "strategyId": "", "strategyTag": "" } ``` **Body fields:** - `force` (boolean, (optional)) - `limitPrice` (number, (optional)) - `orderId` (string, (required)) - `quantity` (integer, (optional)) - `stopPrice` (number, (optional)) - `strategyId` (string, (optional)) - `strategyTag` (string, (optional)) **Example:** ```bash curl -X PUT -H "Authorization: Bearer $XTRADE_TOKEN" \ -H "Content-Type: application/json" \ -d '{"force": true, "limitPrice": 0, "orderId": "", "quantity": 1, "stopPrice": 0, "strategyId": "", "strategyTag": ""}' \ "https://app.crosstrade.io/v1/api/accounts/Sim101/orders/Sim101/change" ``` --- #### `POST /v1/api/accounts/{account}/orders/{id}/replace` Cancel Replace Order **Path parameters:** - `account` (required) — Account name (e.g., "Sim101") - `id` (required) — Resource ID **Request body:** ```json { "action": "Buy", "force": true, "instrument": "ES 03-26", "orderId": "", "orderType": "", "quantity": "", "strategyTag": "", "timeInForce": "" } ``` **Body fields:** - `action` (string, (required)) - `force` (boolean, (optional)) - `instrument` (string, (required)) - `orderId` (string, (required)) - `orderType` (string, (required)) - `quantity` (string, (required)) - `strategyTag` (string, (optional)) - `timeInForce` (string, (required)) **Example:** ```bash curl -X POST -H "Authorization: Bearer $XTRADE_TOKEN" \ -H "Content-Type: application/json" \ -d '{"action": "Buy", "force": true, "instrument": "ES 03-26", "orderId": "", "orderType": "", "quantity": "", "strategyTag": "", "timeInForce": ""}' \ "https://app.crosstrade.io/v1/api/accounts/Sim101/orders/Sim101/replace" ``` --- #### `GET /v1/api/accounts/{account}/orders/{id}/status` Get Order Status by ID **Path parameters:** - `account` (required) — Account name (e.g., "Sim101") - `id` (required) — Resource ID **Example:** ```bash curl -H "Authorization: Bearer $XTRADE_TOKEN" "https://app.crosstrade.io/v1/api/accounts/Sim101/orders/Sim101/status" ``` --- #### `GET /v1/api/orders` Get All Orders (Across all accounts) **Query parameters:** - `activeOnly` (optional) - `lookbackTime` (required) **Example:** ```bash curl -H "Authorization: Bearer $XTRADE_TOKEN" "https://app.crosstrade.io/v1/api/orders" ``` --- #### `POST /v1/api/orders/cancelall` Cancel All Orders in All Accounts **Example:** ```bash curl -X POST -H "Authorization: Bearer $XTRADE_TOKEN" \ -H "Content-Type: application/json" \ "https://app.crosstrade.io/v1/api/orders/cancelall" ``` --- ### Positions #### `GET /v1/api/accounts/{account}/positions` List Active Positions in Account **Path parameters:** - `account` (required) — Account name (e.g., "Sim101") **Example:** ```bash curl -H "Authorization: Bearer $XTRADE_TOKEN" "https://app.crosstrade.io/v1/api/accounts/Sim101/positions" ``` --- #### `POST /v1/api/accounts/{account}/positions/close` Close Position (account, instrument) **Path parameters:** - `account` (required) — Account name (e.g., "Sim101") **Request body:** ```json { "force": true, "instrument": "ES 03-26", "percent": 0, "quantity": 1, "strategyTag": "" } ``` **Body fields:** - `force` (boolean, (optional)) - `instrument` (string, (required)) - `percent` (number, (optional)) - `quantity` (integer, (optional)) - `strategyTag` (string, (optional)) **Example:** ```bash curl -X POST -H "Authorization: Bearer $XTRADE_TOKEN" \ -H "Content-Type: application/json" \ -d '{"force": true, "instrument": "ES 03-26", "percent": 0, "quantity": 1, "strategyTag": ""}' \ "https://app.crosstrade.io/v1/api/accounts/Sim101/positions/close" ``` --- #### `POST /v1/api/accounts/{account}/positions/flatten` Flatten Positions in 1 account (account, instrument) **Path parameters:** - `account` (required) — Account name (e.g., "Sim101") **Request body:** ```json { "cancelOrders": true, "force": true, "instrument": "ES 03-26", "strategyTag": "", "strategyTagMode": "" } ``` **Body fields:** - `cancelOrders` (boolean, (optional)) - `force` (boolean, (optional)) - `instrument` (string, (optional)) - `strategyTag` (string, (optional)) - `strategyTagMode` (string, (optional)) **Example:** ```bash curl -X POST -H "Authorization: Bearer $XTRADE_TOKEN" \ -H "Content-Type: application/json" \ -d '{"cancelOrders": true, "force": true, "instrument": "ES 03-26", "strategyTag": "", "strategyTagMode": ""}' \ "https://app.crosstrade.io/v1/api/accounts/Sim101/positions/flatten" ``` --- #### `POST /v1/api/accounts/{account}/positions/reverse` Reverse **Path parameters:** - `account` (required) — Account name (e.g., "Sim101") **Request body:** ```json { "force": true, "instrument": "ES 03-26", "strategyTag": "" } ``` **Body fields:** - `force` (boolean, (optional)) - `instrument` (string, (required)) - `strategyTag` (string, (optional)) **Example:** ```bash curl -X POST -H "Authorization: Bearer $XTRADE_TOKEN" \ -H "Content-Type: application/json" \ -d '{"force": true, "instrument": "ES 03-26", "strategyTag": ""}' \ "https://app.crosstrade.io/v1/api/accounts/Sim101/positions/reverse" ``` --- #### `POST /v1/api/accounts/{account}/positions/reverseposition` Reverse Position (account, instrument, action, orderType, quantity, timeInForce, limitPrice, stopPrice, ocoId, strategy) **Path parameters:** - `account` (required) — Account name (e.g., "Sim101") **Request body:** ```json { "action": "Buy", "force": true, "instrument": "ES 03-26", "quantity": 1, "strategyTag": "" } ``` **Body fields:** - `action` (string, (optional)) - `force` (boolean, (optional)) - `instrument` (string, (optional)) - `quantity` (integer, (optional)) - `strategyTag` (string, (optional)) **Example:** ```bash curl -X POST -H "Authorization: Bearer $XTRADE_TOKEN" \ -H "Content-Type: application/json" \ -d '{"action": "Buy", "force": true, "instrument": "ES 03-26", "quantity": 1, "strategyTag": ""}' \ "https://app.crosstrade.io/v1/api/accounts/Sim101/positions/reverseposition" ``` --- #### `GET /v1/api/positions` Get All Open Positions (Across all accounts) **Query parameters:** - `includeFlat` (optional) **Example:** ```bash curl -H "Authorization: Bearer $XTRADE_TOKEN" "https://app.crosstrade.io/v1/api/positions" ``` --- #### `POST /v1/api/positions/flatten` Flatten All Positions in All Accounts **Request body:** ```json { "account": "Sim101", "cancelOrders": true, "force": true, "instrument": "ES 03-26", "strategyTag": "", "strategyTagMode": "" } ``` **Body fields:** - `account` (string, (optional)) - `cancelOrders` (boolean, (optional)) - `force` (boolean, (optional)) - `instrument` (string, (optional)) - `strategyTag` (string, (optional)) - `strategyTagMode` (string, (optional)) **Example:** ```bash curl -X POST -H "Authorization: Bearer $XTRADE_TOKEN" \ -H "Content-Type: application/json" \ -d '{"account": "Sim101", "cancelOrders": true, "force": true, "instrument": "ES 03-26", "strategyTag": "", "strategyTagMode": ""}' \ "https://app.crosstrade.io/v1/api/positions/flatten" ``` --- ### Strategies #### `GET /v1/api/accounts/{account}/strategies` Get Active Strategies in Account **Path parameters:** - `account` (required) — Account name (e.g., "Sim101") **Example:** ```bash curl -H "Authorization: Bearer $XTRADE_TOKEN" "https://app.crosstrade.io/v1/api/accounts/Sim101/strategies" ``` --- #### `GET /v1/api/accounts/{account}/strategies/{id}` Get Strategy by ID **Path parameters:** - `account` (required) — Account name (e.g., "Sim101") - `id` (required) — Resource ID **Example:** ```bash curl -H "Authorization: Bearer $XTRADE_TOKEN" "https://app.crosstrade.io/v1/api/accounts/Sim101/strategies/Sim101" ``` --- #### `POST /v1/api/accounts/{account}/strategies/{id}/close` Close Strategy by ID **Path parameters:** - `account` (required) — Account name (e.g., "Sim101") - `id` (required) — Resource ID **Example:** ```bash curl -X POST -H "Authorization: Bearer $XTRADE_TOKEN" \ -H "Content-Type: application/json" \ "https://app.crosstrade.io/v1/api/accounts/Sim101/strategies/Sim101/close" ``` --- ### WebSocket API #### `GET /ws/stream` Streaming WebSocket endpoint **Example:** ```bash curl -H "Authorization: Bearer $XTRADE_TOKEN" "https://app.crosstrade.io/ws/stream" ``` --- ## More resources - OpenAPI 3.1 spec: https://app.crosstrade.io/v1/api/openapi.json - Endpoint catalog (lighter): https://app.crosstrade.io/v1/api/_endpoints - Human docs: https://crosstrade.io/docs/api/overview - AI-assisted dev guide: https://crosstrade.io/docs/api/ai-assisted-development