Skip to main content
Every command works without a person at the keyboard. This page explains how to drive the CLI from a script, a CI job or an AI agent.

Output formats

Commands that read print a table for people by default. Add --output json (or -o json) to get JSON instead:
The JSON uses the same field names as the REST API, so you can use the API reference to read it. Pipe it to a tool like jq:
A few commands print a stream of events instead of a table. They take --output text (the default, one readable line per event) or --output json (one JSON document per line):
  • occtoo events subscribe
  • occtoo events list
  • occtoo events destinations pull (here json prints the whole batch as one document)

Data on stdout, messages on stderr

The CLI writes data to stdout and everything meant for people to stderr: prompts, spinners, progress bars and errors. That means you can pipe or redirect the output and still see progress in your terminal:

JSON input

Commands that write, such as create and edit, take their input in one of two ways:
  • Prompts. In a terminal, the CLI asks you for each value.
  • JSON. Pass a JSON file with --file (or -f), or pipe JSON to stdin.
The JSON uses the API’s field names. The CLI rejects a field it doesn’t know, so a typo fails loudly instead of being ignored. Run a command with --help to see the JSON it takes, with an example. For edit commands, a field you leave out stays as it is.

No prompts outside a terminal

The CLI only asks questions when both stdin and stderr are a terminal. In a script it never waits for input. If it needs something you didn’t give, it stops with an error that names the flag or environment variable to set. Interactive pickers are only a shortcut. Everything they do is also possible with arguments, flags and JSON input.

Confirm deletes with --yes

Commands that delete or throw away data ask for confirmation in a terminal. In a script, pass --yes (or -y). Without it, the command fails and tells you to pass --yes.

Exit codes

Error messages say what failed and what to do next. When a request to the API fails, the message includes the trace id of the request, which helps Occtoo support find it.

Long-running work

Some commands start work that runs in the background in Occtoo and wait until it is done, for example occtoo cards activate, occtoo lifecycles activate, occtoo destinations publish and occtoo cards export. Progress goes to stderr. Ctrl-C stops the waiting, not the work itself. Use the matching show command to check how far it is.

Example: CI job

This GitHub Actions job imports a product file every night with an application’s credentials:
See Authentication for how the CLI picks a credential.