# API reference: admin

Who uses the hub, for the hub's own operators. Only a hub admin signed in to the web app may call these. An API key is `403`. Anyone else is `404`.

## GET /v1/admin/users

`listAdminUsers` · scope `session` · Everyone with an account on this hub

The people with an account on this hub, for its operators. Only a hub admin signed in to the web app may call it. A hub admin is a person the deployment names by id, or an owner of an organization it names by id. Handles and slugs never count, since a freed name can be taken by anyone. An API key of any scope is `403`. Anyone else, signed in or not, is `404`.

Each call is recorded in the audit log as `admin.users.view`.

`email` and `sign_in_methods` come from the sign-in provider, Clerk. They are read in one batched call per page and cached for five minutes. When Clerk is not configured or does not answer, `clerk` says so and `sign_in_methods` is null. `email` then falls back to the copy the sign-in token carried, if any (`email_source: hub`).

Counts and `spend_month_usd` cover each person's own account. Work owned by an organization counts toward the organization. `spend_month_usd` is what the calendar month (UTC) recorded: Lucen cloud jobs, the agent, and Coach and planner calls.

`last_active_at` is the person's last authenticated request, stamped at most every five minutes. Keys the hub minted for a robot, a hosted job or an agent turn do not count.

Parameters:

- `q` (query): Matches the handle, the display name and the e-mail address, ignoring case. With Clerk configured, Clerk's own user search is asked too. So an address only Clerk holds still matches.
- `sort` (query): `created`: newest sign-up first. `last_active`: most recently active first, people never seen last. `spend`: the month's highest spend first.
- `method` (query): Only people who can sign in this way, as `sign_in_methods` names it. This needs Clerk. When Clerk is unavailable the page is empty and `clerk` says why.
- `limit` (query): Page size.
- `cursor` (query): Opaque cursor from the previous page's `next_cursor`.

Responses:

- `200`: A page of people.
- `401`: Missing or invalid credentials.
- `403`: Authenticated but not allowed (visibility, membership or scope).
- `404`: Resource not found (or hidden from the caller).
- `422`: Request failed validation.

## GET /v1/admin/stats

`getAdminStats` · scope `session` · How many people use the hub, and what they made

The hub in numbers, for its operators: people, sign-ups per day for 30 days, what exists, and this month's spend. Access is the same as `listAdminUsers`. Every number is one SQL aggregate over the hub's own tables, and nothing is read from Clerk.

Days are whole days in UTC. A 7-day window is today and the six days before it. "Active" means at least one authenticated request in the window, as `AdminUser.last_active_at` records it.

Responses:

- `200`: The hub's numbers.
- `401`: Missing or invalid credentials.
- `403`: Authenticated but not allowed (visibility, membership or scope).
- `404`: Resource not found (or hidden from the caller).
