API v2Account API

Accounts

Connect, inspect and disconnect MetaTrader accounts. Each connected account then gets its own trading API, documented separately.

List trading accounts

Every trading account on the team, newest first — on API v2 and on the Legacy API. Accounts on API v2 also carry the links to their own API, Swagger page and WebSocket tester.

GET
/v2/accounts
X-API-Key<token>

Your team's API key, from dashboard Settings. The same key authenticates each account's own trading API.

In: header

Response Body

curl -X GET "https://api.api2trade.com/v2/accounts"
[
  {
    "id": "string",
    "accountNumber": "string",
    "accountServerHost": "string",
    "name": "string",
    "status": "string",
    "type": "string",
    "statusMessage": "string",
    "createdAt": "string",
    "updatedAt": "string",
    "provisioner": "string",
    "terminalStatus": "string",
    "terminalLastError": "string",
    "suspended": true,
    "suspendedAt": "string",
    "apiBaseUrl": "string",
    "swaggerUrl": "string",
    "wsTesterUrl": "string"
  }
]

Connect a new trading account

Sets up a dedicated connection for the credentials given. Returns straight away with terminalStatus: provisioning — logging in to the broker takes a few minutes. Poll the account until terminalStatus is ready, or error with the reason in terminalLastError.

The server name must match your broker's exactly, as written in the account details email.

POST
/v2/accounts
X-API-Key<token>

Your team's API key, from dashboard Settings. The same key authenticates each account's own trading API.

In: header

accountNumberstring
Match^[0-9]+$
Length1 <= length <= 64
namestring
Match^[^\u0000-\u001f\u007f]+$
Length1 <= length <= 100
typeTypeEnum
  • Metatrader 4 - Metatrader 4
  • Metatrader 5 - Metatrader 5
Value in"Metatrader 4" | "Metatrader 5"
accountPasswordstring
Length1 <= length
accountServerHoststring
Match^[^\u0000-\u001f\u007f]+$
Length1 <= length <= 255

Response Body

curl -X POST "https://api.api2trade.com/v2/accounts" \  -H "Content-Type: application/json" \  -d '{    "accountNumber": "1082118",    "name": "Demo one",    "type": "Metatrader 5",    "accountPassword": "••••••••",    "accountServerHost": "VTMarkets-Demo"  }'
{
  "id": "string",
  "accountNumber": "string",
  "accountServerHost": "string",
  "name": "string",
  "status": "string",
  "type": "string",
  "statusMessage": "string",
  "createdAt": "string",
  "updatedAt": "string",
  "provisioner": "string",
  "terminalStatus": "string",
  "terminalLastError": "string",
  "suspended": true,
  "suspendedAt": "string",
  "apiBaseUrl": "string",
  "swaggerUrl": "string",
  "wsTesterUrl": "string"
}
{
  "error": "string",
  "message": "string"
}
{
  "error": "string",
  "message": "string"
}
{
  "error": "string",
  "message": "string"
}
{
  "error": "string",
  "message": "string"
}

Fetch one trading account

GET
/v2/accounts/{account_id}
X-API-Key<token>

Your team's API key, from dashboard Settings. The same key authenticates each account's own trading API.

In: header

Path Parameters

account_idstring
Formatuuid

Response Body

curl -X GET "https://api.api2trade.com/v2/accounts/497f6eca-6276-4993-bfeb-53cbbbba6f08"
{
  "id": "string",
  "accountNumber": "string",
  "accountServerHost": "string",
  "name": "string",
  "status": "string",
  "type": "string",
  "statusMessage": "string",
  "createdAt": "string",
  "updatedAt": "string",
  "provisioner": "string",
  "terminalStatus": "string",
  "terminalLastError": "string",
  "suspended": true,
  "suspendedAt": "string",
  "apiBaseUrl": "string",
  "swaggerUrl": "string",
  "wsTesterUrl": "string"
}
{
  "error": "string",
  "message": "string"
}

Disconnect and remove a trading account

Disconnects the account and deletes it. This frees the slot immediately. It cannot be undone — reconnecting means providing the credentials again.

DELETE
/v2/accounts/{account_id}
X-API-Key<token>

Your team's API key, from dashboard Settings. The same key authenticates each account's own trading API.

In: header

Path Parameters

account_idstring
Formatuuid

Response Body

curl -X DELETE "https://api.api2trade.com/v2/accounts/497f6eca-6276-4993-bfeb-53cbbbba6f08"
Empty
{
  "error": "string",
  "message": "string"
}