:::endpoint GET /v1/admin/dashboard/owed

Every funded account above its starting balance, with what its trader could
ask for today, largest profit first. The list behind "Owed to funded" in
[money](/docs/api/admin/dashboard-money), whose `owed.amount` is the sum of
every `share` here. The website shows the first two hundred; this pages
through all of them.

Only accounts in the currency the firm sells in, and never an account of our
own staff. Behind the same permission as money, `view_analytics`.

Needs a firm. Our own staff name one with the `Propper-Workspace` header.

## Request

| Parameter        | Description                                                                                  |
| ---------------- | -------------------------------------------------------------------------------------------- |
| `sort`           | `-profit`, largest first (the default), or `profit`, smallest first                          |
| `limit`          | How many, see [pagination](/docs/api/pagination)                                             |
| `starting_after` | The `next_cursor` of the page before. A cursor only works with the `sort` it was handed out with |

```bash
curl "https://api.proppertrading.com/v1/admin/dashboard/owed?limit=2" \
  -H "Authorization: Bearer ptat_9f2c1a44_3b8e7d2f5c9a1b4e6d8f0a2c4e6b8d1f" \
  -H "Propper-Workspace: acme"
```

## Response

```json
{
    "data": [
        {
            "object": "owed_account",
            "id": "acct_gcmnympgg8quua3k",
            "account_number": "PAQ4YX4NQX",
            "trader": {
                "id": "usr_r3v3rnu3kjsj5asc",
                "name": "Alex Morgan",
                "email": "tactical-preview@propper.test"
            },
            "profit": { "value": "2012.60", "currency": "USD" },
            "share": { "value": "1610.08", "currency": "USD" },
            "split": 80,
            "action_url": "/admin/trading-accounts/acct_gcmnympgg8quua3k"
        },
        {
            "object": "owed_account",
            "id": "acct_j55e8c8gkfmrjgxq",
            "account_number": "PADC84F8C5",
            "trader": {
                "id": "usr_x3mh3pt4pgk7m5fk",
                "name": "Tariq Hughes",
                "email": "tariq.hughes.277@example.com"
            },
            "profit": { "value": "1997.32", "currency": "USD" },
            "share": { "value": "1597.86", "currency": "USD" },
            "split": 80,
            "action_url": "/admin/trading-accounts/acct_j55e8c8gkfmrjgxq"
        }
    ],
    "meta": {
        "request_id": "req_01m50f2dfz1bd1pak4gd70pyp1",
        "has_more": true,
        "next_cursor": "eyJzIjoiLXByb2ZpdCIsInYiOiIxOTk3LjMyIiwiaWQiOiJhY2N0X2o1NWU4Yzhna2ZtcmpneHEifQ"
    }
}
```

| Field         | Description                                                                                       |
| ------------- | ------------------------------------------------------------------------------------------------- |
| `id`          | The trading account                                                                               |
| `trader`      | Whose account it is                                                                               |
| `trader.id`   | Their id, only when this person may open traders. Null otherwise                                 |
| `profit`      | Realised profit above the starting balance. Payouts that are pending or approved are still inside it |
| `share`       | What the trader could ask for: `profit` times `split`                                             |
| `split`       | The trader's percentage: the phase's own, or the firm's                                           |
| `action_url`  | Where the website shows the account, a path inside the web application                            |

## Errors

| Status | Code                      | Meaning                                                                         |
| ------ | ------------------------- | ------------------------------------------------------------------------------- |
| 400    | `workspace_required`      | Asked by our own staff without naming a firm                                    |
| 400    | `invalid_sort`            | `sort` is not `profit` or `-profit`                                             |
| 400    | `invalid_limit`           | `limit` is not a positive integer                                               |
| 400    | `invalid_cursor`          | `starting_after` is not a cursor handed out for this `sort`                     |
| 401    | `invalid_token`           | Not a token, or the secret does not match                                       |
| 401    | `revoked_token`           | Signed out here or from another device                                          |
| 401    | `expired_token`           | Ninety days without use, or a set expiry passed                                 |
| 403    | `admin_access_required`   | This account no longer helps run the environment                                |
| 403    | `insufficient_scope`      | This device does not hold `admin:read`                                          |
| 403    | `workspace_not_permitted` | The `Propper-Workspace` header names an environment this account cannot act in |
| 403    | `forbidden`               | Without `view_analytics`                                                        |