# Core Order API

Provides the complete set of API endpoints for managing the lifecycle of  single-leg orders. These endpoints allow you to submit, retrieve, amend, pause, resume, and cancel single-leg orders.&#x20;

For other order-specific API workflows, please refer to the documentation for [Simple Orders](/interacting-with-the-api/api-reference/simple-orders-market-limit-ioc-iceberg.md), [Algorithmic Orders](/interacting-with-the-api/api-reference/algorithmic-orders-vwap-twap-pov.md), [Multi-Orders](/interacting-with-the-api/api-reference/multi-order.md),  and Chained Orders.

## Authentication

All endpoints require Authorization.

* Send Authorization: `Token <API_KEY>` with every request.
* For write endpoints, include `Content-Type: application/json`

### Example:

* Header: Authorization: `Token 1a2b3c...`

## Get all orders

<mark style="color:blue;">`GET`</mark> `/api/orders/`

Get all orders within the past 12 months.  Identity is inferred by API token.

#### Query Parameters

| Name               | Type   | Description                                                                                                                                                                                            |
| ------------------ | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `statuses`         | string | Comma separate values of order statuses. (e.g., "ACTIVE,COMPLETED,CANCELED"). See the [Type Reference page](/interacting-with-the-api/api-reference/type-reference.md) for a list of available values. |
| `account_names`    | string | Comma separated values of account names. If using another user's account, must be scoped with prefix ex. username/account\_name                                                                        |
| `before`           | string | ISO 8601 format timestamp, orders before this timestamp                                                                                                                                                |
| `after`            | string | ISO 8601 format timestamp, orders after this timestamp                                                                                                                                                 |
| `custom_order_ids` | string | Comma separated values of `custom_order_id` submitted with the order                                                                                                                                   |
| `page`             | string | 1-indexed page number, default: 1                                                                                                                                                                      |
| `page_size`        | string | page size, default: 100                                                                                                                                                                                |

#### Response Fields

| Field Name               | Type                | Nullable | Purpose                                                                                        |
| ------------------------ | ------------------- | -------- | ---------------------------------------------------------------------------------------------- |
| `id`                     | string (UUID)       | No       | Unique order identifier                                                                        |
| `custom_order_id`        | string              | No       | Custom order ID provided by client (empty string if not provided)                              |
| `parent_order_id`        | string (UUID)       | Yes      | ID of parent multi-order if this is a child order                                              |
| `batch_order_id`         | string (UUID)       | Yes      | ID of batch order if this order is part of a batch                                             |
| `batch_order_strategy`   | string              | Yes      | Batch strategy name (e.g., "Scale Orders") if part of a batch                                  |
| `notes`                  | string              | Yes      | Order notes or description                                                                     |
| `pair`                   | string              | No       | Trading pair (e.g., "BTC:PERP-USD", "BTC-USDT")                                                |
| `side`                   | string              | No       | Order side: "buy" or "sell"                                                                    |
| `exchanges`              | array (string)      | No       | Array of exchange names where the order was placed                                             |
| `buy_token`              | string              | No       | Token or contract symbol being bought                                                          |
| `buy_token_amount`       | number (float)      | Yes      | Target buy token amount (decimal as number)                                                    |
| `sell_token`             | string              | No       | Token or quote asset being sold                                                                |
| `sell_token_amount`      | number (float)      | Yes      | Target sell token amount (decimal as number)                                                   |
| `executed_qty`           | number (float)      | No       | Executed quantity in the order's target token                                                  |
| `executed_buy_qty`       | number (float)      | Yes      | Executed buy quantity (base asset)                                                             |
| `average_executed_price` | string (decimal)    | Yes      | Volume-weighted average execution price (decimal as string)                                    |
| `executed_notional`      | number (float)      | Yes      | Executed notional value (quote asset)                                                          |
| `target_order_qty`       | number (float)      | No       | Target order quantity                                                                          |
| `target_remaining_qty`   | number (float)      | No       | Remaining quantity to execute                                                                  |
| `target_token`           | string              | No       | Token in which target\_order\_qty and target\_remaining\_qty are measured                      |
| `target_executed_qty`    | number (float)      | Yes      | Executed quantity in target token terms                                                        |
| `pct_filled`             | string (decimal)    | Yes      | Percentage filled (0-100, decimal as string)                                                   |
| `total_fee`              | number (float)      | Yes      | Total fee for the order                                                                        |
| `fee_asset`              | string              | Yes      | Asset in which total\_fee is denominated                                                       |
| `total_fee_in_base`      | number (float)      | Yes      | Total fee converted to base asset                                                              |
| `strategy`               | string              | No       | Execution strategy name (e.g., "Market", "TWAP", "VWAP")                                       |
| `super_strategy`         | string              | Yes      | Super strategy name if applicable                                                              |
| `duration`               | number (integer)    | No       | Order duration in seconds                                                                      |
| `accounts`               | array (string UUID) | No       | Array of exchange credential IDs used for the order                                            |
| `account_names`          | array (string)      | No       | Array of account display names                                                                 |
| `engine_passiveness`     | number (float)      | Yes      | Passiveness parameter (0 = most aggressive, higher = more passive)                             |
| `schedule_discretion`    | number (float)      | Yes      | Schedule discretion parameter                                                                  |
| `pov_limit`              | number (float)      | Yes      | POV (participation) limit for POV orders                                                       |
| `pov_target`             | number (float)      | Yes      | POV target for POV orders                                                                      |
| `alpha_tilt`             | number (float)      | Yes      | Alpha tilt parameter (-1 to 1)                                                                 |
| `strategy_params`        | object              | No       | Strategy-specific parameters (e.g., {"passive\_only": true})                                   |
| `user`                   | string              | No       | User ID who owns the order                                                                     |
| `status`                 | string              | No       | Order status: "ACTIVE", "COMPLETE", "CANCELED", "PAUSED", "SCHEDULED", "SUBMITTED", "FINISHER" |
| `active`                 | boolean             | No       | Whether order is currently active                                                              |
| `is_simple`              | boolean             | No       | Whether this is a simple (single-slice) order                                                  |
| `failure_reason`         | string              | No       | Failure reason if order failed (empty string if no failure)                                    |
| `limit_price`            | string              | No       | Limit price or expression (empty string if not used)                                           |
| `is_reverse_limit_price` | boolean             | No       | Whether limit price is reversed (e.g., for OOL pause)                                          |
| `time_start`             | string (ISO 8601)   | Yes      | Order start time (UTC)                                                                         |
| `time_end`               | string (ISO 8601)   | Yes      | Order end time (UTC)                                                                           |
| `created_at`             | string (ISO 8601)   | No       | Timestamp when order was created (UTC)                                                         |
| `updated_at`             | string (ISO 8601)   | No       | Timestamp when order was last updated (UTC)                                                    |

`Authorization: Token <API_KEY>`

#### Example Request

<pre data-overflow="wrap"><code><strong>GET /api/orders/?statuses=ACTIVE,PAUSED&#x26;account_names=binance_main,coinbase_pro&#x26;page=1&#x26;page_size=50&#x26;after=2023-12-01T00:00:00Z&#x26;before=2023-12-31T23:59:59Z&#x26;custom_order_ids=order_123,order_456
</strong></code></pre>

#### Example Response

```json
{
  "orders": [
    {
      "id": "6debb950-614a-4366-b73b-7d7574fd9e15",
      "custom_order_id": "order_123",
      "parent_order_id": null,
      "notes": "",
      "pair": "BTC-USD",
      "side": "buy",
      "exchanges": ["binance", "coinbase_pro"],
      "buy_token": "BTC",
      "buy_token_amount": "0.1",
      "sell_token": "USD",
      "sell_token_amount": "5000.00",
      "executed_qty": "0.05",
      "executed_buy_qty": "0.05",
      "average_executed_price": "50000.00",
      "executed_notional": "2500.00",
      "target_order_qty": "0.1",
      "target_remaining_qty": "0.05",
      "target_token": "BTC",
      "target_executed_qty": "0.05",
      "pct_filled": "50.00",
      "total_fee": "2.50",
      "strategy": "TWAP",
      "super_strategy": "Standard",
      "duration": 3600,
      "accounts": ["account_1", "account_2"],
      "account_names": ["binance_main", "coinbase_pro"],
      "engine_passiveness": "0.5",
      "schedule_discretion": "0.3",
      "pov_limit": null,
      "pov_target": null,
      "alpha_tilt": "0.0",
      "strategy_params": {},
      "user": "user_123",
      "status": "ACTIVE",
      "active": true,
      "is_simple": true,
      "failure_reason": null,
      "limit_price": "",
      "is_reverse_limit_price": false,
      "time_start": "2023-12-15T10:00:00Z",
      "time_end": "2023-12-15T11:00:00Z",
      "created_at": "2023-12-15T09:55:00Z",
      "updated_at": "2023-12-15T10:30:00Z"
    }
  ],
  "page_number": 1,
  "page_size": 50,
  "num_pages": 1,
  "order_count": 1
}
```

#### Response Codes:

{% tabs %}
{% tab title="200: OK " %}

````json
```json
{
    "orders": [
        {
            "id": "984ffec9-f0bf-4b28-9dc1-81d5dfda1794",
            "custom_order_id": "custom1",
            "notes": "leverage: 10",
            "pair": "ETH:PERP-USDT",
            "side": "buy",
            "buy_token": "ETH:PERP",
            "sell_token": "USDT", 
            "sell_token_amount": 500.0,
            "executed_qty": 0,
            "average_executed_price": null,
            "executed_notional": 0,
            "total_fee": 0,
            "strategy": "TWAP",
            "duration": 120,
            "accounts": ["d0d54d4f-e3a5-49ba-a2c9-559caf2c69d2"],
            "account_names": ["test"],
            "engine_passiveness": 0.1,
            "schedule_discretion": 0.08,
            "strategy_params": { "passive_only": true },
            "user": "2",
            "status": "ACTIVE",
            "is_simple": false,
            "failure_reason": "",
            "limit_price": -1.0,
            "start_datetime": "2023-05-24T19:15:25.026448Z",
            "time_end": "2023-05-24T19:17:25.026448Z",
            "created_at": "2023-05-24T19:15:25.043965Z",
            "updated_at": "2023-05-24T19:15:25.259855Z"
        }
    ],
    "page_number": 1,
    "page_size": 100,
    "num_pages": 1,
    "order_count": 36
}
```
````

{% endtab %}

{% tab title="400: Bad Request" %}
Occurs when:

* Invalid date format provided for before or after parameters (must be ISO 8601 format)
* Account names provided don't exist or user doesn't have access to them
* The specific error message will indicate which parameter caused the issue

{% code title="Sample Error Messages" %}

