Skip to main content

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

CommandDescription
unlayer loginAuthenticate (browser flow)
unlayer login --token <t>Non-interactive login
unlayer login --manualManual token entry
unlayer logoutClear token
unlayer logout --allClear token + workspace + project
unlayer whoamiShow 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, --frameworknextjs · vite-react · vite-vue · nuxt · vanilla
-t, --templateadventure · 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

FlagEffect
--jsonMachine-readable JSON to stdout
--non-interactiveNever prompt; auto-enabled in CI
-v, --verboseVerbose logging to stderr
-q, --quietSuppress 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

VariableEffect
UNLAYER_TOKENPersonal Access Token
UNLAYER_API_URLOverride API base URL
UNLAYER_WORKSPACE_IDOverride active workspace
UNLAYER_PROJECT_IDOverride active project
UNLAYER_NON_INTERACTIVEForce non-interactive mode
CI / CONTINUOUS_INTEGRATIONAuto-enables non-interactive + quiet

The token env var name itself is configurable: unlayer config set token-env-var MY_VAR.


Exit Codes

CodeMeaning
0Success
1Runtime error (API, network, unexpected)
2Usage error (bad flag, not authenticated, missing arg)

Resolution Order

Setting1st2nd3rd4th
Tokenenv varglobal config
API URLUNLAYER_API_URLactive env profileglobal config apiUrlhttps://api.unlayer.com
Workspace IDUNLAYER_WORKSPACE_IDglobal config
Project IDUNLAYER_PROJECT_IDglobal configunlayer.config.json
Output dir--output-dirunlayer.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

See Also