# Admin API

> Manage a team with an admin key: members and their spend, usage, spend and feature limits, and the team policy, with examples and error codes.

Source: https://www.sume.com/docs/admin

A team's Owner and Admins can do from a script what Settings → Admin does in
the app: read who is in the team and what they spent, and set the team's
limits and policy.

```text
GET /v1/admin/members          members with role, join date and spend
GET /v1/admin/usage            the whole team's spend, as GET /v1/usage/summary
GET /v1/admin/spend-limits     the team cap, the member default and each member's limit
PUT /v1/admin/spend-limits     set or remove one of them
GET /v1/admin/feature-limits   limits per feature (video, image, audio, ...)
PUT /v1/admin/feature-limits   set or remove one
GET /v1/admin/policies         features, models, sharing and key rules
PUT /v1/admin/policies         change part of the policy
GET /v1/admin/audit_logs       the team's audit log
```

The audit log has its own page: [Audit log API](https://www.sume.com/docs/audit-logs).

The live [OpenAPI](https://api.sume.com/reference/json) gives the accurate
schemas.

## Admin keys

The admin API takes an **admin key**, and an admin key calls nothing else.

- A team Owner or Admin makes one in the team on
  [Settings → API keys](https://www.sume.com/dashboard/api-keys) with Access
  **Admin**, **Admin, read only** or **Audit log only**. A Creator, Viewer or
  Billing member cannot.
- **Admin** carries `admin:read`, `admin:write`, `audit_logs:read`,
  `audit_logs:write` and `account:read`. **Admin, read only** carries
  `admin:read`, `audit_logs:read` and `account:read` and cannot change
  anything.
- **Audit log only** carries `audit_logs:read` and `account:read`. It reads
  the [audit log](https://www.sume.com/docs/audit-logs) and nothing else: any other admin route answers
  it `403 insufficient_scope`. Make this one for a SIEM.
- An admin key made before audit log access existed carries `admin:read`,
  `admin:write` and `account:read` (or the read-only pair) and cannot read
  the audit log.
- It cannot generate, spend or read work: any route outside `/v1/admin`
  answers `403 insufficient_scope` with `details.reason: "admin_key"`. A
  leaked admin key cannot run up a bill.
- It works for its own team only. There is no team id in the path.
- Every request reads its owner's role again. When they are no longer an
  Owner or Admin of the team, the key answers `403 insufficient_role` until
  an Owner makes them Admin again. When they leave the team, the key is
  revoked.
- The team's maximum key lifetime applies to admin keys as to any key.
- A personal workspace has no admin API: `404 team_only`.

## Members

```bash
curl "https://api.sume.com/v1/admin/members" \
  -H "Authorization: Bearer $SUME_ADMIN_KEY"
```

```json
{
  "object": "list",
  "as_of": "2026-11-26T15:00:00.000Z",
  "data": [
    {
      "user_id": "user_2ana",
      "name": "Ana Kim",
      "email": "ana@example.com",
      "role": "creator",
      "custom_role_id": null,
      "joined_at": "2026-09-02T08:14:00.000Z",
      "today_usd": "4.000000",
      "last_7_days_usd": "5.500000",
      "last_30_days_usd": "31.200000",
      "this_month_usd": "22.005000",
      "last_active_at": "2026-11-26T09:00:00.000Z",
      "by_feature_this_month": { "video": "20.005000", "image": "2.000000" }
    }
  ]
}
```

- `role` is `owner`, `admin`, `creator`, `viewer` (shown as Member in the
  app), `billing` or `custom` (then `custom_role_id` names the role).
- Today and this month are UTC calendar windows, the windows of the limits.
  The last 7 and 30 days count back from now.
- Spend counts charges that are held or settled; a refund gives it back.
- Every amount on the admin API is US dollars as a string with six decimals,
  the exact micro-dollars, as in the [Usage API](https://www.sume.com/docs/usage).
- `last_active_at` is the member's newest usage row in the team, or `null`.

## Usage

`GET /v1/admin/usage` takes the query of `GET /v1/usage/summary` (`from`,
`to`, `group_by`, `timezone`, `date_field`, `model`, `member`, `surface`) and
answers the same body, always for the whole team:

```bash
curl "https://api.sume.com/v1/admin/usage?from=2026-11-01&to=2026-11-30&group_by=member" \
  -H "Authorization: Bearer $SUME_ADMIN_KEY"
```

## Spend limits

`GET /v1/admin/spend-limits` answers what Settings → Members shows:

```json
{
  "data": {
    "can_manage": true,
    "team_cap": {
      "limit_usd": "500.000000",
      "limit_reset": "monthly",
      "enforcement": "block",
      "spent_usd": "120.405000",
      "resets_at": "2026-12-01T00:00:00.000Z"
    },
    "member_default": null,
    "spent_this_month_usd": "120.405000",
    "members": [
      {
        "user_id": "user_2ana",
        "source": "member",
        "source_name": null,
        "limit": {
          "limit_usd": "20.000000",
          "limit_reset": "weekly",
          "enforcement": "notify",
          "spent_usd": "4.000000",
          "resets_at": "2026-11-30T00:00:00.000Z"
        },
        "spent_this_month_usd": "22.005000"
      }
    ],
    "alerts": { "enabled": true }
  }
}
```

`PUT /v1/admin/spend-limits` sets or removes one limit and answers the same
body:

```bash
curl -X PUT "https://api.sume.com/v1/admin/spend-limits" \
  -H "Authorization: Bearer $SUME_ADMIN_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "subject": "member", "user_id": "user_2ana", "limit_usd": "20.00", "limit_reset": "weekly", "enforcement": "notify" }'
```

| Field | Value |
|---|---|
| `subject` | `team` (the monthly cap), `member_default` (each member with no limit of their own) or `member` |
| `user_id` | the member, with `subject: "member"` |
| `limit_usd` | US dollars in whole cents, from 0 to 1,000,000, as a decimal string such as `"20.00"` (a JSON number is taken too); `null` removes the limit |
| `limit_reset` | `daily`, `weekly` or `monthly`; the team cap is always monthly |
| `enforcement` | `block` refuses spending past the limit, `notify` only alerts; left out, a new limit blocks and a change keeps what was set |

## Feature limits

A feature limit caps spend on one feature: `video`, `image`, `audio`,
`avatar`, `model3d`, `agents` or `gpu`, for the whole team (`team`), for each
member who has none of their own (`member_default`) or for one member
(`member`).

```json
{
  "data": {
    "limits": [
      {
        "feature": "video",
        "subject": "team",
        "user_id": null,
        "limit_usd": "100.000000",
        "limit_reset": "monthly",
        "enforcement": "block",
        "spend_usd": "40.000000",
        "resets_at": "2026-12-01T00:00:00.000Z"
      }
    ],
    "can_edit": true
  }
}
```

`spend_usd` is this window's spend on the feature; the member default has
none. `PUT /v1/admin/feature-limits` takes `feature`, `subject`, `user_id`,
`limit_usd`, `limit_reset` and `enforcement` as above.

## Policy

```bash
curl -X PUT "https://api.sume.com/v1/admin/policies" \
  -H "Authorization: Bearer $SUME_ADMIN_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "features": { "gpu": false }, "models": { "mode": "deny", "models": ["kling"] } }'
```

The body names only the parts to change. The answer is the whole policy:

```json
{
  "data": {
    "policy": {
      "models": { "mode": "deny", "models": ["kling"], "makers": [] },
      "features": { "video": true, "image": true, "audio": true, "avatar": true, "model3d": true, "agents": true, "gpu": false },
      "sharing": { "public_links": true, "social_posting": true },
      "api_keys": { "max_lifetime_days": null }
    },
    "can_edit": true,
    "makers": [{ "id": "openai", "label": "OpenAI" }],
    "recent_models": [{ "model": "seedance-2.5", "feature": "video", "maker": "bytedance", "uses_30d": 12 }],
    "updated_at": "2026-11-26T15:00:00.000Z",
    "updated_by_user_id": "user_2ada"
  }
}
```

- A feature turned off, or a model outside `models`, is refused for everyone
  in the team, Owner and Admins included, from the next request, with
  `feature_disabled` or `model_not_allowed`.
- `models.mode` is `all`, `allow` (only the listed models and makers) or
  `deny` (all but them). A model id also matches its versions:
  `kling` matches `kling-4`.
- `recent_models` lists the models the team generated with in the last 30
  days, most used first.

## Audit log

Every change through the admin API is written to the team's audit log with
the key that made it: `spend_limit.changed` for a spend or feature limit,
`policy.changed` for the policy, each with the previous value. A change that
changes nothing is not written. Read the log itself with the
[Audit log API](https://www.sume.com/docs/audit-logs).

## Limits

`GET /v1/admin/usage` shares the usage summary's rate budget and
`GET /v1/admin/members` the usage reports' budget. The other reads use the
read budget and changes the write budget.

## Errors

| Status | Code | When |
|---|---|---|
| 400 | `invalid_request` | A spend limit field is wrong; `details.field` names it. |
| 400 | `invalid_limit` | A feature limit field is wrong; `details.field` names it. |
| 400 | `invalid_policy` | A policy field is wrong; `details.field` names it. |
| 403 | `insufficient_scope` | Not an admin key (`details.required_scope: "admin:read"`), an Audit log only key outside the audit log, a read-only admin key on a change (`"admin:write"`), or an admin key outside `/v1/admin` (`details.reason: "admin_key"`). |
| 403 | `insufficient_role` | The key's owner is no longer an Owner or Admin of the team. |
| 404 | `team_only` | The key belongs to a personal workspace. |
| 404 | `member_not_found` | `user_id` is not a member of the team. |
| 503 | `admin_api_unavailable` | The team's settings cannot be read right now. Retry. |
