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

# Funding, withdrawals and performance fees

> Choose the right account, wait for financial confirmation and reconcile fees.

## Which account moves?

Paths below are relative to `/api/v1/mamx`.

| Intent | Endpoint | Result |
| - | - | - |
| Deposit to a master or investor | `POST /accounts/{account_login}/deposit` | Credits that trading login's MT5 balance. Not valid for payment accounts. |
| Withdraw investor funds | `POST /accounts/{account_login}/withdraw` | Checks available cash, collects applicable PF and then debits the withdrawal. |
| Withdraw master trading funds | Broker's normal MT5 procedure | Not the investor withdrawal endpoint and not a payment withdrawal. |
| Withdraw accumulated fees from payment | `POST /leaders/{master_login}/payment-account/withdraw` | Debits the linked payment account, not the master. Not a bank transfer. |

Example body for a deposit or either API withdrawal:

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "idempotency_key": "crm-txn-000045",
  "amount": "100.00"
}
```

Use a positive amount in account currency. **202 means accepted, not paid.** Poll the operation to `DONE` and store the confirmed MT5 deal ID where returned. After timeout, retry the same endpoint, login, amount and key. Do not send a second deposit through the broker's own funding system for the same transaction. Deposits do not count as trading profit.

An investor withdrawal can return 409 if a close or transfer is pending. An accepted withdrawal checks free cash excluding credit against the requested amount plus applicable PF, waits for the fee debit and payment credit, then checks funds again. Insufficient preflight funds can yield `REJECTED` without a new fee or withdrawal debit. `performance_fee_charged` in the withdrawal result is the newly charged fee for this request, not all historical fees.

## High watermark (HWM)

Fees use the allocation's cumulative realized trading PnL, **not deposits, withdrawals, or all deals whose displayed MT5 date falls inside a week**. At crystallization:

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
fee = round_to_currency(max(cumulative_realized_pnl - high_watermark, 0) × rate)
```

Example with gross HWM policy and a 20% fee: realized profit reaches 100, so the fee is 20 and the confirmed debit advances the HWM to 100. If cumulative profit falls to 70 there is no new fee. If it later reaches 130, the new fee is **6**, not 26. Under the optional net-of-fees policy, both realized PnL and HWM are adjusted once on confirmed debit. The policy is fixed per master profile.

Periods are `OFF`, `MINUTELY`, `HOURLY`, `DAILY`, `WEEKLY` (Sunday boundary), `SEMIMONTHLY` (1st and 16th) and `MONTHLY`, in UTC. Calendar boundaries trigger evaluation of the realized balance over HWM. Investor withdrawal, unsubscribe and fee-term changes can also require crystallization.

## Reconcile both sides of payment

* `GET /allocations/{allocation_id}/fees`: fee ID, amount, HWM and status. `PENDING` is not proof of a charge. `DEBITED` means the investor debit is confirmed. `PAID` means the payment credit is confirmed.
* `GET /leaders/{leader_id}/performance-fees/credit-batches`: use the **internal leader ID**. One credit can cover several investor debits for a master, period, currency and payment login. Match each member's `fee_id`, `debit_ticket` and amount to the batch total; do not expect one payment ticket per investor.
* `POST /leaders/{master_login}/payment-account/balance/refresh`: use the **MT5 master login**. Wait for the resulting operation to finish, then call `GET /leaders/{master_login}/payment-account/balance`. The cached response contains `fresh`, `observed_at` and `metrics`; metrics is null until there is a reading. It includes balance, equity, credit, margin, free margin and withdrawable cash. Fresh lasts 15 seconds; the withdrawal itself performs a new MT5 check.

In the CRM, display **“investor charged”** and **“master paid”** as distinct states. Use [signed webhooks](https://mamx-api.exuratech.com/guides/webhooks.md) for notifications and the GET endpoints for reconciliation.


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