pipsocketDOCS
Guides / Get started

Accounts and ids

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 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} tells you how its terminal is doing (status):

statusMeaning
startingThe terminal is starting, or logging in.
connectedLogged in to the broker: ready to trade.
disconnectedThe terminal has lost the broker's trade server; it reconnects by itself.
unreachableThe broker's server can't be reached; the terminal keeps trying.
stoppedStopped from the dashboard.
auth_failedThe broker refused the login. Fix the password in the dashboard.
server_not_foundThe broker's server name wasn't found.
login_unknownThe terminal went away while trying a password the broker hadn't confirmed yet; give the login again.
refusedPipsocket 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} still answers, and the 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, modify or cancel 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} for 7 days. Its state:

stateMeaning
pendingSent, with no answer from the trade server yet. It is never sent again.
doneMT5 answered: result.retcode says whether it filled, was placed or was rejected.
unknownNo answer within 130 seconds. If the terminal reports the answer later, the request becomes done; check positions and history meanwhile.
refusedThe 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.