@scalar/cli
Scalar CLI
Validate, lint, bundle, mock, and preview OpenAPI and AsyncAPI documents from your terminal, then publish them to Scalar.

npx @scalar/cli document validate openapi.yaml
Documentation · Command reference · CI and scripting · Discord
Common tasks
Every example works with npx @scalar/cli in place of scalar if you have not installed the CLI.
Validate and lint an API description
scalar document validate openapi.yaml
scalar document lint openapi.yaml
scalar document lint openapi.yaml --rule .spectral.yaml
validate checks the document against the OpenAPI or AsyncAPI specification. lint applies Spectral rules and fails only on errors. Lint reports and baselines →
Lint multiple APIs
With no inputs, lint reads API entries from the existing Scalar configuration file:
# scalar.config.yaml
scalar: '2.0.0'
siteConfig: {}
navigation:
routes:
/pets:
type: openapi
filepath: ./apis/pets.yaml
/events:
type: asyncapi
filepath: ./apis/events.yaml
scalar document lint
scalar document lint --format json --output lint-report.json
scalar document lint --config docs/scalar.config.yaml
No aliases or --all flag are needed. The CLI discovers scalar.config or scalar.config.* in the current directory. If several files match, select one with --config. It reads APIs from every version and nested navigation group, including hidden entries, and processes each distinct file path or URL once. Local paths use the config directory and its optional root. Legacy config references and public Scalar Registry references are also supported; inaccessible sources are reported as failures.
To select inputs directly, pass files or URLs. These bypass config discovery and cannot be combined with --config:
scalar document lint apis/pets.yaml apis/billing.yaml
Each API uses the default rules for its OpenAPI or AsyncAPI format. --rule applies one explicit ruleset to every input; documentation publishing policies in the config do not change this command. Explicit ruleset, report, and ignore-file paths remain relative to the current directory.
All report formats support batches. JSON keeps the existing totals and problems fields, adds an api to each problem, and includes an apis list with each input's status (valid, invalid, or failed), counts, and execution error if any. Finding locations still point to the physical file, including shared $ref targets. A single explicit input retains its existing report shape.
The batch continues after an input fails and exits 1 if any API has error-level findings or cannot be linted; warnings alone exit 0. Execution failures appear as scalar-lint-execution errors in combined reports and are always shown. --max-problems limits lint findings across the whole batch without changing totals or exit status.
One ignore baseline applies to the batch, using the existing Scalar-first, Redocly-fallback discovery in the current directory. --generate-ignore-file updates successfully linted APIs and preserves entries for failed or unselected APIs. Findings are matched by physical source, rule, and pointer, so an ignore for a shared reference applies wherever it is used. Reports and baselines cannot overwrite selected inputs, their references, or the selected config.
Bundle split files into one
scalar document bundle openapi.yaml --output openapi.bundled.yaml
scalar document bundle openapi.yaml --output openapi.bundled.yaml --treeShake
scalar document bundle openapi.yaml --output openapi.bundled.yaml --keep-url-references
scalar document bundle openapi.yaml --output public.yaml --remove-unused-components
scalar document bundle openapi.yaml --output - > openapi.bundled.yaml
scalar document bundle openapi.yaml --output build/ --ext json
Pulls external $ref values into a single file, including references in extensions and custom schema keywords. Literal data in examples, defaults, enums, and const values stays unchanged. --treeShake retains its existing external-content tree shaking behavior. To remove unused root components as well, pass --remove-unused-components independently or together with --treeShake. This opt-in option supports OpenAPI 2.0 and 3.x and can be combined with --keep-url-references. Generic and AsyncAPI documents reject it. The input can be a URL.
Use --keep-url-references (or -k) to retain authored absolute HTTP(S) $ref values, including fragments, without fetching their targets. Local files and internal pointers are still bundled. This does not make bundling offline: URL inputs and relative references with an HTTP(S) base, including an HTTP(S) $id on a local schema, are still fetched.
Bundled schema identities and anchors retain their meaning when the output moves. Relative local schema identities become absolute file: URIs, so they can include source paths; requested URL maps also retain source locations. Preserved references do not require --force. Tree shaking is skipped when a preserved reference names an indexed resource, so that its target stays in the bundle.
Bundle output uses .json, .yaml, or .yml filename suffixes to select the format. --ext json|yaml|yml overrides the format and replaces recognized output suffixes; other suffixes are retained before appending the selected extension. New extensionless output names receive .yaml by default; unrecognized suffixes keep their filename and JSON format unless --ext is supplied.
Existing files without --ext and special destinations (devices and pipes) retain their exact path. Special destinations are written directly. Regular files are replaced atomically, preserving ownership and permissions; both the file and its parent directory must be writable. If ownership transfer is denied for a shared writable file, it is updated in place to preserve ownership; this fallback is not atomic. Hard-link aliases retain the old contents after atomic replacement.
Existing output directories and paths ending in a separator receive an input-derived filename. Missing parent directories are created. URL inputs use a decoded, filename-safe pathname basename, or openapi when no basename exists. Missing symlink-target parents are not created.
When the destination resolves to the input, interactive local use confirms overwriting the original input path in its original format. An incompatible --ext requires --output. URLs and non-interactive use always require --output. Exact --output - preserves the root document’s JSON or YAML format, detected from its contents, unless overridden with --ext; diagnostics go to stderr.
Unresolved references fail without changing the output file. Use --force (or -f) to write an incomplete bundle with warnings and unresolved references retained. For this command, --force only permits unresolved references; it does not skip the overwrite confirmation when --output is omitted. Tree shaking and unused-component removal are skipped with diagnostics when forced reference errors make reachability uncertain. Unreadable or unparseable input, serialization errors, and write errors still fail with --force.
Unused-component removal starts from API entry points and follows transitive references, security requirement names, discriminator mappings and inherited subtypes. It keeps reachable cycles and removes unreachable cycles, including unused bundled content under x-ext, without renaming components or moving pointers. The pass follows bundled references in reachable extensions and custom schema keywords, respects schema identifiers and anchors, and treats examples and other literal values as data. It keeps the full bundle and warns if it cannot check the pruning graph, pruning would break a bundled reference, or a reachable preserved external reference cannot be resolved within the bundle. The pass does not fetch remote references.
Bundle multiple APIs
scalar document bundle pets.yaml events.json --output build/bundles
scalar document bundle pets.yaml https://example.com/events.yaml --output build/bundles --ext json
# Bundle every API in the existing Scalar configuration
scalar document bundle --output build/bundles
scalar document bundle --config docs/scalar.config.yaml --output build/bundles
Omit inputs to use the same Scalar configuration discovery, path resolution, and API entries as document lint. Explicit files or URLs bypass discovery and are processed once each, in argument order. Explicit inputs cannot be combined with --config. Named API aliases are not required.
Multiple inputs and configuration-driven invocations require --output <directory>, including when the config contains only one API. The directory may already exist or is created when a bundle is written. Each bundle uses the input basename and the existing format and --ext rules described above. URL basenames are decoded and sanitized. For example, pets.yaml events.json --output build --ext json writes build/pets.json and build/events.json. For configured APIs whose derived names collide, use the first configured route for each source as the filename stem, prefixed by its version and group routes, joined with - and sanitized for filenames. For example, /pets and /events pointing at separate openapi.yaml files write pets.yaml and events.yaml; the same /api route in versions v1 and v2 writes v1-api.yaml and v2-api.yaml. Distinct input-derived names stay unchanged. A batch cannot write to stdout; one explicit input keeps the existing file, directory, stdout, and overwrite-confirmation behavior.
Destination names must be distinct, compared without case and after Unicode normalization, including after --ext normalization. Collisions with another bundle, a selected input, a loaded local reference, or the configuration fail the entire batch before any bundle is written. Symlink and hard-link aliases are checked too. If a source path cannot be inspected to verify collision safety, the entire batch fails before writing. Uninspectable output paths fail only their own API. If configured route names still collide after sanitization, the batch fails too. Choose distinct source basenames or configured routes, or bundle colliding APIs individually with different output filenames. Existing unrelated regular output files are replaced using the same write behavior as single-input bundling; --force does not bypass collision protection.
Independent read, parse, reference, serialization, or write failures identify the API on stderr and do not prevent other APIs from producing bundles. Successful outputs remain; APIs that fail before writing leave their existing outputs unchanged. The command exits 1 if any API fails and 0 if all succeed. With --force, unresolved references produce incomplete bundles with warnings and count as success, as they do for a single input. Batch result messages go to stderr.
For CI, the noninteractive command below bundles every configured API, creates separate JSON outputs, and fails the job if any API cannot be bundled:
- name: Bundle API descriptions
run: npx --yes @scalar/cli document bundle --config scalar.config.yaml --output artifacts/bundles --ext json --no-input
Generate public and environment-specific variants
scalar document transform api.yaml --config public-production.yaml --output public.yaml
scalar document transform api.yaml --config private-staging.yaml --output private.json
scalar document transform api.yaml --config public-production.yaml --output -
Transform accepts JSON/YAML Swagger 2.0, OpenAPI 3.0–3.2, and AsyncAPI 2.x/3.x descriptions supported by Scalar's validators. It preserves the document version. Configuration is a JSON or YAML file; it is never executed as code. Input, configuration, and referenced source files cannot be overwritten, including through symlinks or hardlinks. Output is required. Distinct existing output files must be writable. Regular files are replaced atomically after validation, preserving ownership and permissions; if ownership transfer is denied for a shared writable file, it is updated in place instead. Use .json, .yaml, or .yml; stdout retains the input format, with diagnostics on stderr.
Example public-production.yaml:
version: 1
steps:
- type: remove-internal-operations
- type: set
pointer: /servers
value:
- url: https://api.example.com
- type: set
pointer: /info/title
value: Public API
removeUnusedComponents: true
For a private staging variant, omit remove-internal-operations and change the server to https://staging.example.com. Swagger 2.0 uses set steps for /host (staging.example.com), /basePath (/v1), and /schemes ([https]). AsyncAPI 2.x uses a /servers map, such as {staging: {url: staging.example.com, protocol: amqp}}; AsyncAPI 3.x uses {staging: {host: staging.example.com, protocol: amqp}}. Existing path-, operation-, or channel-level overrides remain unchanged: edit those explicitly, for example /paths/~1pets/servers in OpenAPI or /paths/~1pets/get/schemes in Swagger 2.0. AsyncAPI 2.x channel server-name lists must still name entries in the replacement map; AsyncAPI 3.x channel server references must still resolve.
Steps run in listed order against the bundled document. set adds or replaces the value at an exact JSON Pointer; it does not merge objects or append arrays. remove deletes an exact target. Escape / as ~1 and ~ as ~0 in pointer segments. Parents and array indices must already exist, and removals must match. Root replacement and prototype paths are rejected. Example metadata removal: {type: remove, pointer: /info/x-internal-notes}. Examples and other literal data are only edited when explicitly targeted.
remove-internal-operations removes operations marked x-internal: true, including operations under internal paths/channels. It covers OpenAPI paths, webhooks, callbacks and reusable components/pathItems (even without component pruning); Swagger paths; AsyncAPI 2.x publish/subscribe; and AsyncAPI 3.x operations. Matching nothing is a successful no-op. Unused reusable content remains unless removeUnusedComponents: true is set. That option follows references, security schemes and discriminator mappings, preserves reachable cycles, and removes unused reusable content; AsyncAPI 3.x channels are retained through their operations. This is not a guarantee that all confidential text has been removed: explicitly remove any other private metadata or examples.
The sequence is source loading/reference inspection, bundling without pruning, ordered edits on a copy, optional pruning, reference/format validation, then serialization and output. Unresolved source references fail even when a later filter would remove them. Invalid configuration, missing targets, dangling retained references and invalid final descriptions fail without changing the destination. There is no incomplete-output mode. Source formatting and YAML comments are not preserved. Identical source graphs, configuration and CLI versions produce deterministic output; remote URLs must be pinned by the caller for reproducible builds. Dynamic references retain matching dynamic anchors conservatively. Their targets must resolve within the bundled graph; unresolved targets and unsupported $recursiveRef semantics fail before writing. This configuration is not OpenAPI Overlay or a plugin API.
Format files or piped input
scalar document format openapi.yaml
scalar document format openapi.json --output -
cat openapi.yaml | scalar document format - --output openapi.json
cat openapi.json | scalar document format -
cat openapi.json | scalar document format - --output -
Use - to read JSON or YAML from stdin and --output - to write only document content to stdout in the input’s JSON or YAML format, with diagnostics and timings on stderr. Without --output, stdin is formatted to stdout in its original JSON or YAML format. JSON input produces two-space JSON; YAML input produces YAML. URL inputs require an explicit output destination. Named output files use YAML for .yaml or .yml extensions (case-insensitive), and two-space JSON otherwise. Without --output, a local input file is overwritten in place. Use ./- to refer to a file literally named -.
Preview the API reference
scalar document serve openapi.yaml --watch
Serves an interactive API reference that reloads as you edit. Pass --config reference.json for API Reference options.
Mock the API
scalar document mock openapi.yaml --watch
Starts a mock server that answers with the examples and schemas in your document, so you can try requests before the API exists.
Upgrade and convert
scalar document upgrade swagger.json --output openapi.json
scalar document convert postman-collection.json --output openapi.json
Upgrades Swagger 2.0 and OpenAPI 3.0 to OpenAPI 3.1, and converts Postman collections to OpenAPI.
Publish to Scalar
scalar auth login
scalar registry publish openapi.yaml --namespace acme --slug my-api --version 1.0.0
scalar project preview
scalar project publish --slug my-docs
Push API descriptions to the Scalar Registry, preview a Scalar Docs project locally, and publish it. In CI, run scalar auth login --token <token>, or set SCALAR_API_KEY and run scalar auth login.
Compare schemas
scalar schema diff acme/widget@1.0.0 acme/widget@2.0.0
scalar schema diff acme/widget@1.0.0 acme/widget@2.0.0 --verbose
scalar schema diff acme/widget@1.0.0 acme/widget@latest --json
# CI: fail the job if the local schema drifted from what is published
scalar schema diff acme/widget@latest ./widget.json --check --verbose
scalar schema diff acme/widget@latest ./widget.json --check --quiet --ignore /description /examples
Each side is a published schema (namespace/slug@version, where the version defaults to latest), a file, or a URL. Both sides are parsed and compared structurally, so formatting, key order, and JSON versus YAML never count as changes. The order of items in an array, including required, enum, and type, does count. Changes are listed by JSON Pointer into the documents as written. An existing path always counts as a file: prefix ./ to force a file, or add @latest to force the Scalar Registry. --ignore <pointer...> skips changes at or under a JSON Pointer, so /properties/legacy also skips /properties/legacy/type but not /properties/legacyId. A change above the pointer, such as all of /properties being added, is still reported in full. Put it after the two schemas.
Manage Scalar-hosted MCP servers
scalar mcp list --json --no-input
scalar mcp create --name Petstore --api acme/petstore --json --no-input
scalar mcp create --name Docs --project <project-uid> --json --no-input
scalar mcp get <server-uid> --json --no-input
scalar mcp update <server-uid> --name 'Public API' --no-input
scalar mcp delete <server-uid> --yes --no-input
Use server UIDs from mcp list for get, update, and delete. Creation accepts exactly one existing Scalar Registry API (namespace/slug) or Scalar Docs project UID (project list --json). The server builds from the API's versions and serves the latest unless a current version is set in Scalar Dashboard. Docs projects follow their active publish. API tool exposure follows the API description and the server uses the same default additional headers as servers created in Scalar Dashboard.
Creation reports a created server, without waiting for endpoint readiness. mcp get reports each environment's served version, or null when none is served; a version is not a health check. After an interrupted create, inspect mcp list before repeating the command. Changing a slug changes its address. Deletion stops the server's endpoints; --yes explicitly confirms deletion and is required in JSON or noninteractive mode.
JSON server metadata contains uid (server UID), name, namespace, slug, and url. list returns an array of that metadata; update returns one object. create adds status: "created". get adds an environments array with name, version, and url. delete returns { "uid": "…", "deleted": true }. Tool configuration and credentials are excluded. Errors use stderr and a nonzero exit code.
Addresses use https://mcp.scalar.com by default. Set MCP_URL to the MCP host for a nonproduction deployment, alongside the CLI's BASE_URL service setting. These commands manage hosted servers; they do not start a local MCP runtime.
Install
Standalone binary, no Node.js required:
# macOS and Linux
curl -fsSL https://cdn.scalar.com/cli/install.sh | bash
# Windows (PowerShell)
irm https://cdn.scalar.com/cli/install.ps1 | iex
Or with npm:
npm install --global @scalar/cli
Run scalar upgrade to upgrade a verified global npm installation, including the installed and latest available versions. Project-local, temporary, other-package-manager, and portable installations receive matching instructions without installing anything. The command verifies the version at the target before reporting a completed upgrade. If installation ownership cannot be determined, it explains the limitation and exits with code 1 when an update is available; use the original package manager or installer for that copy. Use scalar upgrade --check to check without installing, or scalar upgrade --json for machine-readable results. These check modes can report versions successfully even when installation ownership is unknown; their instructions explain the limitation. When already up to date, installation probes are skipped and JSON instructions is empty. Package-manager probes run from the home directory with project overrides disabled. The JSON distribution field identifies the release channel (npm or portable), not the package manager. Version checks return exit code 1 when the release service cannot be reached or returns invalid data. scalar --version remains an offline check of the installed version.
Git ships an unrelated scalar executable. If it gets in the way, use npm's scalar-cli alias, or run npm install --global --force @scalar/cli to replace it. The installation guide covers upgrades and shell completion.
Use with AI agents
scalar context prints every command, argument, option, default, and choice as JSON, plus notes on running without prompts. Point your agent at it instead of --help:
scalar context
The package also ships an Agent Skill at skills/scalar-cli/SKILL.md. Copy it into your project:
mkdir -p .claude/skills
cp -r "$(npm root -g)/@scalar/cli/skills/scalar-cli" .claude/skills/
Noninteractive execution
Pass --no-input in scripts and agent commands, including when a pseudo-terminal (PTY) is attached:
scalar --no-input project create --name "My docs"
scalar project rollback --slug my-docs --yes --no-input
scalar document bundle openapi.yaml --output - --no-input
The flag works before or after subcommands. It disables prompts and browser launches. Supply required arguments or options; missing input exits with code 1 and explains what to provide. Optional values retain their defaults, including the generated project slug. Piped data is never read as confirmation.
--no-input does not imply --yes (confirm an action) or --force (override a specific protection). Neither flag chooses an unspecified target. Prompt cancellation, Ctrl-C during a prompt, and EOF exit with code 1 and “Operation cancelled.”
For auth login, supply a personal token using the existing SCALAR_API_KEY source or --token; without one, noninteractive login fails before starting a browser or callback server. project preview still runs the requested preview server but never opens its browser under --no-input, even with an opening option. readme prints the documentation URL without launching a browser.
An explicit --token takes precedence over SCALAR_API_KEY. An empty or whitespace-only --token fails without falling back to the environment or browser login. With no flag, environment-only authentication remains supported; an unset or empty environment value uses browser login, or fails under --no-input.
Compatibility: login previously preferred SCALAR_API_KEY when both sources were supplied. Scripts that rely on the environment credential must omit --token. The selected credential is saved for later commands.
Use in CI
# .github/workflows/openapi.yml
name: OpenAPI
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
- run: npx --yes @scalar/cli document lint --format github-actions
The CI command lints every API in scalar.config. --format github-actions turns findings into annotations on the pull request. JSON output, JUnit reports, and lint baselines →
To fail a job when a schema in the repository drifts from the published version, run schema diff with --check. --verbose prints every changed value to the job log, and a distinct exit code such as --check 2 lets the job tell schema drift apart from an authentication or network error, which exit 1:
steps:
- uses: actions/checkout@v6
- run: npx --yes @scalar/cli auth login
env:
SCALAR_API_KEY: ${{ secrets.SCALAR_API_KEY }}
- run: npx --yes @scalar/cli schema diff acme/widget@latest ./widget.json --check 2 --verbose
schema diff invocation |
Identical | Differ | Error (authentication, download, parse, bad input) |
|---|---|---|---|
no --check |
exit 0 | exit 0 | exit 1 |
--check |
exit 0 | exit 1 | exit 1 |
--check <n> (1–125) |
exit 0 | exit n | exit 1 |
Put --check after the two schemas, or write --check=<n>: an optional value takes the next argument, so --check acme/widget@1.0.0 … is rejected. Errors always print to stderr, even with --quiet. To tell a difference from an error without a distinct code, read identical from --json.
Commands
| Command | Description | Subcommands |
|---|---|---|
scalar auth |
Log in to Scalar and manage your session | login, whoami, logout |
scalar access-group |
Manage access groups, allowed emails and domains for the current team | list, create, get, update, delete, domain add, domain remove, email add, email remove |
scalar document |
Work with OpenAPI and AsyncAPI descriptions | bundle, transform, split, join, format, convert, markdown, mock, serve, share, validate, void, lint, upgrade |
scalar project |
Manage Scalar Docs projects | list, get, init, check-config, create, preview, publish, rollback, deployments list, deployments get, upgrade |
scalar mcp |
Manage Scalar-hosted MCP servers | list, get, create, update, delete |
scalar registry |
Manage API descriptions in the Scalar Registry | publish, update, delete, list, get |
scalar team |
List and switch between your Scalar teams | list, get, set |
scalar sdk |
Manage Scalar SDKs (Enterprise only) | list, get, create, update, delete, build, download |
scalar schema |
Manage shared schemas in the Scalar Registry | delete, update, list, get, publish, diff |
scalar readme |
Open CLI documentation in your browser | generate |
scalar upgrade |
Upgrade the Scalar CLI to the latest version | |
scalar context |
Print every command, argument, and option as JSON for AI agents | |
scalar completion |
Generate shell completion definitions |
Run scalar <command> --help for options, or see the command reference.
Authentication details
Run scalar auth whoami to show your email, current team name and ID, role, and
authentication method (browser session or personal token). Use
scalar auth whoami --json for structured output with email,
team: { uid, name }, role, and authentication (browser_session or
personal_token). If the team name cannot be loaded, the team ID remains
available and JSON returns null for the name. Missing email or role values
also return null. Credentials are never included.
Recover a project publish
scalar project publish --slug my-docs prints the accepted Build ID before waiting up to 600 seconds for deployment. Use --timeout <seconds> to change the wait (positive seconds, at most 2147483), or --no-wait to return immediately after acceptance. Do not combine --no-wait with --timeout.
Inspect the same production or preview build with the original team selected, without publishing again:
scalar project deployments get BUILD_ID
scalar project deployments get BUILD_ID --wait --timeout 600
A one-shot inspection waits at most 30 seconds for its request unless overridden. It exits zero when the record was read, even if that record reports a failed build. With --wait, zero means deployed; a failed build, unavailable status, or expired deadline exits nonzero. publish --no-wait exits zero for acceptance, not completed deployment.
A status-query error or timeout means the outcome is unknown. Stopping local waiting, including Ctrl-C, does not cancel the remote build. Use the printed Build ID to inspect it later instead of resubmitting.
With publish --json, successful waiting returns one deployment result. With --json --no-wait, acceptance returns {uid: string, status: "accepted"}. JSON mode writes no progress to stdout; failures and recovery instructions go to stderr.
Structured command results
Pass --json explicitly for machine output. Human output remains the default,
including when redirected. Success writes one newline-terminated JSON value to
stdout with exit code 0. Empty lists write []. Failures write human-readable
diagnostics to stderr, exit nonzero, and do not write a success result to stdout.
JSON output contains no progress, colors, links, or upgrade notices. In JSON
mutation mode, missing inputs fail with the required flag instead of prompting,
even in a terminal.
List contracts
| Command | JSON value |
|---|---|
team list --json |
Array of {uid: string, name: string, current: boolean} |
registry list --json |
Array of {namespace: string, slug: string, title: string, version: string, isPrivate: boolean} |
schema list --json |
Array of {namespace: string, slug: string, title: string, version: string | null, isPrivate: boolean} |
sdk list --json |
Array of SDK metadata objects described below |
sdk get --slug <slug> --json |
One SDK metadata object |
schema diff <from> <to> --json |
{from: string, to: string, identical: boolean, changes: Array<{type: "added" | "removed" | "changed", path: string, before?: unknown, after?: unknown}>} |
Schema version is the greatest version by semantic-version comparison, or
null when no version exists. Registry version is the current version.
List order is unspecified. These list commands have no pagination flags,
continuation tokens, or incremental output: each invocation returns a single
array from the selected team or namespace. Do not interpret an empty array as
an authentication failure; authentication failures exit nonzero.
SDK metadata fields:
| Field | Type |
|---|---|
uid, namespace, slug, title, description, currentVersion |
string |
isPrivate |
boolean |
createdAt, updatedAt |
number, Unix seconds |
api |
null or {uid: string, namespace: string | null, slug: string | null} |
current |
Object mapping each language with a current build to the version label a request without one serves |
targets |
Array of {language: string, slug?: string} |
versions |
Array of version objects below |
latestBuild |
Latest build by creation time, or null when no build exists |
Versions are listed highest label first. Each version has version: string,
createdAt: number, languages: string[] (the declared languages it serves a
build for), and targets, an array of
{language: string, activeBuild: string, builtAt: number | null}.
Each latest build has uid: string, version: string, createdAt: number,
api: {uid: string, namespace: string, slug: string, version: string}, and
targets, an array of
{language: string, slug?: string, buildStatus: string, failedStage: string | null, gitStatus: string | null}.
currentVersion is current as one label, the highest when languages differ.
All timestamps are Unix seconds. Optional target slugs are omitted when absent;
nullable fields are emitted as null. Source API coordinates are null when
the linked API no longer exists. SDK JSON fails if required build or source
metadata cannot be loaded. It excludes configuration, credentials, repository
authentication bindings, and build log messages.
Mutation contracts
Command with --json |
Success object |
|---|---|
registry publish, schema publish |
{uid, namespace, slug, version} |
registry update |
{namespace, slug, status: "updated"} |
registry delete |
{namespace, slug, deleted: true} |
schema update, sdk update |
{uid, namespace, slug, status: "updated"} |
schema delete, sdk delete |
{uid, namespace, slug, deleted: true} |
sdk create |
{uid} |
sdk build |
{uid, namespace, slug, version, status: "started"} |
All identifiers, coordinates, versions and status values are strings. SDK
build version is the API document version the build builds. deleted is a
boolean. Fields shown in each success object
are always present. A build receipt means the server accepted the build request,
not that generation finished; no build ID is returned by that endpoint.
SDK create returns the new SDK UID without an additional metadata request.
Updates and deletes acknowledge the resolved target; they are not resource
snapshots. A transport failure can leave a mutation's outcome unknown, so inspect
the resource before retrying a write.
Supply the existing targeting flags and arguments, for example:
scalar registry list --namespace acme --json
scalar registry update acme widgets --title "Widgets API" --json
scalar schema publish schema.json --namespace acme --slug widget --title Widget --version 1.0.0 --json
scalar sdk create --namespace acme --api widgets --language typescript --json
scalar sdk build --namespace acme --slug widgets --json
Team list UIDs can be passed directly to scalar team set --team <uid> when
using browser-session authentication. Personal tokens belong to one team and
cannot switch teams. Registry/schema list coordinates and SDK list slugs can
likewise be passed to their mutation commands.
Team and project results
The same explicit JSON mode, stdout/stderr separation, and noninteractive input rules apply to the following commands. Existing team and project list/get output is preserved.
Command with --json |
Result |
|---|---|
team set --team <uid> |
{uid: string, name: string, current: true} after switching the session |
project create --name <name> |
{uid: string, slug: string, name: string}; an omitted slug is generated by the server |
project init --subdomain <name> |
{configPath: string, subdomain: string, files: string[], availabilityChecked: boolean} |
project upgrade [config] |
{configPath: string, changed: boolean, files: string[], dropped: string[]} |
project publish --slug <slug> |
{uid: string, status: "deployed", url: string | null, preview: boolean, hasWarnings: boolean} |
project rollback --slug <slug> --yes |
{uid: string, projectUid: string, slug: string, status: "redeployed" | "already-live"} |
project deployments list --slug <slug> |
Array of {uid: string, status: string, current: boolean, createdAt: number, deployedAt: number | null, commitSha: string | null} |
Project init and upgrade return absolute paths. files lists the files written.
Initialization's availabilityChecked: false means no authenticated subdomain
availability check was performed, not that the subdomain was reserved.
Initialization checks the configuration, docs-quickstart.md, and
docs-openapi.json before writing any project file. If any destination exists,
an interactive session asks once before replacing the listed conflicts. Without
an interactive terminal, rerun with --force to replace all three init files; --json and --no-input do not authorize replacement. Directories and
symlinks are rejected even with --force.
Files are staged before installation. A handled write failure rolls back this
initialization's changes. If restoration fails, the command exits with an error
and reports where recovery files were retained. It does not guarantee recovery
after a process crash or power loss. If only staging-directory cleanup fails,
initialization succeeds with a warning. JSON output includes an optional
warnings array with the retained directory path.
An already-current config upgrade returns changed: false, files: [], and
dropped: []. A completed upgrade reports settings without a v2 equivalent in
dropped.
By default, project publish waits for the deployment to finish in both output modes.
With --no-wait, it returns after acceptance; JSON output is {uid: string, status: "accepted"}.
Its uid is the build ID. url is null when no public URL can be resolved.
Warnings about local configuration are sent to stderr; build warnings are
reported by hasWarnings. Failed or cancelled builds exit nonzero without a
success object. The behavior also applies to --github and --preview.
Rollback requires --yes before changing the live deployment. JSON does not
supply confirmation. already-live is a successful no-op and performs no
redeploy request; redeployed acknowledges a successful redeploy request.
Deployment history includes production builds only, newest creation time first,
with no pagination flags or continuation tokens. Empty history is [].
Timestamps are Unix seconds; older records without a deployment timestamp use
deployedAt: null. The full uid can be passed to rollback's --to:
scalar project deployments list --slug docs --json
scalar project rollback --slug docs --to <build-id> --yes --json
Existing project list --json returns an array sorted by slug, while
project get <slug> --json returns one object. Each object contains
uid, name, and slug (strings), isPrivate (boolean), provider
(github, forgejo, bitbucket, or unlinked), repository (null or
{name: string, branch: string, configPath: string}), and activeDeployment
(null or {uid: string, domain: string, publishedAt: number}, with Unix seconds).
Project listing follows service continuation cursors internally and prints no
partial list if a cursor or fetch fails. It merges legacy projects, preferring
unified projects with the same UID or slug.
Existing access-group contracts
Access-group JSON formats remain unchanged:
Command with --json |
Result |
|---|---|
access-group list |
Array of group metadata objects; empty [] |
access-group get <slug> |
One group metadata object |
access-group create <slug> |
Group metadata plus createdAt and updatedAt (numbers, Unix seconds) |
access-group update <slug> |
null after success |
access-group delete <slug> --yes |
null after success |
access-group domain add <slug> <domain> |
null after success |
access-group domain remove <slug> <domain> |
null after success |
Group metadata is {uid: string, name: string, slug: string, allowedDomains: string[], allowedEmails: string[]}. Ordering is unspecified;
no pagination flags or continuation tokens are exposed. Deletion requires
--yes in JSON mode even in a terminal. A successful null response is an
acknowledgement, not an empty list or a failed lookup; failures use stderr and a
nonzero exit status.
Long-running project preview, configuration validation, and raw file downloads
are not mutation-result streams and do not gain --json from this feature.
File and download failures
URL input for document format, upgrade, markdown, mock, serve, postman, and share, plus Registry and schema publish input, has a 10-second download deadline. registry get and schema get use the same deadline. It includes reading the response body, but is not a total command runtime limit. Downloads are not automatically retried.
File and download failures report the input, a known cause when available, and a recovery step on stderr, with exit code 1. Diagnostic URLs omit credentials, query strings, and fragments. Remote error bodies are not echoed because they may contain credentials; HTTP status remains available. Successful document output is unchanged.
Access-group emails
scalar access-group email add partners alex@example.com
scalar access-group email remove partners alex@example.com --json
scalar access-group get partners --json
These commands manage individual addresses in the current team's access group by slug. Addresses are lowercased; repeated adds and removals are safe to retry. Both mutations support --json, print null on success in JSON mode, and require no confirmation prompt. Invalid addresses and API failures exit nonzero. If a request times out, inspect the group with get --json to check whether the change completed.
No invitation is sent and no team membership is created. Removing an email preserves independent grants from domains, other groups, and team membership.
Download an SDK or generated CLI
Export an exact build target with your existing scalar auth login session:
scalar sdk get --slug widgets --json
scalar sdk download --slug widgets --language cli --build <build-uid> --output ./widgets-cli.zip --json
Pass --namespace to select a namespace other than the team's default. The language, build UID, SDK slug, and output path are required. The output is a ZIP archive; the parent directory must exist and existing files are never overwritten. Failed downloads remove temporary files and return a nonzero exit status. Unavailable builds, languages, or artifacts and authorization failures also return nonzero.
JSON success contains uid, namespace, slug, language, build, artifactBuild, version, api (uid, namespace, slug, version), absolute output, bytes, and sha256. artifactBuild identifies the original artifact when a build reused earlier generated output. sha256 hashes the downloaded ZIP bytes. Private artifacts remain private and require no separate Scalar Registry login or GitHub token.