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" }
}
| Field | Meaning |
|---|---|
schema | Always surfacedd.cli/v1 for this version of the format |
command | The command's fixed words, such as visibility, answers search, gsc top or report run. Never the arguments, so you can branch on it safely |
ok | true |
context.brand | The brand the command used (id, name, kind of brand or person), or null when the command has none |
context.range | The period applied, such as 7d or 2026-10-01..2026-10-31, or null |
data | For 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.code | Typical cause |
|---|---|
usage | Unknown command or option, bad --range, missing argument, an API key passed as a flag |
licence | This computer isn't activated, or a job was started on a read-only licence |
budget | The estimate is over --max-usd or a hard budget cap, or a run stopped at either part-way (see data.limit) |
confirmation | A paid run without --yes outside a terminal, or "no" at the prompt |
threshold | agent-readiness check scored under --fail-under. Stdout still carries the success document; see the note below |
not_found | The brand, report, answer, product or person doesn't exist |
sample | A paid or changing command on the sample workspace |
busy | Another surfacedd job is running |
keys | A run needs an API key that isn't saved |
database | The workspace file is missing or unreadable |
app, doctor, mcp, error | Problems talking to the app, a failed doctor check, the MCP server, anything else |
Three exceptions to know
- A failing agent readiness threshold is still a success document.
agent-readiness check --fail-under Nprintsok: truewithdata.passed: false,data.fail_underand the full result, then exits 5. Read the scores and failing rules fromdataeither way. doctorwith a failing check prints its report (data.ok: false) and exits 1.exportwithout--outprints the export itself, not an envelope: a JSON file in the app's export format (format: "surfacedd-export",version: 1), CSV or NDJSON.surfacedd mcpspeaks 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
- DocsEvery surfacedd command, its options and the MCP tool behind itRead commands are free and read-only and return exactly what the matching MCP tool returns. Actions say what they need and what they cost before they start.Read
- DocsWhat each surfacedd exit code means, and how to handle it in a scriptSix exit codes cover every outcome, so a script or CI job can tell a broken check from a failing site, and a refused payment from an error.Read
- DocsEvery Surfacedd MCP tool, with its arguments and what it returnsAll tools are read-only, return compact JSON of at most 64 KB, and read the database on your computer. None starts a run, spends money or reads your keys.Read
- DocsFail a build when AI agents can no longer read your siteOne step after your deploy crawls the live site with Surfacedd's agent readiness rules and fails the job when the score drops under your threshold. It costs $0 and stores nothing.Read
How we research, write and correct pages: read our editorial policy.