Authentication
One API key for everything, and where each API expects it.
Every API2Trade API authenticates with your team's API key, which you copy from Settings in the dashboard. One key covers the Account API, every connected account's Trading API, and the WebSocket stream.
X-API-Key: YOUR_API_KEYRotating the key reconnects your v2 accounts
Generating a new key in Settings invalidates the old one immediately, and every v2 account reconnects with the new one — unreachable for about a minute while its connection restarts. Positions at your broker are untouched. Update your own code before you rotate.
API v2
The key goes in the X-API-Key header, and the account is part of the
path.
curl -H "X-API-Key: $API2TRADE_API_KEY" \
'https://api.api2trade.com/v2/accounts'curl -H "X-API-Key: $API2TRADE_API_KEY" \
'https://api.api2trade.com/v2/{account_id}/AccountSummary'The account_id in the path is routing, not authentication: the key still
has to have access to that account, or the answer is 401.
The WebSocket is the one exception
A browser cannot set a header on a WebSocket, so the socket reads the key from the query string:
wss://api.api2trade.com/v2/{account_id}/ws?api_key=YOUR_API_KEYTreat a URL containing your key as the key itself — it lands in shell histories and server logs the way a header does not.
API v1 (Legacy)
The Legacy API will be switched off on 31 December 2026 — see Migrating to API v2.
The legacy API takes the same key in the same header, but identifies the account
with an id query parameter rather than a path segment:
curl -H "x-api-key: $API2TRADE_API_KEY" \
'https://api.api2trade.com/AccountSummary?id=YOUR_ACCOUNT_UUID'Accounts are connected either in the dashboard or through /RegisterAccount,
described in the MetaTrader 5 and
MetaTrader 4 sections.
At a glance
| Credential | Where | Account identified by | |
|---|---|---|---|
| v2 REST | API key | X-API-Key header | path: /v2/{account_id}/… |
| v2 WebSocket | API key | ?api_key= query | path: /v2/{account_id}/ws |
| v1 REST | API key | x-api-key header | query: ?id={uuid} |