> ## Documentation Index
> Fetch the complete documentation index at: https://mam-api.exuratech.com/llms.txt
> Use this file to discover all available pages before exploring further.

# End-to-end integration

> Recommended sequence for publishing a strategy and connecting a follower.

This walkthrough uses leader account `139682` and follower account `146502`. The values are illustrative.

**1. Create or register the accounts**

If an account does not exist in MT5, create it with `POST /api/v1/mam/accounts/create`. If it already exists, use `POST /api/v1/mam/accounts/add`.

When importing an existing leader, set `can_be_leader=true`. The required history synchronization is created automatically:

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "mt5_login": "139682",
  "name": "Imported leader",
  "currency": "USD",
  "account_mode": "HEDGING",
  "can_be_leader": true,
  "can_be_follower": false,
  "status": "ACTIVE"
}
```

Call `GET /api/v1/mam/accounts/139682/history-sync` until you receive `COMPLETED`. A follower with `can_be_leader=false` is available immediately. If you later enable it as a leader through `PATCH /api/v1/mam/accounts/{account_login}`, its history begins importing at that time.

**2. Wait for the imported leader history**

This step applies only to leaders that already existed in MT5. Until their history import is complete, the API responds with `409` when you attempt to create a subscription. If the import fails or is canceled, retry it before receiving investors.

**3. Enable and publish the leader**

Confirm `can_be_leader=true` on the operational account and create the profile.

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "account_login": "139682",
  "payment_account_login": null,
  "strategy_name": "Momentum Global",
  "description": "Diversified trend-following strategy.",
  "leaderboard_visibility": false,
  "restrict_simultaneous_connections": false,
  "min_deposit": 1000,
  "performance_fee_rate": 0.20,
  "performance_fee_period": "MONTHLY",
  "propagation_mode": "ORIGINAL_ONLY",
  "status": "ACTIVE"
}
```

Store the returned `leader_id` and `payment_account_login`.

**4. Fund and validate the follower**

Deposit with an idempotent key and then retrieve eligibility.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST "https://mam-api.example.com/api/v1/mam/allocations/subscription-eligibility" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"leader_login":"139682","follower_login":"146502"}'
```

**5. Create the allocation**

Send the limit authorized by your CRM product in this request.

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "leader_login": "139682",
  "follower_login": "146502",
  "status": "PAUSED",
  "allocation_mode": "EQUITY",
  "mode_parameter": 1,
  "equity_stop": 1000,
  "unsubscribe_policy": "CLOSE_ON_UNSUBSCRIBE",
  "performance_fee_rate": null,
  "performance_fee_enabled": true,
  "max_active_leaders_per_follower": 1
}
```

**6. Activate and monitor**

Change the status to `ACTIVE` with `PATCH /api/v1/mam/allocations/{allocation_id}`. Retrieve metrics, history, and subscribers as required by your product.

**7. Terminate correctly**

Use `POST /api/v1/mam/allocations/{allocation_id}/unsubscribe`. If you receive an in-progress status, monitor it until `CANCELLED`.

> [!WARNING]
>
> Do not terminate an active allocation with a direct `PATCH` to `CANCELLED`. The `unsubscribe` endpoint applies the configured policy and coordinates pending obligations.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.