Skip to content

Create account replica

About

Starts cloud API server for a MetaTrader account replica using specified primary 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 MetatraderAccountReplica.

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

Path parameters

Name Type Required Description
accountId string Yes Id of the primary account

Body

Name Type Required Description
magic number Yes Magic value the trades should be performed using. When manualTrades field is set to true, magic value must be 0
region string Yes Region id to deploy account replica at. One of returned by the /users/current/regions endpoint
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
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
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

Response

  • 201 - New MetaTrader account replica created successfully. Schema:
Name Type Required Description
id string Yes Created MetaTrader account replica 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

Example request:

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'auth-token: token' -d '{
    "magic": 123456,
    "region": "london"
}' 'https://mt-provisioning-api-v1.agiliumtrade.agiliumtrade.ai/users/current/accounts/861ceafd-a58e-2fb9-a9bb-c9dd449f3bb4/replicas'

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 or recreate the primary 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. This error indicates that your primary account is no longer valid and needs to be recreated.

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 recreate the primary 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"
}