> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agg.market/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> To integrate AGG, start with Quickstart: REST (https://docs.agg.market/quickstart/rest), then Order lifecycle & statuses (https://docs.agg.market/concepts/order-lifecycle).
> Track every trade until it reaches a terminal status. Before retrying a failed or timed-out call, read Errors, retries & idempotency (https://docs.agg.market/concepts/errors).
> The API reference is generated from https://docs.agg.market/openapi/openapi.json.

# Partner admin

> Read your app's users, balances, positions, orders, deposits, withdrawals, and analytics from your backend.

Use these endpoints for reporting and reconciliation from your backend. Authenticate with
`x-app-api-key`; `x-app-id` and a user token are not required. The `{appId}` in the path must
match the key's app. A `read` key can access every user in that app.

First [create a server API key](/environments#server-api-keys). For a signed-in user's activity
screen or the app leaderboard, follow [Portfolio](/recipes/portfolio).

`AggAdminClient` provides methods for users, orders, analytics, and market-resolution holders.
Use `admin.request()` for the per-user reads below. Manage app members and settings in the
admin dashboard.

```ts theme={null}
import { AggAdminClient } from "@agg-build/sdk/server";

const admin = new AggAdminClient({
  baseUrl: "https://api.agg.market",
  apiKey: process.env.AGG_APP_API_KEY!,
});
```

## Users

<CodeGroup>
  ```ts SDK theme={null}
  const users = await admin.listUsers(appId, { limit: 20 });
  ```

  ```bash cURL theme={null}
  curl -s -H "x-app-api-key: $AGG_APP_API_KEY" \
    "$API/apps/$APP_ID/users?limit=20"
  ```
</CodeGroup>

Full shape on [List users](/api-reference/partner-admin/list-users).

<CodeGroup>
  ```ts SDK theme={null}
  const user = await admin.getUser(appId, userId);
  ```

  ```bash cURL theme={null}
  curl -s -H "x-app-api-key: $AGG_APP_API_KEY" \
    "$API/apps/$APP_ID/users/$USER_ID"
  ```
</CodeGroup>

Full shape on [Get user](/api-reference/partner-admin/get-user).

## Balances, positions, orders

<CodeGroup>
  ```ts SDK theme={null}
  const balances = await admin.request(`/apps/${appId}/users/${userId}/balances`);
  ```

  ```bash cURL theme={null}
  curl -s -H "x-app-api-key: $AGG_APP_API_KEY" \
    "$API/apps/$APP_ID/users/$USER_ID/balances"
  ```
</CodeGroup>

Full shape on [Get user balances](/api-reference/partner-admin/get-user-balances).

<CodeGroup>
  ```ts SDK theme={null}
  const positions = await admin.request(`/apps/${appId}/users/${userId}/positions`);
  ```

  ```bash cURL theme={null}
  curl -s -H "x-app-api-key: $AGG_APP_API_KEY" \
    "$API/apps/$APP_ID/users/$USER_ID/positions"
  ```
</CodeGroup>

Full shape on [Get user positions](/api-reference/partner-admin/get-user-positions).

<CodeGroup>
  ```ts SDK theme={null}
  const orders = await admin.request(`/apps/${appId}/users/${userId}/orders`);
  ```

  ```bash cURL theme={null}
  curl -s -H "x-app-api-key: $AGG_APP_API_KEY" \
    "$API/apps/$APP_ID/users/$USER_ID/orders"
  ```
</CodeGroup>

Full shape on [Get user orders](/api-reference/partner-admin/get-user-orders).

<CodeGroup>
  ```ts SDK theme={null}
  const feed = await admin.listOrders(appId, { limit: 50 });
  ```

  ```bash cURL theme={null}
  curl -s -H "x-app-api-key: $AGG_APP_API_KEY" \
    "$API/apps/$APP_ID/orders?limit=50"
  ```
</CodeGroup>

Full shape on [List orders across your app](/api-reference/partner-admin/list-orders-across-your-app). This feed is ordered by last update. Upsert by `id`.

## Deposits and withdrawals

<CodeGroup>
  ```ts SDK theme={null}
  const deposits = await admin.request(`/apps/${appId}/users/${userId}/deposits`);
  ```

  ```bash cURL theme={null}
  curl -s -H "x-app-api-key: $AGG_APP_API_KEY" \
    "$API/apps/$APP_ID/users/$USER_ID/deposits"
  ```
</CodeGroup>

Full shape on [Get user deposits](/api-reference/partner-admin/get-user-deposits). `amountRaw` is an integer string in the token's decimals.

<CodeGroup>
  ```ts SDK theme={null}
  const withdrawals = await admin.request(`/apps/${appId}/users/${userId}/withdrawals`);
  ```

  ```bash cURL theme={null}
  curl -s -H "x-app-api-key: $AGG_APP_API_KEY" \
    "$API/apps/$APP_ID/users/$USER_ID/withdrawals"
  ```
</CodeGroup>

Full shape on [Get user withdrawals](/api-reference/partner-admin/get-user-withdrawals).

## Analytics and resolution

<CodeGroup>
  ```ts SDK theme={null}
  const analytics = await admin.getAnalytics(appId);
  ```

  ```bash cURL theme={null}
  curl -s -H "x-app-api-key: $AGG_APP_API_KEY" \
    "$API/apps/$APP_ID/analytics"
  ```
</CodeGroup>

Full shape on [Get analytics](/api-reference/partner-admin/get-analytics). Cash and position values
reflect current holdings; fees are cumulative. `usersLast7Days`, `usersLast30Days`,
`ordersLast7Days`, and `ordersLast30Days` cover the named rolling windows.

<CodeGroup>
  ```ts SDK theme={null}
  const holders = await admin.listMarketResolutionUsers(appId, venueMarketId, {
    includeEmails: true,
  });
  ```

  ```bash cURL theme={null}
  curl -s -H "x-app-api-key: $AGG_APP_API_KEY" \
    "$API/apps/$APP_ID/market-resolutions/$VENUE_MARKET_ID/users?includeEmails=true"
  ```
</CodeGroup>

Full shape on [List users affected by market resolution](/api-reference/partner-admin/list-users-affected-by-market-resolution).


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