> ## Documentation Index
> Fetch the complete documentation index at: https://www.1password.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# 1Password CLI reference

export const CodeResult = ({children, resultLang, wrap, expandable}) => {
  const parseChildren = () => {
    let language = "text";
    let codeContent = "";
    const extractText = node => {
      if (typeof node === "string") {
        return node;
      }
      if (Array.isArray(node)) {
        return node.map(extractText).join("");
      }
      if (node?.props?.children) {
        return extractText(node.props.children);
      }
      return "";
    };
    const extractLanguage = node => {
      if (!node) return null;
      if (node.props?.className) {
        const className = node.props.className;
        const langMatch = className.match(/language-(\w+)/);
        if (langMatch) {
          return langMatch[1];
        }
      }
      if (node.props?.["data-language"]) {
        return node.props["data-language"];
      }
      if (node.props?.language) {
        return node.props.language;
      }
      return null;
    };
    if (typeof children === "string") {
      codeContent = children;
    } else if (Array.isArray(children)) {
      codeContent = extractText(children);
      for (const child of children) {
        const detectedLang = extractLanguage(child);
        if (detectedLang) {
          language = detectedLang;
          break;
        }
      }
    } else if (children?.props) {
      const detectedLang = extractLanguage(children);
      if (detectedLang) {
        language = detectedLang;
      }
      codeContent = extractText(children);
    }
    const parts = codeContent.split("#code-result");
    if (parts.length < 2) {
      return {
        command: codeContent.trim(),
        result: null,
        language,
        defaultOpen: false
      };
    }
    const resultText = parts[1].trim();
    const defaultOpen = resultText.startsWith("open");
    const cleanResult = defaultOpen ? resultText.slice(4).trim() : resultText;
    return {
      command: parts[0].trim(),
      result: cleanResult,
      language,
      defaultOpen
    };
  };
  const {command, result, language, defaultOpen} = parseChildren();
  const [isOpen, setIsOpen] = useState(defaultOpen);
  if (!result) {
    return children;
  }
  return <div className="codeblock_accordion not-prose mb-4">
      {}
      <div className="[&>*]:!mb-0 [&>*]:!rounded-b-none">
        <CodeBlock language={language} children={command} wrap={wrap} expandable={expandable} />
      </div>

      {}
      <div className="see_results_container border-t-0 bg-gray-100/80 dark:bg-gray-800/80 overflow-hidden" style={{
    marginTop: "-0.25rem"
  }}>
        <button onClick={() => setIsOpen(!isOpen)} className="w-full px-4 py-2.5 flex items-center gap-1 text-left text-[14px] font-medium text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 hover:bg-gray-200/60 dark:hover:bg-gray-700/60 transition-all duration-150" aria-expanded={isOpen}>
          {isOpen ? <Icon icon="caret-down" size="14" iconType="solid" /> : <Icon icon="caret-right" size="14" iconType="solid" />}

          <span>See result...</span>
        </button>

        {isOpen && <div className="[&>*]:!mt-0 [&>*]:!rounded-t-none border-t border-gray-200/50 dark:border-gray-700/50">
            <CodeBlock language={resultLang || language} children={result} wrap={wrap} expandable={expandable} />
          </div>}
      </div>
    </div>;
};

<Note>
  **Get started**

  If you're new to 1Password CLI, [learn how to set it up and sign in to your account](/cli/get-started/).
</Note>

## Command structure

```
op [command] <flags>
```

1Password CLI uses a noun-verb command structure that groups commands by topic rather than by operation.

The basic structure of a command starts with the 1Password program `op`, then the `command name (noun)`, often followed by a `subcommand (verb)`, then `flags` (which include additional information that gets passed to the command).

For example, to retrieve a list of all the items in your Private vault:

```shell theme={null}
op item list --vault Private
```

To get a list of all global commands and flags, run the following:
​

```shell theme={null}
op --help
```

## Command reference

