# CLI Guide

> The Synento Command Line Interface (CLI) provides quick project and session management from the terminal.

The Synento Command Line Interface (CLI) provides quick project and session management from the terminal.

## Installation

The CLI is published as an npm package in `cli/`:

```bash
npx synento --help
```

Or install globally for convenience:

```bash
cd cli && npm install -g .
synento --help
```

## Commands

### `synento login [apiKey] [--url <baseUrl>]`

Authenticate and store credentials locally. Credentials are saved to `~/.config/synento/credentials.json`.

**Interactive mode:**
```bash
synento login
# Prompts: Enter your API key (sk_live_xxx): 
```

**Non-interactive mode:**
```bash
synento login sk_live_xxxxx

# Or via stdin (for scripting):
echo "sk_live_xxxxx" | synento login
```

Every command talks to the hosted API, `https://api.synento.com`.

**Environment variable override:**
```bash
export SYNENTO_API_KEY=sk_live_xxxxx
synento login  # uses env var if no argument provided
```

### `synento create-project [name] [--env <environment>] [--url <baseUrl>]`

Create a new project under your organisation. In non-interactive mode, pass the name as an argument:

```bash
# Interactive — prompts for project name and environment
synento create-project

# Non-interactive with all values
synento create-project "My App" --env production
```

Response (printed to stdout):
```json
{ "id": "proj_abc123", "name": "My App", "org_id": "org_xyz789" }
```

### `synento create-session [name] -p|--project <projectId> [--url <baseUrl>]`

Create a new session under the specified project:

```bash
# Interactive — prompts for session name (defaults to "Untitled session")
synento create-session -p proj_abc123

# Non-interactive
synento create-session "Team Standup" -p proj_abc123
```

Response (printed to stdout):
```json
{ "id": "sess_def456", "project_id": "proj_abc123", "name": "Team Standup" }
```

## Credential Storage

Credentials are stored in `~/.config/synento/credentials.json`:
```json
{ "apiKey": "sk_live_xxxxx", "apiUrl": "https://api.synento.com" }
```

This file is excluded from git via the root `.gitignore`. Never commit this file.

## Scripting Examples

### Create a project and session in one script
```bash
#!/bin/bash
KEY="sk_live_xxxxx"
PROJECT=$(synento create-project "CI Test" -p "" | grep '"id"' | cut -d'"' -f4)
SESSION=$(synento create-session "Test Run" -p "$PROJECT" | grep '"id"' | cut -d'"' -f4)
echo "Created project: $PROJECT, session: $SESSION"
```

### Pipe API key from CI environment variable
```bash
export SYNENTO_API_KEY="${{ secrets.SYNENTO_API_KEY }}"
echo "$SYNENTO_API_KEY" | synento login --url https://api.synento.com
synento create-project "Pipeline Project" | npx json -a id  # extract ID via `json` CLI
```

## Limitations

The current CLI provides basic project and session management. Future commands planned:
- `synento list-sessions` — list sessions with filtering
- `synento create-session-token` — get connection tokens for CLI-driven streaming
- `synento export` — download/export sessions to MP4
