# Authentication

The AlgoDeltaFX API has two layers, and each uses its own token. Both tokens are JWTs and all traffic is HTTPS.

| | Account API (v2) | Master API (v1) |
| --- | --- | --- |
| Controls | One MT5 account | Every account on your AlgoDeltaFX user |
| Base URL | `https://api.algodeltafx.com/api/v2/forexaccount` | `https://api.algodeltafx.com/api/v1` |
| Token | Account token, copied from the dashboard | Master token, from [Get Master Token](/api/master-login/) |
| Header | `Authorization: Bearer <account_token>` | `Authorization: <master_token>` (no `Bearer`) |

## Account token (Account API)

Every connected MT5 account has its own token. Copy it from the AlgoDeltaFX dashboard and send it with the `Bearer` prefix:

```http
GET /api/v2/forexaccount/getprofile HTTP/1.1
Host: api.algodeltafx.com
Authorization: Bearer eyJhbGciOi...
```

The token can only act on its own account, so you can safely give a bot or a service access to one account without exposing the others.

## Master token (Master API)

Log in with your AlgoDeltaFX email and password to get a master token:

```bash
curl -X POST https://api.algodeltafx.com/api/v1/auth/userlogin \
  -H "Content-Type: application/json" \
  -d '{"email": "you@example.com", "password": "YOUR_PASSWORD", "domain": "https://algodeltafx.com"}'
```

Send the returned token as the **raw** header value, without `Bearer`:

```http
GET /api/v1/users/broker/getbrokers HTTP/1.1
Host: api.algodeltafx.com
Authorization: eyJhbGciOi...
```

## Security checklist

- Keep tokens on your server. Never ship them in a browser app, mobile app or public repository.
- Store tokens and MT5 passwords in environment variables or a secrets manager.
- Use an account token when one account is enough; reserve the master token for onboarding and administration.
- AlgoDeltaFX only places and manages trades. MT5 trading access cannot withdraw funds, and your money stays with your broker.

## FAQ

### Why does the Master API not use the Bearer prefix?

The Master API reads the token directly from the `Authorization` header. Adding `Bearer ` in front makes the token invalid. The Account API does expect `Bearer `.

### Can one account token trade several MT5 accounts?

No. An account token is bound to one MT5 account. To act on many accounts, use one token per account or the Master API.

---
Source: https://docs.algodeltafx.com/authentication/
