# Account

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

Login, status, balance, equity and margin.

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

## Get the account

`GET /v1/accounts/{account}`

The account's login, status and connection, and the balance, equity and margin from its terminal's last report (once a second). Read from the engine, not the terminal, so it answers while the terminal is away.

### Path

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

### Response

- `id` (string): The account's id.
- `login` (integer): The MT5 login.
- `server` (string): The broker's trade server.
- `status` (string): What the engine knows of the account's terminal: `starting`, `connected`, `disconnected`, `unreachable` (the broker's server can't be reached; it keeps trying), `stopped`, or a status someone has to act on: `auth_failed` (the broker refused the login), `server_not_found`, `login_unknown` or `refused`.
- `connected` (boolean): Whether the terminal reports a connection to the trade server.
- `trade_allowed` (boolean, or null): Whether MT5 lets this terminal trade: the terminal, the account and automated trading all allow it. False for an investor (read-only) login.
- `company` (string, or null): The broker.
- `currency` (string, or null): The account's currency.
- `leverage` (integer, or null): 
- `margin_mode` (string, or null): `hedging`, `netting` or `exchange`.
- `trade_mode` (string, or null): `demo`, `contest` or `real`.
- `balance` (number, or null): 
- `equity` (number, or null): 
- `credit` (number, or null): 
- `margin` (number, or null): 
- `margin_free` (number, or null): 
- `server_time` (integer, or null): The trade server's time at the last report: broker server time, seconds since 1970.
- `kill_switch` (object): Whether the account's kill switch is engaged.
  - `engaged` (boolean): 
  - `since` (integer, or null): When it was engaged: seconds since 1970 (UTC). Null when it is not engaged.
  - `deviation` (integer, or null): The deviation, in points, its closing deals carry. Null when it is not engaged.

### Answers

- 200: The account.
- 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: - `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: - `engine_timeout`: The account's engine did not answer within 30 seconds.

### Example

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

200 connected:

```json
{
  "balance": 10000,
  "company": "FBS Markets Inc.",
  "connected": true,
  "credit": 0,
  "currency": "USD",
  "equity": 10012.4,
  "id": "acc_01m6tx3k9f2qw8r7bznd5yvh4c",
  "kill_switch": {
    "deviation": null,
    "engaged": false,
    "since": null
  },
  "leverage": 500,
  "login": 5058427372,
  "margin": 21.68,
  "margin_free": 9990.72,
  "margin_mode": "hedging",
  "server": "FBS-Demo",
  "server_time": 1794067825,
  "status": "connected",
  "trade_allowed": true,
  "trade_mode": "demo"
}
```
