📘 MASTER–SLAVE TRADER API DOCUMENTATION
This documentation contains full technical details of all Master and Slave Trader APIs including schemas, validation rules, field descriptions, and examples.
# 🔐 Global Rule — IP Restriction Behavior
All API routes first verify the client's IP:
restricted_ip fetched from Company Info
Restriction Logic Used in Every API
# Check if the user's IP is allowed to access the system:
RETURN:
{
"success": True,
"message": "This IP (X.X.X.X) is not allowed to access this site"
}
✔ If restricted_ip is empty, ALL IPs are allowed.
✔ If restricted_ip is set, ONLY that IP is allowed.
✔ Even failed operations return { success: true } when blocked.
====================
# 👨✈️ MASTER TRADER API
====================
## 1️⃣ Get All Master Traders
Endpoint
GET /api/get-all-master-traders
Description
Fetches a full list of all master traders.
Headers Required
None (only IP validation)
Response Format
{
"success": true,
"data": [...]
}
Response Example
{
"success": true,
"data": [
{
"trade_id": 1,
"create_time": "2025-10-13T17:02:28",
"update_time": "2025-11-25T16:39:29",
"last_login_time": "2025-11-28 15:58:20.440001",
"name": "John Deo",
"email": "wovexo8700@eoilup.com",
"mobile_number": "5986547578",
"password": "123",
"no_of_slave": 15,
"status": 1,
"mt_path": 1,
"mt5_login": "{\"server\":\"octafx1234\",\"account\":\"456987\",\"password\":\"123\"}",
"login_status": "success",
"account_no": 456987
}
]
}
## 2️⃣ Add a New Master Trader
Endpoint
POST /api/add-master-trader
Description
Adds a new master trader.
Request Schema
{
"name": "string",
"email": "string",
"password": "string",
"mobile_number": "string",
"no_of_slave": "integer",
"status": "integer (1 or 0)",
"start_date": "YYYY-MM-DD",
"end_date": "YYYY-MM-DD",
"mt_path": "integer (optional)"
}
Field Descriptions
| name | string | Yes | Full name of master trader |
| email | string | Yes | Must be unique |
| password | string | Yes | Password stored as plain text |
| mobile_number | string | Yes | Phone number |
| no_of_slave | int | Yes | Number of allowed slave accounts |
| status | int | Yes | 1=active, 0=inactive |
| start_date | string | No | Subscription start date |
| end_date | string | No | Subscription end date |
| mt_path | int | No | MT5 path ID |
Example Request
{
"name": "John Deo",
"email": "johndeo@test.com",
"password": "123456",
"mobile_number": "9873214568",
"no_of_slave": 5,
"status": 1,
"start_date": "2025-01-01",
"end_date": "2025-12-31"
}
Success Response
{
"success": true,
"message": "Master trader added successfully."
}
Error Response
{
"success": false,
"message": "Email already exists OR failed to add."
}
## 3️⃣ Update Master Trader
Endpoint
POST /api/edit-master-trader/{trade_id}
Description
Updates any field of master trader.
Request Schema
{
"name": "string (optional)",
"email": "string (optional)",
"password": "string (optional)",
"mobile_number": "string (optional)",
"no_of_slave": "integer (optional)",
"status": "integer (optional)",
"start_date": "YYYY-MM-DD (optional)",
"end_date": "YYYY-MM-DD (optional)",
"mt_path": "integer (optional)"
}
Example
{
"name": "John Deo",
"email": "johndeo@test.com",
"password": "123",
"mobile_number": "9873214568",
"no_of_slave": 15,
"status": 1
}
Success Response
{
"success": true,
"message": "Master trader updated successfully."
}
## 4️⃣ Delete Master Trader
Endpoint
POST /api/delete-master-trader/{trade_id}
Description
Deletes a master trader using ID.
Success Response
{
"success": true,
"message": "Master trader ID 6 deleted successfully."
}
## 5️⃣ Update Master Trader MT5 Login
Endpoint
POST /api/update-master-mt5-login/{trade_id}
Description
Updates MT5 login and clears trading-related fields.
Also checks if account number is already used by any master or slave.
Request Schema
{
"server": "string",
"password": "string",
"account": "string or number"
}
Example
{
"server": "octafx1234",
"password": "123home",
"account": "15975356"
}
Success Response
{
"success": true,
"message": "Master MT5 login updated successfully."
}
Duplicate Account Error
{
"success": false,
"message": "Account number already exists in master or slave trader."
}
=================
# 👨💻 SLAVE TRADER API
=================
## 6️⃣ Get All Slave Traders
Endpoint
GET /api/get-all-slave-traders
Description
Fetches all slave traders.
Response Example
{
"success": true,
"data": [
{
"slave_id": 1,
"name": "Slave User",
"email": "slave@example.com",
"mobile_number": "5698458965",
"status": 1,
"master_id": 1,
"master_email": "wovexo8700@eoilup.com",
"start_date": "2025-01-01",
"end_date": "2025-12-31",
"mt5_login": "{\"server\":\"112233\", \"account\":\"123789\", \"password\":\"123456\"}",
"account_no": 123789
}
]
}
## 7️⃣ Add a New Slave Trader
Endpoint
POST /api/add-slave-trader
Description
Adds a new slave trader under a master trader.
Master ID + Master Email must match an existing master (validated by master_exists()).
Request Schema
{
"name": "string",
"email": "string",
"mobile_number": "string",
"status": 1,
"start_date": "YYYY-MM-DD",
"end_date": "YYYY-MM-DD",
"master_id": 6,
"master_email": "string",
"mt_path": 1
}
Field Descriptions
name | string | Yes | Full name of the slave trader. |
email | string | Yes | Email of the slave trader. Must be unique across master + slave users. |
mobile_number | string | Yes | Phone number of the slave trader. |
status | int | Yes | Status of the slave: 1 = active, 0 = inactive. |
start_date | string | No | Subscription start date in YYYY-MM-DD format. |
end_date | string | No | Subscription end date in YYYY-MM-DD format. |
master_id | int | Yes | ID of the master trader under whom this slave is created. Must exist in master table. |
master_email | string | Yes | Email of the same master trader. Must match the master_id. |
mt_path | int | No | Optional MT5 terminal/path identifier for this slave. |
Example Request
{
"name": "Slave User",
"email": "slavetest@test.com",
"mobile_number": "5824568569",
"status": 1,
"start_date": "2025-01-01",
"end_date": "2025-12-31",
"master_id": 6,
"master_email": "test@test.com"
}
Success Response
{
"success": true,
"message": "Slave trader added successfully."
}
Validation Error (Invalid Master)
{
"success": false,
"message": "Invalid master credentials (master_id and email do not match)."
}
## 8️⃣ Update Slave Trader
Endpoint
POST /api/edit-slave-trader/{slave_id}
Example
{
"name": "Slave User",
"email": "slavetest@test.com",
"mobile_number": "5824568569",
"status": 0,
"start_date": "2025-11-01",
"end_date": "2026-02-01"
}
Success Response
{
"success": true,
"message": "Slave trader updated successfully."
}
## 9️⃣ Delete Slave Trader
Endpoint
POST /api/delete-slave-trader/{slave_id}
Success Response
{
"success": true,
"message": "Slave trader ID 4 deleted successfully."
}
## 🔟 Update Slave Trader MT5 Login
Endpoint
POST /api/update-slave-mt5-login/{slave_id}
Request Example
{
"server": "Exness-Trial9",
"password": "123test",
"account": "5858694"
}
Success Response
{
"success": true,
"message": "Slave MT5 login updated successfully."
}
Account Already Exists
{
"success": false,
"message": "Account number already exists in master or slave trader."
}
## 1️⃣1️⃣ Update Slave Inputs
Endpoint
POST /api/update-slave-inputs/{slave_id}
Description
Updates trade input configuration for a specific Slave Trader.
Stores values under input column as JSON.
Request Body Schema
{
"magic": 12345,
"lot_type": "fix | same_master | multiply_from_master | auto_lot",
"fix_size": 0.5,
"multiplier": 2.0,
"trade_type": "as_it_is | opposite"
}
Field Descriptions
magic | int | Magic number identifier used in MT5 trades. |
lot_type | enum | Defines lot behaviour.🔹 fix → use fixed lot🔹 same_master → same lot as master🔹 multiply_from_master → lot = master * multiplier🔹 auto_lot → dynamic allocation |
fix_size | float | Fixed lot size. |
multiplier | float | Used for Multiplier value. |
trade_type | enum | 🔹 as_it_is → copy trade direction🔹 opposite → take reverse direction |
Example Request
{
"magic": 12345,
"lot_type": "multiply_from_master",
"fix_size": 0.01,
"multiplier": 2,
"trade_type": "as_it_is"
}
Success Response
{
"success": true,
"message": "Slave Inputs updated successfully."
}
Failure Response
{
"success": false,
"message": "Slave Inputs update failed"
}
## 1️⃣2️⃣ Update Trade Symbols for Master
Endpoint
POST /api/update-trade-symbol/{trade_id}
Description
Assigns tradable symbols to a master trader.
Moves symbols from all_symbol → trade_symbol, invalid symbols ignored.
Request Body Schema
{
"trade_symbol": ["XAUUSD", "BTCUSD"]
}
Validation Behavior
Symbol exists inside all_symbol | Added to trade_symbol |
| Symbol not present in allowed list | Returned under "invalid_ignored" |
| No valid symbols provided | Request fails |
Example Request
{
"trade_symbol": ["EURUSD", "GBPUSD", "FAKE"]
}
Success Response
{
"success": true,
"message": "Trade symbols updated",
"trade_symbol_added": ["EURUSD", "GBPUSD"],
"invalid_ignored": ["FAKE"],
"updated_all_symbol": ["XAUUSD", "BTCUSD"]
}
No valid symbol case
{
"success": false,
"message": "No valid symbols found inside all_symbol!",
"invalid_symbols": ["FAKE"]
}
## 1️⃣3️⃣ Update Magic Numbers (Master Trader)
Endpoint
POST /api/update-magic-no/{trade_id}
Description
Updates Master magic numbers list and replaces previous values.
Request Body Schema
{
"magic_no": [1234, 5678, 9999]
}
Success Response
{
"success": true,
"message": "Magic Numbers updated successfully",
"magic_no": [1234, 5678, 9999]
}
Failure Example
{
"success": false,
"message": "Failed to update magic numbers"
}
## 1️⃣4️⃣ Re-login All Slave Traders
Endpoint
POST /api/relogin-slave-all
Description
Clears all failed login status for slave traders and resets them for relogin.
Success Response
{
"success": true,
"message": "Failed slave traders cleared successfully.",
"failed_before_clear": 7
}
## 1️⃣5️⃣ Re-login All Master Traders
Endpoint
POST /api/relogin-master-all
Description
Clears failed login state for all master traders.
Success Response
{
"success": true,
"message": "All failed traders cleared successfully.",
"failed_before_clear": 4
}
=================
# 📌 RULES FOR MASTER + SLAVE
=================
1. Email Must Be Unique
A master and a slave cannot share the same email.
2. MT5 Account Number Must Be Unique
Checked using account_no_exists().
3. Updating MT5 Login Clears These Fields
all_symbol
trade_symbol
login_status
account_name
balance
equity
today_profit
weekly_profit
monthly_profit
currency
broker_time_zone
mt5_version
mt5_terminal_info
mt5_account_info
4. All Dates Are Strings in YYYY-MM-DD Format