Spec0docsCLI 0.7.0

Setup walkthrough

A guided, end-to-end tour of Spec0 — set up a team, publish your first API, connect an AI agent, add governance, and open it to the world. Every step explained, with recommendations along the way.

The Getting started page is the fast path — six commands, no explanation. This is the guided version: the same journey, but with the why behind each step, the decisions you'll face, and our recommendations for getting the most out of Spec0.

By the end you'll have a team that owns an API, an AI agent that can answer questions about it, automated quality gates, a live mock, and — if you want it — a public registry others can discover.

You don't have to start from zero. Every new org ships with a sample Pet Store API already published, linted, and MCP-queryable. If you just want to feel how Spec0 works before bringing your own spec, skip to step 4 and ask an agent about the Pet Store. The dashboard adapts as you complete each step below.

The mental model

Three nouns explain almost everything in Spec0:

  • Organisation — your company. The first person to sign up becomes the Org Owner and names the org on first run. You can belong to more than one organisation and switch between them. Billing, governance rulesets, and org-wide settings live here.
  • Team — a group inside the org that owns APIs (e.g. payments, growth). Teams approve subscriptions and mint service-account tokens. An API always belongs to exactly one team.
  • API — a published OpenAPI spec, versioned over time. Each version carries a quality score, a changelog, and a diff against the previous one.

Everything else — mocks, the MCP server, governance, the public registry — is a capability layered on top of those three. We'll set them up in the order you'd actually use them.


1. Create a team

APIs are owned by teams, not individuals — so the first thing to do is create the team that will own your work. A team gives you a clean ownership boundary, a place to invite collaborators, and the --team handle you'll pass to the CLI.

You can do this in the dashboard or the CLI:

Go to Teams in the left nav → New team. Give it a short, distinct name (payments, growth-api) and an optional one-line description. Then open the team and use Members → Invite to add at least one Team Admin — Team Admins can manage membership and mint tokens; Team Members get read/write on APIs.

spec0 team create payments

You'll need to be signed in first (step 2) and be an Org Owner or Org Admin. Invite members from the dashboard once the team exists.

The full walkthrough — roles, invites, and verification — is in the Create a team recipe. For the role model, see Access control.

Recommendation — mirror your code ownership, not your org chart. The teams that work best map to who owns the repository the spec lives in. If payments-service is one repo with one on-call rotation, that's one Spec0 team. Avoid one giant engineering team — it makes subscription approvals and governance meaningless.

2. Install the CLI

The CLI is how specs get into Spec0. Install it globally and authenticate once:

npm install -g @spec0/cli
spec0 --version
spec0 auth login          # opens a browser, stores creds in ~/.spec0/config.json

For CI and agents, set the SPEC0_TOKEN environment variable instead of an interactive login — see step 6.

3. Publish your first API

From a directory containing your openapi.yaml:

spec0 init                                  # detect the spec, write .spec0.yaml
spec0 push openapi.yaml --team payments     # publish, team-scoped & private

spec0 init writes a .spec0.yaml config that records which spec to publish and under which team — commit it so the same settings apply everywhere. spec0 push uploads the spec, computes a version, runs the lint, and produces a diff against the previous version.

push vs publish — the one distinction that matters. spec0 push keeps an API private to your org and team. spec0 publish registers it to the public registry with a shareable URL. Start with push — you can open an API to the public later (step 9) once it's stable. You can't easily un-share.

Recommendation — let Git drive publishing, don't push by hand. The single highest-leverage decision you'll make: wire spec0 push into CI so every merge to main republishes the spec automatically (we set this up in step 6). The git-native flow means your registry is never stale, breaking changes are caught in the PR that introduces them, and nobody has to remember to run a command. Manually governing and publishing APIs works, but the return on the git-native path is far higher — it's the difference between docs that drift and docs that are correct by construction. Treat the manual push above as a one-time bootstrap.

