# Positions

Source: https://docs.pipsocket.com/api/positions

Open positions, read fresh from the terminal.

All calls: `https://api.pipsocket.com`, with `Authorization: Bearer <your workspace key>`.

## List open positions

`GET /v1/accounts/{account}/positions`

The account's open positions, read fresh from its terminal.

### Path

- `account` (string, required): The account's id, `acc_` and 26 characters, as the dashboard shows it.

### Response

A list of:

- `ticket` (integer, MT5 `POSITION_TICKET`): The position's ticket: use it to close the position or set its stops.
- `identifier` (integer, MT5 `POSITION_IDENTIFIER`): The position's id, which stays the same if the broker changes the ticket.
- `symbol` (string, MT5 `POSITION_SYMBOL`): 
- `type` (enum): `buy` or `sell` (MT5's `POSITION_TYPE`). One of: `buy`, `sell`.
- `volume` (number, MT5 `POSITION_VOLUME`): 
- `price_open` (number, MT5 `POSITION_PRICE_OPEN`): 
- `sl` (number, MT5 `POSITION_SL`): 
- `tp` (number, MT5 `POSITION_TP`): 
- `magic` (integer, MT5 `POSITION_MAGIC`): 
- `comment` (string, MT5 `POSITION_COMMENT`): 
- `time_msc` (integer, MT5 `POSITION_TIME_MSC`): When it was opened: broker server time, milliseconds since 1970.

### Answers

- 200: Every open position.
- 401: - `missing_api_key`: No API key: send it as `Authorization: Bearer <key>`.; `invalid_api_key`: The key is not a workspace's current key (a rolled key stops working within about a minute).
- 404: - `no_such_account`: No such account, or one the key's workspace doesn't have: the two look the same.
- 503: - `account_not_connected`: The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.; `engine_busy`: The account's engine host has too many calls in flight (256). Nothing was done; try again.; `engine_unavailable`: The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.
- 504: - `terminal_timeout`: The account's terminal did not answer within 5 seconds.; `engine_timeout`: The account's engine did not answer within 30 seconds.

### Example

```bash
curl "https://api.pipsocket.com/v1/accounts/acc_01m6tx3k9f2qw8r7bznd5yvh4c/positions" \
  -H "Authorization: Bearer $PIPSOCKET_KEY"
```

200 positions:

```json
[
  {
    "comment": "",
    "identifier": 881402311,
    "magic": 0,
    "price_open": 1.08412,
    "sl": 1.079,
    "symbol": "EURUSD",
    "ticket": 881402311,
    "time_msc": 1794067801211,
    "tp": 0,
    "type": "buy",
    "volume": 0.1
  }
]
```
