Skip to content

JSON Output Contract

All GPC commands return structured output. The format depends on TTY detection or the --output flag.

Output Formats

FormatFlagWhen UsedPurpose
table--output tableDefault in TTY (terminal)Human-readable
json--output jsonDefault in pipe/CIMachine-parseable
yaml--output yamlExplicit onlyConfig-friendly
markdown--output markdownExplicit onlyGitHub $GITHUB_STEP_SUMMARY

Auto-Detection

bash
# Terminal (TTY) — renders a table
gpc releases status

# Pipe — outputs JSON automatically
gpc releases status | jq '.data'

# CI (CI=true) — outputs JSON automatically
CI=true gpc releases status

# Override in any context
gpc releases status --output json
gpc releases status --output yaml
gpc releases status --output markdown

Success Response

json
{
  "success": true,
  "data": {
    "track": "production",
    "status": "inProgress",
    "versionCodes": ["142"],
    "rolloutPercentage": 10,
    "releaseNotes": [
      {
        "language": "en-US",
        "text": "Bug fixes and performance improvements."
      }
    ]
  },
  "metadata": {
    "command": "releases status",
    "app": "com.example.myapp",
    "timestamp": "2026-03-06T12:00:00Z",
    "duration_ms": 342
  }
}

Fields

FieldTypeAlways PresentDescription
successbooleanYestrue on success, false on error
dataobject | arrayYes (on success)Command-specific response data
metadataobjectYesExecution metadata
metadata.commandstringYesThe command that was executed
metadata.appstringWhen availablePackage name used
metadata.timestampstringYesISO 8601 timestamp
metadata.duration_msnumberYesExecution time in milliseconds

Error Response

json
{
  "success": false,
  "error": {
    "code": "API_FORBIDDEN",
    "message": "The service account does not have permission to manage releases for this app.",
    "suggestion": "Ensure the service account has the required permissions for this operation."
  },
  "metadata": {
    "command": "releases upload",
    "app": "com.example.myapp",
    "timestamp": "2026-03-06T12:00:05Z",
    "duration_ms": 1203
  }
}

Error Fields

FieldTypeAlways PresentDescription
error.codestringYesMachine-readable error code (e.g., API_FORBIDDEN)
error.messagestringYesHuman-readable error description
error.suggestionstringWhen availableActionable fix suggestion

Parsing Examples

jq

bash
# Extract data
gpc releases status --output json | jq '.data.rolloutPercentage'

# Check success
gpc releases upload app.aab --output json | jq -e '.success'

# Extract error
gpc releases upload app.aab --output json | jq -r '.error.suggestion // "No suggestion"'

# List all version codes across tracks
gpc status --output json | jq -r '.data.tracks[].releases[].versionCodes[]'

Node.js

javascript
import { execSync } from "node:child_process";

const output = execSync("gpc releases status --output json", {
  encoding: "utf-8",
  env: {
    ...process.env,
    GPC_APP: "com.example.myapp",
  },
});

const result = JSON.parse(output);

if (result.success) {
  console.log(`Rollout: ${result.data.rolloutPercentage}%`);
} else {
  console.error(`Error: ${result.error.code} — ${result.error.message}`);
}

Python

python
import json
import subprocess

result = subprocess.run(
    ["gpc", "releases", "status", "--output", "json"],
    capture_output=True,
    text=True,
    env={**os.environ, "GPC_APP": "com.example.myapp"},
)

data = json.loads(result.stdout)

if data["success"]:
    print(f"Rollout: {data['data']['rolloutPercentage']}%")
else:
    print(f"Error: {data['error']['code']}")

Secrets Redaction

All output (including JSON) automatically redacts sensitive fields:

FieldRedacted To
private_key[REDACTED]
private_key_id[REDACTED]
access_token[REDACTED]
refresh_token[REDACTED]
client_secret[REDACTED]
token[REDACTED]
password[REDACTED]
secret[REDACTED]
credentials[REDACTED]

Redaction is applied before output formatting and cannot be disabled.

Released under the MIT License.