Create items
To create a new item in your 1Password account and assign information to it, use the op item create
command.
You can specify basic information about the item with flags and use assignment statements to assign built-in and custom fields. To assign sensitive values, use a JSON template.
Requirements
Before you can use 1Password CLI to create items, you'll need to:
If you want to follow along with the examples in this guide, sign in to your account then create a new vault named Tutorial
where the example items will be saved:
Create an item
To create a new item, use op item create
and specify basic information about the item with flags.
For example, to create a Login item named Netflix
in the Tutorial
vault:
- Bash, Zsh, sh, fish
- PowerShell
Here's what each of the above flags does:
--category Sets the item category, in this case a Login item. Use op item template list
to get a list of available categories. The category value is case-insensitive and ignores whitespace characters. For example, the Social Security Number
category can also be specified as socialsecuritynumber
.
--title Gives the item a name so that you can easily identify it. If unspecified, 1Password CLI selects a default name. For example, Untitled Login item
.
--vault Specifies which vault the item should be created in. If unspecified, the item will be created in your built-in Personal, Private, or Employee vault. The name of this vault varies depending on your account type.
--url Sets the website where 1Password suggests and fills a Login, Password, or API Credential item.
--generate-password Generates a strong password for Login and Password category items. You can specify a password recipe, as shown in the example. If left unspecified, a default recipe will be used to generate a 32-character password consisting of letters, digits, and symbols.
--tags Adds tags to the item using a comma-separated list.
Create a customized item
Each item category has its own set of built-in fields that you can use to save more information to the item. You can also create custom fields to save additional details about the item.
Learn more about built-in and custom fields.
You can assign built-in and custom fields to your item in two ways:
With assignment statements
Command arguments can be visible to other processes on your machine. If you're assigning sensitive values, use an item JSON template instead.
The op item create
command can take a list of assignment statements as arguments to create fields on an item.
Assignment statements are formatted like this:
- section (Optional) The name of the section where you want to create the field.
- field The name of the field you want to create.
- fieldType The type of field you want to create. If unspecified,
fieldType
will default topassword
. - value The information you want to save in the field.
For built-in fields, the field name should match the built-in field id
in the item category template. Don't include a fieldType for built-in fields.
For custom fields, the fieldType should match the custom field type
you want to create. The field name can be anything you want.
If you need to use periods, equal signs, or backslashes in the name of a section or field, use a backslash character to escape them. Don't use backslashes to escape the value.
Here's an example of an assignment statement for the built-in field username on a Login item, set to john.doe@acme.org:
And here's an example of an assignment statement for a custom field type titled date, which is set to 2022-12-31, in a field named Renewal Date within a section titled Subscription Info:
To add both of the above assignment statements to a new item, HBO Max
, in the Tutorial
vault:
- Bash, Zsh, sh, fish
- PowerShell
With an item JSON template
To assign sensitive values, fill out an item JSON template for the category of item you want to create. If you combine field assignment statements with a template, the assignment statements overwrite the template's values.
To see a list of available templates, run op item template list
. To get a template for a category, run op item template get <category>
.
For example, to create a new Login item using a template:
-
Get the template for a Login item and save it in your current directory:
-
Edit the template file to add your information.
-
Create the item using the
--template
flag to specify the path to the template file:This example template file creates a Login item named
Hulu
in a vault specified by its ID. It specifies values for built-inusername
,password
, andnotesPlain
fields. It also adds a customdate
field.Example Login template
login.json
-
Delete the edited template file from your computer.
You can also create an item from standard input using a template:
Create an item from an existing item
You can create a new item from an existing item by piping the item JSON from standard input.
For example, to create a new item based on the HBO Max
item you created in the assignment statement section, with a new title, username, and password:
Add a one-time password to an item
You can attach a one-time password to an item using a custom field assignment statement. The fieldType
should be otp
and the value
should be the otpauth:// URI for the one-time password.
- Bash, Zsh, sh, fish
- PowerShell
Attach a file to an item
You can attach a file to an item using a custom field assignment statement. The field
should be the name the file will have in 1Password, the fieldType
should be file
, and the value
should be the path to the file.
The file in the above example will be named myFileName
. To preserve the original file name, you can omit the field
:
Here's what an example PlayStation Store
login would look like with the file /wendyappleseed/documents/receipt.png
attached, named JanuaryReceipt
.
- Bash, Zsh, sh, fish
- PowerShell
Next steps
If you want to continue learning about item management, keep the example items you created and move on to the edit items tutorial.
If you created a Tutorial vault and don't want to continue on, you can delete the vault and the examples items you created by running: