> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/cli/for-devops-and-administrators/automate/json-output.md).

# Read results as JSON

Get Devolutions CLI results as JSON or YAML, in one envelope for every command, so scripts can check success and errors reliably.

The default text output is written for people: its layout differs from one command to the next and can change. For a script, ask for JSON or YAML. Every command then answers with the same envelope, for successes and for errors, so your script checks one field to know what happened.

## Choose the output format

<table><thead><tr><th width="250">OPTION</th><th>WHAT YOU GET</th></tr></thead><tbody><tr><td><code>--output text</code> (default)</td><td>Readable text, different for each command. Don't parse it.</td></tr><tr><td><code>--output json</code> or <code>--json</code></td><td>The JSON envelope, indented.</td></tr><tr><td><code>--output yaml</code> or <code>--yaml</code></td><td>The same envelope, in YAML.</td></tr></tbody></table>

These options work with every command. Use only one of them per command: `--json` with `--yaml`, or `--json` with `--output yaml`, stops the command with the error `conflictingOptions`. `--json` with `--output json` is accepted.

```bash
devo vault list --json
```

## The envelope

```json
{
  "status": "success",
  "command": "vault.list",
  "operationId": null,
  "data": [ ],
  "warnings": [],
  "errors": []
}
```

<table><thead><tr><th width="180">FIELD</th><th>WHAT IT CONTAINS</th></tr></thead><tbody><tr><td><code>status</code></td><td><code>success</code>, <code>partial</code>, or <code>error</code>. Check this field first. <code>partial</code> means the command completed but some items failed: <code>data</code> holds what succeeded, <code>errors</code> lists what didn't, and the exit code is <code>0</code>.</td></tr><tr><td><code>command</code></td><td>The command that ran, as a dotted path such as <code>vault.list</code> or <code>entry.references</code>. Aliases and option values don't change it.</td></tr><tr><td><code>operationId</code></td><td>An identifier when the command produced one, otherwise <code>null</code>.</td></tr><tr><td><code>data</code></td><td>The result. Its shape depends on the command.</td></tr><tr><td><code>warnings</code></td><td>Notices that didn't stop the command.</td></tr><tr><td><code>errors</code></td><td>One item per error. Empty when <code>status</code> is <code>success</code>; not empty when it's <code>partial</code> or <code>error</code>.</td></tr></tbody></table>

Each item in `errors` has these fields:

<table><thead><tr><th width="180">FIELD</th><th>WHAT IT CONTAINS</th></tr></thead><tbody><tr><td><code>code</code></td><td>A stable error code, such as <code>missingParameter</code> or <code>conflictingOptions</code>. Base your script's decisions on this field.</td></tr><tr><td><code>message</code></td><td>An explanation for people. Its wording can change, so don't match on it.</td></tr><tr><td><code>target</code></td><td>The option, argument, or resource the error is about, when known.</td></tr><tr><td><code>blockerStatus</code>, <code>stageStatuses</code></td><td>Details from the workspace runtime, when the error comes from it.</td></tr></tbody></table>

A command line that Devolutions CLI can't parse, such as a misspelled command, also returns the envelope, with errors coded `usageError`, and sometimes a `usageSuggestion` item that proposes the right spelling.

## Use it in a script

Check the exit code first, then read the envelope. A `partial` result exits with `0`, so also report `errors` when the exit code is `0`. For example, with `jq`:

{% tabs %}
{% tab title="Bash" %}

```bash
if result=$(devo vault list --json); then
  echo "$result" | jq -r '.data[].name'
  # A partial result exits with 0 and still lists errors.
  echo "$result" | jq -r '.errors[] | "\(.code): \(.message)"' >&2
else
  echo "$result" | jq -r '.errors[] | "\(.code): \(.message)"' >&2
  exit 1
fi
```

{% endtab %}

{% tab title="PowerShell" %}

```powershell
$result = devo vault list --json | ConvertFrom-Json
# 'partial' and 'error' both list their errors.
$result.errors | ForEach-Object { Write-Warning "$($_.code): $($_.message)" }
if ($result.status -eq 'error') {
    exit 1
}
# 'success' or 'partial': data holds what succeeded.
$result.data | ForEach-Object { $_.name }
```

{% endtab %}
{% endtabs %}

The exit codes are listed in [Exit codes and errors](/cli/reference/exit-codes-and-errors.md).

## Standard output and standard error

<table><thead><tr><th width="200">STREAM</th><th>WHAT GOES THERE</th></tr></thead><tbody><tr><td><strong>Standard output</strong></td><td>The envelope, in JSON or YAML, for successes and errors. In text, the result. In text, errors from <code>devo login</code> and from commands available only on Devolutions Cloud or only on Devolutions Server also go here, as <code>&#x3C;code>: &#x3C;message></code>.</td></tr><tr><td><strong>Standard error</strong></td><td>In text, most errors, as <code>&#x3C;code>: &#x3C;message></code>. Notices about what Devolutions CLI is doing, such as <code>Starting Devolutions CLI daemon...</code>, and the prompts and messages of interactive sign-in.</td></tr></tbody></table>

So in JSON or YAML, read standard output only: it contains exactly one envelope. The exception is `devo secret run`, described below.

## Quiet or verbose

Notices about what Devolutions CLI is doing, such as starting the background process, are written to standard error:

* In text output, they appear by default. `--quiet` hides them.
* In JSON or YAML output, they're hidden by default. `--verbose` shows them, still on standard error.

`--quiet` and `--verbose` together stop the command with `conflictingOptions`.

## Good to know

* `devo secret run` doesn't wrap the output of the program it starts: the program's output goes to your terminal as the program writes it, with secret values masked. How its own errors come back depends on when they happen:
  * A launch Devolutions CLI rejects before resolving anything, such as a reference in the command's arguments (`secretLaunchArgumentReference`), a failed `--check`, or a program that can't start, returns the envelope on standard output with `--json` or `--yaml`.
  * A reference that doesn't resolve is always written to standard error as `<code>: <message>`, even with `--json`, and the program doesn't start.
  * A program stopped by `--timeout-seconds` exits with `124`; an interrupted run exits with `130`.
  * Otherwise, `devo secret run` returns the program's own exit code. See [Exit codes and errors](/cli/reference/exit-codes-and-errors.md).
* Every command and its options are in [Commands](/cli/reference/commands.md).

## Next

* [Run without prompts](/cli/for-devops-and-administrators/automate/non-interactive.md)
* [Exit codes and errors](/cli/reference/exit-codes-and-errors.md)
* [Global options](/cli/reference/global-options.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.devolutions.net/cli/for-devops-and-administrators/automate/json-output.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