How the version is chosen: spec0 push reads the spec's info.version. Add --semver to auto-bump the patch component when the last version is valid semver, or --version <tag> to pin one explicitly. Re-pushing identical content is a no-op. The full model is in Versioning.

4. Connect an AI agent

This is where Spec0 starts paying off. Spec0 runs an MCP server so your coding agent can search and read your org's APIs directly — no copy-pasting specs into a chat window. The CLI writes the client config for you:

spec0 mcp install            # auto-detect Cursor / Claude / VS Code, write config
spec0 mcp url                # or print the endpoint to wire up manually

Because you're logged in, mcp install includes your auth header, so the org-scoped tools light up immediately. Restart your client and the Spec0 tools appear.

If you'd rather configure it by hand, point your client at https://api.spec0.io/mcp:

~/.cursor/mcp.json
{
  "mcpServers": {
    "spec0": {
      "url": "https://api.spec0.io/mcp"
    }
  }
}
claude mcp add --transport http spec0 https://api.spec0.io/mcp
.vscode/mcp.json
{
  "servers": {
    "spec0": {
      "type": "http",
      "url": "https://api.spec0.io/mcp"
    }
  }
}

These are the tools your agent gets once connected:

ToolWhat it doesInputs
get_api_changelogRead the changelog and breaking-change history for ONE of your organisation's APIs, by API id (UUID). Requires authentication. Three modes by argument: (1) no version args → the latest published version's changelog prose, its breaking-change summary, when it was published, the source (MANUAL vs AUTO_LLM), plus a short list of recent versions; (2) toVersion only → that version's stored changelog + breaking-change summary; (3) fromVersion AND toVersion → a LIVE diff computed across those two (possibly non-adjacent) versions, answering "what breaks if I upgrade from X to Y?" with a digest of breaking changes. Versions are matched by their tag (e.g. "1.2.0"). Unknown tags return a clean error. A version with no authored changelog still returns its breaking-change summary. Cite the returned url verbatim.apiId, fromVersion?, toVersion?
get_api_healthReport the quality/health of ONE of your organisation's APIs from its latest Spectral lint run, by API id (UUID). Requires authentication: sign in via your MCP client's OAuth browser flow (no token header). Returns an overall score (0–100, higher is better), the count of error/warning/info/hint findings, when it was last linted, the ruleset used, and a short digest of the top issues (severity-ordered) with rule code, message, and JSON path. Use this to answer "is this API healthy / spec-clean?", to decide whether a spec is ready to publish, or to surface the worst lint problems. If the API has never been linted you get an actionable state (run `spec0 lint <spec>`), not an error. Cite the returned url verbatim.apiId
get_api_ownerFind who owns ONE of your organisation's APIs, by API id (UUID). The OWNER is the team: the returned team id and name are the authoritative answer to "who owns this API?" or "who do I talk to about this endpoint?". Also returns the team's member count and the members' display names where available (names only — never email addresses; members with no display name set are omitted from the name list but still counted, so prefer the team name over individual names). Requires authentication. Scoped to your org: an API that belongs to another organisation reports "not found".apiId
get_api_specFetch a HIGH-LEVEL overview/index of ONE of your organisation's indexed APIs by its id (UUID). Requires authentication. Returns the API name, version, a citation URL, and — for small specs — the raw OpenAPI document. For large specs the raw body is omitted and a structured overview (title, version, server URLs, operation/schema counts, and the list of operations as method+path+operationId+summary) is returned instead, to keep the response bounded. Use this only to orient yourself or to count or list operations — NEVER to read full endpoint content. For the detail of a specific endpoint use search_operations then get_operation; for a schema/model use search_components. Optionally pass an environment name to get the spec that is current in that environment (e.g. 'staging' vs 'production'); omit it to get the API's latest spec.apiId, environment?
get_operationFetch the structured detail of ONE exact operation — a single HTTP method + path — from one of your organisation's indexed APIs. Requires authentication. Use after search_operations (or get_api_spec's overview) once you know the method and path: returns the operationId, summary, description, a compact list of parameters (name/in/required/type), a compact request-body view (media types + top-level field types), and the response codes with their descriptions — bounded to that one operation, never the whole spec. method is the HTTP verb (GET, POST, …); path is the exact template (e.g. /v1/refunds/{id}).apiId, method
list_apisList the OpenAPI specs YOUR organisation has indexed in Spec0, each with its id, name, version, and a one-line summary. Requires authentication. Use this to discover which APIs exist before calling search_apis or get_api_spec.
list_my_teamsList the teams in YOUR organisation, each with its id, name, and member count. Requires authentication. Scoped to your org — only your organisation's teams are returned, never another org's. Use this to discover team ids before calling get_api_owner or search_apis_by_owner, or to answer "what teams exist here?". Names and counts only — no member emails.
search_apisSemantic search across YOUR organisation's indexed OpenAPI specs (operations, schemas, descriptions). Requires authentication: sign in via your MCP client's OAuth browser flow (no token header). Returns up to top-k chunks with the API title, a citation URL into the Spec0 app, an excerpt, and a similarity score. Use this to answer questions about the caller's own APIs — what an endpoint does, which API owns an operation, etc. Optionally narrow to a single API with apiId. Cite the URLs verbatim.query, apiId?, topK?
search_apis_by_ownerList the APIs owned by ONE of your organisation's teams, by team id (UUID). Requires authentication. Returns the team name and each owned API's id, name, and version. Use after list_my_teams to answer "what does team X own?". Scoped to your org: a team that belongs to another organisation reports "not found" and never leaks its APIs.teamId
search_componentsSemantic search across the COMPONENTS (schemas/models — request and response data shapes) of ONE of your organisation's indexed APIs. Requires authentication. Use this for questions about a data model or type ("what fields does the Customer object have", "the shape of the error response") instead of fetching the whole spec. Returns just the matching component chunks (component name + the full grounded text). apiId is required; resolve it first with search_apis or list_apis if you only have a name.apiId, query, topK?
search_operationsSemantic search across the OPERATIONS (endpoints) of ONE of your organisation's indexed APIs. Requires authentication: sign in via your MCP client's OAuth browser flow (no token header). PREFER THIS over get_api_spec for any endpoint-specific question ("what does the refund endpoint do", "how do I create a charge") — it returns just the matching operation chunks (HTTP method, path, operationId, and the full grounded operation text) instead of the whole multi-MB spec. apiId is required; resolve it first with search_apis or list_apis if you only have a name.apiId, query, topK?
whoamiIdentify the authenticated caller behind the current Spec0 token: returns your organisation id, your user id, your team id (if you belong to one), and the token's granted scopes. Requires authentication: sign in via your MCP client's OAuth browser flow (no token header). Takes no arguments and reads nothing from the database — it just reflects the identity Spec0 resolved from your token. Use this first to confirm which org and team you are acting as before calling the other org-scoped tools. Anonymous or invalid-token callers get a structured "not authenticated" result, not an error.

