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

# End-to-end workflow

> Implement the recommended PAMM lifecycle for newly provisioned MT5 accounts.

Use this sequence for new accounts. Each financial step should have a unique CRM reference and a durable record before the request is sent.

## 1. Create the Master

```bash theme={null}
curl -X POST "https://pamm-api.example.com/api/v1/master/create" \
  -H "Authorization: Bearer YOUR_CRM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "first_name": "Laura",
    "last_name": "Gomez",
    "name": "Momentum Weekly",
    "username": "laura.gomez@example.com",
    "platform_group": "<MT5_MASTER_GROUP>",
    "leverage": "100",
    "min_deposit": "500",
    "strategy_name": "Momentum",
    "strategy": "Trend-following strategy"
  }'
```

Persist `id`, `mt5_login`, and `payment_account_login` as different identifiers. Do not fund the Master trading account directly.

## 2. Create the Investor

```bash theme={null}
curl -X POST "https://pamm-api.example.com/api/v1/investor/create" \
  -H "Authorization: Bearer YOUR_CRM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "first_name": "Carlos",
    "last_name": "Perez",
    "name": "Investor Demo",
    "username": "carlos.perez@example.com",
    "platform_group": "<MT5_INVESTOR_GROUP>",
    "leverage": "100"
  }'
```

The account starts without a balance and without a Master assignment.

## 3. Credit initial capital

```bash theme={null}
curl -X POST \
  "https://pamm-api.example.com/api/v1/investor/deposit?login=146600&amount=1000&currency=USD&comment=CRM-DEP-8451" \
  -H "Authorization: Bearer YOUR_CRM_API_KEY"
```

Store the returned `deal_id`. Deposit before assignment because assignment validates the Investor balance against the Master's `min_deposit`.

## 4. Assign the Investor

```bash theme={null}
curl -X POST "https://pamm-api.example.com/api/v1/investor/assign" \
  -H "Authorization: Bearer YOUR_CRM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "master_login": "146512",
    "investor_login": "146600",
    "perf_fee": {
      "rate": 0.30,
      "enabled": true
    }
  }'
```

`0.30` means 30%. An `ACTIVE` response confirms the relationship, but the initial balance reflection can still be processing.

## 5. Confirm the operating state

Poll the subscription and relevant balances until the expected state is visible:

```bash theme={null}
curl "https://pamm-api.example.com/api/v1/info/subscriptions?investor_login=146600" \
  -H "Authorization: Bearer YOUR_CRM_API_KEY"
```

## 6. Operate and reconcile

* Send later credits through `/investor/deposit`.
* Send every Investor withdrawal through `/investor/withdraw`.
* End the relationship through `/subscriptions/unassign` and wait for `CANCELLED`.
* Reconcile fee credits and Investor-level payments through both performance fee listing endpoints.

<CardGroup cols={2}>
  <Card title="Previous: Authentication" icon="arrow-left" href="/getting-started/authentication">
    Review access and secret handling.
  </Card>

  <Card title="Next: Masters" icon="arrow-right" href="/guides/masters">
    Choose between provisioning and migration registration.
  </Card>
</CardGroup>
