# Replace MT5 Account

Update the login, password or server of an existing connected account.

`POST https://api.algodeltafx.com/api/v1/users/broker/replacebroker`

- API: Master API (v1)
- Authentication: Send the master token as `Authorization: <MASTER_TOKEN>` (no `Bearer` prefix). Get one from [Get Master Token](/api/master-login/).

Swap the MT5 credentials or server behind an existing account slot, for example after a password change, a server migration or when a prop firm issues a new funded account. The `broker_id` stays the same.

## Request body (JSON)

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `broker_id` | integer | yes |  | ID of the connected account to replace. Get it from [List MT5 Accounts](/api/list-accounts/). |
| `nic_name` | string | yes |  | Nickname shown for this account in the dashboard and API responses. |
| `fx_server` | string | yes |  | MT5 broker server name exactly as it appears in the MetaTrader 5 login window, for example `Exness-MT5Real29`. |
| `fx_login` | integer | yes |  | MT5 account number (login ID). |
| `fx_password` | string | yes |  | MT5 trading (master) password of the account. The investor (read-only) password cannot place trades. |
| `is_host_based` | boolean | yes |  | `false` to connect by broker server name (`fx_server`). `true` to connect directly to an access-server IP and port (`fx_host`, `fx_port`). |
| `fx_host` | string | no |  | Access-server IP address. Required when `is_host_based` is `true`. |
| `fx_port` | integer | no | 443 | Access-server port. Used when `is_host_based` is `true`. |

## Example: cURL

```bash
curl -X POST https://api.algodeltafx.com/api/v1/users/broker/replacebroker \
  -H "Authorization: $MASTER_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "broker_id": 101,
  "nic_name": "Joe Max",
  "fx_server": "Exness-MT5Real29",
  "fx_login": 12345678,
  "fx_password": "MT5_PASSWORD",
  "is_host_based": false,
  "fx_host": "192.168.1.1",
  "fx_port": 443
}'
```

## Example: Python

```python
import os
import requests

res = requests.post(
    "https://api.algodeltafx.com/api/v1/users/broker/replacebroker",
    headers={"Authorization": os.environ["MASTER_TOKEN"]},
    json={
        "broker_id": 101,
        "nic_name": "Joe Max",
        "fx_server": "Exness-MT5Real29",
        "fx_login": 12345678,
        "fx_password": "MT5_PASSWORD",
        "is_host_based": False,
        "fx_host": "192.168.1.1",
        "fx_port": 443
    },
    timeout=30,
)
data = res.json()
print(data["status"], data.get("msg"), data.get("data"))
```

## Response

Standard envelope: `status` (boolean), `msg` (string), `data` (object or array).

## Related

- [List MT5 Accounts](https://docs.algodeltafx.com/api/list-accounts.md): List every MT5 account connected to your AlgoDeltaFX user.
- [Add MT5 Account](https://docs.algodeltafx.com/api/add-account.md): Connect a new MetaTrader 5 account to your AlgoDeltaFX user.
- [Delete MT5 Account](https://docs.algodeltafx.com/api/delete-account.md): Disconnect and remove an MT5 account.


---
Source: https://docs.algodeltafx.com/api/replace-account/