Ask it something

Restart your client and try prompts like these — each maps to a tool above:

  • "Which of our APIs handles refunds, and what do I send to issue one?"
  • "List every endpoint in the payments API that creates a resource."
  • "What changed in the orders API between the last two versions? Anything breaking?"
  • "Generate a typed client for the createCharge operation."
  • "Who owns the inventory API and what's its current quality score?"

The agent searches your registry, reads the exact spec, and answers against your APIs — not a hallucinated guess. See API discovery for how this works under the hood.

Recommendation — make connecting the MCP server part of onboarding. The value compounds: the more of your APIs are in the registry, the more questions an agent can answer without a human in the loop. Add spec0 mcp install to your new-engineer setup script alongside cloning the repo.

5. Set governance rules at the org level

Now make quality automatic. Spec0 governance is built on Spectral rulesets — a set of lint rules every spec is checked against. Define the ruleset once at the org level and every team inherits it.

Go to Settings → API governance and either start from the Spec0 default ruleset or paste your own. Rules can require descriptions on every operation, ban additionalProperties: true, enforce naming conventions, mandate error response schemas — anything Spectral can express.

Each API version then gets a quality score (the percentage of rules it passes), surfaced on the dashboard and via the MCP get_api_health tool. See Governance for the ruleset format and scoring.