```json
{
  "400": {
    "description": "Bad Request",
    "examples": [
      {
        "scenario": "Invalid date format for 'after' parameter",
        "response": {
          "message": "Invalid after date format"
        }
      },
      {
        "scenario": "Invalid date format for 'before' parameter", 
        "response": {
          "message": "Invalid after date format"
        }
      },
      {
        "scenario": "Invalid account names",
        "response": {
          "error": "Account display name 'invalid_account' not found for user"
        }
      },
      {
        "scenario": "Missing required fields (POST)",
        "response": {
          "error": "Missing required fields: ['pair', 'accounts', 'side', 'duration', 'strategy']"
        }
      },
      {
        "scenario": "No quantity fields provided (POST)",
        "response": {
          "errors": "Need one of the qty fields: ['base_asset_qty', 'quote_asset_qty', 'sell_token_amount']"
        }
      },
      {
        "scenario": "Multiple quantity fields provided (POST)",
        "response": {
          "errors": "Cannot have more than one of the qty fields: ['base_asset_qty', 'quote_asset_qty', 'sell_token_amount']"
        }
      },
      {
        "scenario": "General validation errors (POST)",
        "response": {
          "errors": [
            "Invalid order data",
            "Pair is required", 
            "Side must be either 'Buy' or 'Sell'"
          ]
        }
      },
      {
        "scenario": "Superuser restriction (POST)",
        "response": {
          "error": "Superusers on retail cannot place orders"
        }
      }
    ]
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="401: Unauthorized " %}
Occurs when:

* No valid authentication token provided in Authorization header
* Token is expired or invalid
* User account is not active

{% code title="Sample Error Messages:" %}

```json
{
  "401": {
    "description": "Unauthorized", 
    "examples": [
      {
        "scenario": "No authentication credentials provided",
        "response": {
          "detail": "Authentication credentials were not provided."
        }
      },
      {
        "scenario": "Invalid or expired token",
        "response": {
          "detail": "Invalid token."
        }
      }
    ]
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="500: Internal Server Error " %}
Occurs when:

* Database connection issues
* Unexpected server errors during order retrieval

{% code title="Sample Error Message" %}

```json
{
  "500": {
    "description": "Internal Server Error",
    "examples": [
      {
        "scenario": "Unexpected server error",
        "response": {
          "errors": ["An unexpected error occurred. Please try again later."]
        }
      }
    ]
  }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Get active orders

<mark style="color:green;">`get`</mark> `/api/active_orders/`

Get all currently active orders for the authenticated user.

| Name             | Type   | Description                                          |
| ---------------- | ------ | ---------------------------------------------------- |
| `exclude_paused` | string | Whether to exclude paused orders. Default: true      |
| `account_names`  | string | Comma separated values of account names to filter by |
| `only_active`    | string | Whether to return only active orders. Default: false |

**Headers**

* `Authorization: Token <API_KEY>`

#### Example Request

{% code overflow="wrap" %}

```
GET /api/active_orders/?exclude_paused=true&account_names=binance_main,coinbase_pro&only_active=false
```

{% endcode %}

#### Example Response

```json
{
  "orders": [
    {
      "id": "6debb950-614a-4366-b73b-7d7574fd9e15",
      "custom_order_id": "my_custom_order_123",
      "parent_order_id": null,
      "notes": "Buy BTC over 1 hour using TWAP strategy",
      "pair": "BTC-USD",
      "side": "buy",
      "exchanges": ["binance", "coinbase_pro"],
      "buy_token": "BTC",
      "buy_token_amount": "0.5",
      "sell_token": "USD",
      "sell_token_amount": "22500.00",
      "strategy": "TWAP",
      "duration": 3600,
      "status": "ACTIVE",
      "time_start": "2023-12-01T10:00:00Z",
      "time_end": "2023-12-01T11:00:00Z",
      "limit_price": "45000.00",
      "engine_passiveness": 0.5,
      "schedule_discretion": 0.3,
      "alpha_tilt": 0.1,
      "pos_side": "long",
      "user": "user_123",
      "created_at": "2023-12-01T09:55:00Z",
      "updated_at": "2023-12-01T09:55:00Z",
      "fills": [
        {
          "id": "fill_123",
          "order_id": "6debb950-614a-4366-b73b-7d7574fd9e15",
          "exchange": "binance",
          "pair": "BTC-USD",
          "side": "buy",
          "quantity": "0.1",
          "price": "44950.00",
          "timestamp": "2023-12-01T10:15:00Z",
          "fee": "0.001",
          "fee_currency": "BTC"
        }
      ]
    },
    {
      "id": "7fecb061-725b-5477-c84c-8e8685ge0f26",
      "custom_order_id": "my_custom_order_456",
      "parent_order_id": null,
      "notes": "Sell ETH using VWAP strategy",
      "pair": "ETH-USD",
      "side": "sell",
      "exchanges": ["coinbase_pro"],
      "buy_token": "USD",
      "buy_token_amount": "5000.00",
      "sell_token": "ETH",
      "sell_token_amount": "2.5",
      "strategy": "VWAP",
      "duration": 1800,
      "status": "PAUSED",
      "time_start": "2023-12-01T11:00:00Z",
      "time_end": "2023-12-01T11:30:00Z",
      "limit_price": "2000.00",
      "engine_passiveness": 0.3,
      "schedule_discretion": 0.2,
      "alpha_tilt": 0.0,
      "pos_side": "short",
      "user": "user_123",
      "created_at": "2023-12-01T10:45:00Z",
      "updated_at": "2023-12-01T11:10:00Z",
      "fills": []
    }
  ],
  "order_count": 2
}
```

**Response Codes**

{% tabs %}
{% tab title="200: OK List active orders" %}

```json
{
    "orders": [
        {
            "id": "984ffec9-f0bf-4b28-9dc1-81d5dfda1794",
            "status": "ACTIVE",
            "pair": "BTC-USDT",
            "side": "buy",
            "executed_qty": 0.5,
            "target_order_qty": 1.0,
            "pct_filled": 50.0
        }
    ],
    "order_count": 1
}
```

{% endtab %}

{% tab title="400: Bad Request" %}
Occurs when:

* Invalid account names are provided in the account\_names query parameter
* The user doesn't have access to the specified accounts
* There's an issue resolving the account display names to account IDs

The specific error message depends on what went wrong in the account lookup process, but the response structure is always: `{"error": "error message from account lookup"}S`

{% code title="Sample Error Message" %}

```json
{
  "400": {
    "description": "Bad Request",
    "examples": [
      {
        "scenario": "Invalid account names",
        "response": {
          "error": "Account display name 'invalid_account' not found for user"
        }
      }
    ]
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="401: Unauthorized" %}
Occurs when:

* No valid authentication token provided
* Token is expired or revoked

{% code title="Sample Error Messages" %}

```json
{
  "401": {
    "description": "Unauthorized",
    "examples": [
      {
        "scenario": "No authentication credentials provided",
        "response": {
          "detail": "Authentication credentials were not provided."
        }
      },
      {
        "scenario": "Invalid or expired token/session",
        "response": {
          "detail": "Invalid token."
        }
      }
    ]
  }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Submit an order

<mark style="color:green;">`POST`</mark> `/api/orders/`&#x20;

Submit an order for scheduling and execution.  The request contains all the parameters necessary to carry out the execution until completion.

The order is queued immediately if `start_datetime` is not set or is in the past.

#### Request Body

<table><thead><tr><th>Name</th><th>Type</th><th>Required<select><option value="GYzbHvFaEsbE" label="Yes" color="blue"></option><option value="SYGRHTAVJmWq" label="No" color="blue"></option><option value="6wzg5n2TrkgL" label="Conditional" color="blue"></option></select></th><th>Description</th></tr></thead><tbody><tr><td><code>pair</code></td><td>string</td><td><span data-option="GYzbHvFaEsbE">Yes</span></td><td>Symbol for the token pair, refer to token pairs reference</td></tr><tr><td><code>side</code></td><td>string</td><td><span data-option="GYzbHvFaEsbE">Yes</span></td><td>Order side: buy or sell</td></tr><tr><td><code>pos_side</code></td><td>string</td><td><span data-option="SYGRHTAVJmWq">No</span></td><td>short or long. Use when the account's position mode is set to "Hedge"</td></tr><tr><td><code>base_asset_qty</code></td><td>decimal</td><td><span data-option="6wzg5n2TrkgL">Conditional</span></td><td>Quantity of base asset. Must provide exactly one of: <code>base_asset_qty</code>, <code>quote_asset_qty</code>, or <code>sell_token_amount</code></td></tr><tr><td><code>quote_asset_qty</code></td><td>decimal</td><td><span data-option="6wzg5n2TrkgL">Conditional</span></td><td>Quantity of quote asset. Must provide exactly one of: <code>base_asset_qty</code>, <code>quote_asset_qty</code>, or <code>sell_token_amount</code></td></tr><tr><td><code>sell_token_amount</code></td><td>decimal</td><td><span data-option="6wzg5n2TrkgL">Conditional</span></td><td>Quantity of sell token. Must provide exactly one of: <code>base_asset_qty</code>, <code>quote_asset_qty</code>, or <code>sell_token_amount</code></td></tr><tr><td><code>strategy</code></td><td>string</td><td><span data-option="GYzbHvFaEsbE">Yes</span></td><td>Trading algorithm UUID. See the Type Reference page for a list of values</td></tr><tr><td><code>strategy_params</code></td><td>object</td><td><span data-option="SYGRHTAVJmWq">No</span></td><td>Various options for configuring the strategy. See the Type Reference page for more details</td></tr><tr><td><code>accounts</code></td><td>array[string]</td><td><span data-option="GYzbHvFaEsbE">Yes</span></td><td>List of account names. You pick this name when linking a new exchange key under key management</td></tr><tr><td><code>duration</code></td><td>integer</td><td><span data-option="6wzg5n2TrkgL">Conditional</span></td><td>Duration of execution in seconds. <strong>Required</strong> unless <code>pov_target</code> is provided</td></tr><tr><td><code>start_datetime</code></td><td>string (ISO 8601)</td><td><span data-option="SYGRHTAVJmWq">No</span></td><td>Time represented in Epoch milliseconds of when to start execution. If not provided, defaults to now</td></tr><tr><td><code>limit_price</code></td><td>string</td><td><span data-option="SYGRHTAVJmWq">No</span></td><td>Limit price for passive orders. If not provided, the algorithm will decide</td></tr><tr><td><code>is_reverse_limit_price</code></td><td>boolean</td><td><span data-option="SYGRHTAVJmWq">No</span></td><td>Engine will only trade at prices worse than <code>limit_price</code></td></tr><tr><td><code>engine_passiveness</code></td><td>decimal [0, 1]</td><td><span data-option="GYzbHvFaEsbE">Yes</span></td><td>Passiveness of the engine (accepted values: 0 to 1). A higher passiveness will result in the engine placing further from the spread. For more information, read about Passiveness</td></tr><tr><td><code>schedule_discretion</code></td><td>decimal [0.02, 0.5]</td><td><span data-option="GYzbHvFaEsbE">Yes</span></td><td>Ratio of order size allowed to deviate from the target i.e. decides the upper and lower bounds of the schedule. For more information, read about Discretion</td></tr><tr><td><code>alpha_tilt</code></td><td>decimal [-1, 1]</td><td><span data-option="SYGRHTAVJmWq">No</span></td><td>Implied short-term alpha. See Alpha Tilt for more detail</td></tr><tr><td><code>pov_limit</code></td><td>decimal (0, 1]</td><td><span data-option="SYGRHTAVJmWq">No</span></td><td>The engine will trade at no more than this fraction of market volume. See Participation Rate Limit for more detail. Note that the GUI interprets this value as a percentage</td></tr><tr><td><code>pov_target</code></td><td>decimal (0, 1]</td><td><span data-option="SYGRHTAVJmWq">No</span></td><td>Participation Rate Target. Note that the GUI interprets this value as a percentage</td></tr><tr><td><code>max_otc</code></td><td>decimal [0, 1]</td><td><span data-option="SYGRHTAVJmWq">No</span></td><td>Upper bound of the fraction of the parent order that will be executed via OTC. See Max OTC Percentage. Note that the GUI interprets this value as a percentage</td></tr><tr><td><code>order_condition</code></td><td>string</td><td><span data-option="SYGRHTAVJmWq">No</span></td><td>An expression representing the condition that would trigger the start of execution. Refer to Conditional Order</td></tr><tr><td><code>notes</code></td><td>string</td><td><span data-option="SYGRHTAVJmWq">No</span></td><td>Arbitrary string to add notes</td></tr><tr><td><code>custom_order_id</code></td><td>string</td><td><span data-option="SYGRHTAVJmWq">No</span></td><td>64 max length string that can be used to filter in GET orders endpoint. When TaaS sends orders to supported exchanges, the client order id of the exchange orders will start with "TL" followed by first 9 alphanumeric characters of the custom_order_id</td></tr><tr><td><code>updated_leverage</code></td><td>integer</td><td><span data-option="SYGRHTAVJmWq">No</span></td><td>Leverage for the account can be updated prior to submitting the order (behavior varies based on the venue)</td></tr><tr><td><code>stop_price</code></td><td>decimal</td><td><span data-option="SYGRHTAVJmWq">No</span></td><td>Stop price for stop orders</td></tr><tr><td><code>order_slices</code></td><td>integer</td><td><span data-option="SYGRHTAVJmWq">No</span></td><td>Number of order slices to use for execution. Higher values create more granular execution with smaller individual placements.</td></tr><tr><td><code>target_asset</code></td><td>string</td><td><span data-option="SYGRHTAVJmWq">No</span></td><td>Specifies which asset (<code>base</code> or <code>quote</code>) the order quantity refers to. This determines how the order quantity is interpreted and calculated.</td></tr><tr><td><code>exposure_tolerance</code></td><td>decimal</td><td><span data-option="SYGRHTAVJmWq">No</span></td><td>Tolerance for exposure limits in multi-order scenarios</td></tr><tr><td><code>market_type</code></td><td>string</td><td><span data-option="SYGRHTAVJmWq">No</span></td><td>Market type for the order</td></tr><tr><td><code>super_strategy</code></td><td>string (UUID)</td><td><span data-option="SYGRHTAVJmWq">No</span></td><td>Super strategies are predefined configurations that include strategy parameters, engine passiveness, schedule discretion, and alpha tilt settings.</td></tr></tbody></table>

**Headers**

* `Authorization: Token <API_KEY>`
* `Content-Type: application/json`

#### Example Request

```json
{
  "pair": "BTC-USD",
  "side": "buy",
  "accounts": ["binance_main", "coinbase_pro"],
  "strategy": "TWAP",
  "duration": 3600,
  "base_asset_qty": 0.5,
  "custom_order_id": "my_custom_order_123",
  "notes": "Buy BTC over 1 hour using TWAP strategy",
  "limit_price": "45000.00",
  "start_datetime": "2023-12-01T10:00:00Z",
  "engine_passiveness": 0.5,
  "schedule_discretion": 0.3,
  "alpha_tilt": 0.1,
  "pos_side": "long"
}
```

| Field                     | Type                       | Nullable | Description                                                                                   |
| ------------------------- | -------------------------- | -------- | --------------------------------------------------------------------------------------------- |
| id                        | string (UUID)              | No       | Unique identifier for the order                                                               |
| parent\_order             | string (UUID)              | Yes      | FK to MultiOrder - parent grouping for related orders                                         |
| batch\_order              | string (UUID)              | Yes      | FK to BatchOrder - batch grouping (e.g., scale orders)                                        |
| chained\_orders           | array\[object]             | No       | List of chained orders linked to this order                                                   |
| created\_at               | string (ISO 8601 datetime) | No       | Timestamp when the order was created                                                          |
| buy\_token                | string                     | No       | Token symbol being bought (e.g., 'BTC:PERP', 'ETH')                                           |
| sell\_token               | string                     | No       | Token symbol being sold (e.g., 'USDT', 'USD')                                                 |
| pair                      | string                     | No       | Trading pair in format 'BASE-QUOTE' (e.g., 'BTC:PERP-USDT')                                   |
| side                      | string                     | No       | Order side: 'buy' or 'sell'                                                                   |
| sell\_token\_amount       | string (decimal)           | No       | Amount of sell token (notional for buy orders, quantity for sell orders)                      |
| buy\_token\_amount        | string (decimal)           | Yes      | Target buy token quantity. If set, order targets this quantity instead of sell\_token\_amount |
| target\_order\_qty        | number (decimal)           | No       | Computed: target quantity based on buy\_token\_amount or sell\_token\_amount                  |
| target\_remaining\_qty    | number (decimal)           | No       | Computed: remaining quantity to fill                                                          |
| strategy                  | string (UUID)              | No       | FK to Strategy - execution algorithm used                                                     |
| super\_strategy           | string                     | Yes      | Name of the super strategy (e.g., 'Impact Minimization', 'Arrival Price')                     |
| super\_strategy\_name     | string                     | Yes      | Display name of the super strategy                                                            |
| strategy\_params          | object                     | No       | Refer to StrategyParams in type reference, all fields are nullable                            |
| limit\_price              | string (decimal)           | No       | Limit price for the order (empty string if no limit)                                          |
| is\_reverse\_limit\_price | boolean                    | No       | If true, limit price acts as floor (buy) or ceiling (sell)                                    |
| time\_start               | string (ISO 8601 datetime) | No       | Scheduled start time for order execution                                                      |
| time\_end                 | string (ISO 8601 datetime) | No       | Computed: scheduled end time (time\_start + duration)                                         |
| is\_simple                | boolean                    | No       | Whether this is a simple/immediate order                                                      |
| orig\_time\_end           | string (ISO 8601 datetime) | Yes      | Original end time before any extensions                                                       |
| duration                  | integer                    | No       | Order duration in seconds                                                                     |
| accounts                  | array\[string (UUID)]      | No       | List of ExchangeCredential IDs to execute on                                                  |
| account\_names            | array\[string]             | No       | Computed: human-readable account names                                                        |
| unique\_venues            | array\[string]             | No       | Computed: list of unique exchange venues                                                      |
| user                      | string                     | No       | User ID who created the order                                                                 |
| placements                | array\[object]             | No       | List of placement objects (child orders sent to exchanges)                                    |
| executed\_qty             | number (decimal)           | No       | Computed: total executed sell token quantity                                                  |
| executed\_buy\_qty        | number (decimal)           | No       | Computed: total executed buy token quantity                                                   |
| executed\_price           | string (decimal)           | Yes      | Computed: volume-weighted average execution price. Null if no fills                           |
| executed\_notional        | number (decimal)           | No       | Computed: total executed notional value                                                       |
| executed\_token           | number (decimal)           | No       | Computed: executed token quantity (base or quote depending on side)                           |
| active                    | boolean                    | No       | Computed: whether order is currently active                                                   |
| status                    | string                     | Yes      | Order status: 'SCHEDULED', 'ACTIVE', 'COMPLETED', 'CANCELLED', 'FAILED', etc.                 |
| engine\_passiveness       | string (decimal)           | No       | Passiveness parameter (0-1). Higher = more passive/maker orders                               |
| schedule\_discretion      | string (decimal)           | Yes      | Schedule discretion parameter (0-1). Controls execution timing flexibility                    |
| alpha\_tilt               | string (decimal)           | Yes      | Alpha tilt parameter. Biases execution toward start or end of window                          |
| exposure\_tolerance       | string (decimal)           | Yes      | Computed from parent\_order: max exposure deviation tolerance (e.g., 0.09 = 9%)               |
| pov\_limit                | string (decimal)           | Yes      | Maximum participation rate as fraction of market volume (e.g., 0.15 = 15%)                    |
| pov\_target               | string (decimal)           | Yes      | Target participation rate as fraction of market volume (e.g., 0.05 = 5%)                      |
| order\_condition          | string                     | Yes      | Trigger condition in reverse polish notation                                                  |
| order\_condition\_vars    | object                     | Yes      | Variables used in order condition expressions                                                 |
| order\_condition\_expiry  | string (ISO 8601 datetime) | Yes      | When the order condition expires                                                              |
| failure\_reason           | string                     | No       | Reason for order failure (empty string if not failed)                                         |
| stop\_price               | string (decimal)           | No       | Stop price for stop orders. -1 if not a stop order                                            |
| notes                     | string                     | No       | User notes for the order                                                                      |
| custom\_order\_id         | string                     | No       | User-defined custom order identifier (max 64 chars)                                           |
| updated\_leverage         | integer                    | Yes      | Leverage setting applied to the account for this order                                        |
| vwap                      | string (decimal)           | Yes      | Computed: market VWAP during order execution window. Populated on completion                  |
| interval\_volume          | string (decimal)           | Yes      | Computed: total market volume during order execution window. Populated on completion          |
| arrival\_price            | string (decimal)           | Yes      | Computed: market price at order start. Populated on completion                                |
| departure\_price          | string (decimal)           | Yes      | Computed: market price at order end. Populated on completion                                  |
| pct\_filled               | number (decimal)           | No       | Computed: percentage of order filled (0-100)                                                  |
| order\_variable\_normal   | object                     | No       | Computed: order condition variables in human-readable infix notation                          |
| order\_condition\_normal  | string                     | No       | Computed: order condition in human-readable infix notation                                    |
| paused\_at                | string (ISO 8601 datetime) | Yes      | Timestamp when order was paused                                                               |
| resumed\_at               | string (ISO 8601 datetime) | Yes      | Timestamp when order was resumed after pause                                                  |
| market\_type              | string                     | No       | Market type: 'spot', 'perp', 'future', 'option'                                               |
| max\_otc                  | string (decimal)           | No       | Maximum OTC allocation (0 = no OTC)                                                           |
| pos\_side                 | string                     | Yes      | Position side for perpetuals: 'long' or 'short'                                               |
| order\_slices             | integer                    | Yes      | Number of slices to divide the order into                                                     |
| auto\_order\_metadata     | object                     | No       | Metadata for auto-generated orders                                                            |
| batch\_order\_strategy    | string                     | Yes      | Computed: batch strategy name (e.g., 'Scale Orders', 'Entry & Exit')                          |
| chase\_decay              | integer                    | Yes      | Chase decay in seconds. Controls how frequently passive placements are re-pegged              |

#### Response body

| Field                            | Value          | Description                                            |
| -------------------------------- | -------------- | ------------------------------------------------------ |
| parent\_order                    | UUID           | FK to MultiOrder - parent grouping for related orders  |
| batch\_order                     | UUID           | FK to BatchOrder - batch grouping (e.g., scale orders) |
| buy\_token\_amount               | "0.01118596"   | \~1000 USDT / 89411.25 price = target BTC qty          |
| strategy\_params.max\_clip\_size | "500"          | Max notional per slice (must be ≥100 per validation)   |
| executed\_price                  | "89385.50"     | Weighted avg fill price (slightly better than limit)   |
| exposure\_tolerance              | "0.09"         | Default from codebase is 0.09 (9%)                     |
| pov\_limit                       | "0.15"         | Max % of interval volume (15% is typical)              |
| pov\_target                      | "0.05"         | Target % of volume participation (5%)                  |
| order\_condition\_expiry         | datetime       | 5 mins after time\_end - when condition expires        |
| updated\_leverage                | 10             | Integer leverage setting for the perp                  |
| vwap                             | "89392.75"     | Volume-weighted avg price during execution window      |
| interval\_volume                 | "125847.32"    | Total market volume during the order interval          |
| arrival\_price                   | "89411.25"     | Price at order start (same as limit)                   |
| departure\_price                 | "89378.50"     | Price at order end                                     |
| paused\_at                       | datetime       | When order was paused (if ever)                        |
| resumed\_at                      | datetime       | When order resumed after pause                         |
| pos\_side                        | "long"         | Position side for perps - "long" for buy orders        |
| batch\_order\_strategy           | "Scale Orders" | One of: "Scale Orders", "Entry & Exit"                 |
| chase\_decay                     | 30             | Seconds between re-pegging passive orders              |

<br>

{% tabs %}
{% tab title="201: Created Order successfully submitted, returns uuid" %}

```javascript
​
{
  "id": "a13f34c2-7529-4ed9-97cb-f52f9daea4a0",
  "parent_order": null,
  "batch_order": null,
  "chained_orders": [],
  "created_at": "2026-01-21T16:22:40.008559Z",
  "buy_token": "BTC:PERP",
  "sell_token": "USDT",
  "pair": "BTC:PERP-USDT",
  "side": "buy",
  "sell_token_amount": "1000",
  "buy_token_amount": null,
  "target_order_qty": 1000.0,
  "target_remaining_qty": 1000.0,
  "strategy": "8fd62b68-85d9-4346-8366-311c9a2a1d7a",
  "super_strategy": "Impact Minimization",
  "super_strategy_name": "Impact Minimization",
  "strategy_params": {
    "ool_pause": true,
    "entry": false,
    "max_clip_size": null
  },
  "limit_price": "89411.25",
  "is_reverse_limit_price": false,
  "time_start": "2026-01-21T16:22:39.986704Z",
  "time_end": "2026-01-21T16:27:39.986704Z",
  "is_simple": false,
  "orig_time_end": "2026-01-21T16:27:39.986704Z",
  "duration": 300,
  "accounts": [
    "31fbd341-9486-4c28-87c2-bd786fd072c7"
  ],
  "account_names": [
    "bybit"
  ],
  "unique_venues": [
    "Bybit"
  ],
  "user": "2",
  "placements": [],
  "executed_qty": 0.0,
  "executed_buy_qty": 0.0,
  "executed_price": null,
  "executed_notional": 0.0,
  "executed_token": 0,
  "active": false,
  "status": "SCHEDULED",
  "engine_passiveness": "0.02",
  "schedule_discretion": "0.06",
  "alpha_tilt": "0",
  "exposure_tolerance": null,
  "pov_limit": null,
  "pov_target": null,
  "order_condition": "BTC:PERP-USDT@Bybit 89411.25 <=",
  "order_condition_vars": {},
  "order_condition_expiry": null,
  "failure_reason": "",
  "stop_price": "-1",
  "notes": "",
  "custom_order_id": "",
  "updated_leverage": null,
  "vwap": null,
  "interval_volume": null,
  "arrival_price": null,
  "departure_price": null,
  "pct_filled": 0.0,
  "order_variable_normal": {},
  "order_condition_normal": "BTC:PERP-USDT@Bybit <= 89411.25",
  "paused_at": null,
  "resumed_at": null,
  "market_type": "perp",
  "max_otc": "0",
  "pos_side": null,
  "order_slices": 2,
  "auto_order_metadata": {},
  "batch_order_strategy": null,
  "chase_decay": null
}
```

{% endtab %}

{% tab title="400: Bad Request" %}
Occurs when:

* Missing required fields: pair, side, accounts, strategy, or duration (unless pov\_target provided)
* No quantity field provided: must include exactly one of base\_asset\_qty, quote\_asset\_qty, or sell\_token\_amount
* Multiple quantity fields provided: cannot have more than one of base\_asset\_qty, quote\_asset\_qty, or sell\_token\_amount
* Invalid parameter values (e.g., negative quantities, invalid strategy UUID)
* Invalid account names or insufficient permissions
* Invalid pair format or unsupported trading pair
* Invalid limit price format or value
* Invalid strategy parameters
* Invalid order condition expression
* Invalid time format for start\_datetime
* Invalid leverage value for the specified venue

{% code title="Sample Error Messages" %}

```json
{
  "400": {
    "description": "Bad Request",
    "examples": [
      {
        "scenario": "Missing required fields",
        "response": {
          "errors": ["Need one of the qty fields: ['base_asset_qty', 'quote_asset_qty', 'sell_token_amount']"]
        }
      },
      {
        "scenario": "Multiple quantity fields",
        "response": {
          "errors": ["Cannot have more than one of the qty fields: ['base_asset_qty', 'quote_asset_qty', 'sell_token_amount']"]
        }
      },
      {
        "scenario": "Invalid strategy UUID",
        "response": {
          "errors": ["Invalid strategy: 6fe4ba3e-c578-45bd-824c-c523bf3c56de"]
        }
      },
      {
        "scenario": "Invalid account names",
        "response": {
          "error": "Account display name 'invalid_account' not found for user"
        }
      },
      {
        "scenario": "Invalid pair format",
        "response": {
          "errors": ["Invalid buy_token ASDF"]
        }
      },
      {
        "scenario": "Invalid limit price",
        "response": {
          "errors": ["Limit price must be a positive number"]
        }
      }
    ]
  }
}
```

{% endcode %}

<br>
{% endtab %}

{% tab title="401: Unauthorized " %}
Occurs when:

* Missing or invalid API token
* Token has expired
* Insufficient permissions to access the specified accounts

{% code title="Sample Error Messages" %}

```json
{
  "401": {
    "description": "Unauthorized",
    "examples": [
      {
        "scenario": "Missing API token",
        "response": {
          "detail": "Authentication credentials were not provided."
        }
      },
      {
        "scenario": "Invalid API token",
        "response": {
          "detail": "Invalid token header. No credentials provided."
        }
      },
      {
        "scenario": "Expired token",
        "response": {
          "detail": "Token has expired."
        }
      }
    ]
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="403: Forbidden " %}
Occurs when:

* Superusers on retail environment cannot place orders
* Account access restrictions
* Trading restrictions on the specified pair or venue

{% code title="Sample Error Message" %}

```json
{
  "403": {
    "description": "Forbidden",
    "examples": [
      {
        "scenario": "Superuser on retail environment",
        "response": {
          "error": "Superusers on retail cannot place orders"
        }
      },
      {
        "scenario": "Account access denied",
        "response": {
          "error": "Access denied to specified accounts"
        }
      },
      {
        "scenario": "Trading restrictions",
        "response": {
          "error": "Trading not allowed for this pair on the specified venue"
        }
      }
    ]
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="422: Unprocessable Entity" %}
Occurs when:

* Insufficient balance for the order
* Market restrictions prevent order execution
* Exchange-specific limitations
* Invalid order configuration for the selected strategy

{% code title="Sample Error Messages" %}

```json
{
  "422": {
    "description": "Unprocessable Entity",
    "examples": [
      {
        "scenario": "Insufficient balance",
        "response": {
          "errors": ["Insufficient balance for order execution"]
        }
      },
      {
        "scenario": "Market restrictions",
        "response": {
          "errors": ["Market is closed for the specified trading pair"]
        }
      },
      {
        "scenario": "Exchange limitations",
        "response": {
          "errors": ["Order size exceeds exchange limits"]
        }
      },
      {
        "scenario": "Invalid strategy configuration",
        "response": {
          "errors": ["Strategy parameters not compatible with selected trading pair"]
        }
      }
    ]
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="500: Internal Server Error" %}
Occurs when:

* Database connection issues
* External service failures
* Unexpected system errors

{% code title="Sample Error Messages" %}

```json
{
  "500": {
    "description": "Internal Server Error",
    "examples": [
      {
        "scenario": "Database connection error",
        "response": {
          "error": "Database connection failed"
        }
      },
      {
        "scenario": "External service failure",
        "response": {
          "error": "Price feed service unavailable"
        }
      },
      {
        "scenario": "Unexpected system error",
        "response": {
          "error": "Something went wrong"
        }
      }
    ]
  }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Get order summary

<mark style="color:blue;">`GET`</mark> `/api/order_summary/{id}`

Get basic order information including execution status, quantities, and key parameters. This endpoint provides a concise summary of the order without detailed fill information.

* **Purpose**: Get a list of orders with statistics
* **Scope**: Multiple orders (paginated)
* **Data**: Basic order info + statistics + fills for each order
* **Use Case**: Dashboard, order list view, bulk analytics
* **Performance**: Optimized for bulk retrieval

#### Path Parameters

| Name                                 | Type          | Description                   |
| ------------------------------------ | ------------- | ----------------------------- |
| id<mark style="color:red;">\*</mark> | string (UUID) | UUID of the order to retrieve |

**Query Parameters**

* None.

**Headers**

`Authorization: Token <API_KEY>`

**Example Request**

`GET /api/order_summary/45a18223-aeab-4451-9253-c3135261d55b`

#### Response Codes

{% tabs %}
{% tab title="200: OK " %}

<pre class="language-json"><code class="lang-json"><strong>{'id': '45a18223-aeab-4451-9253-c3135261d55b',
</strong> 'pair': 'BTC-USDT',
 'side': 'buy',
 'status': 'COMPLETE',
 'start_datetime': '2024-10-25T16:55:03.842747Z',
 'duration': 108,
 'target_token': 'USDT',
 'order_qty': 60000.0,
 'remaining_qty': 3.38620187,
 'executed_qty': 59996.61379813,
 'executed_notional': 59996.61379813,
 'exchange_names': ['MockExchange'],
 'account_names': ['mock'],
 'schedule_discretion': 0.08,
 'engine_passiveness': 0.02,
 'alpha_tilt': 0.01,
 'strategy': None,
 'trajectory': 'VWAP',
 'strategy_params': {'passive_only': True},
 'participation_rate_target_percent': 8.0,
 'market_type': 'spot',
 'parent_order_id': None,
 'failure_reason': '',
 'limit_price': ''}
</code></pre>

{% endtab %}

{% tab title="400: Bad Request" %}
Occurs when:

* No order ID provided in the URL path
* Invalid UUID format for the order ID
* Order ID is malformed or contains invalid characters

{% code title="Sample Error Messages" %}

```json
{
  "400": {
    "description": "Bad Request",
    "examples": [
      {
        "scenario": "No order ID provided",
        "response": "No order ID given!"
      },
      {
        "scenario": "Invalid UUID format",
        "response": "Invalid order ID format"
      }
    ]
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="401: Unauthorized" %}
Occurs when:

* Missing or invalid API token
* Token has expired
* User does not have permission to access the specified order

{% code title="Sample Error Messages" %}

```json
{
  "401": {
    "description": "Unauthorized",
    "examples": [
      {
        "scenario": "Missing API token",
        "response": {
          "detail": "Authentication credentials were not provided."
        }
      },
      {
        "scenario": "Invalid API token",
        "response": {
          "detail": "Invalid token header. No credentials provided."
        }
      },
      {
        "scenario": "Expired token",
        "response": {
          "detail": "Token has expired."
        }
      },
      {
        "scenario": "Order access denied",
        "response": "Unauthorized"
      }
    ]
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="404: Order Not Found" %}
Occurs when:

* Order with the specified ID does not exist
* Order has been deleted or is not accessible
* Order ID is valid but the order is not found in the database

```json
{
  "404": {
    "description": "Not Found",
    "examples": [
      {
        "scenario": "Order does not exist",
        "response": "No order found with given ID!"
      },
      {
        "scenario": "Order not accessible",
        "response": "Order not found or access denied"
      }
    ]
  }
}
```

{% endtab %}

{% tab title="500: Internal Server Error" %}
Occurs when:

* Database connection issues
* External service failures
* Unexpected system errors during order retrieval

{% code title="Sample Error Message" %}

```json
{
  "500": {
    "description": "Internal Server Error",
    "examples": [
      {
        "scenario": "Database connection error",
        "response": {
          "error": "Database connection failed"
        }
      },
      {
        "scenario": "External service failure",
        "response": {
          "error": "Price feed service unavailable"
        }
      },
      {
        "scenario": "Unexpected system error",
        "response": {
          "error": "Something went wrong"
        }
      }
    ]
  }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Get orders with statistics

`GET /api/orders_with_stats/`

Retrieve a paginated list of orders with their associated statistics and analytics data. This endpoint provides comprehensive order information including execution statistics, fill breakdowns, and performance metrics.

* **Purpose**: Get a list of orders with statistics
* **Scope**: Multiple orders (paginated)
* **Data:**
  * **Basic Order Information**: ID, pair, side, status, duration, etc.
  * **Execution Statistics**: VWAP, arrival price, departure price, interval volume
  * **Fill Data**: Detailed fill information with placement details
  * **Performance Metrics**: Fee calculations, execution analytics
  * **Account Information**: Associated accounts and exchange details
* **Use** Case: Dashboard, order list view, bulk analytics
* Performance: Optimized for bulk retrieval

#### **Query Parameters**

| Name        | Type    | Description                                                   |
| ----------- | ------- | ------------------------------------------------------------- |
| `page`      | integer | <p>Page number for pagination<br>(Default: 1; Optional)</p>   |
| `page_size` | integer | <p>Number of orders per page <br>(Default: 500, Max: 100)</p> |

**Headers**

`Authorization: Token <API_KEY>`

**Example Request**

`GET /api/orders_with_stats/?page=1&page_size=100`

#### Example Response

```json
{
  "orders": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "pair": "BTC/USDT",
      "side": "buy",
      "status": "COMPLETE",
      "time_start": "2024-01-15T10:00:00Z",
      "duration": 3600,
      "target_token": "BTC",
      "order_qty": "1.00000000",
      "remaining_qty": "0.00000000",
      "executed_qty": "1.00000000",
      "executed_notional": "45000.00",
      "exchange_names": ["binance", "coinbase"],
      "account_names": ["main_account"],
      "schedule_discretion": "0.10000000",
      "engine_passiveness": "0.05000000",
      "alpha_tilt": "0.00000000",
      "strategy": "TWAP",
      "trajectory": "TWAP",
      "strategy_params": {},
      "participation_rate_target_percent": null,
      "market_type": "SPOT",
      "parent_order_id": null,
      "stats": {
        "order_id": "550e8400-e29b-41d4-a716-446655440000",
        "stat_id": "123e4567-e89b-12d3-a456-426614174000",
        "interval_volume": "1000000.00000000",
        "vwap": "45000.00000000",
        "arrival_price": "44950.00000000",
        "departure_price": "45050.00000000"
      },
      "fills": [
        {
          "placement_id": "123e4567-e89b-12d3-a456-426614174001",
          "exchange": "binance",
          "role": "taker",
          "executed_price": "45000.00",
          "executed_qty": "0.50000000",
          "executed_notional": "22500.00",
          "fee": "22.50",
          "fill_time": "2024-01-15T10:30:00Z"
        }
      ]
    }
  ],
  "page_number": 1,
  "page_size": 100,
  "num_pages": 5,
  "order_count": 450
}
```

**Response Codes**

{% tabs %}
{% tab title="200: OK" %}

```json
{
  "200": {
    "description": "Orders with statistics retrieved successfully",
    "content": {
      "application/json": {
        "example": {
          "orders": [
            {
              "id": "550e8400-e29b-41d4-a716-446655440000",
              "pair": "BTC/USDT",
              "side": "buy",
              "status": "COMPLETE",
              "stats": {
                "vwap": "45000.00000000",
                "arrival_price": "44950.00000000",
                "departure_price": "45050.00000000"
              }
            }
          ],
          "page_number": 1,
          "page_size": 100,
          "num_pages": 5,
          "order_count": 450
        }
      }
    }
  }
}
```

{% endtab %}

{% tab title="400: Bad Request" %}
Occurs when:

* The page\_size parameter is greater than 1000
* Invalid query parameters are provided

{% code title="Sample Error Message" %}

```json
{
  "400": {
    "description": "Invalid request parameters",
    "content": {
      "application/json": {
        "example": {
          "error": "page_size cannot be greater than 1000"
        }
      }
    }
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="401: Unauthorized" %}
Occurs when:

* Invalid or missing authentication token
* User is not authenticated

{% code title="Sample Error Message" %}

```json
{
  "401": {
    "description": "Unauthorized",
    "content": {
      "application/json": {
        "example": {
          "error": "Unauthorized"
        }
      }
    }
  }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

**Notes**

* Superuser Access: Superusers can retrieve orders for all users; regular users only see their own orders.
* Pagination: Use `page` and `page_size` to control result set size.
* Statistics: Each order includes a `stats` object with VWAP, arrival price, departure price, and interval volume.
* Fills: Each order includes detailed fill data if available.

**Related Endpoints**

* [`GET /api/orders/`](#get-all-orders) - Get orders (basic info, no stats)
* [`GET /api/order/<id>`](#get-order-details)- Get single order details

## Get order details

<mark style="color:blue;">`GET`</mark> `/api/order/{id}`

Get detailed single order info along with executed fills&#x20;

* **Purpose**: Get detailed information about a single order
* **Scope**: One specific order
* **Data**: Comprehensive order details including:
  * Full order configuration
  * All placements and fills
  * Execution analytics
  * Market data
  * Performance metrics
  * Audit trail
* **Use Case:** Order detail page, deep analysis of one order
* **Performance:** Heavy computation for single order

#### Path Parameters

| Name                                   | Type   | Description                  |
| -------------------------------------- | ------ | ---------------------------- |
| `id`<mark style="color:red;">\*</mark> | string | UUID of the order (Required) |

#### Query Parameters

| Name            | Type    | Description                                                          |
| --------------- | ------- | -------------------------------------------------------------------- |
| `include_fills` | boolean | Whether to include fill data in response. (Default: false, Optional) |

**Headers**

`Authorization: Token <API_KEY>`

**Example Request**

`GET /api/order/6debb950-614a-4366-b73b-7d7574fd9e15?include_fills=true`

**Example Response**

```json
{
  "id": "6debb950-614a-4366-b73b-7d7574fd9e15",
  "custom_order_id": "my_custom_order_123",
  "parent_order_id": null,
  "notes": "Buy BTC over 1 hour using TWAP strategy",
  "pair": "BTC-USD",
  "side": "buy",
  "exchanges": ["binance", "coinbase_pro"],
  "buy_token": "BTC",
  "buy_token_amount": "0.5",
  "sell_token": "USD",
  "sell_token_amount": "22500.00",
  "executed_qty": "0.25",
  "executed_buy_qty": "0.25",
  "average_executed_price": "45000.00",
  "executed_notional": "11250.00",
  "target_order_qty": "0.5",
  "target_remaining_qty": "0.25",
  "target_token": "BTC",
  "target_executed_qty": "0.25",
  "pct_filled": "50.00",
  "total_fee": "5.63",
  "strategy": "TWAP",
  "super_strategy": "Impact Minimization",
  "duration": 3600,
  "accounts": ["account_id_1", "account_id_2"],
  "account_names": ["binance_main", "coinbase_pro"],
  "engine_passiveness": "0.02",
  "schedule_discretion": "0.06",
  "pov_limit": null,
  "pov_target": null,
  "alpha_tilt": "0.00",
  "strategy_params": {
    "max_clip_size": "1000.00"
  },
  "user": "user_123",
  "status": "ACTIVE",
  "active": true,
  "is_simple": false,
  "failure_reason": null,
  "limit_price": null,
  "is_reverse_limit_price": false,
  "time_start": "2023-12-01T10:00:00Z",
  "time_end": "2023-12-01T11:00:00Z",
  "created_at": "2023-12-01T09:59:30Z",
  "updated_at": "2023-12-01T10:30:00Z",
  "fills": [
    {
      "placement_id": "placement_123",
      "exchange": "binance",
      "role": "MAKE",
      "executed_price": "45000.00",
      "executed_qty": "0.125",
      "executed_notional": "5625.00",
      "fee": "2.81",
      "fill_time": "2023-12-01T10:15:00Z"
    },
    {
      "placement_id": "placement_124",
      "exchange": "coinbase_pro",
      "role": "TAKE",
      "executed_price": "45000.00",
      "executed_qty": "0.125",
      "executed_notional": "5625.00",
      "fee": "2.82",
      "fill_time": "2023-12-01T10:30:00Z"
    }
  ]
}
```

&#x20;

{% tabs %}
{% tab title="200: OK " %}

<pre class="language-javascript"><code class="lang-javascript">{
    "id": "6debb950-614a-4366-b73b-7d7574fd9e15",
    "buy_token": "ETH",
    "sell_token": "USD",
    "side": "buy",
    "pair": "ETH-USDT",
    "sell_token_amount": 50000.0,
    "strategy": "6fe4ba3e-c578-45bd-824c-c523bf3c56de",
    "super_strategy": "d960c28f-a6bd-4f55-9c5c-fc561cc95640",
    "super_strategy_name": "Impact Minimization",
    "strategy_params": {
        "passive_only": true
    },
    "limit_price": 1.0,
    "start_datetime": "2023-08-08T23:54:06.300319Z",
    "time_end": "2023-08-08T23:59:06.300319",
    "duration": 300,
    "accounts": ["09d3144b-9359-4ec3-8772-2dd1bfb86652"],
    "account_names": ["Binance_1"],
    "user": "2",
    "status": "ACTIVE",
    "engine_passiveness": "0.2",
    "schedule_discretion": "0.08",
    "failure_reason": "",
    "executed_qty": 1.2,
    "executed_price": 1846.5,
    "executed_notional": 2215.8,
    "notes": "",
    "custom_order_id": "",
    "updated_leverage": 10,
    "placements": [
        {
            'id': '6abb7966-9641-4c78-8bd6-f4c9bd075399',
            'created_at': '2023-08-01T08:25:31.704064Z',
            'order': "6debb950-614a-4366-b73b-7d7574fd9e15",
            'placement_type': 'MAKE',
            'price': '28931.15000000000000000000',
            'qty': '0.00000100000000000000',
            'exchange': 'Binance',
            'fills': [
                {
                    "id": "44c82c49-1e9d-43f8-98cd-318a2c01a317",
                    "created_at": '2023-08-01T08:25:31.704064Z',
                    "fill_time": '2023-08-01T08:25:31.704064Z',
                    "role": "MAKE",
                    "external_id": "21949858",
                    "executed_price": 1658.40,
                    "executed_qty": 3.5,
                    "exchange": "Binance",
                    "fee": 0.0443
                },
                //...
            ],
            'passiveness': '0.0078071000',
            'filled': False,
            'external_id': None,
            'status': 'FAILED',
            'sub_status': 'MIN_AMOUNT',
            'is_cross': False,
            'is_simple': False,
            'contract_value': '1.00000000000000000000'
        },
        //...
<strong>    ],
</strong>}
</code></pre>

{% endtab %}

{% tab title="500: Internal Server Error " %}

```javascript
{
    "message": "Something went wrong"
}
```

{% endtab %}

{% tab title="404: Not Found Order" %}

```
No order found with given ID!
```

{% endtab %}

{% tab title="401: Unauthorized Not authorized" %}

```javascript
{
    'detail': 'Invalid token.'// Response
}
```

{% endtab %}
{% endtabs %}

**Response Fields**

| Field                               | Type              | Description                                                                 |
| ----------------------------------- | ----------------- | --------------------------------------------------------------------------- |
| `id`                                | string (UUID)     | Unique identifier for the order                                             |
| `parent_order_id`                   | string (UUID) \\  | <p>null<br><sub>Note: ID of the parent multi-order, if applicable</sub></p> |
| `pair`                              | string            | Trading pair symbol                                                         |
| `side`                              | string            | Order side: buy or sell                                                     |
| `status`                            | string            | Current order status (e.g., ACTIVE, COMPLETED, CANCELED)                    |
| `start_datetime`                    | string (ISO 8601) | Order start time in UTC                                                     |
| `duration`                          | integer           | Order duration in seconds                                                   |
| `target_token`                      | string            | Token being targeted for the order                                          |
| `target_order_qty`                  | decimal           | Total order quantity                                                        |
| `remaining_qty`                     | decimal           | Remaining quantity to be executed                                           |
| `executed_qty`                      | decimal           | Quantity already executed                                                   |
| `executed_notional`                 | decimal           | Total notional value of executed quantity                                   |
| `exchange_names`                    | array\[string]    | List of exchanges where the order is being executed                         |
| `account_names`                     | array\[string]    | List of account names used for the order                                    |
| `schedule_discretion`               | decimal           | Schedule discretion parameter                                               |
| `engine_passiveness`                | decimal           | Engine passiveness parameter                                                |
| `alpha_tilt`                        | decimal           | Alpha tilt parameter                                                        |
| `strategy`                          | string \\         | <p>null<br><sub>Note: Super strategy name, if applicable</sub></p>          |
| `trajectory`                        | string            | Trading strategy/trajectory name                                            |
| `strategy_params`                   | object            | Strategy-specific parameters                                                |
| `participation_rate_target_percent` | decimal \\        | <p>null<br><sub>Note: Participation rate target as percentage</sub></p>     |
| `market_type`                       | string            | Market type (e.g., spot, perp, option)                                      |
| `failure_reason`                    | string            | Reason for order failure, if applicable                                     |
| `limit_price`                       | string            | Limit price for the order                                                   |
| `placement_live_qty`                | decimal           | Quantity currently in live placements                                       |

## Get order details by custom ID

To retrieve orders by custom order ID, use the main orders endpoint with the `custom_order_ids` query parameter:

`GET /api/orders/?custom_order_ids={custom_order_id}`

#### Query Parameters

| Name                 | Type   | Required | Description                                           |
| -------------------- | ------ | -------- | ----------------------------------------------------- |
| `custom_order_ids`\* | string | Yes      | Comma-separated list of custom order IDs to filter by |

**Optional Filters (same as** [**Get All Orders**](#get-all-orders)**):** `account_names`, `after`, `before`, `page`, `page_size`, `statuses`.

**Headers**

`Authorization: Token <API_KEY>`

#### Example Request

`GET /api/orders/?custom_order_ids=ETH_ACC_001`

#### Example Response

```json
{
  "orders": [
    {
      "id": "6debb950-614a-4366-b73b-7d7574fd9e15",
      "custom_order_id": "ETH_ACC_001",
      "parent_order_id": null,
      "notes": "ETH accumulation order",
      "pair": "ETH-USDT",
      "side": "buy",
      "exchanges": ["Binance"],
      "buy_token": "ETH",
      "buy_token_amount": 10.5,
      "sell_token": "USDT",
      "sell_token_amount": 17330.25,
      "executed_qty": 0,
      "executed_buy_qty": 0,
      "average_executed_price": null,
      "executed_notional": 0,
      "target_order_qty": 17330.25,
      "target_remaining_qty": 17330.25,
      "target_token": "USDT",
      "target_executed_qty": 0,
      "pct_filled": 0,
      "total_fee": 0,
      "strategy": "TWAP",
      "super_strategy": null,
      "duration": 3600,
      "accounts": ["09d3144b-9359-4ec3-8772-2dd1bfb86652"],
      "account_names": ["my_binance_account"],
      "engine_passiveness": 0.2,
      "schedule_discretion": 0.08,
      "pov_limit": 0.05,
      "pov_target": 0.1,
      "alpha_tilt": 0.1,
      "strategy_params": {
        "passive_only": true
      },
      "user": "2",
      "status": "ACTIVE",
      "active": true,
      "is_simple": false,
      "time_start": "2023-08-08T23:54:06.300319Z",
      "time_end": "2023-08-09T00:54:06.300319Z",
      "limit_price": "1650.50",
      "is_reverse_limit_price": false,
      "placements": [],
      "fills": []
    }
  ],
  "page_number": 1,
  "page_size": 100,
  "num_pages": 1,
  "order_count": 1
}
```

#### Response Codes

{% tabs %}
{% tab title="200: OK " %}

<pre class="language-javascript"><code class="lang-javascript"><strong>[
</strong><strong> {
</strong>    "id": "6debb950-614a-4366-b73b-7d7574fd9e15",
    "buy_token": "ETH",
    "sell_token": "USD",
    "side": "buy",
    "pair": "ETH-USDT",
    "sell_token_amount": 50000.0,
    "strategy": "6fe4ba3e-c578-45bd-824c-c523bf3c56de",
    "super_strategy": "d960c28f-a6bd-4f55-9c5c-fc561cc95640",
    "super_strategy_name": "Impact Minimization",
    "strategy_params": {
        "passive_only": true
    },
    "limit_price": 1.0,
    "start_datetime": "2023-08-08T23:54:06.300319Z",
    "time_end": "2023-08-08T23:59:06.300319",
    "duration": 300,
    "accounts": ["09d3144b-9359-4ec3-8772-2dd1bfb86652"],
    "account_names": ["Binance_1"],
    "user": "2",
    "status": "ACTIVE",
    "engine_passiveness": "0.2",
    "schedule_discretion": "0.08",
    "failure_reason": "",
    "executed_qty": 1.2,
    "executed_price": 1846.5,
    "executed_notional": 2215.8,
    "notes": "",
    "custom_order_id": "my_custom_id",
    "updated_leverage": 10,
    "placements": [
        {
            'id': '6abb7966-9641-4c78-8bd6-f4c9bd075399',
            'created_at': '2023-08-01T08:25:31.704064Z',
            'order': "6debb950-614a-4366-b73b-7d7574fd9e15",
            'placement_type': 'MAKE',
            'price': '28931.15000000000000000000',
            'qty': '0.00000100000000000000',
            'exchange': 'Binance',
            'fills': [
                {
                    "id": "44c82c49-1e9d-43f8-98cd-318a2c01a317",
                    "created_at": '2023-08-01T08:25:31.704064Z',
                    "fill_time": '2023-08-01T08:25:31.704064Z',
                    "role": "MAKE",
                    "external_id": "21949858",
                    "executed_price": 1658.40,
                    "executed_qty": 3.5,
                    "exchange": "Binance",
                    "fee": 0.0443
                },
                //...
            ],
            'passiveness': '0.0078071000',
            'filled': False,
            'external_id': None,
            'status': 'FAILED',
            'sub_status': 'MIN_AMOUNT',
            'is_cross': False,
            'is_simple': False,
            'contract_value': '1.00000000000000000000'
        },
        //...
<strong>    ],
</strong> },
 {
   //
 },
]
</code></pre>

{% endtab %}

{% tab title="400: Bad Request" %}
Occurs when:

* Missing custom\_order\_ids parameter
* Invalid format for custom\_order\_ids parameter
* Invalid account names in account\_names filter
* Invalid date format in after or before parameters

{% code title="Sample Error Messages" %}

```json
{
  "400": {
    "description": "Bad Request",
    "examples": [
      {
        "scenario": "Missing custom_order_ids",
        "response": {
          "error": "custom_order_ids parameter is required"
        }
      },
      {
        "scenario": "Invalid account names",
        "response": {
          "error": "Account display name 'invalid_account' not found for user"
        }
      },
      {
        "scenario": "Invalid date format",
        "response": {
          "message": "Invalid after date format"
        }
      }
    ]
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="401: Unauthorized" %}
Occurs when:

* Missing or invalid API token
* Token has expired
* Insufficient permissions to access the specified accounts

{% code title="Sample Error Messages" %}

```json
{
  "401": {
    "description": "Unauthorized",
    "examples": [
      {
        "scenario": "Missing API token",
        "response": {
          "detail": "Authentication credentials were not provided."
        }
      },
      {
        "scenario": "Invalid API token",
        "response": {
          "detail": "Invalid token header. No credentials provided."
        }
      },
      {
        "scenario": "Expired token",
        "response": {
          "detail": "Token has expired."
        }
      }
    ]
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="500: Internal Server Error " %}
Occurs when:

* Database connection issues
* External service failures
* Unexpected system errors

{% code title="Sample Error Messages" %}

```json
{
  "500": {
    "description": "Internal Server Error",
    "examples": [
      {
        "scenario": "Database connection error",
        "response": {
          "error": "Database connection failed"
        }
      },
      {
        "scenario": "External service failure",
        "response": {
          "error": "Price feed service unavailable"
        }
      },
      {
        "scenario": "Unexpected system error",
        "response": {
          "error": "Something went wrong"
        }
      }
    ]
  }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Get order errors

<mark style="color:blue;">`GET`</mark> `/api/order_errors/`

Retrieve order errors and messages for orders. This endpoint returns error messages, warnings, and informational messages associated with orders, organized by order ID.

**The response includes:**

1. **Order Errors**: System-generated errors, warnings, and info messages
2. **Message Types**: ERROR, WARN, INFO classifications
3. **Timestamps:** When each message was created
4. **Order Association**: Messages grouped by order ID

**Notes**

* There are non-error order messages ex with type message\_type "INFO" or "WARNING"
* There is currently no dedicated `/api/order_messages/{id}` endpoint. Order messages are included as part of the response in endpoints such as `/api/order/{id}` and `/api/multi_order/{id}`

#### Query Parameters

| Name        | Type   | Description                                                           |
| ----------- | ------ | --------------------------------------------------------------------- |
| `order_ids` | string | <p>Comma-separated list of order UUIDs to filter by<br>(Optional)</p> |

**Headers**

`Authorization: Token <API_KEY>`

#### Example Request

`GET /api/order_errors/?order_ids=6debb950-614a-4366-b73b-7d7574fd9e15,7fecb061-725b-5477-c84c-8e8685ge0f26`

\
Example Response

```json
{
"6debb950-614a-4366-b73b-7d7574fd9e15": [
{
"message": "Insufficient balance for order execution",
"message_type": "ERROR",
"created_at": "2023-12-01T10:30:00Z"
},
{
"message": "Generating execution schedule",
"message_type": "INFO",
"created_at": "2023-12-01T10:25:00Z"
}
],
"7fecb061-725b-5477-c84c-8e8685ge0f26": [
{
"message": "Order execution completed",
"message_type": "INFO",
"created_at": "2023-12-01T11:00:00Z"
}
]
}
```

#### Response Codes

{% tabs %}
{% tab title="200: OK " %}

```json
{
  "550e8400-e29b-41d4-a716-446655440000": [
    {
      "message_type": "ERROR",
      "message": "Failed to place order on exchange: insufficient balance",
      "created_at": "2024-01-15T10:30:00Z"
    },
    {
      "message_type": "WARN",
      "message": "Order partially filled due to market conditions",
      "created_at": "2024-01-15T10:25:00Z"
    }
  ],
  "123e4567-e89b-12d3-a456-426614174000": [
    {
      "message_type": "INFO",
      "message": "Order successfully completed",
      "created_at": "2024-01-15T09:45:00Z"
    }
  ]
}
```

{% endtab %}

{% tab title="400: Bad Request" %}
Occurs when:

* No order ID provided in the URL path
* Invalid UUID format for the order ID

{% code title="Sample Error Messages" %}

```json
{
  "400": {
    "description": "Invalid request parameters",
    "content": {
      "application/json": {
        "example": {
          "error": "No order ID given!"
        }
      }
    }
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="401: Unauthorized" %}
Occurs when:

* The order does not belong to the authenticated user and the user is not a superuser

{% code title="Sample Error Message" %}

```json
{
  "401": {
    "description": "Unauthorized",
    "content": {
      "application/json": {
        "example": {
          "error": "Order 6debb950-614a-4366-b73b-7d7574fd9e15 does not belong to you"
        }
      }
    }
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="404: Not Found" %}
Occurs when:

* No order exists with the given ID

{% code title="Sample Error Message" %}

```json
{
  "404": {
    "description": "Order not found",
    "content": {
      "application/json": {
        "example": {
          "error": "Order 6debb950-614a-4366-b73b-7d7574fd9e15 not found"
        }
      }
    }
  }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

Notes:

* If no order\_ids parameter is provided, returns errors for all orders accessible to the user
* Response is a dictionary where keys are order IDs and values are arrays of error messages
* Messages are sorted by creation time (newest first)
* Includes non-error messages with types "INFO" and "WARNING" in addition to "ERROR"

## Cancel order

<mark style="color:red;">`DELETE`</mark> `/api/order/{id}`

Cancels the order and all active placements across venues.

#### Path Parameters

| Name                                   | Type   | Description       |
| -------------------------------------- | ------ | ----------------- |
| `id`<mark style="color:red;">\*</mark> | string | UUID of the order |

**What Happens When You Cancel an Order**

When you cancel an order, the following actions are performed:

1. **Cancel Active Placements:** All active placements across all venues are canceled
2. **Update Order Status:** Order status is changed to "CANCELED"
3. **Cancel Sibling Orders:** If this is a child order in a multi-order, sibling orders are also canceled
4. **Trigger Chain Progression:** If this is part of a chained order, chain progression is triggered
5. **Cleanup Tasks:** Order cleanup tasks are queued for execution
6. **Analytics: On-complete analytics are scheduled to run**
7. **Broadcast Updates:** Order cancellation event is broadcast to connected clients
8. **Notifications:** Order event notifications are sent
9. **Points & Achievements:** Points and achievements are applied based on order performance

**Headers**

`Authorization: Token <API_KEY>`

#### Example Request

**Example Request**

`DELETE /api/order/6debb950-614a-4366-b73b-7d7574fd9e15`

#### Example Response

```json
"Order canceled!"
```

Note: The response is a simple string message. If the order was already canceled, the response would be:

```json
"Order already canceled!"
```

#### Response Codes

{% tabs %}
{% tab title="200: OK" %}

```json
{
  "200": {
    "description": "OK",
    "examples": [
      {
        "scenario": "Order successfully canceled",
        "response": "Order canceled!"
      },
      {
        "scenario": "Order already canceled",
        "response": "Order already canceled!"
      }
    ]
  }
}
```

{% endtab %}

{% tab title="400: Bad Request" %}
Occurs when:

* No order ID provided in the URL path
* Invalid UUID format for the order ID
* Order ID is malformed or contains invalid characters

{% code title="Sample Error Messages" %}

```json
{
  "400": {
    "description": "Bad Request",
    "examples": [
      {
        "scenario": "No order ID provided",
        "response": "No order ID given!"
      },
      {
        "scenario": "Invalid UUID format",
        "response": "Invalid order ID format"
      }
    ]
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="401: Unauthorized" %}
Occurs when:

* Missing or invalid API token
* Token has expired
* User does not have permission to access the specified order

{% code title="Sample Error Messages" %}

```json
{
  "401": {
    "description": "Unauthorized",
    "examples": [
      {
        "scenario": "Missing API token",
        "response": {
          "detail": "Authentication credentials were not provided."
        }
      },
      {
        "scenario": "Invalid API token",
        "response": {
          "detail": "Invalid token header. No credentials provided."
        }
      },
      {
        "scenario": "Expired token",
        "response": {
          "detail": "Token has expired."
        }
      },
      {
        "scenario": "Order access denied",
        "response": "Unauthorized"
      }
    ]
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="404: Not Found" %}
Occurs when:

* Order with the specified ID does not exist
* Order has been deleted or is not accessible
* Order ID is valid but the order is not found in the database

{% code title="Sample Error Messages" %}

```json
{
  "404": {
    "description": "Not Found",
    "examples": [
      {
        "scenario": "Order does not exist",
        "response": "No order found with given ID!"
      },
      {
        "scenario": "Order not accessible",
        "response": "Order not found or access denied"
      }
    ]
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="422: Unprocessable Entity" %}
Occurs when:

* Order is in a state that prevents cancellation
* Failed to cancel active placements on exchanges
* Exchange-specific cancellation failures
* Database transaction failures during cancellation
* Network connectivity issues with exchanges
* Order is part of a complex workflow that cannot be interrupted

{% code title="Sample Error Messages" %}

```json
{
  "422": {
    "description": "Unprocessable Entity",
    "examples": [
      {
        "scenario": "Failed to cancel placements",
        "response": {
          "error": "Failed to cancel all placements"
        }
      },
      {
        "scenario": "Exchange cancellation failure",
        "response": {
          "error": "Unexpected cancel failure"
        }
      },
      {
        "scenario": "Database transaction failure",
        "response": {
          "error": "Failed to commit cancellation changes"
        }
      },
      {
        "scenario": "Network connectivity issue",
        "response": {
          "error": "Connection timeout while canceling placements"
        }
      },
      {
        "scenario": "Order state prevents cancellation",
        "response": {
          "error": "Order is in a state that cannot be canceled"
        }
      }
    ]
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="500: Internal Server Error " %}
Occurs when:

* Database connection issues
* External service failures
* Unexpected system errors during cancellation process
* Worker queue failures
* Analytics service failures

{% code title="Example Responses" %}

```json
{
  "500": {
    "description": "Internal Server Error",
    "examples": [
      {
        "scenario": "Database connection error",
        "response": {
          "error": "Database connection failed"
        }
      },
      {
        "scenario": "External service failure",
        "response": {
          "error": "Exchange API service unavailable"
        }
      },
      {
        "scenario": "Worker queue failure",
        "response": {
          "error": "Failed to queue cleanup tasks"
        }
      },
      {
        "scenario": "Unexpected system error",
        "response": {
          "error": "Something went wrong"
        }
      }
    ]
  }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

**Notes**

* **Idempotent:** Canceling an already canceled order will return a success message
* **Sibling Orders:** Canceling a child order in a multi-order will also cancel sibling orders
* **Chained Orders:** Canceling an order in a chain may trigger progression to the next order
* **Placement Cancellation:** All active placements, including OTC placements, are canceled
* **Cleanup:** Order cleanup happens asynchronously and includes reconciliation of active placements
* **Analytics:** Order analytics are generated 3 minutes after cancellation to ensure all data is collected

## Pause order

<mark style="color:green;">`POST`</mark> `/api/pause_order/`

Pause an active order, canceling all active placements and stopping execution until resumed. The order will maintain its current state and can be resumed later.

**What Happens When You Pause an Order**

When you pause an order, the following actions are performed:

1. **Cancel Active Placements:** All active placements across all venues are canceled, including OTC placements
2. **Update Order Status:** Order status is changed to "PAUSED"
3. **Set Pause Timestamp:** The paused\_at timestamp is recorded
4. **Clear Resume Condition:** For manual pauses, any resume condition is cleared to prevent automatic resumption
5. **Clear Future Schedule Points:** Future schedule points are removed to prevent confusion during resumption
6. **Pause Market Data Collection:** Market data collection for the order is paused
7. **Broadcast Updates:** Order paused event is broadcast to connected clients
8. **Send Notifications:** Order pause event notifications are sent

#### Path Parameters

| Name      | Type   | Description       |
| --------- | ------ | ----------------- |
| order\_id | string | UUID of the order |

**Headers**

* `Authorization: Token <API_KEY>`
* `Content-Type: application/json`

**Example Request**

`POST /api/pause_order/`

**Body:**

```
{
  "order_id": "6debb950-614a-4366-b73b-7d7574fd9e15"
}
```

#### Example Response

```json
{
  "message": "Successfully paused order."
}
```

#### Response Codes

{% tabs %}
{% tab title="202: Accepted " %}
Occurs when:

* Order is successfully paused
* All active placements are canceled
* Order status is updated to "PAUSED"

{% code title="" %}

```json
{
  "202": {
    "description": "Accepted",
    "examples": [
      {
        "scenario": "Order successfully paused",
        "response": {
          "message": "Successfully paused order."
        }
      }
    ]
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="400: Bad Request " %}
Occurs when:

* Missing `order_id` in request body
* Invalid UUID format for the order ID
* Order ID is malformed or contains invalid characters

{% code title="Sample Error Messages" %}

```json
{
  "400": {
    "description": "Bad Request",
    "examples": [
      {
        "scenario": "Missing order_id",
        "response": {
          "error": "Missing required field: order_id"
        }
      },
      {
        "scenario": "Invalid UUID format",
        "response": {
          "error": "Invalid order ID format"
        }
      }
    ]
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="401: Unauthorized" %}
Occurs when:

* Missing or invalid API token
* Token has expired
* User does not have permission to access the specified order

{% code title="Sample Error Messages" %}

```json
{
  "401": {
    "description": "Unauthorized",
    "examples": [
      {
        "scenario": "Missing API token",
        "response": {
          "detail": "Authentication credentials were not provided."
        }
      },
      {
        "scenario": "Invalid API token",
        "response": {
          "detail": "Invalid token header. No credentials provided."
        }
      },
      {
        "scenario": "Expired token",
        "response": {
          "detail": "Token has expired."
        }
      }
    ]
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="404: Order Not Found" %}
Occurs when:

* No order exists with the given ID

{% code title="Sample Error Message" %}

```
{ 
"error": "No order found with given ID!" 
}
```

{% endcode %}
{% endtab %}

{% tab title="422: Unprocessable Entity" %}
Occurs when:

* Order is not in an active/running state
* Order is already paused
* Order is completed, canceled, or in another terminal state
* Failed to cancel active placements on exchanges
* Exchange-specific cancellation failures
* Database transaction failures during pause operation
* Network connectivity issues with exchanges
* Order is part of a complex workflow that cannot be paused

{% code title="Sample Error Messages" %}

```json
{
  "422": {
    "description": "Unprocessable Entity",
    "examples": [
      {
        "scenario": "Order not running",
        "response": {
          "error": "Order is not running."
        }
      },
      {
        "scenario": "Order already paused",
        "response": {
          "error": "Order is not running."
        }
      },
      {
        "scenario": "Order completed",
        "response": {
          "error": "Order is not running."
        }
      },
      {
        "scenario": "Failed to cancel placements",
        "response": {
          "error": "Failed to cancel all placements"
        }
      },
      {
        "scenario": "Exchange cancellation failure",
        "response": {
          "error": "Unexpected cancel failure"
        }
      },
      {
        "scenario": "Database transaction failure",
        "response": {
          "error": "Failed to commit pause order changes: Database connection failed"
        }
      },
      {
        "scenario": "Network connectivity issue",
        "response": {
          "error": "Failed to commit pause order changes: Connection timeout"
        }
      },
      {
        "scenario": "Order not found",
        "response": {
          "error": "Order not found."
        }
      }
    ]
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="500" %}
Occurs when:

* Database connection issues
* External service failures
* Unexpected system errors during pause process
* Market data service failures
* Notification service failures

{% code title="Sample Error Messages" %}

```json
{
  "500": {
    "description": "Internal Server Error",
    "examples": [
      {
        "scenario": "Database connection error",
        "response": {
          "error": "Database connection failed"
        }
      },
      {
        "scenario": "External service failure",
        "response": {
          "error": "Market data service unavailable"
        }
      },
      {
        "scenario": "Notification service failure",
        "response": {
          "error": "Failed to send pause notification"
        }
      },
      {
        "scenario": "Unexpected system error",
        "response": {
          "error": "Something went wrong"
        }
      }
    ]
  }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

**Notes**

* **Order State Requirement:** Only orders with status "ACTIVE" can be paused
* **Idempotent**: Pausing an already paused order will return an error
* **Placement** **Cancellation**: All active placements, including OTC placements, are canceled during pause
* **Schedule Preservation:** Future schedule points are cleared to prevent confusion during resumption
* **Manual vs System Pause:** Manual pauses clear resume conditions to prevent automatic resumption
* **Resume Condition:** If a resume condition is provided, it will be set for automatic resumption
* **Market Data:** Market data collection is paused to conserve resources
* **Notifications:** Pause notifications are sent to inform users of the order state change

**Related Endpoints**

* [Resume Order: ](#resume-order)`POST /api/resume_order/` - Resume a paused order
* Pause All Orders: `POST /api/pause_all_orders/`- Pause all active orders for the user
* [Pause Multi Order: ](/interacting-with-the-api/api-reference/multi-order.md#pause-multi-order)`POST /api/pause_multi_order/` - Pause a multi-order and all its child orders
* Pause Chained Order: `POST /api/pause_chained_order/` - Pause a chained order

## Resume order

<mark style="color:green;">`POST`</mark> `/api/resume_order/`

Resume a previously paused order. This operation will restart order execution, update the order status to "ACTIVE", and trigger the execution workflow.

#### Path Parameters

| Name      | Type   | Description       |
| --------- | ------ | ----------------- |
| order\_id | string | UUID of the order |

**Headers**

* `Authorization: Token <API_KEY>`
* `Content-Type: application/json`

#### Example Request

`POST /api/resume_order/`

**Body**:

```
{
  "order_id": "6debb950-614a-4366-b73b-7d7574fd9e15"
}
```

#### Example Response

```json
{
  "message": "Successfully resumed order."
}
```

#### Response Codes

{% tabs %}
{% tab title="202: Accepted" %}

```
{
  "202": {
    "description": "Order successfully resumed",
    "content": {
      "application/json": {
        "example": {
          "message": "Successfully resumed order."
        }
      }
    }
  }
}
```

{% endtab %}

{% tab title="400: Bad Request" %}
Occurs when:

* The `order_id` field is missing from the request body
* The provided `order_id` is not a valid UUID

{% code title="Sample Error Message" %}

```json
{
  "400": {
    "description": "Invalid request parameters",
    "content": {
      "application/json": {
        "example": {
          "error": "Missing required field: order_id"
        }
      }
    }
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="404: Not Found" %}
Occurs when:

* No order exists with the given `order_id`

{% code title="Sample Error Message" %}

```json
{
  "404": {
    "description": "Order not found",
    "content": {
      "application/json": {
        "example": {
          "error": "Order not found."
        }
      }
    }
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="422: Resume operation failed" %}
Occurs when:

* The order is not in a paused state (cannot be resumed)
* There is a failure amending the order schedule
* There is a database or internal error during the resume process

{% code title="Sample Error Message" %}

```json
{
  "422": {
    "description": "Resume operation failed",
    "content": {
      "application/json": {
        "example": {
          "error": "Order is not paused."
        }
      }
    }
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="500" %}
{&#x20;

"error": "Internal server error"

&#x20;}
{% endtab %}
{% endtabs %}

## Amend order

&#x20;<mark style="color:green;">`POST`</mark> `/api/amend_order/`

Amend an existing order by updating specific fields. This operation allows you to modify order parameters such as quantity, duration, limit price, and POV target while the order is still active.

**Request Body**

| Name         | Type          | Required | Description                                                 |
| ------------ | ------------- | -------- | ----------------------------------------------------------- |
| `order_id`\* | string (UUID) | Yes      | UUID of the order to amend                                  |
| `changes`\*  | object        | Yes      | Object containing the fields to update and their new values |

**Updatable Fields**

| Field             | Type    | Description                                                 | Constraints                                |
| ----------------- | ------- | ----------------------------------------------------------- | ------------------------------------------ |
| `base_asset_qty`  | number  | Base asset quantity (cannot be used with quote\_asset\_qty) | Must be positive                           |
| `quote_asset_qty` | number  | Quote asset quantity (cannot be used with base\_asset\_qty) | Must be positive                           |
| `duration`        | integer | Order duration in seconds                                   | Must be at least 5% more than elapsed time |
| `pov_target`      | number  | Percentage of volume target (0-1)                           | Must be between 0 and 1                    |
| `limit_price`     | string  | Limit price for the order                                   | Must be valid price expression             |

**Headers**

* `Authorization: Token <API_KEY>`
* `Content-Type: application/json`

#### Example Request

`POST /api/amend_order/`

**Body**:

```
{
  "order_id": "6debb950-614a-4366-b73b-7d7574fd9e15",
  "changes": {
    "duration": 900,
    "limit_price": "51000"
  }
}
```

#### Example Response

```json
{
  "message": "Successfully amended order."
}
```

{% tabs %}
{% tab title="202: Accepted" %}

```json
{
  "202": {
    "description": "Order successfully amended",
    "content": {
      "application/json": {
        "example": {
          "message": "Successfully amended order."
        }
      }
    }
  }
}
    }
  }
}
```

{% endtab %}

{% tab title="400: Bad Request" %}
Occurs when:

* The `order_id` or changes field is missing from the request body
* The changes field is not an object
* Both `base_asset_qty` and `quote_asset_qty` are provided
* The provided values are not valid (e.g., non-numeric quantities)

{% code title="Sample Error Message" %}

```json
{
  "400": {
    "description": "Invalid request parameters",
    "content": {
      "application/json": {
        "example": {
          "error": "Missing required field(s): order_id, changes"
        }
      }
    }
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="403: Forbidden" %}
Occurs when:

* A superuser attempts to amend an order in a retail environment

{% code title="Sample Error Message" %}

```json
{
  "403": {
    "description": "Superuser on retail cannot place orders",
    "content": {
      "application/json": {
        "example": {
          "error": "Superusers on retail cannot place orders"
        }
      }
    }
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="404: Not Found" %}
Occurs when:

* No order exists with the given `order_id`

{% code title="Sample Error Message" %}

```json
{
  "404": {
    "description": "Order not found",
    "content": {
      "application/json": {
        "example": {
          "error": "Order 6debb950-614a-4366-b73b-7d7574fd9e15 not found"
        }
      }
    }
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="422: Unprocessable Entity" %}
Occurs when:

* The order is too close to completion (less than 15 seconds remaining)
* The order is a child order (unless in dev mode)
* Both `base_asset_qty` and `quote_asset_qty` are provided
* The new `sell_token_amount` is less than 5% above executed quantity
* The new `duration` is less than 5% above elapsed time
* The new `limit_price` is invalid
* There is a failure updating the order or schedule

{% code title="Sample Error Message" %}

```json
{
  "422": {
    "description": "Amendment failed",
    "content": {
      "application/json": {
        "example": {
          "error": "Cannot update both base_asset_qty and quote_asset_qty"
        }
      }
    }
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="500: Internal Server Error Something went wrong, contact support" %}
Occurs when:

* Database connection issues
* Unexpected server errors during order retrieval

{% code title="Sample Error Message" %}

```json
{
  "500": {
    "description": "Internal Server Error",
    "examples": [
      {
        "scenario": "Unexpected server error",
        "response": {
          "errors": ["An unexpected error occurred. Please try again later."]
        }
      }
    ]
  }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Cancel all orders

&#x20;<mark style="color:green;">`POST`</mark> `/api/cancel_all_orders/`

Cancel all active orders for the authenticated user. This operation will cancel all orders that are not in a terminated state (excluding COMPLETED, CANCELED, and other final statuses). By default, paused orders are also excluded unless specified otherwise.

**Request Body**

| Name            | Type                    | Description                                                                                                                                                                                      |
| --------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `account_names` | Comma-separated strings | **Optional**. List of account names. You pick this name when creating an account under account management (e.g., binance\_main,coinbase\_pro) If not provided, all user accounts are considered. |

#### Query Parameters

| Name             | Type    | Description                                                                            |
| ---------------- | ------- | -------------------------------------------------------------------------------------- |
| `exclude_paused` | boolean | **Optional.** Whether to exclude paused orders from cancellations. (Default: **true**) |

**Headers**

`Authorization: Token <API_KEY>`

`Content-Type: application/json (only when sending a body)`

#### Example Request

`POST /api/cancel_all_orders/?exclude_paused=true`

```
{
  "account_names": "binance_main,coinbase_pro"
}
```

#### Example Response

```json
{
  "message": "Successfully canceled all orders."
}
```

#### Response Codes

{% tabs %}
{% tab title="200 OK" %}

```json
{
  "200": {
    "description": "Orders successfully canceled or no orders to cancel",
    "content": {
      "application/json": {
        "example": {
          "message": "Successfully canceled all orders."
        }
      }
    }
  }
}
```

{% endtab %}

{% tab title="400: Bad Request Invalid Request" %}
Occurs when:

* The `account_names` field is provided but is not a comma-separated string
* There are errors fetching the specified accounts

{% code title="Sample Error Message" %}

```json
{
  "400": {
    "description": "Invalid request parameters",
    "content": {
      "application/json": {
        "example": {
          "message": "No active orders to cancel. Failed to fetch accounts: ['Account not found: bad_account']"
        }
      }
    }
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="422: Unprocessable Entity" %}
Occurs when:

* Some orders could not be canceled due to internal errors
* There were failures canceling placements or updating order status
* There were errors fetching the specified accounts and some orders failed to cancel

{% code title="Sample Error Message" %}

```json
{
  "422": {
    "description": "Cancellation failed for some or all orders",
    "content": {
      "application/json": {
        "example": {
          "error": "Canceled 2 orders with 1 failures: ['Failed to cancel order 12345'] Failed to fetch accounts: ['Account not found: bad_account']"
        }
      }
    }
  }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Pause all orders

<mark style="color:green;">`POST`</mark>` ``/api/pause_all_orders/`

Pause all active orders for the authenticated user. This operation will pause all orders with status "ACTIVE" and cancel their active placements. The orders will maintain their current state and can be resumed later.

What Happens When You Pause All OrdersWhen you pause all orders, the following actions are performed for each active order:

1. Cancel Active Placements: All active placements across all venues are canceled, including OTC placements
2. Update Order Status: Order status is changed from "ACTIVE" to "PAUSED"
3. Record Pause Time: The paused\_at timestamp is recorded
4. Clear Resume Condition: Any resume conditions are cleared to prevent automatic resumption
5. Clear Future Schedule Points: Future schedule points are removed to prevent confusion
6. Pause Market Data Collection: Market data collection for the order is paused
7. Send Notifications: Order pause notifications are sent

**Request Body**

This endpoint does not require any request body parameters.

**Headers**

`Authorization: Token <API_KEY>`

**Example Request**

`POST /api/pause_all_orders/`

#### Example Response

```
{
  "message": "Successfully paused all orders."
}
```

**Response Codes**

{% tabs %}
{% tab title="200: OK" %}

```json
{
  "200": {
    "description": "All orders paused successfully",
    "content": {
      "application/json": {
        "example": {
          "message": "Successfully paused all orders."
        }
      }
    }
  }
}
```

{% endtab %}

{% tab title="400: Bad Request" %}
Occurs when:

* No active orders to pause, or invalid request parameters (e.g., account not found)

{% code title="Sample Error Message" %}

```json
{
  "400": {
    "description": "Invalid request parameters",
    "content": {
      "application/json": {
        "example": {
          "message": "No active orders to cancel. Failed to fetch accounts: ['Account not found: bad_account']"
        }
      }
    }
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="401: Unauthorized" %}
Occurs when:

* Invalid or missing authentication token
* User is not authenticated

{% code title="Sample Error Message" %}

```json
{
  "401": {
    "description": "Unauthorized",
    "content": {
      "application/json": {
        "example": {
          "error": "Unauthorized"
        }
      }
    }
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="422: Unprocessable Entity" %}
Occurs when:

* Some orders failed to pause due to system errors
* Orders are in an invalid state for pausing

{% code title="Sample Error Message" %}

```json
{
  "422": {
    "description": "Unprocessable entity",
    "content": {
      "application/json": {
        "example": {
          "error": "Paused 5 orders with 2 failures: ['order-id-1', 'order-id-2']"
        }
      }
    }
  }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

**Notes**

* **Superuser Access:** Superusers can pause all orders across all users
* **Regular Users:** Regular users can only pause their own active orders
* **Partial Failures:** If some orders fail to pause, the response will indicate which orders failed
* **Order State:** Paused orders maintain their current execution state and can be resumed later
* **No Request Body:** This endpoint does not require any request parameters

**Related Endpoints**

* &#x20;[`POST /api/resume_all_orders/`](#resume-all-orders)- Resume all paused orders
* &#x20;[`POST /api/pause_order/`](/order-tracking-and-portfolio-management/manage-order/pause-order.md)- Pause a single order
* &#x20;[`POST /api/resume_order/`](#resume-order)- Resume a single order

## Resume all orders

`POST` `/api/resume_all_orders/`

Resumes all PAUSED single-leg orders for the authenticated user and sets them back to ACTIVE.. This operation will resume all orders with status "PAUSED" and restart their execution. Orders will transition back to "ACTIVE" and execution will continue from where they left off.

**What Happens When You Resume All Orders**

When you resume all orders, the following actions are performed for each paused order:

1. **Update Order Status:** Order status is changed from "PAUSED" to "ACTIVE"
2. **Resume Execution:** Order execution is restarted from the paused state
3. **Resume Market Data Collection:** Market data collection for the order is resumed
4. **Send Notifications:** Order resume notifications are sent

**Request Body**

This endpoint does not require any request body parameters.

**Headers**

`Authorization: Token <API_KEY>`

#### Example Request

`POST /api/resume_all_orders/`

#### Example Response

```json
{
  "message": "Successfully resumed all orders."
}
```

#### Response Codes

{% tabs %}
{% tab title="200: OK" %}

```json
{
  "200": {
    "description": "All orders resumed successfully",
    "content": {
      "application/json": {
        "example": {
          "message": "Successfully resumed all orders."
        }
      }
    }
  }
}
```

{% endtab %}

{% tab title="400: Bad Request" %}
Occurs when:

* No paused orders to resume

```json
{
  "400": {
    "description": "No paused orders to resume",
    "content": {
      "application/json": {
        "example": {
          "message": "No paused orders to resume."
        }
      }
    }
  }
}
```

{% endtab %}

{% tab title="401: Unauthorized" %}
Occurs when:

* Invalid or missing authentication token
* User is not authenticated

{% code title="Sample Error Message" %}

```json
{
  "401": {
    "description": "Unauthorized",
    "content": {
      "application/json": {
        "example": {
          "error": "Unauthorized"
        }
      }
    }
  }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

**Notes**

* **Superuser Access**: Superusers can resume all paused orders across all users
* **Regular Users:** Regular users can only resume their own paused orders
* **No Request Body:** This endpoint does not require any request parameters

**Related Endpoints**

* [`POST /api/pause_all_orders/`](#pause-all-orders)- Pause all active orders
* &#x20;[`POST /api/pause_order/`](/order-tracking-and-portfolio-management/manage-order/pause-order.md)- Pause a single order
* &#x20;[`POST /api/resume_order/`](#resume-order) - Resume a single order

<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tread.fi/interacting-with-the-api/api-reference/core-order-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
