Skip to main content
The UserApi class provides comprehensive user management functionality including creating users, updating account information, managing deposits/withdrawals, and password resets.

Constructor

public function __construct(
    ClientInterface $client = null,
    Configuration $config = null,
    HeaderSelector $selector = null
)
Creates a new UserApi instance.
client
ClientInterface
Guzzle HTTP client instance. If not provided, a new Client will be created.
config
Configuration
SDK configuration object. If not provided, a new Configuration will be created.
selector
HeaderSelector
Header selector instance. If not provided, a new HeaderSelector will be created.

Methods

getConfig

Retrieves the current configuration object.
public function getConfig(): Configuration
Configuration
Configuration
The current SDK configuration object

userAddPost

Creates a new trading user account.
public function userAddPost(\D4T\MT5Sdk\Models\User $body): \D4T\MT5Sdk\Models\UserReturnType
body
\D4T\MT5Sdk\Models\User
required
User object containing:
  • password_investor: Investor password (string)
  • password: Main password (string)
  • name: User name (string)
  • email: User email address (string)
  • group: Trading group name (string)
  • leverage: Account leverage (int)
UserReturnType
\D4T\MT5Sdk\Models\UserReturnType
Object containing the created user’s details including the assigned login ID
Throws:
  • \D4T\MT5Sdk\ApiException - On non-2xx response (200 success, 400 error)
  • \InvalidArgumentException - When body parameter is missing
Example:
use D4T\MT5Sdk\MT5Manager\UserApi;
use D4T\MT5Sdk\Models\User;

$userApi = new UserApi();

$newUser = new User();
$newUser->setPassword('123456Aa');
$newUser->setPasswordInvestor('123456Aa');
$newUser->setName('John Doe');
$newUser->setEmail('[email protected]');
$newUser->setGroup('demo\\demoforex');
$newUser->setLeverage(100);

try {
    $result = $userApi->userAddPost($newUser);
    echo "User created with login: " . $result->getLogin();
} catch (\D4T\MT5Sdk\ApiException $e) {
    echo "Error creating user: " . $e->getMessage();
}

userAddPostWithHttpInfo

Creates a new user account with HTTP response details.
public function userAddPostWithHttpInfo(\D4T\MT5Sdk\Models\User $body): array
body
\D4T\MT5Sdk\Models\User
required
User object with account creation parameters
array
array
Array containing:
  • [0]: \D4T\MT5Sdk\Models\UserReturnType - The created user details
  • [1]: int - HTTP status code
  • [2]: array - HTTP response headers
Throws:
  • \D4T\MT5Sdk\ApiException - On non-2xx response
  • \InvalidArgumentException - When body parameter is missing

userAddPostAsync

Asynchronously creates a new user account.
public function userAddPostAsync(\D4T\MT5Sdk\Models\User $body): \GuzzleHttp\Promise\PromiseInterface
body
\D4T\MT5Sdk\Models\User
required
User object with account creation parameters
PromiseInterface
\GuzzleHttp\Promise\PromiseInterface
Promise that resolves to \D4T\MT5Sdk\Models\UserReturnType
Throws:
  • \InvalidArgumentException - When body parameter is missing

updateUser

Updates an existing user’s information.
public function updateUser(\D4T\MT5Sdk\Models\User $body): void
body
\D4T\MT5Sdk\Models\User
required
User object containing:
  • login: User login ID (int)
  • password: New password (string, optional)
  • name: New name (string, optional)
  • Other updatable user fields
Throws:
  • \D4T\MT5Sdk\ApiException - On non-2xx response (400 error)
  • \InvalidArgumentException - When body parameter is missing
Example:
$user = new User();
$user->setLogin(12345);
$user->setPassword('newPassword123');
$user->setName('Jane Doe');

try {
    $userApi->updateUser($user);
    echo "User updated successfully";
} catch (\D4T\MT5Sdk\ApiException $e) {
    echo "Error: " . $e->getMessage();
}

updateUserWithHttpInfo

Updates user information with HTTP response details.
public function updateUserWithHttpInfo(\D4T\MT5Sdk\Models\User $body): array
body
\D4T\MT5Sdk\Models\User
required
User object with fields to update
array
array
Array containing:
  • [0]: null - No response body
  • [1]: int - HTTP status code
  • [2]: array - HTTP response headers
Throws:
  • \D4T\MT5Sdk\ApiException - On non-2xx response
  • \InvalidArgumentException - When body parameter is missing

userUserLoginGet

Retrieves user details by login ID.
public function userUserLoginGet(string $user_login): \D4T\MT5Sdk\Models\User
user_login
string
required
The user login ID to fetch
User
\D4T\MT5Sdk\Models\User
User object containing complete user information
Throws:
  • \D4T\MT5Sdk\ApiException - On non-2xx response (200 success, 400 error)
  • \InvalidArgumentException - When user_login is missing
