# API reference

> Look up customer HTTP operations, request fields, responses and errors.

Source: https://www.sorus.run/docs/reference/api
Reviewed: 2026-10-28

Generated from the operation catalogue; the served document is `https://app.lathe.run/api/openapi.json`. Every operation below is an operation of that document, with the same identifier.

## Authentication

- Tenant credential: `Authorization: Bearer <credential>`. A CLI device token (`lathe_cli_...`) carries the person's role; an agent credential (`lathe_agent_...`) carries its scopes.
- Scopes: `read` (viewer), `submit` (member), `settings`, `credentials` and `admin` (admin or owner). A person's role maps onto scopes as bracketed.
- Dashboard session: the `lathe_session` cookie, for the browser. Over HTTP it reaches the session-only operations, which perform human acts, and the operations the browser reads directly (`jobs.logs`, `jobs.logs_stream`, `usage.export`); every other operation the dashboard performs in-process as the signed-in person, and requires a bearer credential over HTTP.

## Contract

- Every customer mutation requires one `idempotency-key` header. General mutations retain their receipt for 24 hours, refuse a changed body as `idempotency_key_reused`, and report `idempotency_key_in_flight` while their five-minute reservation remains outstanding. Job submission and source transfer instead reconcile their durable original owner: equal retries preserve the original job or upload, and changed input conflicts. Source mutation keys are the upload ID, containing 1 to 128 ASCII letters, digits, `-`, `_`, `.`, or `:`. Chunk keys are additionally bound to their path's part number.
- The source archive protocol separates a 1 GiB regular-file budget, 250000 file/link entries, 250000 derived directories and 32 MiB metadata from its 4 MiB raw transfer chunks. The verified identity binds directory demand for scratch accounting. Uploads expire after one hour; expired bytes still count toward the tenant's 16 GiB and 32-unclaimed-upload reservations until cleanup completes. Runtime availability and execution support require separately qualified management, host, guest and CLI composition.
- Settings writes carry the `version` the caller observed; a moved version is refused as `stale_version` naming the current one.
- A job's wall-clock ceiling is resolved at admission and never changes: the `wall_clock_ceiling_seconds` its submission gives (`jobs.submit`), then the `wall_clock_ceiling_seconds` pin in the captured `sorus.toml`, then the dashboard repository setting, then the platform default of 21600 seconds. A submission's ceiling is a whole number of seconds from 60 to 21600; the bounds are the platform's and no tenant or repository setting narrows them, so it may be above or below the repository's. Outside them it is refused as `invalid_request` naming the field, before any job exists. It is no part of the job's description, its build state, its compile cache or a platform prebuild, which stays under the repository's ceiling. The job records the ceiling as `wall_clock_ceiling_seconds` with `ceiling_source`, which is `platform_default` or `repository_override` and gains no other value, and, only when the submission gave it, `ceiling_origin` `command` beside `repository_override`; a reader treats a `ceiling_origin` it does not know as an origin it cannot name. A replay under the submission key that gives another ceiling than the job's, or none where the job's came from its submission, is refused as `conflict`. `repositories.settings.get` answers `job_wall_clock_ceiling` with the bounds on a release that takes a submission's ceiling and omits it on one that does not, and such a release refuses a `jobs.submit` request carrying the member as `invalid_request`.
- A repository declares the environment its jobs run on in an `[environment]` table of its configuration file: `packages`, `toolchains`, `targets`, `[[environment.download]]` entries (`name`, an `https` `url`, `sha256`, `bytes` up to 4 GiB, `unpack`: `none`, `tar`, `zip` or `deb`, and optionally the `path` under `/opt/lathe/env` it is placed at), `[[environment.file]]` entries (`path` under `/opt/lathe/env` and literal `content` of at most 4096 bytes), `[[environment.link]]` entries (`home` or `repository`, the path the link is made at, and `target` under `/opt/lathe/env`), `[[environment.runtime]]` entries (`name` and an exact `version`) and `[environment.variables]`. Nothing in it runs, and any other key, any other table, a version or range of a package, a channel or range of a toolchain, a download without a digest or length, a path that is absolute or holds `.` or `..` (or, for a link, `.git`), two entries placed at one path, more than 256 packages, 32 downloads, 64 files or 32 links, and a declaration that needs more than four layers are refused at submission naming the key or entry. Its variables join the job's declared environment, a variable the submission declares itself keeping its own value. The job records the declaration's digest and origin (`environment_declaration`). A key whose layer this service does not attach yet (a toolchain the guest's base does not hold, a target beyond the host's, and packages, downloads and runtimes, which need a repository layer) is refused naming it rather than run without it. `[[environment.service]]` entries, the services a job's tests need (`openspec/changes/declare-job-services`), are read by the same rules and refused naming `environment.service[0]` until the release that runs them: a service names a catalogue entry by `name` and exact `version`, and no image, command or script.
- Every list pages by an opaque `cursor` in a stable order and returns `next_cursor` while rows remain; `limit` is 1 to 1000, 200 by default.
- An attempt's output is retained on its execution host and sealed when the attempt closes, whatever closed it. It is readable once the job has ended and does not advance while the job runs: until then `jobs.logs` answers pages with no records that are not `settled`. A job's log is the output of the attempt that produced each unit's result; the unit's watermark names that `attempt` and, when the platform discarded an attempt and ran the unit again, the `earlier_attempts`, whose output is not part of the log. A page is `settled` when nothing more will arrive, and `complete` when it is settled, reports no gap and every unit's command marked the end of its own output (`published`). An attempt the host stopped before its command finished, by a cancellation, the wall-clock ceiling or a platform failure, settles with `complete` false: its watermark has `published` false, `next_sequence` at the end of the stream the host sealed, and `durable` true on the page whose cursor has read every record before it, so everything the host received is retained and whatever the command wrote after its last record never reached the host. `jobs.cargo_output` serves the same sealed stream of one attempt as bytes, with or without a Cargo result, and answers `not_found` only when the host retained none. An attempt retains at most its host's required output bound of that stream, 67108864 bytes on a production host, with the platform's own records. A command that writes more is not failed for it and keeps its own result: the host keeps the start of its output and its last records, an eighth of what it keeps for the command's records, and between them writes two standard error lines that begin `sorus: output not kept:`, the first where it stopped keeping records and the second, once the command ended its output, counting the records and bytes it left out.
- A job read by `jobs.get` states its `provenance`, from what the service holds without reaching an execution host. `tree` is the Git tree the job's commit names, read from the commit object the submission carried and admission checked against the commit's ID; it is absent when the submission carried none. The job's files are that tree's exactly when the guest made them a Git work tree; a source that differs from its commit gets none, and the job's standard error then starts with a line that says so. `units` has one entry for each execution unit that has an attempt: the `unit`, the `attempt` that produced its result (the one a job's log is read from), the guest `image` that attempt booted and, once it has closed, the `output` it retained. `image.root_hash` is the dm-verity root hash of the image's root filesystem, 64 hexadecimal digits, as the attempt's launch manifest names it: the host's kernel checks every block of the image against it. `image.release` is the label a configured execution host gives that exact image; it is absent once no host lists the image, so an old job keeps its root hash and can lose its label. `layers` lists the environment layers the attempt's launch manifest attached beside the image, in slot order, and is absent for an attempt that ran on the image alone: each layer's `kind` (`toolchain`, `targets` or `repository`), its `name` (a toolchain layer's exact toolchain) and its `root_hash`, the layer's dm-verity root hash, against which the guest checks every block it reads. `output.sha256` and `output.bytes` are the SHA-256 and the length of the exact bytes `jobs.cargo_output` serves for the attempt, as the attempt's receipt names them. Those bytes are the attempt's guest protocol stream, one JSON object a line, in which an object whose one key is `JobLog` is one output record (`sequence`, `source`, `continued`, `line`). `cargo sorus logs <job> --raw <file>` writes them to a file unchanged, so `sha256sum <file>` prints `output.sha256`; the text `cargo sorus logs <job>` prints and the records `jobs.logs` pages are rendered from those bytes and hash to neither. `output.records` is the number of output records the command wrote, counted by the host when the command reported its result, and absent for an attempt the host stopped before that. The commit, toolchain, command and declared environment are in the job's `description`, as admitted: `toolchain` and `toolchain_origin`, and under `source.workspace` the `base_commit` and the `invocation` with its `operation`, `arguments`, `working_directory` and `environment`. A list of jobs carries no `provenance`, and a job without one states nothing by its absence.
- `jobs.test_results` answers what a job's test binaries reported, for a job that has ended; one that has not is refused as a `conflict`. It reads the output the attempt of each execution unit retained, from that attempt's execution host, each time it is asked: at most 67108864 bytes of it. Each unit's entry names the `attempt` and the `output` it was computed from, the same `sha256` and `bytes` the job's `provenance` states, and `read` says how much was read: `bytes`, `records`, `ended` (the command marked the end of its output and every record before the mark was read) and `truncated` (the read stopped at the bound, short of the output's length). A `parsed` entry lists `binaries` in the order Cargo started them, with `totals` and `complete`. An entry of `binaries` is one test run: its `target` as Cargo printed it (`unittests src/lib.rs`, `tests/x.rs`, `Doc-tests <crate>`), the `executable` and its `path`, the `tests` it said it would run, and from its result line `result` (`ok` or `failed`), `passed`, `failed`, `ignored`, `measured`, `filtered_out` and `seconds`, with its `failed_tests` by name and `cargo_failed`, whether Cargo reported the target as failed. A run that printed no result line (its process crashed, exited or was stopped) has `reported` false and none of those counts. A crate's documentation tests have one entry for each run rustdoc made of them. `complete` is true only when the output ended, was read whole and every run reported; it is not the job's result, which is the job's `status`. An entry is `unparsed`, with a `code` and a `reason` and no count, when the output's lines do not fit together as test binaries Cargo ran: a test binary with its own harness or `--format json` prints none of libtest's lines, and then nothing is stated for any binary of the unit. An output the host kept only the start and the end of reads `ended` false and its entry is `unparsed` with `output_gap`, because what the host left out may hold any binary's lines. An entry is `unavailable`, with a `code` and a `reason`, when the output was not read: an output marked `host_unreachable` may be read by a later call; `retention_expired`, `no_output` and `no_attempt` will not change.
- Limits per credential: 600 API requests a minute by default, or the `requests_per_minute` an agent credential was created with; at most 32 event streams open at once (`events.stream`, `cli.events`, `jobs.logs_stream`), and 120 opened a minute, reconnections included. A request over its limit is refused as `rate_limited` (429) naming the reset time; a stream over either stream limit is answered 429 with `Retry-After` and the seconds to wait, and streams already open are unaffected.
- Every refusal is a JSON `Refusal` document: `code`, `status`, `detail` and the members the code names.
- A caller names itself in a `User-Agent` header. The customer client sends `sorus/<version> (<calling name>)`: a version of three decimal numbers and the name the client was called by: `cargo-sorus`, `sorus`, or `cargo-lathe` under its earlier name. The service records what the header states and varies one answer by it. It can be configured with a minimum client version, and then refuses a request to any customer operation other than the served OpenAPI document that states an older version, before it reads a credential, as `client_too_old`: `client_version` is the version stated, `minimum_version` the minimum and `install` how to get a client at or above it. A request that names another program is never refused for a client version, and no answer depends on the calling name. A request with no `User-Agent` is read as a client released before 0.2.0, which sent none: it is served unless the configured minimum covers such requests, so any other program sends a `User-Agent` of its own.
- Every job, settings write, credential operation, audit entry and usage record names its principal: the user ID for a person, `agent:<name>` for an agent.

## Refusal codes

| Code | Status | Meaning |
| --- | --- | --- |
| `unauthenticated` | 401 | No credential or session was presented, or it did not verify |
| `credential_revoked` | 401 | The presented credential was revoked; the refusal names the revocation |
| `credential_expired` | 401 | The presented credential passed its expiry; the refusal names the expiry |
| `out_of_scope` | 403 | The credential does not hold the operation's scope; the refusal names the scope |
| `role_required` | 403 | The session's role does not permit the operation; the refusal names the role |
| `human_principal_required` | 403 | The operation is a human act; no agent credential performs it |
| `session_required` | 403 | The operation is performed only inside a signed-in session |
| `not_found` | 404 | The record does not exist for the active tenant |
| `gone` | 410 | The record's retention expired; it is no longer served and retention is not extended |
| `invalid_request` | 400 | The request did not satisfy the operation's schema or rules; the detail names the field |
| `idempotency_key_required` | 400 | The mutation carried no idempotency-key header or more than one |
| `idempotency_key_reused` | 409 | The idempotency-key was used with a different request body inside the retention window |
| `idempotency_key_in_flight` | 409 | The idempotency-key's first request is still being performed; a repeat after it answers receives its receipt |
| `stale_version` | 409 | The settings write named a version the record has moved past; the refusal names the current version |
| `conflict` | 409 | The record's state does not admit the mutation; the detail names the state |
| `confirmation_required` | 400 | The mutation did not carry the confirmation its consequence requires |
| `client_too_old` | 400 | The request states a client version older than the minimum this service is configured with, or states none where that minimum covers such requests; the refusal names the minimum and how to get it, and nothing was performed |
| `rate_limited` | 429 | The credential's request limit was reached; the refusal names the reset time |
| `unavailable` | 503 | A store or service the operation needs did not answer; retry after the named interval |
| `legacy_unsupported` | 501 | The composed runtime does not serve the retained predecessor form |
| `upstream_failed` | 502 | A provider the operation depends on refused or failed |

## Sources

### `sources.capabilities`

`GET /api/source-capabilities`: Read source transport capabilities

Read source protocol versions and independent limits before capturing or uploading a workspace. Configured streamed submission still requires per-invocation execution checks and available capacity.

- Security: Tenant credential with the `submit` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least member
- Idempotency: Safe read
- Query `repository` (required): The authorized repository owning this upload
- Response: `SourceCapabilities` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `invalid_request`, `not_found`, `client_too_old`
- CLI: `cargo sorus test`

### `sources.lookup`

`GET /api/sources`: Find retained source by digest

Find the calling tenant's retained upload of this repository whose canonical archive SHA-256 is the given digest: an admitted or verified upload a job may bind with no upload of its own, or one still being uploaded, and the chunk encodings `sources.chunk.put` accepts. The tenant is the credential's and the repository must be onboarded; no other tenant's or repository's upload is ever named. Bind only an upload whose whole identity equals the capture's; admission checks the exact reference again. Reserves and changes nothing.

- Security: Tenant credential with the `submit` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least member
- Idempotency: Safe read
- Query `repository` (required): The authorized repository owning this upload
- Query `sha256` (required): The canonical archive's 64 lowercase hexadecimal SHA-256 digits
- Response: `SourceLookup` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `invalid_request`, `not_found`, `client_too_old`
- CLI: `cargo sorus test`

### `sources.reserve`

`POST /api/sources`: Reserve captured source

Reserve immutable source identity for an onboarded repository. The idempotency-key is the upload ID and remains bound to these exact inputs.

- Security: Tenant credential with the `submit` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least member
- Idempotency: Keyed mutation: `idempotency-key` required; a replay with the same key and body answers the original receipt
- Body: `SourceReservation` (`application/json`)
- Response: `SourceUpload` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `idempotency_key_required`, `idempotency_key_reused`, `idempotency_key_in_flight`, `invalid_request`, `not_found`, `gone`, `conflict`, `client_too_old`
- CLI: `cargo sorus test`

### `sources.status`

`GET /api/sources/{upload}`: Read source upload status

Read the original tenant and repository bound upload, including expiry and retained admission state.

- Security: Tenant credential with the `submit` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least member
- Idempotency: Safe read
- Path: `upload`
- Query `repository` (required): The authorized repository owning this upload
- Response: `SourceUpload` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `invalid_request`, `not_found`, `client_too_old`
- CLI: `cargo sorus test`

### `sources.chunk.put`

`POST /api/sources/{upload}/chunks/{part}`: Upload an immutable source chunk

Upload one source chunk of at most 4194304 bytes, raw or, with `content-encoding: zstd` when `sources.lookup` lists it, as one zstd frame of at most 4194304 bytes that decodes to exactly the chunk. Digests and stored bytes are the raw chunk's. Repeat bytes verify the original chunk; changed bytes conflict. The idempotency-key must equal the upload ID.

- Security: Tenant credential with the `submit` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least member
- Idempotency: Keyed mutation: `idempotency-key` required; a replay with the same key and body answers the original receipt
- Path: `upload`, `part`
- Query `repository` (required): The authorized repository owning this upload
- Body: `SourceChunk` (`application/octet-stream`)
- Response: No body
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `idempotency_key_required`, `idempotency_key_reused`, `idempotency_key_in_flight`, `invalid_request`, `not_found`, `gone`, `conflict`, `client_too_old`
- CLI: `cargo sorus test`

### `sources.chunk.check`

`GET /api/sources/{upload}/chunks/{part}`: Verify a retained source chunk

Verify a retained chunk against the caller's SHA-256 before resuming. An absent chunk reports present=false; changed bytes conflict.

- Security: Tenant credential with the `submit` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least member
- Idempotency: Safe read
- Path: `upload`, `part`
- Query `repository` (required): The authorized repository owning this upload
- Query `sha256` (required): 64 lowercase hexadecimal SHA-256 digits
- Response: `SourceChunkStatus` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `invalid_request`, `not_found`, `gone`, `conflict`, `client_too_old`
- CLI: `cargo sorus test`

### `sources.complete`

`POST /api/sources/{upload}/complete`: Verify completed source

Verify every archive byte and manifest rule before source can authorize admission. The idempotency-key must equal the upload ID; repeated completion preserves the original owner.

- Security: Tenant credential with the `submit` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least member
- Idempotency: Keyed mutation: `idempotency-key` required; a replay with the same key and body answers the original receipt
- Path: `upload`
- Query `repository` (required): The authorized repository owning this upload
- Response: `SourceUpload` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `idempotency_key_required`, `idempotency_key_reused`, `idempotency_key_in_flight`, `invalid_request`, `not_found`, `gone`, `conflict`, `client_too_old`
- CLI: `cargo sorus test`

## OpenAPI

### `openapi.document`

`GET /api/openapi.json`: The served OpenAPI document

The document this build serves, generated from the catalogue that also binds the routes.

- Security: Public; no credential
- Idempotency: Safe read
- Response: `OpenApiDocument` (application/json)
- Refusals: `unavailable`
- CLI: `cargo sorus openapi` (generated)

## Device

### `device.start`

`POST /api/device/start`: Start a device authorization

Begin the CLI device flow. The answer names the approval page and the user code a signed-in person confirms there.

- Security: Public; no credential
- Response: `DeviceAuthorization` (application/json)
- Refusals: `rate_limited`, `upstream_failed`, `unavailable`, `client_too_old`
- CLI: `cargo sorus login`

### `device.poll`

`GET /api/device/poll`: Poll a device authorization

Poll the device flow until a person approves the code; an approved poll issues the device token once.

- Security: Public; no credential
- Idempotency: Safe read
- Query `device_code` (required): The device code the start answered with
- Response: `DevicePoll` (application/json)
- Refusals: `rate_limited`, `unavailable`, `client_too_old`
- CLI: `cargo sorus login`

### `device.pending`

`GET /api/device/pending`: Read a pending device code

The pending device authorization for a user code, for the approval page inside a signed-in session.

- Security: Signed-in dashboard session only; no credential of any scope
- Idempotency: Safe read
- Query `user_code` (required): The user code the CLI printed
- Response: `PendingDevice` (application/json)
- Refusals: `unauthenticated`, `session_required`, `unavailable`, `client_too_old`
- CLI: None: the approval page is a human surface inside a signed-in session

### `device.approve`

`POST /api/device/approve`: Approve a device code

Approve a pending device code. Only a signed-in human session performs this; no credential, scope or other operation approves a device code.

- Security: Signed-in dashboard session only; no credential of any scope
- Idempotency: Keyed mutation: `idempotency-key` required; a replay with the same key and body answers the original receipt
- Query `user_code` (required): The user code to approve
- Response: `DeviceApprovalReceipt` (application/json)
- Refusals: `unauthenticated`, `session_required`, `invalid_request`, `idempotency_key_required`, `idempotency_key_reused`, `idempotency_key_in_flight`, `client_too_old`
- CLI: None: device approval is a human act inside a signed-in session

## Identity

### `identity.current`

`GET /api/identity`: The calling principal

The principal the credential or session resolves to: a person with role and memberships, or an agent with its scopes.

- Security: Tenant credential with the `read` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least viewer
- Idempotency: Safe read
- Response: `Identity` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `client_too_old`
- CLI: `cargo sorus whoami` (generated)
- MCP tool: `identity_current`

## Onboarding

### `onboarding.surface`

`GET /api/onboarding`: The onboarding state

Whether the GitHub App installation is claimed, the installation and claim links, and whether a job has arrived.

- Security: Tenant credential with the `read` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least viewer
- Idempotency: Safe read
- Response: `Onboarding` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `client_too_old`
- CLI: `cargo sorus onboarding status` (generated)
- MCP tool: `onboarding_surface`

### `onboarding.claim`

`POST /api/onboarding/claims`: Retained installation claim route (deprecated)

The attempt runtime requires browser authorization and refuses this route with a claim_url. Read onboarding.surface, open claim_url in a signed-in browser and let GitHub verify administrative ownership. The predecessor runtime retains its original API behavior.

- Security: Tenant credential with the `admin` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least admin
- Idempotency: Keyed mutation: `idempotency-key` required; a replay with the same key and body answers the original receipt
- Body: `ClaimRequest` (`application/json`)
- Response: `ClaimReceipt` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `idempotency_key_required`, `idempotency_key_reused`, `idempotency_key_in_flight`, `invalid_request`, `conflict`, `upstream_failed`, `client_too_old`
- CLI: None: claim in a signed-in browser using onboarding status's claim_url; GitHub authorization is required

## Jobs

### `jobs.list`

`GET /api/jobs`: List jobs

Jobs of the active tenant, newest first, filtered and paged by an opaque cursor in a stable order.

- Security: Tenant credential with the `read` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least viewer
- Idempotency: Safe read
- Query `repository`: Only jobs of this owner/name repository
- Query `branch`: Only jobs of this branch
- Query `status`: Only jobs in this status
- Query `class`: Only jobs of this class
- Query `cursor`: The opaque cursor a previous page returned; absent starts at the newest row
- Query `limit`: Rows per page, 1 to 1000; the default is 200
- Response: `JobsPage` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `invalid_request`, `client_too_old`
- CLI: `cargo sorus jobs list` (generated)
- MCP tool: `jobs_list`

### `jobs.submit`

`POST /api/v4/jobs`: Submit a captured Cargo workspace

Submit a captured Cargo workspace for check, build, test, clippy or fmt (fmt only with --check among its arguments, clippy never with --fix), or for a declared command (cargo_exec, whose arguments are --, a program and the program's arguments, run without a shell as the workload, with no compile cache and no build state), or for a nextest job (cargo_nextest, whose arguments begin with run: nextest's run with the repository's own configuration and a JUnit report, then cargo test --doc once it passes; its record states both commands). An optional wall_clock_ceiling_seconds is the wall-clock ceiling of this one job, before the repository's pin and setting. The idempotency-key is the submission identity: a replay with the same key and body answers the original job.

- Security: Tenant credential with the `submit` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least member
- Idempotency: Keyed mutation: `idempotency-key` required; a replay with the same key and body answers the original receipt
- Body: `CargoWorkspaceRequest` (`application/json`)
- Response: `JobId` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `idempotency_key_required`, `idempotency_key_reused`, `idempotency_key_in_flight`, `invalid_request`, `not_found`, `conflict`, `gone`, `client_too_old`
- CLI: `cargo sorus test`
- MCP tool: `jobs_submit`

### `jobs.get`

`GET /api/jobs/{id}`: Read a job

The authoritative job record, with its `provenance`: the tree its commit names and, for each execution unit that has an attempt, the guest image the attempt booted and the output it retained, read from what the service already holds, and its `commands`: what the job runs, exactly, with when each runs.

- Security: Tenant credential with the `read` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least viewer
- Idempotency: Safe read
- Path: `id`
- Response: `Job` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `not_found`, `client_too_old`
- CLI: `cargo sorus jobs get` (generated)
- MCP tool: `jobs_get`

### `jobs.evidence`

`GET /api/jobs/{id}/evidence`: Read a job's evidence

The job, its evidence report, its usage record and, paged by cursor, its attempt evidence.

- Security: Tenant credential with the `read` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least viewer
- Idempotency: Safe read
- Path: `id`
- Query `cursor`: The attempt evidence cursor a previous page returned
- Response: `JobEvidence` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `not_found`, `invalid_request`, `client_too_old`
- CLI: `cargo sorus jobs evidence` (generated)
- MCP tool: `jobs_evidence`

### `jobs.cargo_output`

`GET /api/jobs/{id}/attempts/{attempt}/cargo-output`: Download an attempt's Cargo output

The output the host retained of one closed attempt, as bytes: the stream its receipt names, whether a Cargo result was sealed over it or the host stopped the attempt first. They are the bytes whose `sha256` and length the job's `provenance` states for the attempt, and the answer repeats that digest in `x-lathe-output-sha256`. Not found when the host retained none.

- Security: Tenant credential with the `read` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least viewer
- Idempotency: Safe read
- Path: `id`, `attempt`
- Response: Bytes
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `not_found`, `client_too_old`
- CLI: `cargo sorus logs`

### `jobs.test_results`

`GET /api/jobs/{id}/test-results`: Read a job's test results

What the test binaries of a job that has ended reported, one entry per execution unit: for each test run Cargo started, its target, the tests it said it would run, the counts and seconds of its result line and its failed tests by name, with totals. Each entry is read, when asked for, from the output the unit's attempt retained on its execution host, and names that output's `sha256` and length as the job's `provenance` does. A nextest job's entry (`cargo sorus nextest run`) comes instead from the JUnit report its attempt retained: `nextest` states each test's binary, name and status (passed, failed, flaky, timed_out or skipped), the doctest step, and the report's `path`, `sha256` and length, the bytes `jobs.test_report` serves; only the doctest step's runs are read from the output. An entry whose output or report cannot be read is `unavailable`, and one whose lines do not fit together as test binaries Cargo ran is `unparsed`; each gives a code and a reason and states no count. A job that has not ended is refused as a conflict.

- Security: Tenant credential with the `read` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least viewer
- Idempotency: Safe read
- Path: `id`
- Response: `JobTestResults` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `not_found`, `conflict`, `client_too_old`
- CLI: `cargo sorus jobs test-results` (generated)
- MCP tool: `jobs_test_results`

### `jobs.test_report`

`GET /api/jobs/{id}/test-report`: Download a nextest job's JUnit report

The JUnit report a nextest job's attempt retained beside its output (`cargo sorus nextest run`), unchanged: the bytes whose `sha256` and length the job's test results state, repeated in `x-lathe-report-sha256`. Not found for a job that is no nextest job, or whose nextest step wrote no report; a conflict for a job that has not ended.

- Security: Tenant credential with the `read` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least viewer
- Idempotency: Safe read
- Path: `id`
- Response: Bytes
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `not_found`, `conflict`, `gone`, `client_too_old`
- CLI: `cargo sorus logs`

## Environment

### `environment.layer_record`

`GET /api/environment-layers/{digest}/build-record`: Read an environment layer's build record

The build record of an environment layer a job runs on, named by the SHA-256 of the layer's image as the job's `environment_layers` gives it: every input the layer was built from with its digest, how it was sealed and what it sealed to. It is answered only to a tenant that may run on the layer, and to any other tenant the layer is `not_found`, as an unknown one is. The record is read from the release store and checked against the digest the service's layer catalogue holds for it.

- Security: Tenant credential with the `read` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least viewer
- Idempotency: Safe read
- Path: `digest`
- Response: `LayerBuildRecord` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `invalid_request`, `not_found`, `client_too_old`
- CLI: `cargo sorus environment layer-record` (generated)
- MCP tool: `environment_layer_record`

## Jobs

### `jobs.artifacts`

`GET /api/jobs/{id}/artifacts`: List a job's artifacts

The published artifact inventory of a job.

- Security: Tenant credential with the `read` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least viewer
- Idempotency: Safe read
- Path: `id`
- Response: `ArtifactInventory` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `not_found`, `gone`, `client_too_old`
- CLI: `cargo sorus artifacts`
- MCP tool: `jobs_artifacts`

### `jobs.artifact_bytes`

`GET /api/jobs/{id}/artifacts/{attempt}/{index}`: Download an artifact

One published artifact file as bytes.

- Security: Tenant credential with the `read` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least viewer
- Idempotency: Safe read
- Path: `id`, `attempt`, `index`
- Response: Bytes
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `not_found`, `gone`, `client_too_old`
- CLI: `cargo sorus artifacts`

### `jobs.logs`

`GET /api/jobs/{id}/logs`: Read a page of job logs

One page of job log records from a cursor. A job's log is the retained output of the attempt that produced each unit's result, readable once that attempt has closed.

- Security: Tenant credential with the `read` scope as a bearer token; the signed-in dashboard session reaches it with its cookie at a role of at least viewer
- Idempotency: Safe read
- Path: `id`
- Query `cursor`: The log cursor a previous page returned
- Query `limit`: Records per page; the default is 100
- Response: `JobLogPage` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `not_found`, `invalid_request`, `client_too_old`
- CLI: `cargo sorus logs`
- MCP tool: `jobs_logs`

### `jobs.logs_stream`

`GET /api/jobs/{id}/logs/stream`: Stream job logs

Job log pages as server-sent events from a cursor until the job settles.

- Security: Tenant credential with the `read` scope as a bearer token; the signed-in dashboard session reaches it with its cookie at a role of at least viewer
- Idempotency: Safe read
- Path: `id`
- Query `cursor`: The log cursor to resume from
- Query `limit`: Records per page
- Response: Server-sent events
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `not_found`, `invalid_request`, `client_too_old`
- CLI: `cargo sorus logs`

### `jobs.cancel`

`POST /api/jobs/{id}/cancel`: Cancel a job

Request cancellation; running units are reaped and metering closes.

- Security: Tenant credential with the `submit` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least member
- Idempotency: Keyed mutation: `idempotency-key` required; a replay with the same key and body answers the original receipt
- Path: `id`
- Response: `CancellationReceipt` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `idempotency_key_required`, `idempotency_key_reused`, `idempotency_key_in_flight`, `not_found`, `conflict`, `upstream_failed`, `client_too_old`
- CLI: `cargo sorus cancel`
- MCP tool: `jobs_cancel`

### `jobs.retry`

`POST /api/jobs/{id}/retry`: Retry a terminal job

Submit a fresh job linked to a terminal original.

- Security: Tenant credential with the `submit` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least member
- Idempotency: Keyed mutation: `idempotency-key` required; a replay with the same key and body answers the original receipt
- Path: `id`
- Response: `RetryReceipt` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `idempotency_key_required`, `idempotency_key_reused`, `idempotency_key_in_flight`, `not_found`, `conflict`, `client_too_old`
- CLI: `cargo sorus jobs retry` (generated)
- MCP tool: `jobs_retry`

## Repositories

### `repositories.admission`

`GET /api/repositories/{owner}/{name}/admission`: Retained repository ref admission (deprecated)

The attempt runtime does not serve ref admission: an onboarded repository receives legacy_unsupported (501), and an unknown or foreign repository receives not_found (404). Submit a captured workspace with cargo sorus test. The predecessor runtime retains ref resolution.

- Security: Tenant credential with the `submit` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least member
- Idempotency: Safe read
- Path: `owner`, `name`
- Query `base_ref` (required): The predecessor base ref to resolve
- Response: `Admission` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `not_found`, `legacy_unsupported`, `upstream_failed`, `client_too_old`
- CLI: None: ref admission is not served by the attempt runtime; submit a captured workspace with cargo sorus test

### `repositories.list`

`GET /api/repositories`: List repositories

Onboarded repositories with their lineage storage, the tenant quota and live advisories, paged by cursor.

- Security: Tenant credential with the `read` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least viewer
- Idempotency: Safe read
- Query `cursor`: The opaque cursor a previous page returned; absent starts at the newest row
- Query `limit`: Rows per page, 1 to 1000; the default is 200
- Response: `RepositoriesPage` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `invalid_request`, `client_too_old`
- CLI: `cargo sorus repositories list` (generated)
- MCP tool: `repositories_list`

### `repositories.prebuilds`

`GET /api/repositories/{owner}/{name}/prebuilds`: List a repository's platform prebuilds

The platform's prebuild jobs (job zero) of one repository, newest first and paged by an opaque cursor: the jobs that built its prebuilt dependency state. They run in the tenant but are the platform's work, so no job list shows them and no member cancels or retries them; each is read by its ID like any job. Only the active tenant's jobs are read: a repository with no prebuild there, the tenant's or not, answers an empty page, never not_found. As in the job list, the total and the summary count before the repository filter, so they cover the tenant's platform prebuilds of all its repositories.

- Security: Tenant credential with the `read` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least viewer
- Idempotency: Safe read
- Path: `owner`, `name`
- Query `cursor`: The opaque cursor a previous page returned; absent starts at the newest row
- Query `limit`: Rows per page, 1 to 1000; the default is 200
- Response: `JobsPage` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `invalid_request`, `client_too_old`
- CLI: `cargo sorus repositories prebuilds` (generated)
- MCP tool: `repositories_prebuilds`

### `repositories.get`

`GET /api/repositories/{owner}/{name}`: Read a repository

One repository: its lineages by class against the quota and its advisories with their measured basis.

- Security: Tenant credential with the `read` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least viewer
- Idempotency: Safe read
- Path: `owner`, `name`
- Response: `RepositoryPage` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `not_found`, `client_too_old`
- CLI: `cargo sorus repositories get` (generated)
- MCP tool: `repositories_get`

### `repositories.settings.get`

`GET /api/repositories/{owner}/{name}/settings`: Read repository settings

The repository's build settings with their version, effective origin and attribution and when each takes effect, and the wall-clock ceiling a job for it carries with the documented bounds, and the bounds of a ceiling one submission may give for its own job. Admission snapshots the settings for each submitted job; a build setting the repository's own Cargo configuration already sets is reported in the job's evidence as not applied, never replaced. The read requires the member role a submission requires and has no lifecycle effect, so a client that bounds a job's cost reads it before it submits.

- Security: Tenant credential with the `submit` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least member
- Idempotency: Safe read
- Path: `owner`, `name`
- Response: `RepositorySettings` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `not_found`, `client_too_old`
- CLI: `cargo sorus repositories settings get` (generated)
- MCP tool: `repositories_settings_get`

### `repositories.settings.write`

`POST /api/repositories/{owner}/{name}/settings`: Write a repository setting

Write one setting at the version the caller observed; a moved version is refused naming the current one. The receipt states when the value takes effect.

- Security: Tenant credential with the `settings` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least admin
- Idempotency: Keyed mutation: `idempotency-key` required; a replay with the same key and body answers the original receipt
- Path: `owner`, `name`
- Body: `SettingWrite` (`application/json`)
- Response: `SettingReceipt` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `idempotency_key_required`, `idempotency_key_reused`, `idempotency_key_in_flight`, `invalid_request`, `stale_version`, `client_too_old`
- CLI: `cargo sorus repositories settings set` (generated)
- MCP tool: `repositories_settings_write`

### `repositories.advisories.dismiss`

`POST /api/repositories/{owner}/{name}/advisories/{advisory}/dismissal`: Dismiss an advisory

Dismiss a repository advisory; the dismissal is remembered and attributed.

- Security: Tenant credential with the `settings` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least admin
- Idempotency: Keyed mutation: `idempotency-key` required; a replay with the same key and body answers the original receipt
- Path: `owner`, `name`, `advisory`
- Response: `DismissalReceipt` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `idempotency_key_required`, `idempotency_key_reused`, `idempotency_key_in_flight`, `not_found`, `client_too_old`
- CLI: `cargo sorus repositories advisories dismiss` (generated)
- MCP tool: `repositories_advisories_dismiss`

### `repositories.lineages.purge`

`POST /api/repositories/{owner}/{name}/purges`: Purge a lineage

Delete a lineage so the next matching job starts cold. The request carries the confirmation the consequence requires.

- Security: Tenant credential with the `admin` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least admin
- Idempotency: Keyed mutation: `idempotency-key` required; a replay with the same key and body answers the original receipt
- Path: `owner`, `name`
- Body: `PurgeRequest` (`application/json`)
- Response: `PurgeReceipt` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `idempotency_key_required`, `idempotency_key_reused`, `idempotency_key_in_flight`, `confirmation_required`, `not_found`, `invalid_request`, `client_too_old`
- CLI: `cargo sorus repositories lineages purge` (generated)
- MCP tool: `repositories_lineages_purge`

## Tenant

### `tenant.settings.get`

`GET /api/tenant/settings`: Read tenant settings


- Security: Tenant credential with the `read` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least viewer
- Idempotency: Safe read
- Response: `TenantSettings` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `client_too_old`
- CLI: `cargo sorus settings get` (generated)
- MCP tool: `tenant_settings_get`

### `tenant.settings.write`

`POST /api/tenant/settings`: Write a tenant setting


- Security: Tenant credential with the `settings` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least admin
- Idempotency: Keyed mutation: `idempotency-key` required; a replay with the same key and body answers the original receipt
- Body: `SettingWrite` (`application/json`)
- Response: `SettingReceipt` (application/json)
- CLI: `cargo sorus settings set` (generated)
- MCP tool: `tenant_settings_write`

### `tenant.registry_credential.replace`

`POST /api/tenant/registry-credentials`: Replace a private registry credential

Replace a registry credential on every host, removing the prior value once every host acknowledges. The request carries the confirmation.

- Security: Tenant credential with the `credentials` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least admin
- Idempotency: Keyed mutation: `idempotency-key` required; a replay with the same key and body answers the original receipt
- Body: `RegistryCredentialReplacement` (`application/json`)
- Response: `RegistryCredentialReceipt` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `idempotency_key_required`, `idempotency_key_reused`, `idempotency_key_in_flight`, `confirmation_required`, `invalid_request`, `upstream_failed`, `client_too_old`
- CLI: `cargo sorus registry-credential replace` (generated)
- MCP tool: `tenant_registry_credential_replace`


## CLI tokens

### `cli_tokens.list`

`GET /api/cli/tokens`: List the caller's CLI tokens

The calling person's device tokens with creation, last use and revocation, paged by cursor. Tokens belong to people; an agent credential is refused.

- Security: A person's device token with the `credentials` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least admin; an agent credential is refused
- Idempotency: Safe read
- Query `cursor`: The opaque cursor a previous page returned; absent starts at the newest row
- Query `limit`: Rows per page, 1 to 1000; the default is 200
- Response: `TokensPage` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `human_principal_required`, `invalid_request`, `client_too_old`
- CLI: `cargo sorus tokens list` (generated)

### `cli_tokens.revoke`

`POST /api/cli/tokens/{id}/revocation`: Revoke a CLI token

Revoke one of the caller's device tokens; the next request presenting it is refused.

- Security: A person's device token with the `credentials` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least admin; an agent credential is refused
- Idempotency: Keyed mutation: `idempotency-key` required; a replay with the same key and body answers the original receipt
- Path: `id`
- Response: `RevocationReceipt` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `idempotency_key_required`, `idempotency_key_reused`, `idempotency_key_in_flight`, `human_principal_required`, `not_found`, `client_too_old`
- CLI: `cargo sorus tokens revoke` (generated)

## CLI

### `cli.tenant`

`GET /api/cli/tenant`: The credential's tenant

The tenant the credential is bound to.

- Security: Tenant credential with the `read` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least viewer
- Idempotency: Safe read
- Response: `TenantId` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `client_too_old`
- CLI: `cargo sorus tenant` (generated)
- MCP tool: `cli_tenant`

### `cli.events`

`GET /api/cli/events`: Stream tenant job events

Tenant job status events as server-sent events, resumable from a durable sequence.

- Security: Tenant credential with the `read` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least viewer
- Idempotency: Safe read
- Query `after`: The durable sequence already observed
- Response: Server-sent events
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `invalid_request`, `client_too_old`
- CLI: `cargo sorus status`

## Events

### `events.stream`

`GET /api/events`: Stream dashboard hints

Job transitions for the signed-in session's tenant as server-sent events; hints the dashboard reconciles against authoritative reads.

- Security: Signed-in dashboard session only; no credential of any scope
- Idempotency: Safe read
- Response: Server-sent events
- Refusals: `unauthenticated`, `session_required`, `rate_limited`, `client_too_old`
- CLI: None: the dashboard hint stream is a browser session surface; the CLI reads the tenant event stream

## Usage

### `usage.report`

`GET /api/usage`: Read the usage report

The period's usage rolled up from per-second records, per day and per repository, with the rate card where one is set.

- Security: Tenant credential with the `read` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least viewer
- Idempotency: Safe read
- Query `period`: The period as YYYY-MM; absent means the current month
- Response: `Usage` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `invalid_request`, `client_too_old`
- CLI: `cargo sorus usage report` (generated)
- MCP tool: `usage_report`

### `usage.export`

`GET /api/usage/export`: Export the period's records

The period's per-second records and adjustments as a document whose totals equal the report.

- Security: Tenant credential with the `read` scope as a bearer token; the signed-in dashboard session reaches it with its cookie at a role of at least viewer
- Idempotency: Safe read
- Query `period`: The period as YYYY-MM; absent means the current month
- Response: `UsageExport` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `invalid_request`, `client_too_old`
- CLI: `cargo sorus usage export` (generated)
- MCP tool: `usage_export`

## Credentials

### `credentials.create`

`POST /api/credentials`: Mint an agent credential

Mint a named, scoped, expiring agent credential. The value is shown once. A human admin performs this; no agent credential mints another.

- Security: A person's device token with the `admin` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least admin; an agent credential is refused
- Idempotency: Keyed mutation: `idempotency-key` required; a replay with the same key and body answers the original receipt
- Body: `CredentialRequest` (`application/json`)
- Response: `CredentialIssued` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `idempotency_key_required`, `idempotency_key_reused`, `idempotency_key_in_flight`, `human_principal_required`, `invalid_request`, `conflict`, `client_too_old`
- CLI: `cargo sorus credential create`

### `credentials.list`

`GET /api/credentials`: List agent credentials

The tenant's agent credentials with name, scopes, expiry, last use and revocation, paged by cursor.

- Security: Tenant credential with the `credentials` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least admin
- Idempotency: Safe read
- Query `cursor`: The opaque cursor a previous page returned; absent starts at the newest row
- Query `limit`: Rows per page, 1 to 1000; the default is 200
- Response: `CredentialsPage` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `invalid_request`, `client_too_old`
- CLI: `cargo sorus credential list` (generated)
- MCP tool: `credentials_list`

### `credentials.revoke`

`POST /api/credentials/{name}/revocation`: Revoke an agent credential

Revoke a credential by name; its next use is refused as revoked.

- Security: Tenant credential with the `credentials` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least admin
- Idempotency: Keyed mutation: `idempotency-key` required; a replay with the same key and body answers the original receipt
- Path: `name`
- Response: `CredentialRevocationReceipt` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `idempotency_key_required`, `idempotency_key_reused`, `idempotency_key_in_flight`, `not_found`, `client_too_old`
- CLI: `cargo sorus credential revoke` (generated)
- MCP tool: `credentials_revoke`

## Audit

### `audit.list`

`GET /api/audit`: List tenant audit entries

Attributed management mutations of the tenant, newest first, paged by cursor.

- Security: Tenant credential with the `read` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least viewer
- Idempotency: Safe read
- Query `cursor`: The opaque cursor a previous page returned; absent starts at the newest row
- Query `limit`: Rows per page, 1 to 1000; the default is 200
- Response: `AuditPage` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `invalid_request`, `client_too_old`
- CLI: `cargo sorus audit list` (generated)
- MCP tool: `audit_list`

## Jobs

### `jobs.submit_diff`

`POST /api/jobs`: Submit a local diff (predecessor) (deprecated)

A retained predecessor route. The attempt runtime refuses it and names the captured Cargo workspace submission; new clients do not call it.

- Security: Tenant credential with the `submit` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least member
- Idempotency: Predecessor mutation; not keyed
- Body: `LocalDiffRequest` (`application/json`)
- Response: `JobId` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `invalid_request`, `not_found`, `conflict`, `legacy_unsupported`, `idempotency_key_required`, `client_too_old`
- CLI: None: a retained predecessor route; the CLI submits captured Cargo workspaces

### `jobs.submit_diff_v2`

`POST /api/v2/jobs`: Submit a local diff with artifacts (predecessor) (deprecated)

A retained predecessor route. The attempt runtime refuses it and names the captured Cargo workspace submission; new clients do not call it.

- Security: Tenant credential with the `submit` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least member
- Idempotency: Predecessor mutation; not keyed
- Body: `LocalDiffRequest` (`application/json`)
- Response: `JobId` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `invalid_request`, `not_found`, `conflict`, `legacy_unsupported`, `idempotency_key_required`, `client_too_old`
- CLI: None: a retained predecessor route; the CLI submits captured Cargo workspaces

### `jobs.submit_diff_keyed`

`POST /api/v3/jobs`: Submit a local diff with an idempotency-key (predecessor) (deprecated)

A retained predecessor route. The attempt runtime refuses it and names the captured Cargo workspace submission; new clients do not call it.

- Security: Tenant credential with the `submit` scope as a bearer token; the dashboard reaches it in-process with its session at a role of at least member
- Idempotency: Predecessor mutation; not keyed
- Body: `LocalDiffRequest` (`application/json`)
- Response: `JobId` (application/json)
- Refusals: `unauthenticated`, `credential_revoked`, `credential_expired`, `out_of_scope`, `role_required`, `rate_limited`, `unavailable`, `invalid_request`, `not_found`, `conflict`, `legacy_unsupported`, `idempotency_key_required`, `client_too_old`
- CLI: None: a retained predecessor route; the CLI submits captured Cargo workspaces

## Schemas

The component schemas are in the served document under `components.schemas`; each operation names its body and response schema above.