* [account](/cli/reference/management-commands/account): Manage your locally configured 1Password accounts
* [completion](/cli/reference/commands/completion): Generate shell completion information
* [connect](/cli/reference/management-commands/connect): Manage Connect server instances and tokens in your 1Password account
* [document](/cli/reference/management-commands/document): Perform CRUD operations on Document items in your vaults
* [environment](/cli/reference/management-commands/environment): Manage your 1Password Environments and their variables (Beta)
* [events-api](/cli/reference/management-commands/events-api): Manage Events API integrations in your 1Password account
* [group](/cli/reference/management-commands/group): Manage the groups in your 1Password account
* [inject](/cli/reference/commands/inject): Inject secrets into a config file
* [item](/cli/reference/management-commands/item): Perform CRUD operations on the 1Password items in your vaults
* [plugin](/cli/reference/management-commands/plugin): Manage the shell plugins you use to authenticate third-party CLIs
* [read](/cli/reference/commands/read): Read a secret reference
* [run](/cli/reference/commands/run): Pass secrets as environment variables to a process
* [service-account](/cli/reference/management-commands/service-account): Manage service accounts
* [signin](/cli/reference/commands/signin): Sign in to a 1Password account
* [signout](/cli/reference/commands/signout): Sign out of a 1Password account
* [update](/cli/reference/commands/update): Check for and download updates
* [user](/cli/reference/management-commands/user): Manage users within this 1Password account
* [vault](/cli/reference/management-commands/vault): Manage permissions and perform CRUD operations on your 1Password vaults
* [whoami](/cli/reference/commands/whoami): Get information about a signed-in account

## Global flags

```
      --account string     Select the account to execute the command by account shorthand, sign-in address, account ID, or user ID. For a list of available accounts, run 'op account list'. Can be set as the OP_ACCOUNT environment variable.
      --cache              Store and use cached information. Caching is enabled by default on UNIX-like systems. Caching is not available on Windows. Options: true, false. Can also be set with the OP_CACHE environment variable. (default true)
      --config directory   Use this configuration directory.
      --debug              Enable debug mode. Can also be enabled by setting the OP_DEBUG environment variable to true.
      --encoding type      Use this character encoding type. Default: UTF-8. Supported: SHIFT_JIS, gbk.
      --format string      Use this output format. Can be 'human-readable' or 'json'. Can be set as the OP_FORMAT environment variable. (default "human-readable")
  -h, --help               Get help for op.
      --iso-timestamps     Format timestamps according to ISO 8601 / RFC 3339. Can be set as the OP_ISO_TIMESTAMPS environment variable.
      --no-color           Print output without color.
      --session token      Authenticate with this session token. 1Password CLI outputs session tokens for successful `op signin` commands when 1Password app integration is not enabled.
```

## Unique identifiers (IDs)

When you retrieve information about an object using the `get` and `list` subcommands, you'll see a string of 26 numbers and letters that make up the object's unique identifier (ID).

