This section describes the most common use cases for the Web Services API. It also lists the API calls needed to perform specific actions as well as the corresponding request/response examples.
Note that all examples below assume that
moneyDigits=2
.
All examples below are made to a ‘sandbox’ allowing you to quickly test them provided you append a valid manager’s token.
To create a new trader with the minimum possible number of parameters in the request body, perform the following request (API call 4.1).
curl -X POST ‘https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/traders?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc’ -H ‘Accept: application/json’ -H ‘Content-Type: application/json’ -d ‘{"accessRights": "FULL_ACCESS", "accountType": "HEDGED", "balance": "00", "brokerName": "BESTBROKER", "depositCurrency": "EUR", "groupName": "Default", "hashedPassword": "c5678ghf94578ce06iqrs5ag76a62c5ca4", "leverageInCents": 10000}’
You will receive the following response.
{
"login": 8035344,
"groupName": "Default",
"depositCurrency": "EUR",
"accessRights": "FULL_ACCESS",
"brokerName": "BESTBROKER",
"balance": 0,
"bonus": 0,
"nonWithdrawableBonus": 0,
"leverageInCents": 10000,
"contactDetails": {},
"registrationTimestamp": 1680163530801,
"lastUpdateTimestamp": 1680163530802,
"equity": 0,
"usedMargin": 0,
"freeMargin": 0,
"accountType": "HEDGED",
"limitedRisk": false,
"sendOwnStatement": false,
"swapFree": false,
"totalMarginCalculationType": "MAX",
"isLimitedRisk": false,
"moneyDigits": 2,
}
Send the following request to create another trader (API call 4.1).
curl -X POST ‘https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/traders?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc’ -H ‘Accept: application/json’ -H ‘Content-Type: application/json’ -d ‘{"accessRights": "FULL_ACCESS", "accountType": "HEDGED", "balance": "00", "brokerName": "BESTBROKER", "depositCurrency": "EUR", "groupName": "Default", "hashedPassword": "c5678ghf94578ce06iqrs5ag76a62c5ca4", "leverageInCents": 10000}’
You will receive the following response.
{
"login": 8035345,
"groupName": "Default",
"depositCurrency": "EUR",
"accessRights": "FULL_ACCESS",
"balance": 0,
"bonus": 0,
"nonWithdrawableBonus": 0,
"leverageInCents": 10000,
"contactDetails": {},
"registrationTimestamp": 1680163530801,
"lastUpdateTimestamp": 1680163530802,
"equity": 0,
"usedMargin": 0,
"freeMargin": 0,
"accountType": "HEDGED",
"limitedRisk": false,
"sendOwnStatement": false,
"swapFree": false,
"totalMarginCalculationType": "MAX",
"isLimitedRisk": false,
"moneyDigits": 2,
}
Note that groupName
is "Default"
.
Now, send the request to update the trader you have just created (API call 4.5.1).
curl -X POST ‘https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/traders/8035345?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc’ -H ‘Accept: application/json’ -H ‘Content-Type: application/json’ -d ‘{"accessRights": "FULL_ACCESS", "accountType": "HEDGED", "balance": "00", "brokerName": "BESTBROKER", "depositCurrency": "EUR", "groupName": "DX_452", "hashedPassword": "c5678ghf94578ce06iqrs5ag76a62c5ca4", "leverageInCents": 10000}’
In the request body, we have changed groupName
to "DX_452"
while leaving all other parameters unchanged.
After receiving code 204
, send the below request to check whether the trader’s group has changed as requested (API call 4.2).
curl -X GET "https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/traders/8035345?token=8fe4a3a3-1fa6-c4cf-da0f-9c04ee0307b1" -H "accept: */*"
In the response you receive, groupName
should be equal to "DX_452"
.
You may want to prevent new traders from performing any trading operations inside the platform until they pass a KYC check.
To create a new trader, send the request below (API call 4.1).
curl -X POST ‘https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/traders?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc’ -H ‘Accept: application/json’ -H ‘Content-Type: application/json’ -d ‘{"accessRights": "NO_TRADING", "accountType": "HEDGED", "balance": "00", "brokerName": "BESTBROKER", "depositCurrency": "EUR", "groupName": "Default", "hashedPassword": "c5678ghf94578ce06iqrs5ag76a62c5ca4", "leverageInCents": 10000}’
Note that accessRights
is "NO_TRADING"
in the request body.
You will receive a response containing the following parameters.
{
"accessRights": "NO_TRADING",
"login": 8035346,
...
}
After you see that the trader has passed their KYC check in your client area, send the following request (API call 4.5.1).
curl -X POST ‘https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/traders/8035346?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc’ -H ‘Accept: application/json’ -H ‘Content-Type: application/json’ -d ‘{"accessRights": "FULL_ACCESS", "accountType": "HEDGED", "balance": "00", "brokerName": "BESTBROKER", "depositCurrency": "EUR", "groupName": "DX_452", "hashedPassword": "c5678ghf94578ce06iqrs5ag76a62c5ca4", "leverageInCents": 10000}’
If you send the request to read the trader’s details (API call 4.2), you should see that the accessRights
parameter has switched to "FULL_ACCESS"
.
curl -X GET "https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/traders/8035346?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc" -H "Accept: application/json"
The response to this call should be as follows.
{
"accessRights": "FULL_ACCESS",
"login": 8035346,
...
}
To deposit funds to a trader, send the following request (API call 4.7).
curl -X POST 'https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/traders/8035345/changebalance?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc' -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"login": 8035345, "preciseAmount": 123.45, "type": "DEPOSIT"}'
You will receive the following example response.
{
"balanceHistoryId": 74217197
}
To see the trader’s current balance, perform the below request (API call 4.2).
curl -X GET "https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/traders/8035345?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc" -H "Accept: Application/json"
You will receive a response containing the following parameter.
{
"balance": 12345,
...
}
To perform a withdrawal, send the following request (API call 4.7).
curl -X POST 'https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/traders/8035345/changebalance?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc' -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"login": 8035345, "preciseAmount": 111.11, "type": "WITHDRAWAL"}'
Note that the value of the
preciseAmount
parameter is still positive even though we are performing a withdrawal.
The response should be as follows.
{
"balanceHistoryId": 74217198
}
The trader’s current balance should now accurately represent both the previous deposit and the withdrawal. Again, perform API call 4.2).
curl -X GET "https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/traders/8035345?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc" -H "Accept: Application/json"
The response should account for your latest withdrawal.
{
"balance": 1234,
...
}
To deposit bonus to a trader, send the following request (API call 4.10).
curl -X POST 'https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/traders/8035345/changebonus?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc' -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"login": 8035345, "preciseAmount": 123.45, "type": "DEPOSIT"}'
You should receive the following response.
{
"bonusHistoryId": 11691
}
If you then check the trader’s details (API call 4.2), you should see your allocated bonus being added to the value of the bonus
parameter.
curl -X GET "https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/traders/8035345/?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc" -H "Accept: Application/json"
The response to the call should reflect the trader’s increased bonus.
{
"bonus": 12345,
...
}
To withdraw bonus, perform API call 4.10 with type=WITHDRAW
.
curl -X POST 'https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/traders/8035345/changebonus?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc' -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"login": 8035345, "preciseAmount": 123.45, "type": "WITHDRAW" }
Note that the value of the
preciseAmount
parameter is still positive even though we are performing a withdrawal.
The response should be as follows.
{
"bonusHistoryId": 11692
}
To see the current amount of bonus allocated to the trader, perform the below request (API call 4.2).
curl -X GET "https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/traders/8035345?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc" -H "Accept: Application/json"
The response should account for the recent withdrawal of bonus.
{
"bonus": 1234
}
To attribute a new trader to a partner, simply specify the values of the contactDetails.introducingBroker1
and/or contactDetails.introducingBroker2
keys when creating a new trader (API call 4.1).
curl -X POST ‘https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/traders?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc’ -H ‘Accept: application/json’ -H ‘Content-Type: application/json’ -d ‘{"accessRights": "FULL_ACCESS", "accountType": "HEDGED", "balance": "00", "brokerName": "BESTBROKER", "contactDetails": {"introducingBroker1": "GreatPartner", "introducingBroker2": "BestPartner"} "depositCurrency": "EUR", "groupName": "Default", "hashedPassword": "c5678ghf94578ce06iqrs5ag76a62c5ca4", "leverageInCents": 10000}’
Assuming that login=8035581
in the response, afterward, you can send API call 4.2 to see that the trader contains information about the specified partners.
curl -X GET "https://HOST:PORT/v2/webserv/traders/8035581/?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc" -H "Accept: application/json"
In the response, you should see the following information.
{
...
"contactDetails": {
"introducingBroker1": "GreatPartner",
"introducingBroker2": "BestPartner"
},
...
}
To attribute an existing trader to a partner, send specify the values of the contactDetails.introducingBroker1
and/or contactDetails.introducingBroker2
keys when updating a trader (API call 4.5.1).
curl -X POST ‘https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/traders/8035581?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc’ -H ‘Accept: application/json’ -H ‘Content-Type: application/json’ -d ‘{"accessRights": "FULL_ACCESS", "accountType": "HEDGED", "balance": "00", "brokerName": "BESTBROKER", "contactDetails": {"introducingBroker1": "GreatestPartner", "introducingBroker2": "SuperPartner"} "depositCurrency": "EUR", "groupName": "DX_452", "hashedPassword": "c5678ghf94578ce06iqrs5ag76a62c5ca4", "leverageInCents": 10000}’
Send API call 4.1 again, and you should see the new partners in the response.
{
...
"contactDetails": {
"introducingBroker1": "GreatestPartner",
"introducingBroker2": "SuperPartner"
},
...
}
To quickly create a new user with minimal parameters, perform the following request (API call 5.1).
curl -X POST 'https://https://demo-chsandbox2.webapi.ctrader.com:8443/v2/cid/ctid/create?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc' -H 'Content-Type: Application/json' -H 'Accept: Application/json' -d '{"email": "test@emailone.com"}'
You should receive the following response.
{
"userId": 18615,
"nickname": "ctid18615",
"email": "test@emailone.com",
"utcCreateTimestamp": 1680266904176,
"status": "CTID_NEW"
}
In many cases, your clients could request the creation of additional accounts the deposit currency and/or the White Label of which differs from their original account.
Consider an example of a trader with the following parameters.
{
"login": 8035346,
"depositCurrency": "EUR",
"brokerName": "BESTBROKER",
...
}
The userId
of the user to which this account is linked is 18615
.
To create a new account with different parameters, perform the following request (API call 4.1).
curl -X POST ‘https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/traders?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc’ -H ‘Accept: application/json’ -H ‘Content-Type: application/json’ -d ‘{"accessRights": "FULL_ACCESS", "accountType": "HEDGED", "balance": "00", "brokerName": "BESTBROKER_UK", "depositCurrency": "USD", "groupName": "Default", "hashedPassword": "c5678ghf94578ce06iqrs5ag76a62c5ca4", "leverageInCents": 10000}’
You should receive the following response.
{
"login": 8035344,
"groupName": "Default",
"depositCurrency": "USD",
"accessRights": "FULL_ACCESS",
"balance": 0,
"bonus": 0,
"brokerName": "BESTBROKER_UK",
"nonWithdrawableBonus": 0,
"leverageInCents": 10000,
"contactDetails": {},
"registrationTimestamp": 1680163530801,
"lastUpdateTimestamp": 1680163530802,
"equity": 0,
"usedMargin": 0,
"freeMargin": 0,
"accountType": "HEDGED",
"limitedRisk": false,
"sendOwnStatement": false,
"swapFree": false,
"totalMarginCalculationType": "MAX",
"isLimitedRisk": false,
"moneyDigits": 2,
}
To link the new trader with a specific cTID, make API call 5.2.
curl -X POST 'https://demo-chsandbox2.webapi.ctrader.com:8443/v2/cid/ctid/link?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc' -Р 'Content-Type: application/json' -H 'Accept: application/json' -d '{"traderLogin": 8035344, "traderPasswordHash": "c5678ghf94578ce06iqrs5ag76a62c5ca4", "userId": 18615, "returnAccountDetails": true}'
You will receive the following response.
{
"ctidTraderAccountId": 61641
}
There may also be cases when you change the structure of one or more existing White Labels (e.g., when rebranding different White Labels that you own). In this situation, you would need to change the White Label(s) of already existing accounts.
To do so for one trader, send the following request API call 5.3. In the example below, we are assuming that the trader with login=8035372
is attributed to any White Label the brokerName
of which is different from "BESTBROKER_UK"
.
curl -X POST 'https://demo-chsandbox2.webapi.ctrader.com:8443/v2/cid/ctid/changeCtidTraderAccount?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc' -H 'Content-Type: application/json' -H 'Accept: application/json' -d '{ "environmentName": "live", "brokerName": "BESTBROKER_UK", "traderLogin": 8035372}'
Note that this API call does not produce any output. To double-check whether the trader has been transferred to another White Label, send the following request (API call 4.2).
curl -X GET "https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/traders/8035372?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc" -H "Accept: application/json"
In the response body, you should see the updated brokerName
key.
{
"brokerName": "BESTBROKER_UK",
...
}
You can retrieve the current attribute sets for one or more traders, or page through all visible traders who have at least one attribute. Traders with no attributes are omitted from the response.
Usage scenario:
You may want to list all traders in your system who have a custom label, colour code or other metadata. This is useful for generating reports or applying bulk actions based on attribute values. To fetch the attributes for all traders visible to your ACL in pages of 25, send the following request:
curl -X POST 'https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/traders/attributes/list?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc' -H 'Content-Type: application/json' -d '{"limit":25, "pageAfterTraderId":101}'
You will receive a response similar to the following:
{
"results": [
{
"traderId": 201,
"attributes": [
{ "name": "colorCode", "value": "FF0000" },
{ "name": "prefixLabel", "value": "VIP" }
],
"utcLastUpdateTimestamp": 1688923200000
},
{
"traderId": 202,
"attributes": [
{ "name": "colorCode", "value": "00FF00" }
],
"utcLastUpdateTimestamp": 1688923200000
}
/* … 23 more trader objects … */
],
"nextPageAfterTraderId": 225
}
To continue retrieving traders, pass the value of nextPageAfterTraderId
from the previous response as pageAfterTraderId
in your next request. You can also fetch attributes for specific traders by specifying their IDs. For example, to get attributes for trader 101 and trader 102, send:
curl -X POST 'https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/traders/attributes/list?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc' -H 'Content-Type: application/json' -d '{"traderIds":[101,102]}'
The response will only include the specified traders if they have attributes:
{
"results": [
{
"traderId": 101,
"attributes": [
{ "name": "colorCode", "value": "FF0000" },
{ "name": "prefixLabel", "value": "VIP" }
],
"utcLastUpdateTimestamp": 1688923200000
},
{
"traderId": 102,
"attributes": [
{ "name": "colorCode", "value": "00FF00" }
],
"utcLastUpdateTimestamp": 1688923200000
}
]
}
If no traders remain beyond the requested pageAfterTraderId
, the results
array will be empty:
{
"results": []
}
You can bulk-insert new attributes or update existing ones for one or multiple traders in a single request.
Usage scenario:
You may want to apply or update labels, colour codes or other metadata for several traders at once, for example, marking a trader as VIP
or changing their assigned colour for internal dashboards. To update the attributes for traders 102 and 999, send the following request:
curl -X PUT 'https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/traders/attributes?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc' -H 'Content-Type: application/json' -d '{"attributeSets":[{"traderId":102,"attributes":[{"name":"prefixLabel","value":"VIP"}]},{"traderId":999,"attributes":[{"name":"colorCode","value":"0000FF"}]}]}'
If you are not authorised to modify any of the specified traders, the request will still succeed for the authorised ones and silently omit the unauthorised IDs from the result. For example, if you are authorised to update trader 102 but not trader 999, you will receive:
{}
You can remove specific attribute names from one or more traders, or delete all attributes for those traders if you provide an empty names
array.
Usage scenario:
You may want to remove an outdated label or colour code from traders, or completely clear their attributes when resetting account metadata. To delete the colorCode
attribute from traders 201 and 202, send the following request:
curl -X DELETE 'https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/traders/attributes?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc' -H 'Content-Type: application/json' -d '{"traderIds":[201,202],"names":["colorCode"]}'
If successful, you will receive:
{}
To delete all attributes for traders 201 and 202, provide an empty names
array:
curl -X DELETE 'https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/traders/attributes?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc' -H 'Content-Type: application/json' -d '{"traderIds":[201,202],"names":[]}'
You will receive:
{}
You can retrieve the current attribute sets for one or more trader groups. Paging is not supported for this request. You must always specify the traderGroupIds
you want to read. Groups with no attributes are omitted from the response.
Usage scenario:
You may want to check which trader groups have specific tags or colours assigned, for example to display them in an admin dashboard or apply special handling for Premium
groups. To fetch the attributes for trader groups 456 and 457, send the following request:
curl -X POST 'https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/tradergroups/attributes/list?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc' -H 'Content-Type: application/json' -d '{"traderGroupIds":[456,457]}'
You will receive a response similar to:
{
"results": [
{
"traderGroupId": 456,
"attributes": [
{ "name": "groupColorCode", "value": "FF0000" },
{ "name": "groupTag", "value": "Premium" }
],
"utcLastUpdateTimestamp": 1688923200000
},
{
"traderGroupId": 457,
"attributes": [
{ "name": "groupColorCode", "value": "00FF00" }
],
"utcLastUpdateTimestamp": 1688923200000
}
]
}
You can bulk-insert new attributes or update existing ones for multiple trader groups in a single request.
Usage scenario:
You may want to assign or update colours, tags, or other metadata for several trader groups at once, for example, changing a group’s colour code to FFAA00
while keeping its Premium
tag. To update attributes for trader groups 456 and 999, send the following request:
curl -X PUT 'https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/tradergroups/attributes?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc' -H 'Content-Type: application/json' -d '{"attributeSets":[{"traderGroupId":456,"attributes":[{"name":"groupColorCode","value":"FFAA00"},{"name":"groupTag","value":"Premium"}]},{"traderGroupId":999,"attributes":[{"name":"groupColorCode","value":"0000FF"}]}]}'
If you are not authorised to modify any of the specified trader groups, the request will still succeed for the authorised ones and omit unauthorised IDs from the response. For example, if you are authorised to update group 456 but not group 999, you will receive:
{}
You can remove specific attribute names from one or more trader groups, or delete all attributes for those groups if you provide an empty names
array.
Usage scenario:
You may want to remove a group’s assigned colour code or tag, or clear all metadata when reclassifying the group. To delete the groupColorCode
attribute from trader groups 456 and 457, send the following request:
curl -X DELETE 'https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/tradergroups/attributes?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc' -H 'Content-Type: application/json' -d '{"traderGroupIds":[456,457],"names":["groupColorCode"]}'
If successful, you will receive:
{}
To delete all attributes for trader groups 456 and 457, provide an empty names
array:
curl -X DELETE 'https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/tradergroups/attributes?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc' -H 'Content-Type: application/json' -d '{"traderGroupIds":[456,457],"names":[]}'
The response will be:
{}
You can retrieve the current attribute sets for one or more managers. A regular manager may only request their own ID, while a super-admin may request any manager IDs. Managers with no attributes are omitted from the response.
Usage scenario:
You may want to check a manager’s personal settings, such as their preferred theme or language, for configuration purposes or to synchronise settings across platforms. To fetch attributes for managers 789 and 790, send the following request:
curl -X POST 'https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/managers/attributes/list?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc' -H 'Content-Type: application/json' -d '{"managerIds":[789,790]}'
You will receive a response similar to:
{
"results": [
{
"managerId": 789,
"attributes": [
{ "name": "theme", "value": "dark" },
{ "name": "language", "value": "en" }
],
"utcLastUpdateTimestamp": 1688923200000
},
{
"managerId": 790,
"attributes": [
{ "name": "theme", "value": "light" }
],
"utcLastUpdateTimestamp": 1688923200000
}
]
}
If only manager 789 has attributes, the response will contain only that manager:
{
"results": [
{
"managerId": 789,
"attributes": [
{ "name": "theme", "value": "dark" },
{ "name": "language", "value": "en" }
],
"utcLastUpdateTimestamp": 1688923200000
}
]
}
You can bulk-insert new attributes or update existing ones for one or more managers in a single request. A regular manager may only specify their own managerId
, while a super-admin may specify any manager IDs.
Usage scenario:
You may want to set or update manager-specific settings, such as their preferred theme or language, across multiple accounts at once. To update the attributes for managers 789 and 790, send the following request:
curl -X PUT 'https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/managers/attributes?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc' -H 'Content-Type: application/json' -d '{"attributeSets":[{"managerId":789,"attributes":[{"name":"theme","value":"dark"},{"name":"language","value":"en"}]},{"managerId":790,"attributes":[{"name":"theme","value":"light"}]}]}'
If you are not authorised to update certain managers, the request will still succeed for authorised IDs and omit the unauthorised ones from the response. For example, if you are authorised to update manager 789 but not manager 790, you will receive:
{}
You can remove specific attribute names from one or more managers, or delete all attributes for those managers if you provide an empty names
array. A regular manager may only delete their own attributes, while a super-admin may delete any manager’s attributes.
Usage scenario:
You may want to remove a setting such as the preferred theme for certain managers, or clear all stored preferences before reassigning or deactivating their accounts. To delete the theme
attribute from managers 789 and 790, send the following request:
curl -X DELETE 'https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/managers/attributes?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc' -H 'Content-Type: application/json' -d '{"managerIds":[789,790],"names":["theme"]}'
If successful, you will receive:
{}
To delete all attributes for managers 789 and 790, provide an empty names
array:
curl -X DELETE 'https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/managers/attributes?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc' -H 'Content-Type: application/json' -d '{"managerIds":[789,790],"names":[]}'
The response will be:
{}
null
Returns 400
ErrorUPDATE
requests are only for adding or modifying attributes. Any attempt to delete an attribute by setting its value
to null
is invalid and will be rejected. To remove attributes, you must use the relevant DELETE
endpoint.
Usage scenario:
If you try to update a trader’s attributes with a null
value instead of using the delete call, the API will return an error. For example, the following request tries to remove colorCode
by setting its value to null
:
curl -X PUT 'https://demo-chsandbox2.webapi.ctrader.com:8443/v2/webserv/traders/attributes?token=1dd4ef40-c5b3-61c0-0689-b1b40c97fadc' -H 'Content-Type: application/json' -d '{"attributeSets":[{"traderId":601,"attributes":[{"name":"colorCode","value":null}]}]}'