# CLI commands (/docs/cloud/cli)

<Component />

| Command | Purpose |
| --- | --- |
| `hypequery login` | Authorize this machine with hypequery cloud and save a default project and environment |
| `hypequery login --device` | Sign in without a browser on this machine: approve a code from any browser |
| `hypequery logout` | Revoke and remove the local cloud credentials |
| `hypequery deploy <source>` | Build, release, and submit a TypeScript publication in one step |
| `hypequery deployment:build <cloud>` | Build a verified deployment bundle without releasing it |
| `hypequery deployment:release <bundle>` | Bind a bundle to a project and environment as a release |
| `hypequery deployment:submit <bundle> --release <path>` | Submit a prebuilt bundle and release |
| `hypequery deployment:status` | Show the live release and hosted REST and MCP URLs |
| `hypequery deployment:validate <artifact>` | Verify a bundle or contract and report its identity |
| `hypequery pull` | Download the source snapshot from the live deployment |
| `hypequery diff [source]` | Compare local source with the live deployment |
| `hypequery mcp --self-test --url <url>` | Check a hosted MCP endpoint |
| `hypequery <group> <action>` | Run any hypequery Cloud operation: `projects`, `releases`, `drafts`, `connections`, `logs`, `members`, `api-keys` and more. See [Cloud operation commands](/docs/cloud/cli-operations) |

Most commands accept `--project` and `--environment` to override the target saved by `hypequery login`.

## Signing in [#signing-in]

`hypequery login` opens a browser on this machine. Where no browser can open
(SSH, a container, a coding agent's sandbox), use device sign-in: the CLI prints
a short code and a URL, and you approve the code from any browser.

<CodeBlock>
```bash
npx hypequery login --device
# To sign in to hypequery Cloud, open https://cloud.hypequery.com/cli/device and enter the code: BCDF-GHJK
npx hypequery login --device --project shop --capabilities workspace:view,deployment:publish
```
</CodeBlock>

The browser opens by itself only when a person is at the terminal and
`--no-input` is not set. The CLI polls until the code is approved, denied or
expires (10 minutes). The code and URL always go to stderr, so `--json` output
stays one document and redirecting stdout never hides them.

| Option | Description |
| --- | --- |
| `--device` | Sign in by approving a code in any browser |
| `--project <slug>` | With `--device`: limit the token to one Cloud project |
| `--capabilities <list>` | With `--device`: cap the token below your role, comma-separated |
| `--cloud-url <url>` | Cloud origin (or `HYPEQUERY_CLOUD_URL`) |
| `--environment <environment>` | Browser sign-in only: the deployment target to save |

Both sign-ins store a management token (`hqmt_`): user-bound, re-checked
against your role on every call, valid for 30 days, and listed under Settings ›
CLI sign-ins where you can revoke it. Browser sign-in also stores the 12-hour
deploy credential it always has. Tokens go to the operating-system credential
vault. Where there is none (common on headless Linux), the management token is
kept in an owner-only file (`0600`) in the CLI's config directory, and the CLI
says so; the deploy credential is never written to a file, so browser sign-in
then keeps only the management token. One management token is kept per Cloud
origin. `hypequery logout` revokes and removes all of them.

Device sign-in doesn't save a deployment target yet, so pass `--project` and
`--environment` to deploy, status, pull and diff after it.

`hypequery login` signs in to `--cloud-url`, else `HYPEQUERY_CLOUD_URL`, else
`https://cloud.hypequery.com`. It refuses a `HYPEQUERY_CLOUD_URL` that came
from a project `.env` file, because that server would receive your sign-in and
the 30-day token; pass `--cloud-url` or set the variable in your shell. When the
shell names a Cloud other than the default, the CLI prints it on stderr before
it opens the browser or shows the code.

The config directory (`HYPEQUERY_CONFIG_DIR`, `XDG_CONFIG_HOME`, `APPDATA`) is
also read only from the shell, never from a `.env` file, and must be an
absolute path.

### Credentials in CI and scripts [#credentials-in-ci-and-scripts]

Every command that talks to Cloud picks its credential in this order:

1. `HYPEQUERY_API_TOKEN`: a management token (`hqmt_…`) or a project deploy
   key (`hqdp_…`). The CLI reads the prefix and sends either to
   `HYPEQUERY_CLOUD_URL` (default `https://cloud.hypequery.com`), unless
   `--endpoint` or `HYPEQUERY_DEPLOYMENT_ENDPOINT` names another endpoint. Any
   other token needs that explicit endpoint. When `HYPEQUERY_API_TOKEN` is set
   in your shell, the CLI refuses a `HYPEQUERY_CLOUD_URL` or
   `HYPEQUERY_DEPLOYMENT_ENDPOINT` that came from a project `.env` file, so a
   cloned repository can't redirect your token. Set them in your shell instead.
   A management token acts on your whole organisation, so it goes only to its
   own Cloud origin: an `--endpoint` or `HYPEQUERY_DEPLOYMENT_ENDPOINT` on
   another host is refused. Only a deploy key may go to a custom endpoint.
2. The management token stored by `hypequery login` or `hypequery login --device`,
   for `HYPEQUERY_CLOUD_URL` when it is set, otherwise for your latest sign-in.
3. The deploy credential stored by browser sign-in. With `HYPEQUERY_CLOUD_URL`
   set, it is used only when it was issued by that Cloud.

<CodeBlock>
```bash
HYPEQUERY_API_TOKEN=hqdp_… npx hypequery deploy analytics/cloud.ts \
  --project acme:analytics --environment production --json --no-input
```
</CodeBlock>

## `hypequery deploy <cloud>` [#hypequery-deploy-cloud]

Builds the publication module, prepares a release for the logged-in target,
and submits it. Once cloud accepts the release, the CLI prints where it's
served:

<CodeBlock>
```text
Hosted endpoints
  REST  https://<environment-slug>.hypequery.app
    orders  POST https://<environment-slug>.hypequery.app/api/analytics/datasets/orders/query
  MCP   https://<environment-slug>.hypequery.app/mcp
```
</CodeBlock>

Cloud provides these URLs, so the CLI follows cloud's current routing. A live
release is required before dataset calls work. A cloud release that doesn't
provide endpoint details leaves deploy output unchanged.

| Option | Description |
| --- | --- |
| `--mcp-config` | Also print MCP client configuration for the hosted endpoint. It reads the key from `${HYPEQUERY_API_KEY}` and never contains a credential |
| `--project`, `--environment` | Override the target from `hypequery login` |
| `--replace-restored` | Replace a live release that was restored from history |
| `--take-ownership` | Replace a live model built in hypequery Cloud. The project is then managed in code. Without it, the CLI asks in a terminal and refuses in CI |
| `--no-source` | Leave project source files out of the bundle |

## `hypequery deployment:status` [#hypequery-deploymentstatus]

Shows the current release and cloud-provided REST and MCP URLs without building
or deploying again. It uses the target and deployment credential saved by
`hypequery login`. With an explicit deployment credential, pass both
`--project` and `--environment`.

<CodeBlock>
```bash
npx hypequery deployment:status
npx hypequery deployment:status --mcp-config
```
</CodeBlock>

The command says when no release is live. Its optional MCP configuration uses
`${HYPEQUERY_API_KEY}` as a placeholder and never includes the stored deployment
credential.

| Option | Description |
| --- | --- |
| `--project`, `--environment` | Override the target from `hypequery login`; pass both together |
| `--endpoint` | Use an explicit cloud submission endpoint with `HYPEQUERY_API_TOKEN` |
| `--mcp-config` | Also print MCP client configuration for the hosted endpoint |