Buildspace
CLI

JSON Output

Use the --json flag for machine-readable CLI output.

Key CLI commands support a --json flag that outputs structured JSON instead of human-readable text. This is useful for scripting, CI pipelines, and LLM agent integrations.

Supported Commands

buildspace app list --json

{
  "apps": [
    { "id": "app_123", "slug": "my-app", "name": "My App" }
  ],
  "activeApp": { "slug": "my-app" }
}

buildspace whoami --json / buildspace auth status --json

{
  "authenticated": true,
  "authMethod": "pat",
  "apiUrl": "https://creator.buildspace.studio",
  "gitUrl": "https://api.buildspace.studio",
  "token": {
    "name": "AI Agent — 5/30/2026",
    "keyPrefix": "bs_pat_ab",
    "accessMode": "unrestricted",
    "apps": [],
    "expiresAt": "2026-08-28T00:00:00.000Z"
  }
}

Exit code 1 when unauthenticated (see Error output below).

buildspace app create --name "My App" --json

Exits immediately after the API call — no provisioning wait. Includes provisioningSession.id for downstream polling.

{
  "app": { "id": "app_123", "slug": "my-app", "name": "My App" },
  "environments": [
    { "id": "env_1", "type": "dev" },
    { "id": "env_2", "type": "prod" }
  ],
  "keys": [
    { "environment": "dev", "type": "secret", "key": "bs_secret_..." }
  ],
  "provisioningSession": { "id": "ps_456", "status": "running" }
}

This is the easiest way to capture the generated slug programmatically.

buildspace app status [<slug>] --json

{
  "app": { "id": "app_123", "slug": "my-app", "name": "My App" },
  "hosting": {
    "dev": { "status": "active", "url": "https://my-app.buildspace.dev" },
    "prod": { "status": "disabled", "url": null }
  }
}

buildspace deploy status --json

{
  "app": {
    "id": "app_123",
    "name": "My App",
    "slug": "my-app"
  },
  "environments": [
    {
      "environment": "dev",
      "status": "success",
      "url": "https://my-app.buildspace.dev",
      "latestDeployment": {
        "id": "dep_abc",
        "status": "success",
        "trigger": "git_push",
        "createdAt": "2025-01-15T10:30:00Z",
        "deploymentUrl": "https://my-app.buildspace.dev",
        "errorMessage": null
      }
    }
  ],
  "deployments": [
    {
      "id": "dep_abc",
      "status": "success",
      "trigger": "git_push",
      "createdAt": "2025-01-15T10:30:00Z",
      "deploymentUrl": "https://my-app.buildspace.dev",
      "errorMessage": null,
      "environment": "dev"
    }
  ]
}

buildspace deploy history --json

{
  "app": {
    "id": "app_123",
    "name": "My App",
    "slug": "my-app"
  },
  "deployments": [
    {
      "id": "dep_abc",
      "status": "success",
      "trigger": "git_push",
      "createdAt": "2025-01-15T10:30:00Z",
      "deploymentUrl": "https://my-app.buildspace.dev",
      "errorMessage": null,
      "environment": "dev"
    }
  ]
}

buildspace env list --json

{
  "variables": [
    { "key": "BUILDSPACE_SECRET_KEY", "value": "bs_secret_...", "isSecret": true, "source": "system" },
    { "key": "STRIPE_KEY", "value": "sk_test_...", "isSecret": true, "source": "creator" }
  ]
}

buildspace app hosting status --json

{
  "environments": [
    { "envType": "dev", "status": "active", "url": "https://my-app.buildspace.dev" },
    { "envType": "prod", "status": "disabled", "url": null }
  ]
}

Error output

When a command is called with --json and fails, the error is written to stderr as structured JSON. Branch on code without string-matching:

{ "error": "App not found", "code": "NOT_FOUND" }
CodeWhen
AUTH_REQUIRED401 / 403 — token missing, expired, or revoked
NOT_FOUND404 — app or resource does not exist
ALREADY_EXISTS409 — slug or resource already taken
PROVISIONING_FAILEDProvisioning reached a failed terminal state
NETWORK_ERRORFetch failure or unexpected 5xx

Usage with LLMs

When building agents or automations that interact with Buildspace, always use --json to get reliable, parseable output:

# Verify auth before running commands
buildspace whoami --json | jq '.authenticated'

# Create an app and capture the slug
BUILDSPACE_TOKEN=<pat> buildspace app create --name "Agent App" --json | jq '.app.slug'

# Check hosting status
buildspace app status my-app --json | jq '.hosting.dev.url'

# Check current deploy status programmatically
buildspace deploy status --json | jq '.environments[0].status'

# List env vars for processing
buildspace env list --json | jq '.variables[] | select(.source == "creator")'

See Build with an AI agent for the full agent-native workflow.

On this page