op environment commands. You can create, get, list, edit, and delete Environments and the secrets they contain.
Every command accepts either the Environment’s name or its unique identifier (ID). If two Environments share a name, use the ID. We also recommend the ID in scripts, because it doesn’t change when an Environment is renamed.
Requirements
Before you can use 1Password CLI to manage Environments, you’ll need to:- Sign up for 1Password
- Install 1Password CLI version
2.43.0or later - Sign in to 1Password CLI with the 1Password desktop app integration, or authenticate with a service account
Service accounts can only use the Environments you grant them access to, and need write access to an Environment to manage its secrets. A service account can only edit or delete Environments it created.
Manage Environments
The examples in this section create an Environment namedStaging, then refer to it by its ID. Replace 6ijsqfxvdxlwjcpsx7yrzs3tka with your Environment’s ID.
Create an Environment
To create an Environment, useop environment create with a name. 1Password CLI returns the new Environment’s name, ID, content version, and when it was created and last updated. Copy the ID to use in the next steps.
Get an Environment
To get an Environment’s details, useop environment get with the Environment’s name or ID.
--format=json.
List Environments
To list the Environments you have access to, useop environment list.
Edit an Environment
To edit an Environment, useop environment edit with the Environment’s name or ID and the --name flag. The name is the only Environment property you can change.
Delete an Environment
To delete an Environment, useop environment delete with the Environment’s name or ID. Nothing is printed on success.
The following example deletes the Environment you renamed in the previous step.
Manage secrets
The examples in this section refer to an Environment by its ID. Replaceblgexucrwfr2dtsxe2q4uu7dp4 with your Environment’s ID. Specify the Environment with the --environment flag, and the secret by name. A secret’s name must start with a letter or underscore and contain only letters, digits, and underscores.
Command arguments can be visible to other processes on your machine. To set a sensitive value, pipe it to the command as JSON instead of using the
--value flag.Create a secret
To add a secret to an Environment, useop environment secret create with the secret’s name and the --environment flag. New secrets are hidden by default. To create a secret whose value is shown by default, add --concealed=false. See Secret visibility.
To create a secret named DB_HOST and show its value by default:
Get a secret
To get one secret, useop environment secret get with the secret’s name and the --environment flag. 1Password CLI returns the secret’s name, value, and whether it’s hidden. The value of a hidden secret is withheld unless you add --reveal.
List secrets
To list the secrets in an Environment, useop environment secret list with the Environment’s name or ID. Add --reveal to include the values of hidden secrets, and --format=dotenv to get output you can save as a .env file.
Edit a secret
To edit a secret, useop environment secret edit with the secret’s name, the --environment flag, and at least one of --name, --value, or --concealed. Anything you don’t specify is left unchanged.
To rename a secret:
Delete a secret
To delete a secret, useop environment secret delete with the secret’s name and the --environment flag. Nothing is printed on success.