Administration: usage and sandboxes
The usage report and the running sandboxes. Administrators only.
| Operation | Method and path |
|---|---|
| Usage report | GET /api/v1/admin/usage |
| The running sandboxes | GET /api/v1/admin/sandboxes |
| Stop an idle sandbox | POST /api/v1/admin/sandboxes/{conversation_id}/stop |
Usage report
GET /api/v1/admin/usage
Relayed-request usage by day, user or route over an inclusive UTC date range (at most 92 days apart, ending no later than tomorrow). Day reports include days without requests; user and route reports are ranked by prompt plus completion tokens, at most 200 rows, with truncated=true when more exist. Totals cover the whole range. Administrators only; a session or a personal token. Route rows are labelled with the route's display name when it has one.
Sign-in: A signed-in session or an API token.
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
from | query | string (date) | First day, UTC. Defaults to 29 days before to. | |
to | query | string (date) | Last day, UTC. Defaults to today. | |
group | query | "day", "user", "route" | ||
compare | query | "previous" | previous: also total the equal-length period that ends the day before from (previous_from, previous_to, previous). |
Responses
| Status | Meaning | Body |
|---|---|---|
| 200 | The report | AdminUsageReport |
| 400 | Invalid parameter (see details) | Error |
| 401 | Authentication required | Error |
| 403 | Not an administrator | Error |
| 503 | Database unavailable or gateway restarting | Error |
The running sandboxes
GET /api/v1/admin/sandboxes
Every running sandbox with its owner, environment, state, size and measured use, the install's limits and totals, and what the sweeps left behind (the Sandboxes page). One consistent read of the records; the engine is never called, and the measured use is the sampler's last values (null until a sandbox has two samples). Nothing of a task but its id: no title, message, file, workspace, route or profile, for other people's tasks and the administrator's own alike. Ordered working, starting, stopping, then idle by soonest stop. Administrators only; a session or a personal token.
Sign-in: A signed-in session or an API token.
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
after | query | string (uuid) | The conversation_id of the previous page's last row (next_after); a token nothing matches starts over. |
Responses
| Status | Meaning | Body |
|---|---|---|
| 200 | The listing | AdminSandboxes |
| 400 | Invalid parameter (see details) | Error |
| 401 | Authentication required | Error |
| 403 | Not an administrator | Error |
| 503 | Database unavailable or gateway restarting | Error |
Stop an idle sandbox
POST /api/v1/admin/sandboxes/{conversation_id}/stop
Asks the retire path to stop the task's sandbox, as an eviction does: the sandbox goes, the task keeps its files and history, its owner reads a notice (sandbox.stopped) and its next message starts a new sandbox. Only an idle sandbox with nothing waiting and no held screen is stopped; a kept-on one is stoppable. Administrators only; a session or a personal token. Idempotency-Key required: a repeat of the key replays the first answer. Audited (area sandboxes, action stop) and counted.
Sign-in: A signed-in session or an API token.
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
conversation_id | path | yes | string (uuid) | The task whose sandbox to stop. |
Idempotency-Key | header | yes | string | A repeat with the same key answers the first result and retires nothing twice. |
Responses
| Status | Meaning | Body |
|---|---|---|
| 202 | The stop is requested (or already on its way) | AdminSandboxStop |
| 400 | Missing or invalid Idempotency-Key, or an invalid id | Error |
| 401 | Authentication required | Error |
| 403 | Not an administrator | Error |
| 404 | not_found: the task has no running sandbox | Error |
| 409 | working: a run is going, the sandbox is starting, or a person holds its screen; work_waiting: a message is queued for it | Error |
| 422 | The key was used with another request | Error |
| 503 | Database unavailable or gateway restarting | Error |