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

# CLI getting started

> Install the widgetic CLI, sign in, make a first call and build a widget from your terminal.

The [`@widgetic/cli`](https://www.npmjs.com/package/@widgetic/cli) package (current release **0.1.17**) is the whole of Widgetic in one command, `widgetic`, with two halves:

* `widgetic api <group> <command>` runs one operation of the public REST API: 159 of them today.
* `widgetic mcp <command>` runs one AI build tool of the [MCP server](https://docs.widgetic.com/docs/agents/overview.md): 56 today, at tool contract **1.26.0**.

Nobody writes the commands by hand. Each one is generated from the contracts that the API and the MCP server publish, so the CLI knows an operation or a tool the day it is released, and every command takes `--json` and `--dry-run`.

Prefer to let your agent set it up? [Copy the setup prompt](https://docs.widgetic.com/docs/quickstart.md#start-with-your-ai-agent) from the **Command line** tab: it installs the CLI, adds a short Widgetic section to `AGENTS.md` and checks the setup with `widgetic doctor`.

## Install and sign in

**1. Install the CLI**

The CLI needs Node 22.12 or later.

```bash theme={"theme":"css-variables"}
npm install -g @widgetic/cli
widgetic --version
```

**2. Make an API key**

In the dashboard, open [**Settings → API keys**](https://widgetic.com/workspaces?settings=api-keys), name the key and choose what it may do. Choose **Full access** if you want to use `widgetic mcp`: the MCP server refuses a key that is limited. [API keys](https://docs.widgetic.com/docs/api-keys.md) explains which key you need.

**3. Save the key**

```bash theme={"theme":"css-variables"}
widgetic auth login
```

The CLI asks for the key without showing it, checks it with the server and saves it. A script or a CI job skips this step and sets `WIDGETIC_API_KEY` instead; see [Configuration](https://docs.widgetic.com/docs/cli/configuration.md#where-the-cli-finds-the-key).

**4. Check the setup**

```bash theme={"theme":"css-variables"}
widgetic doctor
```

It checks the CLI, the key, the REST API and the MCP server, and says which workspace the key works in. When something is wrong it says what to do about it.

## Make your first calls

```bash theme={"theme":"css-variables"}
# REST: list your widgets, as one line of JSON
widgetic api widgets get-widgets --json

# MCP: see whose key this is and which workspace it works in
widgetic mcp get-profile

# Run a command by the name its contract gives it
widgetic api call getWidgets
widgetic mcp call get_profile
```

`widgetic` on its own prints the menu: the commands, the first steps and a few examples. `--help` works at every level: `widgetic api --help` lists the groups of the REST API, and `widgetic api widgets --help` the commands of one group. To see everything one command takes, with the JSON Schema its input is checked against, print its schema:

```bash theme={"theme":"css-variables"}
widgetic schema mcp create-widget
widgetic schema api widgets create-widget
```

Not sure what a call would do? Add `--dry-run`. It prints the exact request, with the key left out, and sends nothing. It needs no key.

## Build a widget

```bash theme={"theme":"css-variables"}
widgetic mcp create-widget \
  --title "Launch countdown" \
  --brief "A countdown to 14 March 2027" \
  --wait
```

A build takes a few minutes. Without `--wait` the command answers at once with the `widget_id` and the build goes on in the background. With it, the CLI asks again every few seconds and prints the finished widget, for up to 15 minutes. [Scripts and CI](https://docs.widgetic.com/docs/cli/scripts-and-ci.md#wait-for-a-build) has the details.

What the CLI builds stays a **draft** until you say otherwise: it sends `publish: false` unless you pass `--publish`. Look at the preview first, then publish and embed:

```bash theme={"theme":"css-variables"}
widgetic mcp get-widget --widget-id <widget-id>
widgetic mcp publish-widget --widget-id <widget-id>
widgetic mcp get-embed-code --composition-id <composition-id> --format html
```

`publish-widget` answers with the `composition_id` that `get-embed-code` takes, and `--format` is `html` (the standard JavaScript embed code, and the default) or `iframe` (for a page that cannot run a script).

> [!WARNING]
>
> Each `create-widget` and `revise-widget` call uses a credit, charged when the build starts. If a build command fails or times out, run `widgetic mcp list-widgets` before you run it again: the build may have started.

## Where to go next

> [card] [Configuration](https://docs.widgetic.com/docs/cli/configuration.md)
>
> The key, profiles, environment variables, the files the CLI keeps and how it updates itself.

> [card] [Keys and workspaces](https://docs.widgetic.com/docs/cli/keys-and-workspaces.md)
>
> Which commands need a partner key, which workspace a change goes to and what a plan changes.

> [card] [Scripts and CI](https://docs.widgetic.com/docs/cli/scripts-and-ci.md)
>
> Exit codes, retries, waiting for a build and a recipe for GitHub Actions.

> [card] [Find a command](https://docs.widgetic.com/docs/cli/find-a-command.md)
>
> How a command maps to an endpoint of the API reference, and how to look one up in the terminal.


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