Use JSON output from the Dosya CLI
Use --json for command-specific Dosya CLI receipts, keep warnings off stdout, and inspect each command’s documented object instead of one schema.
Last reviewed
Pass --json or -j to request pretty-printed JSON on stdout. Dosya does not wrap every command in a universal {ok,data} schema: whoami emits the user object, listing commands retain their API shape, and usage builds its own report.

Before you start
- Confirm the chosen command supports the fields your script needs by running it once against disposable or read-only data.
- Capture stderr separately; warnings and debug information remain there even in JSON mode.
config getredacts the stored API key, so its JSON is safe for diagnosis but cannot reproduce the credential.
Steps
- Run a read-only probe such as
dosya whoami --json, redirecting stdout and stderr to separate files. - Save the exit code before parsing. A nonzero command can leave empty or incomplete stdout even when stderr clearly explains the failure.
- Parse the actual top-level shape. For
whoami, read user fields directly; forls, inspect its listing wrapper rather than expecting the same keys. - Select only required values with
jq -eso a missing field makes the script fail. Avoid storing the entire account or file response when one ID is enough. - Keep stderr with the job log and JSON stdout with the machine receipt. Never merge them with
2>&1before a JSON parser. - Validate the command result semantically, such as the intended workspace ID or returned file ID, before starting a dependent command.

Expected result
A successful command writes one valid, command-specific JSON document to stdout while progress and warnings remain on stderr. The script checks both exit status and required fields.
Troubleshooting
jq reports invalid JSON. Confirm stdout and stderr were not merged, then inspect the original exit code.
A field from another command is absent. Read this command’s output shape; there is no universal result envelope.
The key value is masked. That is expected for config get. Obtain secrets from the secret store that provisioned them, not from CLI diagnostic output.
Related guides
Was this helpful?
Loading helpfulness results…
Voting saves a necessary ballot cookie for up to 180 days so you can change your answer.
Questions and replies
Ask about the steps in this guide. Questions are reviewed before publication.
Keep account details, credentials and private files out of public questions. Use private support for those.
Loading questions…
Sign in to your Dosya account to ask a question.