API contract
Agent API
Use the CLI first. These endpoint contracts exist for callers that need direct HTTP integration with the documented agent surface.
Endpoint map
| Method | Path | Use |
|---|---|---|
| GET | /api/agent/version | API and client version compatibility. |
| GET | /api/agent/auth/status | Authentication status for the current token or profile. |
| POST | /api/agent/auth/device/start | Start device login for interactive CLI auth. |
| POST | /api/agent/auth/device/complete | Complete device login after browser approval. |
| POST | /api/agent/auth/tokens | Create a scoped token. rawToken is shown once. |
| GET | /api/agent/auth/tokens | List token metadata available to the caller. |
| DELETE | /api/agent/auth/tokens/[tokenId] | Revoke a token by id. |
| POST | /api/agent/projects | Create a project for automation. |
| GET | /api/agent/projects/[projectId] | Read project metadata. |
| GET | /api/agent/projects/[projectId]/script | Read a project script file. |
| PUT | /api/agent/projects/[projectId]/script | Write a project script file. |
| GET | /api/agent/projects/[projectId]/artifacts | List public project artifacts for automation. |
| GET | /api/agent/reference-libraries | List Reference Libraries visible to the current token or project. |
| GET | /api/agent/reference-libraries/[libraryId]/items | List visible items for a Reference Library. |
| POST | /api/agent/projects/[projectId]/reference-libraries | Create a user-scoped Reference Library owned by the current token principal. |
| GET | /api/agent/projects/[projectId]/reference-libraries/[libraryId]/grants | List library-level user grants for a Reference Library. |
| POST | /api/agent/projects/[projectId]/reference-libraries/[libraryId]/grants | Grant library-level can-use or admin access to another user. |
| DELETE | /api/agent/projects/[projectId]/reference-libraries/[libraryId]/grants/[grantId] | Revoke a library-level user grant. |
| GET | /api/agent/projects/[projectId]/reference-library-policy | Read project Reference Library capture policy. |
| PATCH | /api/agent/projects/[projectId]/reference-library-policy | Set project Reference Library capture policy. |
| GET | /api/agent/projects/[projectId]/reference-library-bindings | List project Reference Library bindings and rights state. |
| POST | /api/agent/projects/[projectId]/reference-library-bindings | Attach a pinned Reference Library item version to a project artifact. |
| POST | /api/agent/projects/[projectId]/reference-library-bindings/[bindingId]/update | Dry-run or accept a newer Reference Library binding version. |
| DELETE | /api/agent/projects/[projectId]/reference-library-bindings/[bindingId] | Detach a project Reference Library binding while preserving local alternatives. |
| POST | /api/agent/projects/[projectId]/references/capture | Capture a saved project reference into the private draft Reference Library. |
| POST | /api/agent/projects/[projectId]/references/publish-captured | Publish an already captured private-draft project reference. |
| POST | /api/agent/projects/[projectId]/reset-pipeline | Reset pipeline state for scoped retries. |
| POST | /api/agent/pipeline/plan | Plan a pipeline run. |
| POST | /api/agent/pipeline/run | Run pipeline stages or a permitted retry. |
| GET | /api/agent/pipeline/status | Read 15-stage agent pipeline status. |
| GET | /api/agent/jobs/[jobId] | Read durable job state. |
| POST | /api/agent/jobs/[jobId] | Cancel a job. |
| GET | /api/agent/jobs/[jobId]/events | Stream job events as newline-delimited JSON. |
| POST | /api/agent/distribution/package | Generate or refresh a distribution package. |
| GET | /api/agent/distribution/package | Read distribution package status. |
| POST | /api/agent/distribution/thumbnails/upload | Upload and optionally replace a selected YouTube thumbnail. |
| POST | /api/agent/distribution/publish | Publish through a selected server-side connection. |
| GET | /api/agent/distribution/connections | List server-side distribution connections. |
| POST | /api/agent/distribution/connection | Select a distribution connection for publish. |
| POST | /api/agent/release-video | Create and optionally wait for an end-to-end release video run. |
| POST | /api/agent/release-video/preflight | Validate release-video readiness without mutating projects or starting paid work. |
Request and response envelopes
- Successful responses expose ok and data or a command-specific result field.
- Errors expose ok: false plus error.code, error.message, and optional error.details.
- Long-running operations return durable ids and may include an events URL for newline-delimited JSON progress.
- Synchronous runner steps may complete through JSON responses and should be followed by a status refresh.
Agent pipeline status
The status response includes stageOrder and stages using the 15-stage agent view:
- 01setup
- 02script
- 03references
- 04tts-script
- 05tts-render
- 06audio-sync
- 07specs
- 08veo
- 09compositions
- 10music
- 11render
- 12stitch
- 13audit
- 14distribution-package
- 15distribution-publish
- The human UI combines render and stitch under Render.
- The human UI combines distribution-package and distribution-publish under Distribution.
- The agent status API keeps those stages separate so automation can distinguish packaging, upload, render, and stitch failures.
The current order is setup, script, references, tts-script, tts-render, audio-sync, specs, veo, compositions, music, render, stitch, audit, distribution-package, distribution-publish. Async job steps stream or poll progress; synchronous runner steps return JSON and then need a status refresh.
Style Guide boundary
- Style Guide routes are not listed as Phase 1 agent API endpoints.
- Selected Style Guide is a project source artifact consumed by references, specs, video generation, compositions, music, audit, and conditional TTS script behavior.
- Style Guide changes can stale downstream stages through project freshness.
- Distribution is not a direct Style Guide consumer.
openapi.json status
openapi.json is planned for a later phase and is not linked in Phase 1.