Quick Reference
Every command, flag, env var, and exit code on one page.
Install
npm install -g @unlayer/cli # requires Node 20+
unlayer --version # → 0.1.0
Auth
| Command | Description |
|---|---|
unlayer login | Authenticate (browser flow) |
unlayer login --token <t> | Non-interactive login |
unlayer login --manual | Manual token entry |
unlayer logout | Clear token |
unlayer logout --all | Clear token + workspace + project |
unlayer whoami | Show current user / workspace / project |
login flags: -t/--token, -u/--url, -m/--manual, -f/--force, --workspace-id, --project-id, --skip-verify, --skip-context, --json
logout flags: -a/--all, -f/--force, --json
Resources
# Workspaces
unlayer workspace list
unlayer workspace use [id]
# Projects
unlayer project list [-w <workspace-id>]
unlayer project use [id]
unlayer project info [id]
# Templates
unlayer template list [--limit n] [-s <query>] [--project-id <id>]
unlayer template search <query> [--limit n] [--project-id <id>]
unlayer template get [id] [-o <file>] [--design-only] [--project-id <id>]
Sync
unlayer pull [--id <id>] [--output-dir <dir>] [--project-id <id>] [--design-only]
unlayer diff <file> [--remote <id>] [--project-id <id>]
Init
unlayer init [name] [-f <framework>] [-t <template>] [options]
-f, --framework | nextjs · vite-react · vite-vue · nuxt · vanilla |
|---|---|
-t, --template | adventure · product · blank |
Other flags: --no-install, --no-typescript, --skip-connect, --workspace-id, --project-id, -o/--output-dir, --json
Settings
# Global config
unlayer config show
unlayer config path # print config file path
unlayer config set <key> <value> # keys: api-url, token-env-var
unlayer config reset [-f]
# Environment profiles
unlayer env list
unlayer env add <name> --api-url <url> --console-url <url> --accounts-url <url>
unlayer env use [name] [--none]
unlayer env show [name]
unlayer env remove <name>
# Health check (exit 1 when unauthenticated or unreachable)
unlayer status
Global Flags
| Flag | Effect |
|---|---|
--json | Machine-readable JSON to stdout |
--non-interactive | Never prompt; auto-enabled in CI |
-v, --verbose | Verbose logging to stderr |
-q, --quiet | Suppress decorative output |
CI mode auto-enabled when any of CI, CONTINUOUS_INTEGRATION, or UNLAYER_NON_INTERACTIVE is set, or when stdin is not a TTY.
Environment Variables
| Variable | Effect |
|---|---|
UNLAYER_TOKEN | Personal Access Token |
UNLAYER_API_URL | Override API base URL |
UNLAYER_WORKSPACE_ID | Override active workspace |
UNLAYER_PROJECT_ID | Override active project |
UNLAYER_NON_INTERACTIVE | Force non-interactive mode |
CI / CONTINUOUS_INTEGRATION | Auto-enables non-interactive + quiet |
The token env var name itself is configurable: unlayer config set token-env-var MY_VAR.
Exit Codes
| Code | Meaning |
|---|---|
0 | Success |
1 | Runtime error (API, network, unexpected) |
2 | Usage error (bad flag, not authenticated, missing arg) |
Resolution Order
| Setting | 1st | 2nd | 3rd | 4th |
|---|---|---|---|---|
| Token | env var | global config | — | — |
| API URL | UNLAYER_API_URL | active env profile | global config apiUrl | https://api.unlayer.com |
| Workspace ID | UNLAYER_WORKSPACE_ID | global config | — | — |
| Project ID | UNLAYER_PROJECT_ID | global config | unlayer.config.json | — |
| Output dir | --output-dir | unlayer.config.json defaults.outputDir | ./templates | — |
unlayer.config.json
Drop at the repo root to commit project-scoped defaults:
{
"projectId": 17,
"defaults": {
"outputDir": "./templates"
},
"environments": {
"self-hosted": {
"apiUrl": "https://unlayer-api.your-domain.com",
"consoleUrl": "https://unlayer-console.your-domain.com",
"accountsUrl": "https://unlayer-accounts.your-domain.com"
}
}
}
token, apiKey, and $schema are stripped on read. Don't put secrets here.
Common Workflows (one-liners)
# First-time setup
unlayer login && unlayer init my-app -f nextjs
# Pull templates and commit them
unlayer pull --design-only && git add templates && git commit -m "sync"
# CI: token via env, JSON output
UNLAYER_TOKEN=$PAT UNLAYER_PROJECT_ID=17 unlayer pull --json
# Drift gate
for f in templates/*.json; do
unlayer diff "$f" --json | jq -e '.identical' || exit 1
done
# Switch between deployments
unlayer env use self-hosted && unlayer pull
unlayer env use --none && unlayer pull # back to api.unlayer.com
# When something is broken
unlayer status # health check (no auth needed); exits 1 when unhealthy
unlayer <cmd> --verbose # detailed logs