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

# Referrals, earnings, and partner payouts

> Display a partner's referral link and earnings, preview a payout to the selected destination, and handle creation, confirmation, and status updates.

Display a partner's referral link and earnings in their account. If the account supports withdrawals, preview the payout, show the amount and destination, and get the partner's approval before submitting the request.

Private operations require a [Bearer token and HMAC v2 signature](https://exchanger-api.iexexchanger.com/en/start/authentication.md) and act on behalf of the key owner. Grant only the read scopes your integration needs. `public-api:partner:payouts:create` must be granted separately from the default scopes. The commands use `request.mjs` from the [quickstart](https://exchanger-api.iexexchanger.com/en/start/quickstart.md). Run the write examples on a test installation. [Manage API access](https://exchanger-api.iexexchanger.com/en/start/access.md)

## Display the referral link, balance, and earnings

| Request | Scope | Where to find the data |
| - | - | - |
| [GET /private/partner](https://exchanger-api.iexexchanger.com/en/api-reference/partner/get-private-partner.md) | `public-api:partner:read` | `result.referral_link.url`, the profile, program, balance, and account-wide statistics. If there is no link, `url` is `null`. |
| [GET /private/partner/statistics](https://exchanger-api.iexexchanger.com/en/api-reference/partner/get-private-partner-statistics.md) | `public-api:partner:statistics:read` | `result.balance` and `result.statistics` for the key owner's account. |
| [GET /private/partner/referrals](https://exchanger-api.iexexchanger.com/en/api-reference/partner/get-private-partner-referrals.md) | `public-api:partner:referrals:read` | Referrals across all the owner's referral links, with order counts. Use `result[].client.id` to count distinct customers. |
| [GET /private/partner/exchanges](https://exchanger-api.iexexchanger.com/en/api-reference/partner/get-private-partner-exchanges.md) | `public-api:partner:exchanges:read` | Earnings in `result[]` and a summary in `meta.summary`. |
| [GET /private/partner/payouts](https://exchanger-api.iexexchanger.com/en/api-reference/partner/get-private-partner-payouts.md) | `public-api:partner:payouts:read` | Payout history in `result[]` and counts by status in `meta.summary`. |

```bash theme={null}
node request.mjs GET '/api/v3/private/partner'
node request.mjs GET '/api/v3/private/partner/payouts?pagination=cursor&filter%5Bstatus%5D=pending'
```

For an unfiltered report, use `result.statistics.exchanges.by_currency` and `result.statistics.payouts.by_currency` from the profile or statistics response. The aggregate `paid_amount` and `pending_amount` can be `"0"` with a `null` currency when payouts in that status span multiple or unknown currencies. Read the current available balance from `result.balance.available`.

For a filtered report, use the list endpoints. Each `meta.summary` covers the entire filtered result set before pagination.

* **Earnings.** `meta.summary.total` counts every nonzero ledger entry. The monetary summary in `meta.summary.by_currency` includes confirmed positive earnings that have not been reversed. History also includes pending entries and reversals with `is_reversal: true`. `reversal_of_id` points to the original entry when the link is available. An earnings entry for a hidden order can have `order: null`.
* **Payouts.** `meta.summary` contains `total`, `pending`, `paid`, and `rejected` counts. To calculate monetary totals with the same filters, sum `result[].amount.requested` across all pages by `status` and `currency.code`. Use exact decimal arithmetic and keep a separate bucket for unknown currency.

To filter earnings by order, use the internal numeric `filter[order_id]`, the numeric string `filter[order_public_id]`, or the tracking string `filter[order_tracking_id]`. In the payout list, `filter[public_id]` matches the legacy numeric reference as a string. Save `result[].id` to look up individual payouts. `filter[created_from]` and `filter[created_to]` include the specified creation dates, so a payout date range selects when requests were created.

Start with `pagination=cursor`. Cursor sorting supports `sort=id` and `sort=-id` and defaults to `-id`. Pass `meta.pagination.next_cursor` as `cursor` with the same filters and sorting until the list ends. [Response format and pagination](https://exchanger-api.iexexchanger.com/en/start/protocol.md)

## Preview a payout

1. Call [GET /private/partner/payout-methods](https://exchanger-api.iexexchanger.com/en/api-reference/partner/get-private-partner-payout-methods.md) with `public-api:partner:payouts:read`. Take `currency_id` from `result.methods`. Pass the destination in `wallet` as a string of 2 to 191 characters. Use `wallet.mask`, `wallet.min_length`, and `wallet.max_length` as form hints. Preview checks the destination against the exchanger's configured validators.
2. Check `result.balance.can_request`. This flag indicates a positive available balance that meets the minimum payout. Pass `amount` as a decimal string in `result.balance.currency` between `minimum_payout` and `available`, inclusive. The amount must be positive and fit `result.balance.precision` without discarding nonzero digits. The format allows up to 30 digits before the decimal point and up to 18 after it. To request the full available balance, omit `amount` or pass `null`.
3. Call [POST /private/partner/payouts/preview](https://exchanger-api.iexexchanger.com/en/api-reference/partner/post-private-partner-payouts-preview.md) with the same scope. Preview validates the method, amount, and destination while leaving the balance available. The exchanger recalculates the terms when you submit the payout.

Get the available payout methods, then save the parameters as `payout.json`. Replace `currency_id` and `wallet` with values from your test installation.

```bash theme={null}
node request.mjs GET '/api/v3/private/partner/payout-methods'
```

```json payout.json theme={null}
{
  "currency_id": 25,
  "wallet": "test-wallet-123",
  "amount": "12.5"
}
```

```bash theme={null}
node request.mjs POST '/api/v3/private/partner/payouts/preview' --json payout.json
```

Excerpt from a `200` response for a test conversion from `XTS` to `XPT`, with a 10% fee and a fixed fee of `0.75 XPT`.

```json theme={null}
{
  "state": 0,
  "result": {
    "preview": {
      "amount": { "base": "12.5", "base_currency": "XTS", "requested": "21.75" },
      "currency": { "id": 25, "code": "XPT" },
      "fees": { "percent": "10", "fixed": "0.75" }
    }
  }
}
```

Display `amount.base` as the debit in the base currency and `amount.requested` as the payout in `currency.code`. The exchanger deducts the percentage fee in the base currency, converts the remainder, deducts the fixed fee in the payout currency, and rounds the result `HALF_UP` to the method's precision. Display the amounts returned by the exchanger.

## Submit the payout request and save its ID

After the partner approves the amount and destination, send [POST /private/partner/payouts](https://exchanger-api.iexexchanger.com/en/api-reference/partner/post-private-partner-payouts.md) with `public-api:partner:payouts:create`. Before the first attempt, save the body and a unique `Idempotency-Key` of 8 to 191 ASCII letters, digits, or `.`, `_`, `:`, and `-`. Include the key in the signing string.

```bash theme={null}
node request.mjs POST '/api/v3/private/partner/payouts' --json payout.json --idempotency-key partner-test-payout-001
```

A `201` response includes `result.payout.id`, `result.payout.status: "pending"`, and `result.replayed: false`. The exchange deducts the base amount from the available balance when the request is created. `pending` means it has been accepted for processing.

If you lose the response, submit the same body and key with a fresh HMAC signature from the same integration. Rotating an API key preserves that integration. Issuing a separate key creates a different integration, even for the same account. A replay can return the stored `201` with `Idempotency-Replayed: true`, or `200` with `result.replayed: true` if the response was reconstructed from the saved payout request. Use the returned ID to read the current status. For `409 idempotency_conflict`, check the original request body. [Retry a request](https://exchanger-api.iexexchanger.com/en/guides/reliability/idempotency.md)

## Read payout status

Call [GET /private/partner/payouts/{payout}](https://exchanger-api.iexexchanger.com/en/api-reference/partner/get-private-partner-payouts-by-payout.md) with `public-api:partner:payouts:read`. Use the numeric `result.payout.id` from the creation response. A missing payout or a payout belonging to another account returns `404`.

```bash theme={null}
node request.mjs GET '/api/v3/private/partner/payouts/71'
```

| Field | What to tell the partner |
| - | - |
| `status: "pending"` and `result.confirmation_required: true` | The partner must use the link in the email to confirm the request in the exchanger's account area. |
| `status: "pending"` and `result.confirmation_required: false` | The payout request is awaiting processing. |
| `status: "paid"` | The payout is marked as paid. |
| `status: "rejected"` | The payout was rejected. Display `result.payout.reason` when available. When an administrator rejects a payout, the exchanger returns the original debit to the partner's balance. |

Check `status` before reading `confirmation_required`. Email confirmation sets `result.payout.verified_at`. The payout stays `pending` until it is processed. Older records can have an empty `amount.base_currency` and a `null` `currency` or `currency.code`. Treat these as unknown currencies.

For `422 validation_failed`, check the available methods and balance again, then verify the amount, precision, and destination format. For `422 invalid_idempotency_key`, check the `Idempotency-Key` header on creation. For `403 scope_denied`, check the scope of the specific operation. [Error responses](https://exchanger-api.iexexchanger.com/en/guides/reliability/errors.md) · [API reference](https://exchanger-api.iexexchanger.com/en/api.md)

## Prompt for your coding agent

> [accordion] Build a partner report
>
> ```text theme={null}
> Implement a read-only Exchanger API v3 partner report in [STACK]. Include the referral link, balance, and earnings and payout history with separate totals per currency.
>
> Check fields and scopes against the documentation:
> - https://exchanger-api.iexexchanger.com/en/guides/account/partner
> - https://exchanger-api.iexexchanger.com/en/start/authentication
> - https://exchanger-api.iexexchanger.com/en/start/protocol
> - https://exchanger-api.iexexchanger.com/en/guides/reliability/errors
>
> 1. Send signed GET requests on the server with HMAC v2, a timeout, and configuration from the environment. The report covers the key owner's data. Test against a local mock with synthetic responses. Use no real tokens or secrets. Keep all writes, payout previews, and payout creation permissions out of the report.
> 2. Request only the data you need under /api/v3/private/partner. The profile uses public-api:partner:read, /statistics uses public-api:partner:statistics:read, /referrals uses public-api:partner:referrals:read, /exchanges uses public-api:partner:exchanges:read, and /payouts uses public-api:partner:payouts:read. Display result.referral_link.url when a link exists.
> 3. Start history requests with pagination=cursor and send meta.pagination.next_cursor as cursor with the same filters and sort until the list ends. Read the available balance from result.balance.available. For account-wide totals, use result.statistics.exchanges.by_currency and result.statistics.payouts.by_currency. For filtered earnings, use meta.summary.by_currency once and display pending entries and reversals separately from the history. For filtered payouts, use meta.summary for counts once and sum result[].amount.requested across pages by status and currency.code. Preserve decimal precision and keep a separate bucket for unknown currency.
> 4. On 403 scope_denied, show the scopes in error.details.required_scopes. For other 403 responses, use the actual error.code. Distinguish rate_limit_exceeded from quota_exceeded on 429. Observe Retry-After for rate limits and the quota reset time for exhausted quotas.
>
> Add local tests for repeated summaries on multiple pages, a payout status filter, mixed and unknown currencies, reversals, a missing referral link, and access errors. Verify that the report sends only GET requests and counts amounts once. Report the test command and briefly list the fields in the resulting report.
> ```


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