# Scripting with the CLI


> Three output formats, and why JSON plus jq is where the CLI earns its place.
## Choose an output format

`-o` or `--output` takes **table**, **json**, or **csv**. Table is the default and is for reading; the other two are for feeding something else.

```bash
screenly screen list                 # table, for a human
screenly screen list -o json         # for jq
screenly screen list -o csv          # for a spreadsheet
```

CSV is the one to remember when somebody asks for a fleet inventory. It goes straight into a spreadsheet without anyone writing a script.

## JSON and jq

```bash
screenly screen list -o json | jq -r '.[] | select(.status.is_online == false) | .name'
```

That is the shape of most useful one-liners: list something, filter it, print the field you care about.

## Piping in and out

Fetching, transforming, and piping back is the intended style:

```bash
screenly playlist get $PLAYLIST_ID -o json \
  | jq '...' \
  | screenly playlist update
```

## Things worth scripting

**Bulk provisioning.** A loop over pairing codes and names, from an inventory file.

**Content rollouts.** Add an asset, append it to a playlist with a duration, done.

```bash
screenly asset add throughput.html "Throughput Board"
screenly playlist append $PLAYLIST_ID $ASSET_ID 20
```

**Fleet reports.** A scheduled `screen list -o csv` into whatever your organization already reads.

**Authenticated pages.** `basic-auth`, `bearer-auth` and `inject-js` applied consistently across many assets, rather than clicked one at a time.

## Permissions

The CLI carries the permissions of the token, which carries the permissions of the account that made it. A script that only uploads content is safer with a token from an account that can only upload content. See [API tokens](/docs/developers/overview/api-tokens/).