POST Register MT5 Account

abstract

Register a new MetaTrader5 account — verifies credentials against MT5, encrypts the password, stores the account, and returns the created record.

🔒 Authentication

PropertyValue
MechanismNone
RequiredNo

🛠️ Technical Specification

Request

ParameterLocationTypeRequiredDescription
nameBodystring (max 100)YesHuman-readable account label
brokerBodystring (max 100)YesBroker name
loginBodyinteger (> 0)YesMT5 account number
passwordBodystringYesMT5 password (encrypted before storage)
serverBodystring (max 200)YesMT5 server string
is_liveBodybooleanNoTrue = live account (default: false)
allowed_symbolsBodystring[]NoPermitted symbols (default: [])
max_lot_sizeBodyfloat (0–100)NoMax trade volume in lots (default: 0.1)
risk_pctBodyfloat (0–1)NoRisk per trade as fraction (default: 0.01 = 1%)
auto_trade_enabledBodybooleanNoEnable automated trading (default: true)
mt5_pathBodystring (max 500)NoPath to terminal64.exe (overrides global)
account_typeBody"USD" | "USC"NoAccount currency type (default: "USD")

Pydantic Schema: backend/api/routes/accounts.py :: AccountCreate

Logic Flow

📦 Request Body

{
  "name": "Live Trading Account",
  "broker": "MetaQuotes",
  "login": 12345678,
  "password": "MyMT5Password",
  "server": "MetaQuotes-Demo",
  "is_live": false,
  "allowed_symbols": ["EURUSD", "GBPUSD"],
  "max_lot_size": 0.1,
  "risk_pct": 0.01,
  "auto_trade_enabled": true,
  "account_type": "USD"
}

📤 Responses

StatusWhenBody
201 CreatedAccount registeredAccountResponse
400 Bad RequestInvalid credentials or validation error{ "detail": "message" }
409 ConflictLogin already registered{ "detail": "Account 12345678 already exists" }
422 Unprocessable EntityPydantic schema error{ "detail": [...] }
503 Service UnavailableMT5 connection failed{ "detail": "MT5 connection failed; try again later" }

201 Created example:

{
  "id": 42,
  "name": "Live Trading Account",
  "broker": "MetaQuotes",
  "login": 12345678,
  "server": "MetaQuotes-Demo",
  "is_live": false,
  "is_active": true,
  "allowed_symbols": ["EURUSD", "GBPUSD"],
  "max_lot_size": 0.1,
  "risk_pct": 0.01,
  "auto_trade_enabled": true,
  "paper_trade_enabled": false,
  "mt5_path": "",
  "account_type": "USD",
  "created_at": "2026-05-16T14:30:00Z"
}

Pydantic Schema: backend/api/routes/accounts.py :: AccountResponse

RolePath
Routerbackend/api/routes/accounts.py
MT5 Bridgebackend/mt5/bridge.py
Securitybackend/core/security.py :: encrypt()
DB TableDB - accounts
RoleLink
Related EndpointAPI-GET-v1-Accounts
Frontend PagePage - Accounts
DB SchemaDB - accounts