Brokeret LogoDocs
MT4 Web API/Introduction

Introduction

Overview of the Brokeret MT4 Web API for managing MetaTrader 4 via REST.

What is the MT4 Web API?

Brokeret MT4 Web API is a REST API for managing MetaTrader 4 accounts, trades, and server operations via the MT4 Manager interface. Built for CRM integration, it provides 34 endpoints covering user management, balance operations, trade monitoring, and administrative functions.

Version: 1.0.0 | Total Endpoints: 34

Authentication

All endpoints (except health checks) require a JWT Bearer token. Obtain one via the login endpoint.

POST/api/auth/login

AuthNone
Content-Typeapplication/x-www-form-urlencoded

Authenticates with admin credentials and returns a JWT access token. Token expiry defaults to 8 hours and is auto-refreshed when close to expiry.

Request:

POST/api/auth/login
Content-Type: application/x-www-form-urlencoded

username=admin&password=your_password

Response:

{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "token_type": "bearer"
}

Usage: Include the token in all subsequent requests:

Authorization: Bearer eyJhbGciOiJIUzI1NiIs...

Health & Connectivity

Endpoints for monitoring service health, MT4 server connectivity, and diagnostics.

GET/api/health

AuthNone

Returns API service status. Use for uptime monitoring and load balancer health checks.

Response:

{
  "status": "ok",
  "service": "mt4-manager-api",
  "version": "1.0.0"
}

GET/api/test/service-health

AuthNone

Checks whether the internal Windows MT4 service is reachable and has an active connection to the MT4 trade server.

Response:

{
  "status": "ok",
  "service": "mt4-service",
  "connected": true
}

GET/api/test/status

AuthJWT

Returns the current connection status of the MT4 service to the trade server.

Response:

{
  "status": "ok",
  "connected": true
}

GET/api/test/ping

AuthJWT

Sends a ping to the MT4 trade server. Verifies the connection is alive.

Response:

{
  "status": "ok",
  "ping": true
}

GET/api/test/server-time

AuthJWT

Returns the MT4 server's current time as both Unix timestamp and human-readable UTC string.

Response:

{
  "status": "ok",
  "server_time": 1772901814,
  "server_time_str": "2026-03-07 16:43:34 UTC"
}

POST/api/test/connect

AuthJWT

Manually connects the MT4 service to a trade server. Typically not needed as the service auto-connects on startup with auto-reconnect.

Request Body:

{
  "server": "203.0.113.10:443",
  "login": 224,
  "password": "your_manager_password"
}

Response:

{
  "status": "ok",
  "message": "Connected and logged in successfully"
}

POST/api/test/disconnect

AuthJWT

Disconnects the MT4 service from the trade server. All MT4 operations will fail until reconnected.

Response:

{
  "status": "ok",
  "message": "Disconnected"
}

Quick Reference

#MethodEndpointAuthDescription
1GET/api/healthAPI health check
2POST/api/auth/loginGet JWT token
3GET/api/test/service-healthMT4 service reachable?
4POST/api/test/connectJWTConnect to MT4 server
5POST/api/test/disconnectJWTDisconnect from MT4
6GET/api/test/statusJWTConnection status
7GET/api/test/pingJWTPing MT4 server
8GET/api/test/server-timeJWTGet server time
9GET/api/users/JWTList all users
10GET/api/users/{login}JWTGet single user
11POST/api/users/JWTCreate user account
12PUT/api/users/{login}JWTUpdate user account
13PUT/api/users/{login}/passwordJWTChange password
14POST/api/accounts/{login}/depositJWTDeposit funds
15POST/api/accounts/{login}/withdrawJWTWithdraw funds
16POST/api/accounts/{login}/creditJWTAdd/remove credit
17GET/api/accounts/{login}/marginJWTGet margin level
18GET/api/accounts/marginsJWTBulk margin data (all accounts)
19GET/api/trades/openJWTAll open trades
20GET/api/trades/open/{login}JWTUser's open trades
21POST/api/trades/history/{login}JWTUser's trade history
22GET/api/groups/JWTList all groups
23GET/api/groups/onlineJWTOnline users
24GET/api/groups/{name}JWTGet single group
25GET/api/symbols/JWTList all symbols
26GET/api/symbols/{name}JWTGet symbol config
27GET/api/symbols/{name}/priceJWTLive bid/ask price
28POST/api/admin/trades/lookupJWTLookup trades by ticket
29POST/api/admin/trades/by-groupJWTTrades by group
30PUT/api/admin/trades/{order}/modifyJWTModify trade record
31POST/api/admin/trades/deleteJWTDelete trades
32POST/api/admin/mailJWTSend internal mail
33POST/api/admin/users/group-opJWTBatch user operations
34GET/api/server/configJWTServer configuration

Next Steps

  • API Endpoints — Full endpoint reference for users, accounts, trades, groups, symbols, and admin operations
  • Data Models — User, trade, and margin record schemas, error handling, and notes