Accounts
Use these methods to manage client accounts (such as trading accounts and wallets) and view information about them.
GET[host]/api/v2/accounts |
|
GET[host]/api/v2/accounts/{accountId} |
|
POST[host]/api/v2/accounts |
|
PUT[host]/api/v2/accounts/{accountId} PATCH[host]/api/v2/accounts/{accountId} |
|
GET[host]/api/v2/accounts/{accountId}/preferences |
GET[host]/api/v2/accounts/{accountId}/balance |
|
PATCH[host]/api/v2/accounts/{accountId}/balance PUT[host]/api/v2/accounts/{accountId}/balance |
Use this method to archive client trading accounts.
POST[host]/api/v2/accounts/{accountId}/archive |
Get an account list
Use this method to obtain a list of the available client accounts.
Note
If such a request is made by an admin user that is only permitted to view clients with certain tags, a response includes only the accounts of clients marked with these tags.
To obtain detailed information about a specific account, use a separate method to get account details.
Request
Header parameters:
Authorization: Bearer <access_token>
Query parameters:
The following filter parameters are available for this method:
- clientId
The identifier of a client who owns an account.
- platformId
The identifier of a platform on which an account is created.
- productId
The identifier of a product for which an account is created.
The following sorting parameter is available for this method:
- createTime
The date and time when a client account was created.
Refer to the Query parameters section of the API Overview for details on applying filter and sorting parameters.
GET[host]/api/v2/accounts
curl --location -g --request GET 'https://host.name/api/v2/accounts?limit=10&offset=0&sort_order=desc&sort_by=createTime&filter[clientId]=1&filter[platformId]=1&filter[productId]=1' \
--header 'Authorization: Bearer <token>'
Response
A response contains an array of Account objects providing information about the accounts matching the request parameters.
Get account details
Use this method to obtain detailed information about a specified account.
To obtain a list of available client accounts, use a separate method to get an account list.
Request
Header parameters:
Authorization: Bearer <access_token>
Path parameters:
- accountId required
The account identifier.
GET[host]/api/v2/accounts/{accountId}
curl --location --request GET 'https://host.name/api/v2/accounts/1' \
--header 'Authorization: Bearer <token>'
Response
A response contains an Account object providing information about the specified account.
Create a new account
Use this method to create new wallets as well as cTrader, MT4 and MT5 trading accounts for your clients.
Request
Header parameters:
Authorization: Bearer <access_token>
Body:
Specify the following parameters for a new wallet or trading account:
- productCurrencyId integer required
The identifier of a product currency.
The product currency is a specific currency added to a product for which you want to create a wallet or trading account. A new wallet or account is denominated in a selected currency and created for the product to which the currency refers.
To obtain product currency identifiers, use the method to get a list of product currencies.
- clientId integer required
The identifier of a client for whom a wallet or trading account is to be created.
- alreadyExistingPlatformAccount boolean
Applicable only for trading accounts
Set to
true
to create a trading account in B2Core using the account that already exists on a trading platform.Set to
false
to create a new trading account both on a trading platform and in B2Core.
- leverage integer
This parameter is required if
alreadyExistingPlatformAccount
is set totrue
.The leverage ratio specified for an already existing trading account.
- accountNumber string
This parameter is required if
alreadyExistingPlatformAccount
is set totrue
.The number of an already existing trading account.
POST[host]/api/v2/accounts
curl --location --request POST 'https://host.name/api/v2/accounts' \
--header 'Authorization: Bearer <token>' \
--data-raw '{
"productCurrencyId": 1,
"clientId": 1,
"alreadyExistingPlatformAccount": true,
"leverage": 0,
"accountNumber": "2100242175"
}'
Response
A response includes an Account object providing information about the created wallet or trading account.
Update an account
Use this method to update a specified trading account or wallet.
Note
Instead of the method described below, you can use a similar method that uses the HTTP verb PATCH.
Request
Header parameters:
Authorization: Bearer <access_token>
Path parameters:
- accountId required
The account identifier.
Body:
The following field values can be updated for a specified account:
- caption string
The account name displayed in the B2Core UI.
- permissions array
An array of string values specifying the permissions assigned to a wallet. Possible values:
deposit
enabled
exchange
trade
transferDeposit
transferWithdrawal
visible
withdrawal
PUT[host]/api/v2/accounts/{accountId}
curl --location --request PUT 'https://host.name/api/v2/accounts/1' \
--header 'Authorization: Bearer <token>' \
--data-raw '{
"caption": "Bitcoin",
"permissions": [
"deposit",
"trade",
"withdrawal"
]
}'
Response
A response includes an Account object providing information about the account that was updated.
Get account preferences
Use this method to get the leverage ratio assigned to a specified account.
Request
Header parameters:
Authorization: Bearer <access_token>
Path parameters:
- accountId required
The account identifier.
GET[host]/api/v2/accounts/{accountId}/preferences
curl --location --request GET 'https://host.name/api/v2/accounts/1/preferences' \
--header 'Authorization: Bearer <token>'
Response
- leverage integer or null
The leverage ratio assigned to a specified account.
{
"leverage": 1
}
Get account balance
Use this method to get balance of a specified account.
Request
Header parameters:
Authorization: Bearer <access_token>
Path parameters:
- accountId required
The account identifier.
GET[host]/api/v2/accounts/{accountId}/balance
curl --location --request GET 'https://host.name/api/v2/accounts/1/balance' \
--header 'Authorization: Bearer <token>'
Response
- balance string
The balance on a specified account.
{
"balance": "500.00"
}
Change account balance
Use this method to change balance on a specified account.
Important
Balance change operations can be made only for wallets.
Note
Instead of the method described below, you can use a similar method that uses the HTTP verb PATCH.
Request
Header parameters:
Authorization: Bearer <access_token>
Path parameters:
- accountId required
The account identifier.
Body:
Specify the following field value:
- amount number required
The amount by which you want to change balance on a specified account.
Specify a positive value to deposit funds to an account and a negative value to withdraw funds.
PUT[host]/api/v2/accounts/{accountId}/balance
curl --location --request PATCH 'https://host.name/api/v2/accounts/1/balance' \
--header 'Authorization: Bearer <token>' \
--data-raw '{
"amount": -500.00
}'
Response
In case of success, no response body is returned.
Archive an account
Use this method to archive cTrader, MT4 and MT5 trading accounts. Only the accounts with zero balances can be archived.
Request
Header parameters:
Authorization: Bearer <access_token>
Path parameters:
- accountId required
The account identifier.
POST[host]/api/v2/accounts/{accountId}/archive
curl --location --request POST 'https://host.name/api/v2/accounts/1228/archive' \
--header 'Authorization: Bearer <token>'
Response
In case of success, no response body is returned.