epx is built for scripts. Output goes to standard output, errors go to standard error, and the exit code tells you what went wrong, so a script can tell a missing product from a missing scope.

Exit codes

Some commands get a 403 from Emporix that refuses their input rather than the credential, such as orders transition to a status the order can’t take. These exit with 1 and show Emporix’s message, unless the message names a scope or permission. Their help says so.

Errors

Errors start with Error: and go to standard error. When Emporix answers with JSON, epx shows its message, its error code, and the details of each field, and nothing else of the response:
Usage errors (exit code 2) add a hint to run epx --help.

Retries

epx retries a request, up to three times in total, only when it can’t change data twice:
  • Any request after 429 Too Many Requests, honoring Retry-After up to 30 seconds.
  • Any request whose connection couldn’t be made, unless making it timed out.
  • Reads, never writes, after 502, 503, or 504.

Script examples

Check whether a product exists

Handle a conflict

Fail early on a missing scope

Run in CI

In CI, set the EMPORIX_ variables from your CI system’s secrets. Profiles keep their client secret in an OS keychain, which CI runners usually don’t have. See Authenticate.