Example:
try {
    $user = $userApi->userUserLoginGet('12345');
    echo "Name: " . $user->getName() . "\n";
    echo "Email: " . $user->getEmail() . "\n";
    echo "Group: " . $user->getGroup();
} catch (\D4T\MT5Sdk\ApiException $e) {
    echo "User not found: " . $e->getMessage();
}

userUserLoginDelete

Deletes a user account.
public function userUserLoginDelete(string $user_login): void
user_login
string
required
The login ID of the user to delete
Throws:
  • \D4T\MT5Sdk\ApiException - On non-2xx response (400 error)
  • \InvalidArgumentException - When user_login is missing
Example:
try {
    $userApi->userUserLoginDelete('12345');
    echo "User deleted successfully";
} catch (\D4T\MT5Sdk\ApiException $e) {
    echo "Error deleting user: " . $e->getMessage();
}

userDepositPost

Deposits funds into a user’s account.
public function userDepositPost(\D4T\MT5Sdk\Models\BalanceType $body): void
body
\D4T\MT5Sdk\Models\BalanceType
required
Balance operation object containing:
  • login: User login ID (int)
  • amount: Deposit amount (float)
  • type: Operation type (int, typically 3)
  • comment: Transaction comment (string)
Throws:
  • \D4T\MT5Sdk\ApiException - On non-2xx response (400 error)
  • \InvalidArgumentException - When body parameter is missing
Example:
use D4T\MT5Sdk\Models\BalanceType;

$deposit = new BalanceType();
$deposit->setLogin(12345);
$deposit->setAmount(1000.00);
$deposit->setType(3);
$deposit->setComment('Deposit from bank transfer');

try {
    $userApi->userDepositPost($deposit);
    echo "Deposit successful";
} catch (\D4T\MT5Sdk\ApiException $e) {
    echo "Deposit failed: " . $e->getMessage();
}

userWithdrawPost

Withdraws funds from a user’s account.
public function userWithdrawPost(\D4T\MT5Sdk\Models\BalanceType $body): void
body
\D4T\MT5Sdk\Models\BalanceType
required
Balance operation object containing:
  • login: User login ID (int)
  • amount: Withdrawal amount (float)
  • type: Operation type (int, typically 3)
  • comment: Transaction comment (string)
Throws:
  • \D4T\MT5Sdk\ApiException - On non-2xx response (400 error)
  • \InvalidArgumentException - When body parameter is missing
Example:
$withdrawal = new BalanceType();
$withdrawal->setLogin(12345);
$withdrawal->setAmount(500.00);
$withdrawal->setType(3);
$withdrawal->setComment('Withdrawal to bank');

try {
    $userApi->userWithdrawPost($withdrawal);
    echo "Withdrawal successful";
} catch (\D4T\MT5Sdk\ApiException $e) {
    echo "Withdrawal failed: " . $e->getMessage();
}

userResetPwdPost

Resets a user’s password.
public function userResetPwdPost(\D4T\MT5Sdk\Models\ResetPwdType $body): void
body
\D4T\MT5Sdk\Models\ResetPwdType
required
Password reset object containing:
  • login: User login ID (int)
  • password: New password (string)
  • change_investor: Whether to change investor password (int, 0 or 1)
Throws:
  • \D4T\MT5Sdk\ApiException - On non-2xx response (400 error)
  • \InvalidArgumentException - When body parameter is missing
Example:
use D4T\MT5Sdk\Models\ResetPwdType;

$resetPwd = new ResetPwdType();
$resetPwd->setLogin(12345);
$resetPwd->setPassword('newSecurePassword123');
$resetPwd->setChangeInvestor(0);

try {
    $userApi->userResetPwdPost($resetPwd);
    echo "Password reset successful";
} catch (\D4T\MT5Sdk\ApiException $e) {
    echo "Password reset failed: " . $e->getMessage();
}

usersGroupGet

Retrieves a list of user logins for a specific group.
public function usersGroupGet(string $group): \D4T\MT5Sdk\Models\CachedLogins
group
string
required
Group name to retrieve users from
CachedLogins
\D4T\MT5Sdk\Models\CachedLogins
Object containing an array of user login IDs belonging to the specified group
Throws:
  • \D4T\MT5Sdk\ApiException - On non-2xx response (200 success, 400 error)
  • \InvalidArgumentException - When group parameter is missing
Example:
try {
    $logins = $userApi->usersGroupGet('demo\\demoforex');
    foreach ($logins->getLogins() as $login) {
        echo "User login: " . $login . "\n";
    }
} catch (\D4T\MT5Sdk\ApiException $e) {
    echo "Error: " . $e->getMessage();
}

Async Method Variants

All methods have async variants with the following naming patterns:
  • methodNameAsync() - Returns a Promise resolving to the response object
  • methodNameAsyncWithHttpInfo() - Returns a Promise resolving to [response, statusCode, headers]
These variants accept the same parameters as their synchronous counterparts and throw \InvalidArgumentException for missing required parameters.

Build docs developers (and LLMs) love