# al-orc

al-orc is the Orchestrator's CLI: it creates and changes lines and stations, starts runs and reads work records. Install it with `npm install -g @assemblyline/al-orc`. The same package is a JavaScript client for your own code: see [al-orc library](/docs/reference/al-orc-library).

```text
al-orc <resource> <action> [target] [options]
```

| Global option | What it does |
|---|---|
| `--profile <name>`, `--org <name>` | Use this profile's credentials for this command, instead of the current one |
| `-h`, `--help` | Show help; works after any command (`al-orc stations edit --help`) |
| `-v`, `--version` | Show the version |

Most commands also take `--json`, which prints the raw JSON. How to define lines and stations with it: [Lay out a factory repo and define its lines](/docs/guides/factory-repo).

## Sign in

### `al-orc login`

Signs in through the browser, lets you pick organisations, and saves one profile per organisation. The current profile changes only when there was none.

| Option | Default | What it does |
|---|---|---|
| `--api-url` | `https://orchestrator.assemblyline.sh` | The Orchestrator's URL, origin only |
| `--browser` | `true` | Opens the approve page. `--no-browser` only prints its URL, for a machine you reach over SSH. |

### `al-orc status`

Checks the connection to the Orchestrator with the active profile. Option: `--json`.

## Config

`al-orc config profiles <action>` (alias `al-orc config orgs`) manages credential profiles. Profiles live in `~/.al/al-orc/config.yml`; `AL_ORC_CONFIG_DIR` moves the folder. al-orc never reads `.env` or environment credentials.

| Action | What it does | Options |
|---|---|---|
| `list` | List profiles; the current one is marked `*` | `--json` |
| `current` (alias `whoami`) | Show the active profile and where it came from | `--json` |
| `add <name>` | Add or update a profile's credentials | `--api-key` (required), `--api-secret` (required), `--api-url` (default `https://orchestrator.assemblyline.sh`) |
| `use <name>` | Set the current profile | |
| `remove <name>` (alias `rm`) | Remove a profile | |

## Lines

`al-orc lines <action>`. A line owns the location its stations run at. `<id>` is a line's code or id.

| Action | What it does | Options |
|---|---|---|
| `list` | List lines | `--page` (default 1), `--limit` (default 100, max 500), `--location <location>` (only lines at this location), `--include-archived`, `--json` |
| `show <id>` | Show a line and its stations | `--json` |
| `create <code>` | Create a line: `al-orc lines create IN --location my-laptop --name "Invoices"` | `--location` (required; the `FACTORY_LOCATION` of its session), `--name` (default: the code), `--description`, `--json` |
| `edit <id>` | Change a line's code, name, description or location | `--code`, `--name`, `--description` (`""` clears it), `--location`, `--json` |
| `archive <id>` | Archive a line; its stations must be archived first | |
| `unarchive <id>` | Unarchive a line; its stations stay archived | |
| `export <id>` | Print a line and its stations as JSON, without ids, to import elsewhere | |
| `import <file>` | Create a line and its stations from an export, in the `--profile` organisation | `--as <code>` (a new line code; station codes and `from` bins follow), `--location` |

## Stations

`al-orc stations <action>`. `<id>` is a station's id or short code, except where it says id.

| Action | What it does | Options |
|---|---|---|
| `list` | List stations | `--page` (default 1), `--limit` (default 100, max 500), `--tag <name>`, `--line <code or id>`, `--include-archived`, `--json` |
| `show <id>` | Show a station | `--work-records` (recent runs), `--all` (every linked record), `--json` |
| `run <id>` | Start a run on the Orchestrator; the session at the line's location runs it | `--set key=value`, `--json` |
| `create <code>` | Create a station: `al-orc stations create IN2 --line IN --name "Post" --from IN1/output` | The definition options below |
| `edit <id>` | Change a station's definition, field by field | The definition options below, and `--short-code` (`""` clears it), `--add-tag <name>`, `--remove-tag <name>` (both repeatable) |
| `archive <id>` | Archive a station: keeps its history, hides it from `list`, blocks its runs. Takes the station's id. | `--json` |
| `unarchive <id>` | Unarchive a station. Takes the station's id. | `--json` |
| `delete <id>` | Delete a station for good. Takes the station's id. | `--cascade` (also delete its work records; without it, refused while any exist) |

`--set key=value` sets one top-level config key; it is repeatable, and the value is read as JSON (`true`, `2`, `"x"`, `[..]`), else kept as text. On `run`, it changes the key for that run only.

The definition options of `create` and `edit`:

| Option | What it does |
|---|---|
| `--name` | Display name |
| `--description` | What the station does |
| `--line <code>` | Its line; on `edit`, moves the station |
| `--config <json>` | The whole config, as a JSON object; replaces it |
| `--set key=value` | Set one top-level config key; repeatable |
| `--unset <key>` | Remove a top-level config key; repeatable |
| `--from <bin>` | A bin the conveyor moves work from, such as `IN0/output`; repeatable. `--from ""` removes the conveyor. |
| `--schedule <cron>` | Cron expression; `""` clears it |
| `--timezone <zone>` | IANA timezone for the schedule, such as `Europe/London` |
| `--enabled <bool>` | Station on or off. Off: nothing runs, not even by hand. |
| `--schedule-enabled <bool>` | Cron on or off, keeping its expression |
| `--auto-drain-enabled <bool>` | Run whenever work is waiting: in `input/`, or in a line head's `watch_path` |
| `--json` | Print the raw JSON |

A change the factory session acts on at start (`from`, `auto_drain_enabled`, a line head's `watch_path`, a code, a line's location, creating or archiving) prints a warning to restart the session at the line's location. Config, schedule, `schedule_enabled`, `is_enabled`, names and tags take effect at once.

## Work records

`al-orc work-records <action>`. `<id>` is a work record id.

| Action | What it does | Options |
|---|---|---|
| `list` | List work records | `--page`, `--limit`, `--status`, `--station <id or code>`, `--line <code>` (every station on it), `--tag <name>`, `--json` |
| `show <id>` | Show a work record | `--report`, `--output` (the config the run used and its output), `--supporting-docs`, `--activity`, `--all` (every section), `--json` |
| `cancel <id>` | Cancel a running or pending work record | `--json` |
| `edit <id>` | Add or remove tags | `--add-tag <name>`, `--remove-tag <name>`, both repeatable |

## Tags

`al-orc tags <action>`.

| Action | What it does | Options |
|---|---|---|
| `list` | List all tags | `--json` |
| `create <name>` | Create a tag | `--color` (hex), `--description`, `--json` |
| `edit <id>` | Change a tag | `--name`, `--color` (hex), `--description`, `--json` |
| `delete <id>` (alias `rm`) | Delete a tag | |

## Supporting documents

| Action | What it does | Options |
|---|---|---|
| `al-orc supporting-docs show <id>` | Show a supporting document | `--save <path>` (download a file document to this path), `--json` |

## Factory sessions

`al-orc factory-sessions <action>`. A factory session is recorded each time one starts.

| Action | What it does | Options |
|---|---|---|
| `list` | List factory sessions | `--limit`, `--status` (`active`, `expired` or `disconnected`), `--location`, `--stale` (only sessions no longer active), `--json` |
| `show <id>` | Show a session and its outcomes by station | `--runs` (the runs it claimed), `--json` |

## Errors

A failed command prints its error and exits non-zero. Set `AL_DEBUG=1` to print the stack as well.