Recommendation — start loose, ratchet up. Turn on a small set of high-value rules first (descriptions required, error schemas required) so existing specs aren't drowning in warnings on day one. Once teams are green, add stricter rules. A ruleset that flags 200 problems on every spec gets ignored; one that flags the three that matter gets fixed.

6. Add quality gates with Spectral lint

Governance is only as good as its enforcement. Run the same ruleset in CI so a spec that drops below your bar fails the PR instead of silently landing:

spec0 lint openapi.yaml --org-ruleset --min-score 80 --strict
  • --org-ruleset uses the ruleset you defined in step 5 (not just the spec-local one).
  • --min-score 80 fails (exit code 7) if the quality score drops below 80.
  • --strict treats warnings as errors.

Wire it into GitHub Actions alongside the publish step — this is the git-native flow we recommended in step 3:

.github/workflows/spec0.yml
name: Spec0
on:
  push:
    branches: [main]
    paths: ['openapi.yaml']
  pull_request:
    paths: ['openapi.yaml']
jobs:
  spec0:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: '20' }
      - run: npm install -g @spec0/cli
      - run: spec0 lint openapi.yaml --org-ruleset --min-score 80 --strict
      - run: spec0 push openapi.yaml --team payments --semver
        if: github.ref == 'refs/heads/main'
        env:
          SPEC0_TOKEN: ${{ secrets.SPEC0_TOKEN }}
          SPEC0_ORG_ID: ${{ secrets.SPEC0_ORG_ID }}

spec0 ci generate github scaffolds this for you. To also block breaking changes, add spec0 diff --breaking-only — see the block-on-breaking-changes recipe and the full CI guide.

7. Spin up a mock

Every published spec can back a live mock server — no code, no infrastructure. Useful for frontend work before the backend exists, for integration tests, and for letting consumers try an API before you build it:

spec0 mock create --api my-api    # provision a mock (one-time key on first run)
spec0 mock url my-api             # print the base URL

Point your app at that URL and hit any path in the spec — you get realistic responses generated from the schema, always serving the latest published version. For response variants, conditional responses (CEL), and request validation, see Mock server.

8. Where the registry pays off

Once a few APIs are in the registry with governance and MCP connected, the use cases stack up:

Example prompts once your registry is populated

  • "I'm building a checkout page — which of our APIs do I need and in what order do I call them?"
  • "Find every API that touches PII and tell me which ones are missing an auth scheme."
  • "The orders API just bumped a major version — what broke and which of my calls need to change?"
  • "Scaffold a TypeScript SDK for the three payments operations I use most."

9. Open an API to the public registry

Everything so far has been private to your org. When an API is stable and you want others — partners, customers, the public — to discover and integrate it, publish it:

spec0 publish openapi.yaml --semver

This registers the API to the public registry with a shareable URL. Anyone can browse the spec, read the docs, and point the public MCP server at it for discovery. The same versioning, changelog, and quality score follow it to the public side. Keep publishing the same way (or via CI) and the public version tracks your latest.

Public is a one-way door in practice. Once an API is on the public registry, partners may already be integrating against it. Treat the first publish as a commitment to the contract — lock in your governance and breaking-change gates (steps 5–6) before you go public, not after.

Recommendation — public for distribution, private for everything else. Spec0 never gates discovery: publishing to the public registry, reading public specs, and installing public SDKs are free. Reach for publish when sharing is the goal — a partner API, a developer platform, an open standard. Keep internal services on push.

What's next

  • Concepts — the full mental model: registry, specs, versions, mocks, governance.
  • CLI reference — every command and the workflow guides.
  • Agents & MCP — go deeper on letting agents work over your registry.
  • Recipes — focused, task-sized guides (teams, tokens, subscriptions).
Was this helpful?

On this page