Update a Master or Slave account of your Trade Copier cockpit
URL: https://www.trade-copier.com/webservice/v4/account/updateAccount.php
Response: JSON object with account fields
Fields noted with a * are optional
| Field Name | Field Type | Field Description |
|---|---|---|
| account_id | string | Account ID of the account that you want to update |
| type* | int | 0=Master or 1=Slave |
| name* | string | Custom account name |
| broker* | string | mt4, mt5, ctrader, fxcm_fc, tradovate or lmax (always in lower case). For NinjaTrader please use Tradovate |
| login* | string | Your broker account login |
| password* | string | Your broker account password |
| server* | string | MT4: IG-DEMO, FxPro.com-Real02, Ava-Real 1, etc. MT5: ActivTrades-Server, Binary.com-Server, FxPro-MT5, etc. cTrader: write "unknown" LMax Demo: https://web-order.london-demo.lmax.com LMax Live: https://api.lmaxtrader.com FXCM_FC: http://www.fxcorporate.com/Hosts.jsp DXtrade: url of the broker server without https Tradovate/NinjaTrader: Not possible to add via Trade Copier API Fortex: url of the broker server without https |
| environment* | string | Real or Demo |
| status* | int | The account is 0=disabled, 1=enabled |
| group* | string | One of your existing template's ID or it can be null to remove it |
| subscription_key* | string | The subscription key of the subscription to assign to your account or "auto", which this automatically selects an available subscription for this account |
| alert_email* | int | Send warning email for account disconnection is 0=disabled, 1=enabled |
PHP example
<?php
$url="https://www.trade-copier.com/webservice/v4/account/updateAccount.php";
$headers = array(
'Content-Type: application/x-www-form-urlencoded',
'Authorization: Bearer [[TOKEN]]',
);
// Open connection
$ch = curl_init();
// Setting the options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//If needed, we update the Risk Factor's template, you can get the existing template with the "getTemplates.php" webservice
$template= 'DEF';//Template name
//$template= null;//No template
//If needed, we update the subscription for the account, you can get available subscriptions with the "getSubscriptions.php" webservice
$subscription = 'auto';//Automaticaly select an available subscription
//$subscription = 'ABCD1234';
//$subscription = null;
// Account data to be updated
$account = [
'account_id' => 'ABC',//Mandatory
'name' => 'nameZZ',
'broker' => 'mt4',//mt4, mt5, ctrader, lmax, fxcm_fc
'login' => 'login111',
'password' => 'password',
'group' => $template,
'subscription' => $subscription,
'alert_sms' => '0'
];
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($account));
// Execute request
$json = json_decode(curl_exec($ch));
// Close connection
curl_close($ch);
//We access the updated account data
if(array_key_exists('account', $json))
{
//We access the added account data
echo "Account ".$json->account->account_id." updated: ".$json->account->name." ".$json->account->login." ".$json->account->server;
}
else
{
//This is an error message that can be access like this:
//echo $json->code." ".$json->error;
echo json_encode($json);
}
?>