# Setup

The `synctl` CLI uses a personal access token to authenticate with Control Plane's API and provides functionality not exposed via the UI.

## Download the CLI

Download the latest version of the CLI from [Github](https://github.com/synadia-io/control-plane-cli/releases).

## Generate a personal access token

Personal access tokens are generated in your Profile under the `Personal Access Token` tab (`/profile/personal-access-tokens`). They take the form of:

```
uat_vHVOMYLvwoAzJziEYzlxUeuvvKFDYlNSAbjBYdhCiZancDkKGILvlKrDUSPQljOo
```

## Configure the CLI

`synctl` requires several options to be provided to interact with the control plane API. These can be supplied in multiple ways, including a config file, environment variables, and CLI flags.

### Config options

| name     | flag       | envar        | config file | description        |
| -------- | ---------- | ------------ | ----------- | ------------------ |
| `server` | `--server` | `SCP_SERVER` | `server`    | url of the scp api |
| `token`  | `--token`  | `SCP_TOKEN`  | `token`     | user access token  |

### Environment variables

You can set the following environment variables:

* Server URL:

```
export SCP_SERVER=http://127.0.0.1:8080
```

* Personal Access token:

```
export SCP_TOKEN=uat_vHVOMYLvwoAzJziEYzlxUeuvvKFDYlNSAbjBYd...
```

### Config file

`synctl` looks for and loads configuration options from a config file. By default `synctl` will look in the path: `{config home}/synadia/synctl/` for a file named `config`. The file format is indicated by the extension: `.json`, `.yaml`, `.toml`, `.hcl`. Config home is either `$XDG_CONFIG_HOME` if set or `$HOME/.config` if not.

Example config files:

`$HOME/.config/synadia/synctl/config.json`:

```
{

  "server": "http://127.0.0.1:8080",

  "token": "uat_vHVOMYLvwoAzJziEYzlxUeuvvKFDYlNSAbjBYdhCiZancDkKGILvlKrDUSPQljOo"

}
```

`$XDG_CONFIG_HOME/synadia/synctl/config.yaml`:

```
server: 'http://127.0.0.1:8080'

token: 'uat_vHVOMYLvwoAzJziEYzlxUeuvvKFDYlNSAbjBYdhCiZancDkKGILvlKrDUSPQljOo'
```

The full path to the config file can be overridden using the `$SCP_CONFIG` environment variable:

```
export SCP_CONFIG=/tmp/scp-config.yaml
```
