> For the complete documentation index, see [llms.txt](https://manual.dxable.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://manual.dxable.com/1password/item-json-template.md).

# アイテムJSONテンプレート

1Password CLI は、1PasswordでアイテムをCreateする方法を制御するために使えるアイテムJSONテンプレートをサポートしています。アイテムJSON テンプレートを使うと、カスタム セクションやフィールドを含む全ての[詳細を指定してアイテムをCreate](https://developer.1password.com/docs/cli/item-create/#with-an-item-json-template)できます。

アイテム テンプレートは[`op item get`](https://developer.1password.com/docs/cli/reference/management-commands/item/#item-get)のJSON出力と同様の形式になっているため、保存済みのアイテムに基づいて新しいアイテムを簡単にCreateできます。

各アイテムカテゴリーには独自のテンプレートがあります。`op item` `template list`を使うと、全アイテムカテゴリーのリストを取得できます。また、`op item template get <category>`を使うと指定したアイテムカテゴリーのテンプレートを取得できます。

### **アイテムテンプレートキー** <a href="#hagrtwagsmvk" id="hagrtwagsmvk"></a>

アイテムJSON テンプレートには共通言語キーがあり、テンプレート内のフィールドが 1Password内のアイテムとどのように対応しているかを識別できます。

```
{
  ①"title": " ",
  ②"category": " ",
  "sections": [
    {
      ③"id": " ",
      ④"label": " "
    },
  ],
  "fields": [
    {
     ⑤"id": " ",
    "section": {
     ⑥"id": " "
      },
     ⑦"type": " ",
     ⑧"label": " ",
     ⑨"value": " "
    }
  ]
}

```

アイテム

| **名前**                                                 | **説明**                  |
| ------------------------------------------------------ | ----------------------- |
| <mark style="background-color:orange;">`①title`</mark> | 1Passwordに表示されるアイテムの名前。 |
| <mark style="background-color:red;">`②category`</mark> | アイテムのカテゴリー。             |

#### &#x20;セクション <a href="#nerkp6pyfwt" id="nerkp6pyfwt"></a>

| **名前**                                                | **説明**                                         |
| ----------------------------------------------------- | ---------------------------------------------- |
| <mark style="background-color:purple;">`③"id"`</mark> | セクションの識別子。アイテムに複数のセクションがある場合、各IDは一意である必要があります。 |
| `⑤"label"`                                            | 1Passwordに表示される⑤セクションの名前。                      |

カスタムセクションを追加するには、セクションJSONオブジェクトを`sections`配列に挿入します。

<details>

<summary>セクションJSONオブジェクトを表示するには次のようにします。：</summary>

```
{
  "id": " ",
  "label": " "
}
```

</details>

フィールド

| **名前**        | **説明**                                                                                               |
| ------------- | ---------------------------------------------------------------------------------------------------- |
| `⑤id`         | フィールドのID。各IDは一意である必要がある。空のままにすると、1PasswordはランダムなIDを生Createする。                                        |
| `⑥section id` | フィールドが配置されているセクションのID。カスタムセクションに配置されている場合にのみ必須。                                                      |
| `⑦type`       | フィールドのタイプ。[カスタムフィールドタイプの詳細を参照。](https://developer.1password.com/docs/cli/item-fields/#custom-fields) |
| `⑧label`      | 1Passwordに表示されるフィールド名。                                                                               |
| `⑨value`      | フィールドにSaveされる情報。そのタイプに応じて、文字列、シークレット、数値、日付のいずれかになる。                                                  |

テンプレートにカスタムフィールドを追加するには、新しいフィールドJSONオブジェクトを`fields`配列に挿入します。<br>

<details>

<summary>フィールドJSONオブジェクトを表示するには次のようにします。：</summary>

```
{
  "id": " ",
  "section": {
    "id": " "
  },
  "type": " ",
  "label": " ",
  "value": " "
}
```

</details>

### **JSONの表示** <a href="#vp83ufrf2g8p" id="vp83ufrf2g8p"></a>

以下は1Passwordアプリのアイテム`mysql`の表示と、アイテムJSONテンプレートで表現された同じアイテムを示した例です。

{% tabs %}
{% tab title="アプリ内" %}

<figure><img src="/files/wGfRhBmHu2s5BaxdPzZL" alt="" width="375"><figcaption></figcaption></figure>
{% endtab %}

{% tab title="JSONテンプレート内" %}

```
{
  "id": "4l3udxihvvuhszh2kxyjbblxl4",
  "title": "mysql",
  "version": 3,
  "vault": {
    "id": "uteieiwkhgv6hau7xkorejyvru"
  },
  "category": "DATABASE",
  "last_edited_by": "IU2OKUBKAFGQPFPFZEG7X3NQ4U",
  "created_at": "2021-11-25T14:50:14Z",
  "updated_at": "2022-02-25T18:12:12Z",
  "sections": [
    {
      "id": "g52gfotnw7nhnkgq477si2hmmi",
      "label": "Database Owner"
    }
  ],
  "fields": [
    {
      "id": "notesPlain",
      "type": "STRING",
      "purpose": "NOTES",
      "label": "notesPlain"
    },
    {
      "id": "database_type",
      "type": "MENU",
      "label": "type",
      "value": "mysql"
    },
    {
      "id": "hostname",
      "type": "STRING",
      "label": "server",
      "value": "http://localhost"
    },
    {
      "id": "port",
      "type": "STRING",
      "label": "port",
      "value": "5432"
    },
    {
      "id": "database",
      "type": "STRING",
      "label": "database",
      "value": "app-database"
    },
    {
      "id": "username",
      "type": "STRING",
      "label": "username",
      "value": "mysql-user"
    },
    {
      "id": "password",
      "type": "CONCEALED",
      "label": "password",
      "value": "T4Kn7np2bLJXAFoYPoVC"
    },
    {
      "id": "sid",
      "type": "STRING",
      "label": "SID"
    },
    {
      "id": "alias",
      "type": "STRING",
      "label": "alias"
    },
    {
      "id": "options",
      "type": "STRING",
      "label": "connection options"
    },
    {
      "id": "tpcs7jrjikehw5o4tzbe5pklca",
      "section": {
        "id": "g52gfotnw7nhnkgq477si2hmmi",
        "label": "Database Owner"
      },
      "type": "STRING",
      "label": "admin",
      "value": "Wendy Appleseed"
    },
    {
      "id": "sdqueijyulxryvu5ceuwktjkiq",
      "section": {
        "id": "g52gfotnw7nhnkgq477si2hmmi",
        "label": "Database Owner"
      },
      "type": "EMAIL",
      "label": "email",
      "value": "appleseed.wendy@gmail.com"
    }
  ]
}
```

{% endtab %}
{% endtabs %}

### **さらに詳しく知るには** <a href="#id-3dbj9o91r5jb" id="id-3dbj9o91r5jb"></a>

* [Create an item](https://developer.1password.com/docs/cli/item-create/)
* [Work with items](https://developer.1password.com/docs/cli/reference/management-commands/item/)
* [Work with vaults](https://developer.1password.com/docs/cli/reference/management-commands/vault/)
