Repository navigation
docs(api): Runs, Workspaces and platform tokens in the API reference - #169
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eference Adds the Runs tag (create, list, retrieve, events stream or JSON pages, cancel) and a read-only Workspaces tag (list, retrieve by id) to the OpenAPI spec, with the Run, RunEvent (ten kinds), RunResult and Workspace schemas taken from cloud-api origin/main. Documents the platform token (nan_pat_) as a second bearer scheme next to the API key and marks which operations accept which. The workspace routes use api.nan.builders outside /v1. Tests pin the surface, credentials, limits and SSE frames, and validate every new example against its schema. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Scalar shows the scheme names in its auth selector. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The guide keeps one end-to-end example (create a run, follow it with curl -N) and the API keys vs tokens explanation, and links to the reference for the endpoints, fields, events, errors and credentials. Tests check the links and that the reference has the runs operations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Only GET /runs/{id} returns the prompt: drop it from the cancel example.
- GET /runs with an unknown workspace filter is an empty page, not 404.
- GET /api/workspaces/{id} with a token: 403 forbidden or
token_scope_denied (malformed id), never the handler's 400.
- Runs-specific 401 naming both credentials; 128 KiB body cap; the
per-workspace cap never exceeds the per-member total.
- The guide example prints the create error instead of following
/runs/null/events.
- Wording fixes; remove a stray screenshot.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ired The create-and-follow example no longer exits the member's shell when the create fails: it prints the error instead of following the log. The Workspaces 401s show session_required for keys those routes refuse, and the runs 401 notes that the message may vary. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
- GET /api/workspaces/{id} accepts an API key or a platform token
(cloud-api #325); the workspace key is refused on both routes.
- A foreign workspace answers the same 404 as an unknown id (#324); a
non-UUID id is a 404 from the edge. No 403 remains.
- 401 examples are the real /api Auth bodies (unauthorized, invalid
session, session_required), pinned by tests.
- api.nan.builders serves these routes to bearer credentials only, with
no cookies and no browser CORS (nan-devops #805).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Workspaces aligned with cloud-api #324/#325 and nan-devops #805. QA (Opus, foreground, checked against cloud-api origin/main b9fb33b and live api.nan.builders with fake credentials) APPROVED at head 9c2cce1. |
…ering The Workspaces operations override the spec-wide /v1 base URL with a path-level servers entry (OpenAPI 3 allows it). The Spec type in openapiToText did not, so astro check failed in CI; and the text rendering served at /api/docs would have sent agents to /v1/api/workspaces. Type the Path Item with optional servers and print the override per operation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Dependencies deployed and verified in prod (2026-10-10): cloud-api 0.8.238 (#324, a foreign workspace uuid answers the same 404 as an unknown one), cloud-api 0.8.239 (#325,
GET /api/workspaces/{uuid}acceptssk-keys and platform tokens), nan-devops #805 (onlyGET /api/workspaces,/api/workspaces/and/api/workspaces/{lowercase uuid}reach origin onapi.nan.builders; bearer only, no CORS). Ready to merge after review.What
Moves the Agent runs API out of the guide and into the API reference (
/docs/api,/es/docs/api, rendered by Scalar fromsrc/data/openapi.json), and adds the read-only Workspaces endpoints and platform tokens to it.src/data/openapi.jsonRuns tag (on the default
https://api.nan.builders/v1server):POST /runs(create): bodyCreateRunRequestwithworkspace(name or id),agent(pi|hermes),prompt(1 to 32768 bytes),cwd(default/home/nan),git_isolation(null|true|false),timeout_seconds(60..7200, default 1800),model,trigger. OptionalIdempotency-Keyheader. Responses:201,200replay,400,401,403(tier_restricted,workspace_key_not_allowed),404,409(workspace_not_running,agent_not_installed,no_inference_key,idempotency_conflict),429(run_queue_full,rate_limited).GET /runs(filtersworkspace,state,limit1..100 default 20,cursor; list object withnext_cursor).GET /runs/{id}.GET /runs/{id}/events:text/event-stream:run_event/state/endframes,: hbevery 15 s,Last-Event-IDresume, 30-minute stream lifetime, 10 streams per member (429 too_many_streams).application/jsonpages:after,limit1..1000 default 500,next_after,done.POST /runs/{id}/cancel(202, or200when the run had already ended).Schemas:
Run,RunResult,RunArtifact,RunList,RunEvent(10 types,dataas aoneOfof per-type schemas;message= incremental chunks withfinalon the last),RunEventPage,CreateRunRequest,Workspace,WorkspaceDetail,WorkspaceSlot,PlatformError. Errors on/v1/runsuse the existing OpenAIErrorenvelope.Workspaces tag: only the two public routes (path-level server
https://api.nan.builders, outside/v1):GET /api/workspaces: member API key or platform token.GET /api/workspaces/{id}: platform token only (cloud-api acceptssk-keys on the exact list path only).Both say only the caller's own workspaces are returned. No session-only workspace route is documented.
Security:
bearerAuthtoapiKey(the name Scalar shows in its selector), and its description is updated. It stays the global default, so inference operations take the API key only.platformTokenscheme (nan_pat_..., platform API only, refused for inference).Sources (cloud-api origin/main):
internal/runs/api.go: limits, states, codes.internal/runs/protocol: event kinds and data, regexes, error codes.internal/handlers/runs.goandruns_sse.go: routes, body, statuses, frames.internal/handlers/workspace.goandinternal/workspace/models.go: the workspace view.internal/middleware/auth.goandhandlers.PlatformTokenAPIRoutes(#323), plus the/apigroup'sAcceptAPIKeysOnincmd/server/main.go.Guide (
src/content/docs/runs.mdx,docs-es/runs.mdx)jq, follow withcurl -N./docs/api#tag/runs,#tag/workspacesand#description/platform-tokens(or the/es/docs/apiequivalents). I checked these anchor formats in the browser: Scalar sets#tag/runswhen you click the tag, and both locales scroll to it.Workspaces contract (after #324, #325, #805)
401 session_required.GET /api/workspaces/{id}: a foreign workspace and an unknown id answer the same404 {"error":"workspace not found"}; a non-UUID id is a404from the edge (OpenAI shape). No403documented.401examples are the real/apiAuth bodies:{"error":"unauthorized"},{"error":"invalid session"},session_required(pinned by tests).api.nan.buildersserves it to bearer credentials only, with no cookies and no browser CORS./v1/modelsanswers403 token_scope_denied,/v1/chat/completionsanswers401from the gateway; the scheme says "401, or403 token_scope_denied".Tests
src/lib/openapiSpec.test.ts: the surface list now counts operations (11 inference + 5 runs + 2 workspaces), so an undocumented or extra one fails.src/lib/openapiRuns.test.ts(no OpenAPI validator among the dependencies, so it includes a small JSON Schema validator) checks:api.nan.builderswith nothing else under/api, and that no secret fields are present;/api/docstext includes the new operations;src/tests/layouts/runsDocs.test.ts:npx vitest run: 1699 tests passed.npm run build: complete./docs/apiand/es/docs/apishow the Runs tag with all 5 operations and the Workspaces tag with 2, and the auth selector offersapiKeyandplatformToken./api/docs/api.mdincludes the new operations.🤖 Generated with Claude Code