You can use names or IDs in commands that take any [account](/cli/reference/management-commands/account/#account-get), [user](/cli/reference/management-commands/user/#user-get), [vault](/cli/reference/management-commands/vault/#vault-get), or [item](/cli/reference/management-commands/item/#item-get) as an argument.

IDs are the most stable way to reference an item. An item's ID only changes when you move the item to a different vault. Commands provided with an ID are also faster and more efficient.

You can get information about an item, including the item's ID and the ID for the vault where it's stored, with [`op item get`](/cli/reference/management-commands/item#item-get).

<CodeResult>
  ```shell theme={null}
  op item get Netflix
  #code-result
  ID:          t2Vz6kMDjByzEAcq6peKnHL4k3
  Title:       Netflix
  Vault:       Private (sdfsdf7werjgdf8gdfgjdfgkj)
  Created:     6 months ago
  Updated:     1 month ago by Wendy Appleseed
  Favorite:    false
  Version:     1
  Category:    LOGIN
  ```
</CodeResult>

To only fetch the item ID, use the same command with the format set to JSON, then use [jq <Icon icon="arrow-up-right-from-square" />](https://jqlang.github.io/jq/) to parse the output.

<CodeResult>
  ```shell theme={null}
  op item get Netflix --format json | jq .id
  #code-result
  "t2Vz6kMDjByzEAcq6peKnHL4k3"
  ```
</CodeResult>

To get the IDs for all vaults in an account:

<CodeResult>
  ```shell theme={null}
  op vault list
  #code-result
  ID                            NAME
  cfqtakqiutfhiewomztljx4woy    Development
  rr3ggvrlr6opoete23q7c22ahi    Personal
  2gq6v6vzorl7jfxdurns4hl66e    Work
  ```
</CodeResult>

## Shell completion

You can add shell completion so that 1Password CLI automatically completes your commands.

With shell completion enabled, start typing an `op` command, then press Tab to see the available commands and options.

<Tabs groupId="shell">
  <Tab title="Bash">
    To enable shell completion with Bash:

    1. Install the bash-completion package
    2. Add this line to your `.bashrc` file:

       ```
       source <(op completion bash)
       ```
  </Tab>

  <Tab title="Zsh">
    To enable shell completion with Zsh, add this line to your `.zshrc` file:

    ```
    eval "$(op completion zsh)"; compdef _op op
    ```
  </Tab>

  <Tab title="fish">
    To enable shell completion with fish, add this to your `.fish` file:

    ```
    op completion fish | source
    ```
  </Tab>

  <Tab title="PowerShell">
    To enable shell completion with PowerShell, add this to your `.ps1` file:

    ```powershell theme={null}
    op completion powershell | Out-String | Invoke-Expression
    ```

    You'll need to enable script execution in PowerShell to start using shell completion. To do that, start a PowerShell window as an administrator and enter:

    ```powershell theme={null}
    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
    ```
  </Tab>
</Tabs>

## Cache item and vault information

1Password CLI can use its daemon process to cache items, vault information, and the keys to access information in an account.

The daemon stores encrypted information in memory using the same encryption methods as on 1Password.com. It can read the information to pass to 1Password CLI, but can’t decrypt it.

On UNIX-like systems, caching between commands is enabled by default. This helps maximize performance and reduce the number of API calls.

If you use 1Password CLI in an environment where caching is not possible, you can turn it off by appending the `--cache=false` flag to your commands, or by setting the `OP_CACHE` environment variable to false.

Caching is not currently available on Windows.

## Alternative character encoding

By default, 1Password CLI processes input and output with UTF-8 encoding.
You can use an alternative character encoding with the `--encoding` option.

Supported alternative character encoding types:

* `gbk`
* `shift-jis`

## Parse JSON output with jq

You can use the `--format` flag or the `OP_FORMAT` environment variable to set your 1Password CLI command output to `json`.

To parse JSON output, we recommend using the command-line tool [jq. <Icon icon="arrow-up-right-from-square" />](https://jqlang.github.io/jq/)

For example, to use jq to retrieve a secret reference for the password saved on an item named `GitHub`:

<CodeResult>
  ```shell theme={null}
  op item get GitHub --format json --fields password | jq .reference
  #code-result
  "op://development/GitHub/password"
  ```
</CodeResult>

## Beta builds

To download 1Password CLI beta builds, navigate to the [1Password CLI downloads page](https://app-updates.agilebits.com/product_history/CLI2#beta) with the **Show betas** option selected. On Linux, you can switch the channel from "stable" to "beta" when adding the 1Password repository in your package manager.

## Example commands

### Items

To get information about an item:

```shell theme={null}
op item get <item name>
```

You'll see the item's [ID](#unique-identifiers-ids), title, vault, when it was created, when it was last modified, the item's version, if it's marked as a favorite, the type of item it is, and the item's fields.

If an item name includes spaces or special characters, enclose it in quotes. For example:

<CodeResult>
  ```shell theme={null}
  op item get "work email"
  #code-result
  ID:          a5w3is43ohs25qonzajrqaqx4q
  Title:       work email
  Vault:       Work (2gq6v6vzorl7jfxdurns4hl66e)
  Created:     6 years ago
  Updated:     9 months ago by Wendy Appleseed
  Favorite:    true
  Version:     1
  Category:    LOGIN
  Fields:
    username:    wendy.c.appleseed@agilebits.com
    password:    NLuXcEtg27JMjGmiBHXZMGCgce
  URLs:
    website:    https://www.gmail.com (primary)
  ```
</CodeResult>

To use `op item get` to retrieve specific fields, include the `--fields` flag followed by a comma-separated list, with the prefix `label=` before each field name. For example, to only retrieve the username and password for the item `work email`:

<CodeResult>
  ```shell theme={null}
  op item get "work email" --fields label=username,label=password
  #code-result
  wendy.c.appleseed@agilebits.com,NLuXcEtg27JMjGmiBHXZMGCgce
  ```
</CodeResult>

Learn more about working with [items](/cli/reference/management-commands/item/).

### Users and groups

To get details about a user:

<CodeResult>
  ```shell theme={null}
  op user get "Wendy Appleseed"
  #code-result
  ID:                     SPRXJFTDHTA2DDTPE5F7DA64RQ
  Name:                   Wendy Appleseed
  Email:                  wendy.c.appleseed@agilebits.com
  State:                  ACTIVE
  Type:                   MEMBER
  Created:                6 years ago
  Updated:                4 months ago
  Last Authentication:    1 month ago
  ```
</CodeResult>

To list the users who belong to a group:

<CodeResult>
  ```
  op group user list "Provision Managers"
  #code-result
  ID                            NAME              EMAIL                              STATE               TYPE      ROLE
  7YEOODASGJE6VAEIOHYWGP33II    Wendy Appleseed   wendy.c.appleseed@agilebits.com    ACTIVE              MEMBER
  UKCYFVOJSFEXLKKZREG7M2MZWM    Johnny Appleseed  johnny.appleseed@agilebits.com     RECOVERY_STARTED    MEMBER
  ```
</CodeResult>

Learn more about working with [users](/cli/reference/management-commands/user/) and [groups](/cli/reference/management-commands/group/).

### Vaults

To create a new vault named `Test`:

```shell theme={null}
op vault create Test
```

To get details about an existing vault:

<CodeResult>
  ```shell theme={null}
  op vault get Work
  #code-result
  ID:                   jAeq2tfunmifZfG4WkuWvsaGGj
  Name:                 Work
  Type:                 USER_CREATED
  Attribute version:    3
  Content version:      241
  Items:                25
  Created:              1 year ago
  Updated:              1 month ago
  ```
</CodeResult>

To list the vaults in an account:

<CodeResult>
  ```shell theme={null}
  op vault list
  #code-result
  ID                            NAME
  vw8qjYEvsdCcZoULJRCqopy7Rv    Development
  2RNjh43dpHB9sDqZXEHiiw7zTe    Personal
  cGxbZbV2pxKBmVJe9oWja4K8km    Work
  ```
</CodeResult>

Learn more about working with [vaults](/cli/reference/management-commands/vault/).

### Secrets

To insert a secret into an environment variable, config file, or script without putting the plaintext secret in code, use a [secret reference](/cli/secret-reference-syntax/) that specifies where the secret is stored in your 1Password account:

```
op://vault-name/item-name/[section-name/]field-name
```

Then, you can use [`op read`](/cli/reference/commands/read/), [`op run`](/cli/reference/commands/run/), or [`op inject`](/cli/reference/commands/inject/) to replace the secret reference with the actual secret at runtime.

To resolve a secret reference and confirm it outputs correctly:

<CodeResult>
  ```shell theme={null}
  op read "op://Work/work email/username"
  #code-result
  wendy.c.appleseed@agilebits.com
  ```
</CodeResult>

Learn more about [loading secrets](/cli/secret-references/).

## Get help

For help with any command, use the `--help` option:

```
op <command> [subcommand] --help
```
