# Key owners and workloads

**Last updated:** 2026-11-22T07:30:00-03:00 (UTC-3)

Every key can have an **owner**: a console user or a **workload** (agent, job, service) on the same team. That way, when a cost spike shows up or a key leaks, you know who is accountable for it, you can filter the logs by owner, and, if needed, revoke all of a workload's keys at once. Flag: `identity_ownership`.

The owner **does not change what the key can do**: models, routes, team policy, RPM, quotas, and cache still come from the key and the team. The only access rule tied to the owner only takes away: a key whose owner is a deactivated user is refused.

## How to turn it on

```yaml
features:
  identity_ownership: true   # requires identity_management, team_management, console_users, and PostgreSQL
workloads:
  - id: billing-batch        # declared IDs cannot start with wl_
    team: finance
    name: Billing batch
    responsible: usr_0123456789abcdef0123456789abcdef
keys:
  - id: billing-yaml
    team: finance
    owner: {kind: workload, id: billing-batch}
```

| Key | Default | What it does |
| --- | --- | --- |
| `workloads[].id` | required | Unique identifier; declared IDs cannot start with `wl_`, which marks console-created workloads |
| `workloads[].team` | required | The team that owns the workload; a declared workload cannot move to another team |
| `workloads[].name` | required | Display name, 2–128 bytes of UTF-8 on one line |
| `workloads[].description` | empty | Up to 512 bytes |
| `workloads[].responsible` | empty | Optional `usr_…` ID of the console user answerable for the workload; the user must exist |
| `workloads[].disabled` | `false` | A deactivated workload keeps its keys working and accepts no new links. The workload objects of the API carry the same `disabled` beside `status` |

You can turn the flag on without restarting, in **Settings & sources**. The gateway does not start if the YAML points to a user that does not exist or moves a declared workload to another team.

## How to use it

| What | API (`/api/v1/admin`) | Console |
| --- | --- | --- |
| List workloads, with their responsible user and owned key count | `GET /api/v1/admin/workloads` | **Workloads** |
| Read one workload with its recent keys and the YAML keys that reference it | `GET /api/v1/admin/workloads/{id}` | Workload detail |
| Create or edit a workload | `POST /api/v1/admin/workloads`, `PUT /api/v1/admin/workloads/{id}` with `version` | **Workloads** → Create / Edit |
| Delete a workload | `DELETE /api/v1/admin/workloads/{id}` (no active keys) | Delete |
| Revoke all of the workload's keys | `POST /api/v1/admin/workloads/{id}/revoke-keys` | Revoke keys |
| Owner of a new key | `owner` in `POST /keys` | key creation → Owner |
| Change the owner | `PUT /keys/{id}/owner` with `owner_version` | Owner action |
| Investigate usage | `GET /logs?owner=user:<id>` or `workload:<id>` (also as CSV); `GET /users/{id}/detail` | Request logs → Owner filter and column; user detail |

Workloads from the YAML show up in the console read-only; to change them, edit the YAML.

## Rules

- The workload must belong to the key's team and be active at the time it is linked. An owning user must be active and, if they have a team role, be a member of the key's team.
- Only the global admin assigns owners and manages workloads; the global viewer can read. `team_admin` issues keys without an owner.
- A **deactivated workload** keeps its keys working and accepts no new links. To cut off access, use **Revoke keys**.
- A **deactivated owning user** (from the console or through [SCIM](/docs/features/scim/)): their keys are refused for as long as it lasts. Reactivating the user does not undo a key revocation.
- The owner is recorded in every usage event and in the durable receipt. Changing the owner later does not rewrite the past.

## Limits

- The analytics query API groups by owner (`GET /api/v1/admin/analytics/query?group_by=owner`, also used by m7 ai) and by `owner_kind` (`user`, `workload`, or empty for no owner), and filters by both (`owner=workload:batch-jobs`, `owner_kind=user`).
- **Usage → Consumers → Usage by owner** (T168) shows that breakdown on the Analytics screen: group by owner, owner and model, or owner and team; narrow to people, workloads or requests with no owner; filter one exact owner (`user:usr_…` or `workload:…`, or **Filter** on a row); **Logs** opens the request logs of that owner for the same window. It follows the screen's window and filters (team, model, provider, key, principal, operation, end user; tag filters do not apply to it, and the panel says so) and shows the top 50 groups by requests. It reads the analytics query API, so the same rules apply: `analytics:read`, `usage_analytics` and `identity_ownership` (the panel is hidden without it), team-scoped roles and organization admins see only their teams, and with plan entitlements only teams whose plan includes `identity_ownership`. Saved views do not offer an owner grouping.
- Video jobs use the owner of the request that queries the job, unless `video_job_owner` is on (off by default; requires `identity_ownership` and `quota_video`): then a job keeps the owner its key had when the job was created, shows it as `owner_kind`/`owner_id` (console: **Owner at creation**; hidden again when either flag is off), and its status reads and refreshes are attributed to it even if the key's owner changes before the job ends. Jobs created without the flag keep the polling key's current owner. Migration 171 adds the two nullable columns.
- Turning the flag off stops recording owners and hides the screens, without deleting the links.

## See also

- [Access control](/docs/features/access-control/).
- [Key rotation](/docs/features/key-rotation/).


## Owner schema and attribution

An absent owner remains absent. When an owner object is supplied, its kind must be `user` or `workload` and its ID must satisfy the corresponding typed shape. Shared [parameter definitions](/docs/reference/parameter-registry/) publish only those compiled choices, with no invented owner default. Shape validation does not establish existence, team membership, active state or permission: existing authoritative transactional checks still decide those. Clearing an owner in the console represents outer absence, not another kind or an access grant.
