Skip to main content
Every command is made to be run by a program as well as by a person. This page covers what a script needs to know: what a command prints, what its exit code means, what the CLI retries by itself and how to wait for a build.

Output for programs

These flags work on every command: With --json, a REST command prints the body of the response as the server sent it, and an MCP command prints the structuredContent of the tool’s answer. An error looks like this:
code is the server’s own code when it sent one (the error codes of the API) and the CLI’s otherwise, such as USAGE_ERROR. status, requestId, retryAfter, details and hint are there when there is something to say. Quote the requestId to support.

Exit codes

A script reads the exit code before it reads anything else. A workspace without a plan is refused with 3 over REST and with 5 from an MCP tool: see When the workspace has no plan.

Retries and idempotency

The CLI tries a call at most three times, waiting half a second and then a second and a half between tries. What it repeats depends on what the first try could have done.
  • A 429 is always waited out. The server refused the call before it did anything. A Retry-After of up to 30 seconds is honoured. A longer one is reported at once, with exit code 6.
  • A lost answer is repeated only when repeating cannot do anything twice. A dropped connection, a timeout, a 502, a 503 or a 504 may have been carried out and lost on the way, so the CLI repeats the call only when it reads, or when it carries an idempotency key. An MCP tool is repeated when it only reads or when its contract says that repeating it changes nothing more. A tool that starts a build is not repeated.
  • Everything else is returned at once. A 400, a 401 or a 404 would answer the same again.
A REST command that creates something takes --idempotency-key. The CLI makes a key when you leave it out and sends the same one on every try. Give your own, a UUID is ideal, to repeat the call by hand later, for instance after a script was cut off:
The API keeps the answer to a call for 24 hours, and a repeat with the same key gets that answer back. See Idempotency. While the CLI waits to try again it says so on standard error, unless you passed --json.

Wait for a build

create-widget and revise-widget answer at once with the widget’s widget_id and the phase it is in, and the build goes on in the background. (replicate-widget builds nothing: it offers the copy the browser extension stored, so there is nothing to wait for.) Add --wait and the command keeps asking get_widget every 7 seconds until the build has ended, then prints the finished widget:
Without --json, the CLI prints each new phase as Widget <widget-id>: <phase> on standard error. A build that starts is charged a credit, so do not run a build command again just because it failed or timed out. Run widgetic mcp list-widgets first: the widget may exist already.

GitHub Actions

This workflow builds a widget from a brief that you type in when you start it, publishes it and prints the embed code. The key comes from a secret, and the workflow holds every change to the workspace you mean.
  • WIDGETIC_API_KEY is the full access key that widgetic mcp needs. Make it in the workspace you mean and keep it in the repository’s secrets.
  • WIDGETIC_WORKSPACE makes create-widget refuse the call, and change nothing, if the key works in another workspace. See Which workspace a change goes to.
  • The brief goes in through an environment variable ($BRIEF) and not into the script text, so nothing a person types can run as a command.
  • GitHub Actions sets CI, so the CLI never looks for a newer version or asks about one.
  • A build that finishes but cannot publish, because the plan does not include publishing or because the publish did not finish, has no composition_id. The note says why, and the job fails with it.
Any other CI works the same way: store the key as a secret and expose it as WIDGETIC_API_KEY, install the CLI with npm at a version you pinned, and read the exit code.