Optimizely Cloud CLI Reference
Overview
Section titled “Overview”The Optimizely CLI (opti) provides command-line access to cloud platform operations. Use it to deploy code, manage environments, purge CDN caches, and stream logs without leaving your terminal.
Installation
Section titled “Installation”npm (recommended)
Section titled “npm (recommended)”npm install -g @optimizely/clidotnet tool
Section titled “dotnet tool”dotnet tool install -g Optimizely.CliVerify installation
Section titled “Verify installation”opti --versionAuthentication
Section titled “Authentication”opti loginOpens a browser window for interactive authentication. Stores credentials locally for subsequent commands.
API key authentication
Section titled “API key authentication”For CI/CD pipelines, use an API key instead of interactive login:
opti login --api-key <your-api-key>Or set the environment variable:
export OPTI_API_KEY=<your-api-key>Logout
Section titled “Logout”opti logoutRemoves stored credentials.
Project commands
Section titled “Project commands”List projects
Section titled “List projects”opti project listLists all projects in your organization.
| Flag | Description |
|---|---|
--format json | Output as JSON |
--format table | Output as formatted table (default) |
Select project
Section titled “Select project”opti project select <project-id>Sets the default project for subsequent commands. Alternatively, pass --project <id> to any command.
Show project details
Section titled “Show project details”opti project showDisplays project configuration, environments, and deployment history summary.
Deployment commands
Section titled “Deployment commands”Deploy
Section titled “Deploy”opti deploy push --environment IntegrationPushes the current directory as a deployment package to the target environment.
| Flag | Description |
|---|---|
--environment <name> | Target environment (Integration, Preproduction, Production) |
--package <path> | Path to a pre-built deployment package (.zip) |
--wait | Wait for deployment to complete before returning |
--timeout <seconds> | Maximum wait time (default: 600) |
Promote
Section titled “Promote”opti deploy promote --from Integration --to PreproductionPromotes the latest successful deployment from one environment to another.
| Flag | Description |
|---|---|
--from <environment> | Source environment |
--to <environment> | Target environment |
--deployment-id <id> | Promote a specific deployment instead of the latest |
List deployments
Section titled “List deployments”opti deploy list --environment ProductionLists recent deployments for an environment.
| Flag | Description |
|---|---|
--environment <name> | Filter by environment |
--limit <n> | Number of results (default: 10) |
--format json | Output as JSON |
Rollback
Section titled “Rollback”opti deploy rollback --environment ProductionRolls back to the previous successful deployment.
| Flag | Description |
|---|---|
--environment <name> | Target environment |
--deployment-id <id> | Roll back to a specific deployment |
Show deployment details
Section titled “Show deployment details”opti deploy show <deployment-id>Shows detailed information about a deployment including build log, status, and timestamps.
Environment commands
Section titled “Environment commands”List environments
Section titled “List environments”opti env listLists all environments for the current project with their status and URLs.
Show environment details
Section titled “Show environment details”opti env show IntegrationShows detailed information about an environment including resources, variables, and domain configuration.
Restart environment
Section titled “Restart environment”opti env restart IntegrationRestarts the application in the target environment without redeploying.
| Flag | Description |
|---|---|
--wait | Wait for restart to complete |
Environment variable commands
Section titled “Environment variable commands”List variables
Section titled “List variables”opti env vars list --environment IntegrationLists all environment variables (values are masked for sensitive variables).
Set a variable
Section titled “Set a variable”opti env vars set --environment Integration --name MY_SETTING --value "my-value"| Flag | Description |
|---|---|
--environment <name> | Target environment |
--name <key> | Variable name |
--value <value> | Variable value |
--secret | Mark as sensitive (masked in portal and CLI output) |
Remove a variable
Section titled “Remove a variable”opti env vars remove --environment Integration --name MY_SETTINGCDN commands
Section titled “CDN commands”Purge URL
Section titled “Purge URL”opti cdn purge --url "https://www.example.com/en/page/" --environment ProductionPurges a specific URL from the CDN cache.
Purge path
Section titled “Purge path”opti cdn purge --path "/en/blog/*" --environment ProductionPurges all cached content matching a path pattern.
Purge all
Section titled “Purge all”opti cdn purge --all --environment ProductionClears the entire CDN cache for the environment.
Log commands
Section titled “Log commands”Stream logs
Section titled “Stream logs”opti logs stream --environment IntegrationStreams application logs in real time.
| Flag | Description |
|---|---|
--environment <name> | Target environment |
--level <level> | Minimum log level (Debug, Information, Warning, Error) |
--filter <text> | Filter log entries containing the specified text |
Download logs
Section titled “Download logs”opti logs download --environment Production --from "2026-03-01" --to "2026-03-02"Downloads logs for a date range to a local file.
| Flag | Description |
|---|---|
--from <date> | Start date (ISO 8601) |
--to <date> | End date (ISO 8601) |
--output <path> | Output file path (default: stdout) |
Database commands
Section titled “Database commands”Show connection info
Section titled “Show connection info”opti db info --environment IntegrationDisplays database connection details for the specified environment.
Export database
Section titled “Export database”opti db export --environment Production --output backup.bacpacExports the database as a .bacpac file.
Import database
Section titled “Import database”opti db import --environment Integration --input backup.bacpacImports a .bacpac file into the target environment database. This replaces the existing database.
Global flags
Section titled “Global flags”These flags are available on all commands:
| Flag | Description |
|---|---|
--project <id> | Override the default project |
--format <format> | Output format: table, json, csv |
--verbose | Show detailed output including API calls |
--quiet | Suppress non-essential output |
--help | Show help for the command |
--version | Show CLI version |
Exit codes
Section titled “Exit codes”| Code | Meaning |
|---|---|
0 | Success |
1 | General error |
2 | Authentication error |
3 | Resource not found |
4 | Deployment failed |
5 | Timeout |