> ## Documentation Index
> Fetch the complete documentation index at: https://docs.emailx.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# JSON and exit codes

> Build scripts that can distinguish success, denial and uncertainty.

Use `--json` for one result or error object on stdout. Diagnostic text goes to stderr. Success preserves `data` and pagination and adds `meta.http_status`, `meta.request_id` and `meta.idempotent_replayed`.

Errors include `code`, `message`, `http_status`, `request_id`, `retry_after` and `mutation_may_have_succeeded`. Branch on exit status and code rather than parsing human-readable prose.

| Exit | Meaning |
| - | - |
| 0 | Success |
| 2 | Invalid input or configuration |
| 3 | Authentication or authorization |
| 4 | Resource not found or inaccessible |
| 5 | Duplicate, state or idempotency conflict |
| 6 | Rate limit; honor retry\_after |
| 7 | Network, upstream, unavailable feature or uncertain result |
| 1 | Unexpected local failure |
| 130 | Interrupted or canceled |

## Bound your automation

Lists do not fetch all pages automatically. Reads and writes do not retry automatically. Respect request budgets and preserve logical operation keys for mutations. For a timeout or pending result, inspect the resource before deciding how to retry.

A zero exit from `--dry-run` proves local validation only. A nonzero exit after a mutation can still represent a committed change; inspect `mutation_may_have_succeeded` and the [recovery guide](https://docs.emailx.ai/en/api-reference/idempotency.md).

## A read-only shell job

```bash theme={null}
if emailx analytics get --workspace 123 --channel linkedin --json > report.json; then
  jq '.data' report.json
else
  status=$?
  jq '.error' report.json
  exit "$status"
fi
```

`jq` is optional external tooling. Reports and redacted previews can still contain customer information. Store output appropriately and never print keys to job logs.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.