Skip to content

Optimizely Cloud CLI Reference

advanced
📜Advancedcms

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.


Terminal window
npm install -g @optimizely/cli
Terminal window
dotnet tool install -g Optimizely.Cli
Terminal window
opti --version

Terminal window
opti login

Opens a browser window for interactive authentication. Stores credentials locally for subsequent commands.

For CI/CD pipelines, use an API key instead of interactive login:

Terminal window
opti login --api-key <your-api-key>

Or set the environment variable:

Terminal window
export OPTI_API_KEY=<your-api-key>
Terminal window
opti logout

Removes stored credentials.


Terminal window
opti project list

Lists all projects in your organization.

FlagDescription
--format jsonOutput as JSON
--format tableOutput as formatted table (default)
Terminal window
opti project select <project-id>

Sets the default project for subsequent commands. Alternatively, pass --project <id> to any command.

Terminal window
opti project show

Displays project configuration, environments, and deployment history summary.


Terminal window
opti deploy push --environment Integration

Pushes the current directory as a deployment package to the target environment.

FlagDescription
--environment <name>Target environment (Integration, Preproduction, Production)
--package <path>Path to a pre-built deployment package (.zip)
--waitWait for deployment to complete before returning
--timeout <seconds>Maximum wait time (default: 600)
Terminal window
opti deploy promote --from Integration --to Preproduction

Promotes the latest successful deployment from one environment to another.

FlagDescription
--from <environment>Source environment
--to <environment>Target environment
--deployment-id <id>Promote a specific deployment instead of the latest
Terminal window
opti deploy list --environment Production

Lists recent deployments for an environment.

FlagDescription
--environment <name>Filter by environment
--limit <n>Number of results (default: 10)
--format jsonOutput as JSON
Terminal window
opti deploy rollback --environment Production

Rolls back to the previous successful deployment.

FlagDescription
--environment <name>Target environment
--deployment-id <id>Roll back to a specific deployment
Terminal window
opti deploy show <deployment-id>

Shows detailed information about a deployment including build log, status, and timestamps.


Terminal window
opti env list

Lists all environments for the current project with their status and URLs.

Terminal window
opti env show Integration

Shows detailed information about an environment including resources, variables, and domain configuration.

Terminal window
opti env restart Integration

Restarts the application in the target environment without redeploying.

FlagDescription
--waitWait for restart to complete

Terminal window
opti env vars list --environment Integration

Lists all environment variables (values are masked for sensitive variables).

Terminal window
opti env vars set --environment Integration --name MY_SETTING --value "my-value"
FlagDescription
--environment <name>Target environment
--name <key>Variable name
--value <value>Variable value
--secretMark as sensitive (masked in portal and CLI output)
Terminal window
opti env vars remove --environment Integration --name MY_SETTING

Terminal window
opti cdn purge --url "https://www.example.com/en/page/" --environment Production

Purges a specific URL from the CDN cache.

Terminal window
opti cdn purge --path "/en/blog/*" --environment Production

Purges all cached content matching a path pattern.

Terminal window
opti cdn purge --all --environment Production

Clears the entire CDN cache for the environment.


Terminal window
opti logs stream --environment Integration

Streams application logs in real time.

FlagDescription
--environment <name>Target environment
--level <level>Minimum log level (Debug, Information, Warning, Error)
--filter <text>Filter log entries containing the specified text
Terminal window
opti logs download --environment Production --from "2026-03-01" --to "2026-03-02"

Downloads logs for a date range to a local file.

FlagDescription
--from <date>Start date (ISO 8601)
--to <date>End date (ISO 8601)
--output <path>Output file path (default: stdout)

Terminal window
opti db info --environment Integration

Displays database connection details for the specified environment.

Terminal window
opti db export --environment Production --output backup.bacpac

Exports the database as a .bacpac file.

Terminal window
opti db import --environment Integration --input backup.bacpac

Imports a .bacpac file into the target environment database. This replaces the existing database.


These flags are available on all commands:

FlagDescription
--project <id>Override the default project
--format <format>Output format: table, json, csv
--verboseShow detailed output including API calls
--quietSuppress non-essential output
--helpShow help for the command
--versionShow CLI version

CodeMeaning
0Success
1General error
2Authentication error
3Resource not found
4Deployment failed
5Timeout