# Accounts and ids

Source: https://docs.pipsocket.com/accounts

Account ids, MT5 tickets, request ids, and the times the API uses.

## Accounts

An account is one MT5 login on one broker server, running in its own MT5 terminal on a Pipsocket host. You connect it in the [dashboard](https://app.pipsocket.com) with its login, server and password; from then on the API reaches it by its id.

An account's id is `acc_` and 26 characters, such as `acc_01m6tx3k9f2qw8r7bznd5yvh4c`. The dashboard's **API key** page lists your accounts' ids, each with a copy button.

[`GET /v1/accounts/{account}`](/api/account) tells you how its terminal is doing (`status`):

| `status` | Meaning |
| --- | --- |
| `starting` | The terminal is starting, or logging in. |
| `connected` | Logged in to the broker: ready to trade. |
| `disconnected` | The terminal has lost the broker's trade server; it reconnects by itself. |
| `unreachable` | The broker's server can't be reached; the terminal keeps trying. |
| `stopped` | Stopped from the dashboard. |
| `auth_failed` | The broker refused the login. Fix the password in the dashboard. |
| `server_not_found` | The broker's server name wasn't found. |
| `login_unknown` | The terminal went away while trying a password the broker hadn't confirmed yet; give the login again. |
| `refused` | Pipsocket stopped the terminal as it can't be right (for example, it logged in to another account). |

The last four need someone to act in the dashboard. While the terminal isn't running (stopped, starting, or being replaced), calls that need it answer `503 account_not_connected`; [`GET /v1/accounts/{account}`](/api/account) still answers, and the [kill switch](/api/kill-switch) still engages. A terminal that has lost the broker still answers, and MT5 rejects trades with its own retcode.

## MT5's tickets

Orders, deals and positions keep MT5's own numbers:

- **`ticket`** of a position or a pending order: what you pass to [close](/api/close-a-position), [modify](/api/modify-an-order) or [cancel](/api/cancel-an-order) it.
- A position's **`identifier`** stays the same for its whole life, even if the broker changes its ticket. Deals name their position by it (`position`).
- A trade answer's `result` has the `order` and `deal` MT5 made.

## Request ids

Each trade call is recorded as a request, `req_` and 24 characters, returned as `request`. Look it up with [`GET /requests/{request}`](/api/look-up-a-request) for 7 days. Its `state`:

| `state` | Meaning |
| --- | --- |
| `pending` | Sent, with no answer from the trade server yet. It is never sent again. |
| `done` | MT5 answered: `result.retcode` says whether it filled, was placed or was rejected. |
| `unknown` | No answer within 130 seconds. If the terminal reports the answer later, the request becomes `done`; check positions and history meanwhile. |
| `refused` | The terminal didn't send it; `result` says why. |

An `Idempotency-Key` header, 1 to 128 characters, makes a trade call safe to repeat: a call with a key the account used in the last 7 days returns that first request, as it stands now, and sends nothing.

## Times

- `time_msc`, `time_setup_msc`, `time_done_msc` and `server_time` are the **broker's server time**, as MT5 reports it, not UTC: milliseconds (or seconds, for `server_time`) since 1970 in the broker's time zone.
- History ranges (`from`, `to`) and a pending order's `expiration` are broker server time too, in seconds.
- The kill switch's `since` is UTC, in seconds.

