Skip to content
Surfacedd

Read surfacedd's JSON output in scripts, CI and AI agents

Every command prints exactly one JSON document on stdout, in a format named surfacedd.cli/v1. Within v1, fields are only ever added, so a script you write today keeps working.

By the Surfacedd teamUpdated 3 min readMarkdown

On this page

Short answer

When its output isn't a terminal, the surfacedd command prints one JSON document per command, in the versioned format surfacedd.cli/v1. Success has ok: true, a context (brand, range) and data, the matching MCP tool's result. Failure has ok: false and an error with a code, a message and the exit code.

Scripts, CI jobs and AI agents should read the JSON, not the tables. You rarely need to ask for it: the command prints JSON whenever stdout isn't a terminal, which covers pipes, files, CI logs and an agent's shell. --json forces it in a terminal; --human forces tables anywhere. Progress lines, notes and the confirmation question go to stderr, so stdout holds only the document.

The success envelope

{
  "schema": "surfacedd.cli/v1",
  "command": "visibility",
  "ok": true,
  "context": { "brand": { "id": "01a1f315-4dca-…", "name": "Tallyfox", "kind": "brand" }, "range": "30d" },
  "data": { "…": "the MCP tool's answer, unchanged" }
}
FieldMeaning
schemaAlways surfacedd.cli/v1 for this version of the format
commandThe command's fixed words, such as visibility, answers search, gsc top or report run. Never the arguments, so you can branch on it safely
oktrue
context.brandThe brand the command used (id, name, kind of brand or person), or null when the command has none
context.rangeThe period applied, such as 7d or 2026-10-01..2026-10-31, or null
dataFor read commands, the matching MCP tool's result, field for field

Keys come out in alphabetical order, which keeps diffs between two runs small.

Because read commands reuse the MCP tools, the MCP tool reference documents every data shape. The command reference maps each command to its tool.

The error envelope

{
  "schema": "surfacedd.cli/v1",
  "command": "report run",
  "ok": false,
  "error": { "code": "budget", "message": "The estimate ($4.18) is above --max-usd ($2.00). Nothing was spent.",
             "exit_code": 4, "data": { "estimate": { "p50_usd": 4.1823, "…": "…" }, "max_usd": 2.0 } }
}

error.exit_code repeats the process exit code, so a script that only has the file still knows what happened. error.data appears when there's something useful to act on, such as the estimate behind a refusal.

error.codeTypical cause
usageUnknown command or option, bad --range, missing argument, an API key passed as a flag
licenceThis computer isn't activated, or a job was started on a read-only licence
budgetThe estimate is over --max-usd or a hard budget cap, or a run stopped at either part-way (see data.limit)
confirmationA paid run without --yes outside a terminal, or "no" at the prompt
thresholdagent-readiness check scored under --fail-under. Stdout still carries the success document; see the note below
not_foundThe brand, report, answer, product or person doesn't exist
sampleA paid or changing command on the sample workspace
busyAnother surfacedd job is running
keysA run needs an API key that isn't saved
databaseThe workspace file is missing or unreadable
app, doctor, mcp, errorProblems talking to the app, a failed doctor check, the MCP server, anything else

Three exceptions to know

  1. A failing agent readiness threshold is still a success document. agent-readiness check --fail-under N prints ok: true with data.passed: false, data.fail_under and the full result, then exits 5. Read the scores and failing rules from data either way.
  2. doctor with a failing check prints its report (data.ok: false) and exits 1.
  3. export without --out prints the export itself, not an envelope: a JSON file in the app's export format (format: "surfacedd-export", version: 1), CSV or NDJSON. surfacedd mcp speaks MCP, not this format.

Examples with jq

# Overall visibility for the last 7 days, as a number
surfacedd visibility --range 7d | jq '.data.visibility.rate.pct'

# Competitors and their share of voice, tab-separated
surfacedd competitors --range 30d \
  | jq -r '.data.rows[] | select(.is_subject == false) | [.name, .sov_pct] | @tsv'

# Stop a script on any failure, with the message
out=$(surfacedd prompts) || { echo "$out" | jq -r '.error.message'; exit 1; }

We ran these paths against the sample workspace with this version of the command. Field names inside data follow the MCP tools; percentages are plain numbers, such as 41.9 for 41.9%.

The schema and versioning

The JSON Schema for the envelope is published at surfacedd.com/schemas/cli/v1.json, its $id. Point a validator or your editor at it.

Within v1, fields are only ever added, never renamed or removed. Write scripts that ignore fields they don't know. A breaking change would get a new schema value, and surfacedd version prints the one your command speaks:

$ surfacedd version
surfacedd 0.1.0 (output surfacedd.cli/v1, database schema v9)

The CLI's tests keep a shape snapshot for every read command and fail when the output changes shape, so a field doesn't disappear by accident.

Keep reading

How we research, write and correct pages: read our editorial policy.

All docs