# CLI (https://aperture-docs.mountaindev.com/docs/cli)

`aperture-cli` deploys and runs jobs and manages inbound triggers and outbound
webhooks.

## Install [#install]

The CLI is a Go program in the `cli/` directory of the Aperture repository.
With Go 1.24 or later:

```sh
cd cli
go build -o aperture-cli ./cmd/aperture-cli.go
sudo mv aperture-cli /usr/local/bin/
```

## Usage [#usage]

```text
aperture-cli [flags] <command> [args...]
```

Flags can go before or after the arguments.

| Flag | Default | Description |
| --- | --- | --- |
| `-P`, `--project` | `$APERTURE_PROJECT_ID` | Project ID. Required by `deploy`, `run` and `triggers`. |
| `-p`, `--path` | `jobs` | Directory that holds job directories, relative to the current directory. |
| `-s`, `--schedule` | | `run` only: run at this ISO 8601 time (with offset) instead of now. |
| `-c`, `--config` | see [Configuration](#configuration) | Path to the config file. |
| `-h`, `--help` | | Print usage and exit. `aperture-cli help` and running with no arguments do the same. |

A job argument (`<job>`) is the **name of a directory** under `--path`, not a
file path: `deploy hello` reads `./jobs/hello/job.json`.

## Commands [#commands]

### `login <email>` [#login-email]

```sh
aperture-cli login you@example.com
```

Prompts for your password (it needs an interactive terminal), signs in, and
saves the token to the config file. The token isn't printed. The token is valid for 52 weeks. To log in
to a self-hosted server, set `APERTURE_API_URL` first; it's saved too.

### `deploy <job>` [#deploy-job]

```sh
aperture-cli deploy nightly-report -P <project-id>
```

Runs the manifest's `build` command, zips the `includes`, and uploads the job.
Prints a warning if the job declares secrets the project doesn't have. See
[Jobs](/docs/concepts/jobs#deploying).

### `run <job> [NAME=value ...]` [#run-job-namevalue-]

```sh
aperture-cli run nightly-report
aperture-cli run nightly-report REPORT_DATE=2026-11-22 DRY_RUN=true
aperture-cli run nightly-report --schedule 2026-11-24T06:00:00Z
```

Starts a run now, or at `--schedule`. Each `NAME=value` becomes an environment
variable. Names must be valid environment variable names and can't start with
`APERTURE_`. The command prints the execution ID and returns; it doesn't wait
for the run.

### `triggers` [#triggers]

Manage a job's [inbound triggers](/docs/triggers).

```text
aperture-cli triggers [list] <job>
aperture-cli triggers create <job> name=<name> [type=generic|sns] [topic_arn=<arn>]
aperture-cli triggers rotate <job> <trigger-id>
aperture-cli triggers enable <job> <trigger-id>
aperture-cli triggers disable <job> <trigger-id>
aperture-cli triggers delete <job> <trigger-id>
```

`create` and `rotate` print the token **once**. `type=sns` requires
`topic_arn`.

### `webhooks` [#webhooks]

Manage the team's [outbound webhooks](/docs/webhooks).

```text
aperture-cli webhooks [list] <team-id>
aperture-cli webhooks create team_id=<id> url=<url> events=<a,b> [enabled=true] [description=<text>] [project_ids=<a,b>] [schedule=<cron>]
aperture-cli webhooks delete <webhook-id>
```

`create` generates a signing secret and prints it once. Endpoints are created
**disabled** unless you pass `enabled=true`. `schedule` is required when
`events` includes `cron.tick`. There's no update command; use the dashboard or
the [API](/docs/api/webhooks).

`triggers` and `webhooks` need a login token or personal API key; project keys
can't use them.

## Configuration [#configuration]

The CLI stores its settings in a JSON file:

| OS | Default path |
| --- | --- |
| macOS | `~/Library/Application Support/aperture/config.json` |
| Linux | `$XDG_CONFIG_HOME/aperture/config.json` or `~/.config/aperture/config.json` |
| Windows | `%AppData%\aperture\config.json` |

```json
{ "ApiUrl": "https://aperture-server.mountaindev.com", "AuthToken": "eyJ..." }
```

The file holds your token, so the CLI writes it readable only by you (`0600`, in
a `0700` directory).

Environment variables override the file:

| Variable | Description |
| --- | --- |
| `APERTURE_API_URL` | Server URL. Defaults to `https://aperture-server.mountaindev.com` when there's no config file. |
| `APERTURE_AUTH_TOKEN` | Token to send. Any [token type](/docs/concepts/authentication) works. |
| `APERTURE_PROJECT_ID` | Default for `--project`. |

With `APERTURE_AUTH_TOKEN` and `APERTURE_PROJECT_ID` set, no config file or
login is needed; this is how CI uses it. See [Deploying from CI](/docs/ci).

## Output and exit codes [#output-and-exit-codes]

Progress and results are logged to stderr; trigger and webhook listings and
newly issued credentials go to stdout. There's no JSON output mode. The CLI
exits `0` on success (including `help`) and `1` on errors, including unknown
commands. HTTP errors print the status code and
the server's message.

The CLI has no commands for cancelling runs, reading logs, or managing projects
and secrets yet; use the dashboard or the [API](/docs/api).