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
| Auth | None |
| Content-Type | application/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_passwordResponse:
{
"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
| Auth | None |
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
| Auth | None |
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
| Auth | JWT |
Returns the current connection status of the MT4 service to the trade server.
Response:
{
"status": "ok",
"connected": true
}
GET/api/test/ping
| Auth | JWT |
Sends a ping to the MT4 trade server. Verifies the connection is alive.
Response:
{
"status": "ok",
"ping": true
}
GET/api/test/server-time
| Auth | JWT |
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
| Auth | JWT |
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
| Auth | JWT |
Disconnects the MT4 service from the trade server. All MT4 operations will fail until reconnected.
Response:
{
"status": "ok",
"message": "Disconnected"
}
Quick Reference
| # | Method | Endpoint | Auth | Description |
|---|---|---|---|---|
| 1 | GET | /api/health | — | API health check |
| 2 | POST | /api/auth/login | — | Get JWT token |
| 3 | GET | /api/test/service-health | — | MT4 service reachable? |
| 4 | POST | /api/test/connect | JWT | Connect to MT4 server |
| 5 | POST | /api/test/disconnect | JWT | Disconnect from MT4 |
| 6 | GET | /api/test/status | JWT | Connection status |
| 7 | GET | /api/test/ping | JWT | Ping MT4 server |
| 8 | GET | /api/test/server-time | JWT | Get server time |
| 9 | GET | /api/users/ | JWT | List all users |
| 10 | GET | /api/users/{login} | JWT | Get single user |
| 11 | POST | /api/users/ | JWT | Create user account |
| 12 | PUT | /api/users/{login} | JWT | Update user account |
| 13 | PUT | /api/users/{login}/password | JWT | Change password |
| 14 | POST | /api/accounts/{login}/deposit | JWT | Deposit funds |
| 15 | POST | /api/accounts/{login}/withdraw | JWT | Withdraw funds |
| 16 | POST | /api/accounts/{login}/credit | JWT | Add/remove credit |
| 17 | GET | /api/accounts/{login}/margin | JWT | Get margin level |
| 18 | GET | /api/accounts/margins | JWT | Bulk margin data (all accounts) |
| 19 | GET | /api/trades/open | JWT | All open trades |
| 20 | GET | /api/trades/open/{login} | JWT | User's open trades |
| 21 | POST | /api/trades/history/{login} | JWT | User's trade history |
| 22 | GET | /api/groups/ | JWT | List all groups |
| 23 | GET | /api/groups/online | JWT | Online users |
| 24 | GET | /api/groups/{name} | JWT | Get single group |
| 25 | GET | /api/symbols/ | JWT | List all symbols |
| 26 | GET | /api/symbols/{name} | JWT | Get symbol config |
| 27 | GET | /api/symbols/{name}/price | JWT | Live bid/ask price |
| 28 | POST | /api/admin/trades/lookup | JWT | Lookup trades by ticket |
| 29 | POST | /api/admin/trades/by-group | JWT | Trades by group |
| 30 | PUT | /api/admin/trades/{order}/modify | JWT | Modify trade record |
| 31 | POST | /api/admin/trades/delete | JWT | Delete trades |
| 32 | POST | /api/admin/mail | JWT | Send internal mail |
| 33 | POST | /api/admin/users/group-op | JWT | Batch user operations |
| 34 | GET | /api/server/config | JWT | Server 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