Skip to content

Create account

About

Starts cloud API server for a MetaTrader account. It may take some time to determine the server settings, during which the endpoint will return the 202 status code. It takes some time to launch the terminal and connect the terminal to the broker, you can use the connectionStatus field to monitor the current status of the terminal. For more details see MetatraderAccount.

POST /users/current/accounts

For more information see swagger documentation

Headers

Name Type Required Description
auth-token string Yes Authorization token. See Authentication and authorization

Body

Name Type Required Description
login string Yes MetaTrader account number. Only digits are allowed
password string Yes MetaTrader account password. The password can be either investor password for read-only access or master password to enable trading features. Required for cloud account
name string Yes Human-readable account name
server string Yes MetaTrader server name to connect to
provisioningProfileId string Id of the provisioning profile that was used as the basis for creating this account. You need to provide provisioning profile id in case automatic broker settings detection has failed for your broker
platform string MetaTrader platform, enum: mt4, mt5. Required if provisioningProfileId is not specified
magic number Yes Magic value the trades should be performed using. When manualTrades field is set to true, magic value must be 0
type string Account type. Executing accounts as cloud-g2 is faster and cheaper. Cloud and cloud-g2 are aliases, enum: cloud, cloud-g1, cloud-g2, default: cloud-g2
region string Region id to deploy account at.
symbol string Any MetaTrader symbol your broker provides historical market data for. This value should be specified for G1 accounts only and only in case your MT account fails to connect to broker
copyFactoryResourceSlots number Number of CopyFactory 2 resource slots to allocate to account. Allocating extra resource slots results in lower trade copying latency. Please note that allocating extra resource slots is a paid option. Please also note that CopyFactory 2 uses redundant infrastructure so that each CopyFactory resource slot is billed as 2 standard resource slots. You will be billed for CopyFactory 2 resource slots only if you have added your account to CopyFactory 2 by specifying copyFactoryRoles field. Default is 1
manualTrades boolean Flag indicating if trades placed on this account are manual trades. Default is false
slippage number Default trade slippage in points. Should be greater or equal to zero. If not specified, system internal setting will be used which we believe is reasonable for most cases
quoteStreamingIntervalInSeconds number Quote streaming interval in seconds. Set to 0 in order to receive quotes on each tick. Default value is 2.5 seconds. Intervals less than 2.5 seconds are supported only for G2.
extensions Array<Extension> API extensions
tags Array User-defined account tags
metadata object Extra information which can be stored together with your account. Total length of this field after serializing it to JSON is limited to 1024 characters
reliability string Used to increase the reliability of the account. Allowed values are regular and high. Default is regular. 'high' is a recommended value for production environment
baseCurrency string 3-character ISO currency code of the account base currency. Default value is USD. The setting is to be used for copy trading accounts which use national currencies only, such as some Brazilian brokers. You should not alter this setting unless you understand what you are doing.
copyFactoryRoles Array Account roles for CopyFactory2 application. Allowed values are PROVIDER and SUBSCRIBER
resourceSlots number Number of resource slots to allocate to account. Allocating extra resource slots results in better account performance under load which is useful for some applications. E.g. if you have many accounts copying the same strategy via CooyFactory API, then you can increase resourceSlots to get a lower trade copying latency. Please note that allocating extra resource slots is a paid option. Default is 1
riskManagementApiEnabled boolean Flag indicating that risk management API should be enabled on account. Default is false

Response

  • 201 - New MetaTrader account created successfully. Schema:
Name Type Required Description
id string Yes Created MetaTrader account id
  • 202 - Server timezone calculation in progress. Response schema: Retry later message
  • 400 - Validation failed. Response schema: Error
  • 401 - Authorization failed. Response schema: Error
  • 404 - Provisioning profile with specified id not found. Response schema: Error

Examples

Creating an account using automatic broker settings detection

To create an account, supply a request with account data and the platform field indicating the MetaTrader version.

Example request:

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'auth-token: token' -d '{
    "login": "123456",
    "password": "password",
    "name": "testAccount",
    "server": "ICMarketsSC-Demo",
    "platform": "mt5",
    "magic": 123456,
    "application": "MetaApi"
}' 'https://mt-provisioning-api-v1.agiliumtrade.agiliumtrade.ai/users/current/accounts'

If the account has been created successfully, you will receive a response with account id:

{
  "id": "1eda642a-a9a3-457c-99af-3bc5e8d5c4c9"
}

If the settings have not yet been detected for the broker, the server will begin the process of detection, and you will receive a response with wait time:

{
  "message": "Automatic broker settings detection is in progress, please retry in 60 seconds"
}

Response headers:

{
  "Retry-After": 60
}

The retry-after header indicates the amount of seconds to wait until the next attempt can be made. If the settings have been successfully detected, your next request will return the standard response:

{
  "id": "1eda642a-a9a3-457c-99af-3bc5e8d5c4c9"
}

Errors

Several types of errors are possible during the request:

  • Server file not found
  • Authentication error
  • Settings detection error
Server file not found

This error is returned if the server file for the specified server name has not been found. In case of this error it is recommended to check the server name. If the issue persists, it is recommended to create the account using a provisioning profile.

Example:

{
  "id": 3,
  "error": "ValidationError",
  "message": "We were unable to retrieve the server file for this broker. Please check the server name or configure the provisioning profile manually.",
  "details": "E_SRV_NOT_FOUND"
}
Authentication error

This error is returned if the server has failed to connect to the broker using your credentials. In case of this error it is recommended to check your login and password, and try again.

Example:

{
  "id": 3,
  "error": "ValidationError",
  "message": "We failed to authenticate to your broker using credentials provided. Please check that your MetaTrader login, password and server name are correct.",
  "details": "E_AUTH"
}
Settings detection error

This error is return if the server has failed to detect the broker settings. In case of this error it is recommended to retry the request later, or create the account using a provisioning profile.

Example:

{
  "id": 3,
  "error": "ValidationError",
  "message": "We were not able to retrieve server settings using credentials provided. Please try again later or configure the provisioning profile manually.",
  "details": "E_SERVER_TIMEZONE"
}

Creating an account using a provisioning profile

If creating the account with automatic broker settings detection has failed, you can create it using a provisioning profile. To create an account using a provisioning profile, create a provisioning profile for the MetaTrader server, and then add the provisioningProfileId field to the request:

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'auth-token: token' -d '{
    "login": "123456",
    "password": "password",
    "name": "testAccount",
    "server": "ICMarketsSC-Demo",
    "provisioningProfileId": "f9ce1f12-e720-4b9a-9477-c2d4cb25f076",
    "magic": 123456,
    "application": "MetaApi"
}' 'https://mt-provisioning-api-v1.agiliumtrade.agiliumtrade.ai/users/current/accounts'

If the account has been created successfully, you will receive a response with account id:

{
  "id": "1eda642a-a9a3-457c-99af-3bc5e8d5c4c9"
}