# GET All Positions

Retrieve positions across all accounts in a single request. By default, flat positions are excluded. Pass `?includeFlat=true` to include them.

<mark style="color:green;">`GET`</mark> `/v1/api/positions`

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Query Parameters**

| Name          | Type    | Required | Description                                              |
| ------------- | ------- | -------- | -------------------------------------------------------- |
| `includeFlat` | boolean | Optional | Include flat (zero-quantity) positions. Default: `false` |

**Code Examples**

{% tabs %}
{% tab title="Python" %}

```python
import requests

token = 'my-secret-token'
url = "https://app.crosstrade.io/v1/api/positions"
headers = {
    "Authorization": f"Bearer {token}",
    "Content-Type": "application/json"
}

try:
    response = requests.get(url, headers=headers)
    print(f"Response Code: {response.status_code}, Response Text: {response.text}")
except Exception as e:
    print(f"An error occurred: {e}")
```

{% endtab %}
{% endtabs %}

***

**Response**

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

```json
{
  "positions": [
    {
      "type": "NinjaTrader.Cbi.Position",
      "account": "Sim101",
      "instrument": "MES 03-26",
      "instrumentType": "Future",
      "marketPosition": "Long",
      "quantity": 7,
      "averagePrice": 6615.178571428572,
      "marketPrice": 6614.25,
      "unrealizedProfitLoss": -32.50000000000455,
      "tag": null
    },
    {
      "type": "NinjaTrader.Cbi.Position",
      "account": "Sim101",
      "instrument": "NQ 06-26",
      "instrumentType": "Future",
      "marketPosition": "Short",
      "quantity": 1,
      "averagePrice": 24605.25,
      "marketPrice": 24606.25,
      "unrealizedProfitLoss": -20.0,
      "tag": null
    },
  ],
  "count": 2,
  "success": true
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}

#### WebSocket API

This request can also be made over the WebSocket API. Query parameters are passed inside `args`.

```json
{
  "action": "rpc",
  "id": "my-request-id",
  "api": "GetAllPositions",
  "args": {
    "includeFlat": false
  }
}
```
