# アイテムを編集する

フラグを使って[アイテムに関する基本情報を編集](https://developer.1password.com/docs/cli/item-edit/#edit-an-items-basic-information)し、代入文を使って[アイテムの組み込みフィールドとカスタムフィールドを編集](https://developer.1password.com/docs/cli/item-edit/#edit-built-in-and-custom-fields)できます。機密な値を編集するには、[JSONテンプレートを使います](https://developer.1password.com/docs/cli/item-edit/#edit-an-item-using-a-json-template)。

\
op item edit を使ってSSHキーを編集することはできません。1Password CLIを使った SSH鍵[の管理](https://developer.1password.com/docs/cli/ssh-keys)について詳しくは、こちらをご覧ください。

### 必要条件​ <a href="#id-8zlk3w4jd0t9" id="id-8zlk3w4jd0t9"></a>

1Password CLI を使ってアイテムを編集する前に、次のことを行う必要があります。

* [1Passwordにサインアップする](https://1password.com/pricing)
* [1Password CLIをインストールする](https://developer.1password.com/docs/cli/get-started#install)

\
フォローしてください\
このガイドの例に従う場合は、まずアイテムCreateガイドにあるサンプルアイテムをCreateしてください（[create the example items in the guide to creating items](https://developer.1password.com/docs/cli/item-create)）。<br>

アイテムの基本情報を編集する

アイテムを編集するには、アイテムの名前、[一意の識別子 (ID)](https://developer.1password.com/docs/cli/reference#unique-identifiers-ids)、または共有リンクを指定して[op item edit](https://developer.1password.com/docs/cli/reference/management-commands/item#item-edit)を使います。\
フラグを使って、新しいパスワードを生Createしたり、アイテムのタイトル、vault、タグ、URLを編集したりできます。

例えば、サンプルアイテムNetflixの名前を変更するには、それをTutorial vaultからPrivate vaultに移し、タグを更新し、URLを編集して、新しいランダムパスワードを生Createします。

Bash, Zsh, sh, fishの場合

$ op item edit "Netflix" \\

\--title "Edited Netflix" \\

\--vault Private \\

\--tags tutorial \\

\--url <https://www.netflix.com> \\

\--generate-password='letters,digits,symbols,32'

PowerShelの場合

PS C:¥> op item edit "Netflix" \`

\--title "Edited Netflix" \`

\--vault Private \`

\--tags tutorial \`

\--url <https://www.netflix.com> \`

\--generate-password='letters,digits,symbols,32'

\
サンプルアイテムの名前をNetflixに戻し、Tutorial vaultに戻すには、次の手順を実行します。

Bash, Zsh, sh, fishの場合

$ op item edit "Edited Netflix" \\

\--title "Netflix" \\

\--vault Tutorial

PowerShelの場合

PS C:¥> op item edit "Edited Netflix" \`

\--title "Netflix" \`

\--vault Tutorial

### 組み込みフィールドとカスタムフィールドを編集する <a href="#invrxajtpwp" id="invrxajtpwp"></a>

\[①\<section>.]②\<field>\[\[③\<fieldType>]]=④\<value>

* ①section (オプション) フィールドがSaveされるセクションの名前。
* ②field フィールドの名前。
* ③fieldType フィールドのタイプ。指定されていない場合、fieldType は同じままになります。
* ④value フィールドにSaveする情報。指定しない場合は、値は同じままになります。

例えば、HBO Maxアイテムのサブスクリプションの更新日を変更するには、次の手順を実行します。

Bash、 Zsh、sh、 fishの場合

$ op item edit "HBO Max" \\

'Renewal Date=2023-5-15'

PowerShellの場合

PS C:¥> op item edit "HBO Max" \`

'Renewal Date=2023-5-15'

#### カスタムフィールドを削除する <a href="#id-35ch9akbgd6m" id="id-35ch9akbgd6m"></a>

カスタム フィールドを削除するには、fieldType の代わりに\[delete]を指定します。セクション内の全フィールドを削除すると、そのセクションも削除されます。空のフィールドは削除できませんが、空の文字列に設定することはできます。\
代入文を使って、サンプルのHBO Maxアイテムのサブスクリプション更新日を削除するには、次の手順を実行します。

Bash、 Zsh、sh、 fishの場合

$ op item edit "HBO Max" \\

'Renewal Date=2023-5-15'

PowerShellの場合

PS C:¥> op item edit "HBO Max" \`

'Renewal Date=2023-5-15'

### JSONテンプレートを使ってアイテムを編集する <a href="#id-8usfirwby9s3" id="id-8usfirwby9s3"></a>

アイテムの機密値を編集するには、[アイテムJSONテンプレート](https://developer.1password.com/docs/cli/item-template-json)を使います。

①編集したいアイテムのJSON出力を取得し、ファイルにSaveします。\
$ op item get \<item> --format json > newItem.json\
最初からCreateり直したい場合は、op item template getを使ってアイテムのカテゴリーの空のテンプレートを取得できます。

②ファイルを編集します。\
③--templateフラグを使って編集したファイルへのパスを指定し、変更を項目に適用します。\
$ op item edit \<item> --template=newItem.json

④ファイルを削除します。

パイプ入力を使ってアイテムを編集することもできます。

$ cat newItem.json | op item edit \<item>\
衝突を避けるため、パイプ入力と --template フラグを同じコマンドで組み合わせることはできません。

### 次のステップ​ <a href="#id-5pu9ddelzvz8" id="id-5pu9ddelzvz8"></a>

Tutorial vaultをCreateした場合は、そのvaultとCreateしたサンプルアイテムを削除できます。

op vault delete "Tutorial"

### さらに詳しく知りたい場合は... <a href="#id-72y6he1p77u4" id="id-72y6he1p77u4"></a>

* [op item reference documentation](https://developer.1password.com/docs/cli/reference/management-commands/item)
* [Built-in and custom item fields](https://developer.1password.com/docs/cli/item-fields)
* [Item JSON template](https://developer.1password.com/docs/cli/item-template-json)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://manual.dxable.com/1password/edit-items.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
