> 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/load-secrets-using-1password-sdks.md).

# 1Password SDKを使用してアイテムを管理する

### 1Password SDKを使用してアイテムを管理する <a href="#id-269hxczf1ko" id="id-269hxczf1ko"></a>

1Password SDK を使うと、1Password アイテムにSaveされているシークレット値の読み取り、書き込み、更新を行うことができます。始める前に、1Password SDK の[使用を開始するための手順に従ってください。](https://developer.1password.com/docs/sdks#get-started)

アイテムを管理するときは、保管庫名、アイテム名、セクション名、フィールド名の代わりに[一意の識別子 (ID)を使う必要があります。保管庫](https://developer.1password.com/docs/sdks/concepts#unique-identifiers)[とアイテムを一覧表示する](https://developer.1password.com/docs/sdks/list-vaults-items/)ことで ID を取得できます。

[サポートされているフィールド タイプ](https://developer.1password.com/docs/sdks/concepts/#supported-field-types)に対してアイテム管理操Createを実行できます。

ヒント

プロジェクトですぐに複製してテストできるサンプル コードについては、 1Password [Go](https://github.com/1Password/onepassword-sdk-go/tree/main/example)、[JavaScript](https://github.com/1Password/onepassword-sdk-js/tree/main/examples)、または[Python](https://github.com/1Password/onepassword-sdk-python/tree/main/example) SDK GitHub リポジトリの examples フォルダーを参照してください。

### アイテムをCreateする <a href="#v3jba7pyevfp" id="v3jba7pyevfp"></a>

CreateCreateするアイテムのパラメータを指定し、定義したアイテムをclient.Items.Create関数に渡します。

* **Go**

次の例では、ユーザー名、パスワード、ワンタイム パスワード、および 1Password が資格情報を自動入力する Web サイトを含むログイン項目をCreateします。

ワンタイム パスワード フィールドの値は、ワンタイム パスワード シークレットまたは[otpauth://URI の](https://github.com/google/google-authenticator/wiki/Key-Uri-Format)いずれかになります。この例では、ワンタイム パスワード フィールドはカスタム セクションの下に整理されています。

![](/files/Ufi0GmuSXryfLD2q0cWZ) ![](/files/D2hgewHg1TLxVz7juPNV)

* **JavaScript**

次の例では、ユーザー名、パスワード、ワンタイム パスワードを含むログイン項目と、1Password が資格情報を自動入力する Web サイトをCreateします。

ワンタイム パスワード フィールドの値は、ワンタイム パスワード シークレットまたは otpauth:// URI のいずれかです。この例では、ワンタイム パスワード フィールドがカスタム セクションの下に編Createされています。

// Creates an item

let item = await client.items.create({

title: "My Item",

category: sdk.ItemCategory.Login,

vaultId: "7turaasywpymt3jecxoxk5roli",

fields: \[

{

id: "username",

title: "username",

fieldType: sdk.ItemFieldType.Text,

value: "my username",

},

{

id: "password",

title: "password",

fieldType: sdk.ItemFieldType.Concealed,

value: "my secret value",

},

{

id: "onetimepassword",

title: "one-time password",

sectionId: "custom section",

fieldType: sdk.ItemFieldType.Totp,

value:

"otpauth://totp/my-example-otp?secret=jncrjgbdjnrncbjsr\&issuer=1Password",

},

],

sections: \[

{

id: "custom section",

title: "my section",

},

],

tags: \["test tag 1", "test tag 2"],

websites: \[

{

url: "example.com",

label: "url",

autofillBehavior: sdk.AutofillBehavior.AnywhereOnWebsite,

},

],

});

* **Python**

次の例では、ユーザー名、パスワード、ワンタイム パスワードを含むログイン項目と、1Password が資格情報を自動入力する Web サイトをCreateします。

ワンタイム パスワード フィールドの値は、ワンタイム パスワード シークレットまたは otpauth:// URI のいずれかです。この例では、ワンタイム パスワード フィールドがカスタム セクションの下に編Createされています。

\# Create an Item and add it to your vault.

to\_create = ItemCreateParams(

title="MyName",

category="Login",

vault\_id="7turaasywpymt3jecxoxk5roli",

fields=\[

ItemField(

id="username",

title="username",

field\_type="Text",

value="mynameisjeff",

),

ItemField(

id="password",

title="password",

field\_type="Concealed",

value="jeff",

),

ItemField(

id="onetimepassword",

title="one-time-password",

field\_type="Totp",

section\_id="totpsection",

value="otpauth://totp/my-example-otp?secret=jncrjgbdjnrncbjsr\&issuer=1Password",

),

],

sections=\[

ItemSection(id="", title=""),

ItemSection(id="totpsection", title=""),

],

tags=\["test tag 1", "test tag 2"],

websites=\[

Website(

label="my custom website",

url="<https://example.com>",

autofill\_behavior="AnywhereOnWebsite",

)

],

)

created\_item = await client.items.create(to\_create)

アイテムパラメータには以下が含まれます。

| **パラメータ** | **意味**                                                                          |
| --------- | ------------------------------------------------------------------------------- |
| Title     | アイテムの名前。                                                                        |
| Category  | Createする[アイテムの種類](https://support.1password.com/item-categories/)。サポートされているカテゴリ |
| Vault ID  | アイテムをCreateする保管庫の ID。                                                           |
| Tags      | アイテムに追加するタグのリスト。                                                                |
| Websites  | 1Password が項目を自動入力する Web サイトのオプション リスト。ログインとパスワードの項目でのみ使用できます。                  |

カスタム セクション パラメータには次のものが含まれます。

| **パラメータ**     | **説明**        |
| ------------- | ------------- |
| Section ID    | セクションの一意の識別子。 |
| Section Title | セクションの名前。     |

フィールド パラメータには次のものが含まれます。

| **パラメータ**     | **説明**                                                                                                                                                   |
| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ID            | フィールドの一意の識別子。ログイン項目usernameなどの項目カテゴリに固有のフィールドの場合は、適切な[組み込みフィールド](https://developer.1password.com/docs/cli/item-fields#built-in-fields)ID を使用します。password |
| Title         | フィールドの名前。                                                                                                                                                |
| Field type    | [フィールドの](https://developer.1password.com/docs/sdks/concepts#supported-fields)タイプ。サポートされているフィールド                                                          |
| Value         | フィールドに格納される値。                                                                                                                                            |
| Field Details | オプション。                                                                                                                                                   |
| Section ID    | フィールドをカスタム セクションに整理するには、セクションの ID を指定します。オプション。                                                                                                          |

自動入力ウェブサイトパラメータには以下が含まれます:

| **パラメータ** | **説明**                                                                                                                                                                                                                                                                                       |
| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| URL       | ウェブサイトの URL。                                                                                                                                                                                                                                                                                 |
| ラベル       | ウェブサイトの名前。                                                                                                                                                                                                                                                                                   |
| 自動入力の動作   | <p>1Password がウェブサイトで認証情報を自動入力するタイミング。オプションには次のものがあります:</p><ul><li>AnywhereOnWebsite: 1Password は、サブドメインを含む、Web サイトの一部である全てのページで資格情報を自動入力します。</li><li>ExactMatch: 1Password は、ドメイン (ホスト名とポート) が完全に一致する場合にのみ資格情報を自動入力します。</li><li>Never: 1Password はこの Web サイトで資格情報を自動入力することはありません。</li></ul> |

### ワンタイムパスワードを取得する <a href="#gu8myut3fzdz" id="gu8myut3fzdz"></a>

1Password SDK を使うと、フィールドからワンタイム パスワードなどのフィールドにSaveされている値を取得できますtotp。

* **Go**

前の手順でCreateしたアイテムからワンタイム パスワードを取得して印刷するには:

![](/files/Z4SzdvbZsn8BAH6cuskK)

* **JavaScript**

前の手順でCreateしたアイテムからワンタイム パスワードを取得して印刷するには:

![](/files/OxLsdX1Ty9pnPNO5TR8m)

* **Python**

前の手順でCreateしたアイテムからワンタイム パスワードを取得して印刷するには:

![](/files/a4EyiFOMjKvEs8midEIe)

### アイテムを入手する <a href="#rfpafxbmigks" id="rfpafxbmigks"></a>

アイテムを取得するには、取得するアイテムのアイテム ID と保管庫 ID を client.Items.Get 関数に渡します。

* **Go**

前の手順でCreateしたアイテムを取得するには:

// Retrieves the newly created item

login, err := client.Items.Get(context.Background(), createdItem.VaultID, createdItem.ID)

if err != nil {

panic(err)

}

* **JavaScript**

let retrievedItem = await client.items.get(item.vaultId, item.id);

* **Python**

前の手順でCreateしたアイテムを取得するには:

\# Retrieve an item from your vault.

item = await client.items.get(created\_item.vault\_id, created\_item.id)

### アイテムを更新する <a href="#id-1augsdflgzdz" id="id-1augsdflgzdz"></a>

アイテムを更新するには、更新する[アイテムを取得し](https://developer.1password.com/docs/sdks/manage-items/#get-an-item)、変更内容を指定して、更新したアイテムを関数に渡しますclient.Items.Put。

* **Go**

![](/files/MVbT3xOzNxWs5vKW8wgV)

* **JavaScript**

![](/files/eCzliIktpByzmqNLzzCL)

* **Python**

![](/files/hYcq1J82bD9UvzGg3xcV)

### アイテムを削除する <a href="#id-2q2arwgwvzpj" id="id-2q2arwgwvzpj"></a>

アイテムを削除するには、削除するアイテムのアイテム ID と保管庫 ID を client.Items.Delete 関数に渡します。

* **Go**

err := client.Items.Delete(context.Background(), vaultID, itemID)

if err != nil {

panic(err)

}

* **JavaScript**

// Deletes an item

await client.items.delete(item.vaultId, item.id);

* **Python**

\# Delete a item from your vault.

await client.items.delete(created\_item.vault\_id, updated\_item.id)

Troubleshooting

アイテムをCreate、編集、または削除できず、「この引数を実行するための適切な権限がありません」というエラーが表示される場合は、アイテムがSaveされている保管庫内のサービス アカウントの権限を確認してください。

* ①1Password.com のアカウントに[サインインします。](https://start.1password.com/signin)
* ②サイドバーで[開発者ツールを](https://start.1password.com/developer-tools)選択します。
* ③サービス アカウントを選択し、Vaults テーブルの Vault の横にRead & Write が表示されていることを確認します。

サービス アカウントに読み取りアクセス権のみがある場合は、読み取り権限と書き込み権限を持つ[新しいサービス アカウントをCreateする](https://developer.1password.com/docs/service-accounts/get-started#create-a-service-account)必要があります。

![1Password.com ではサービス アカウントの詳細を公開しています。](/files/Cg9LRDNW1DQ7iVj5jJvB)

### 詳しく <a href="#id-3tfb557kbawg" id="id-3tfb557kbawg"></a>

* [秘密参照構文](https://developer.1password.com/docs/cli/secret-reference-syntax/)
* [1Password SDKを使用してシークレットをロードする](https://developer.1password.com/docs/sdks/load-secrets/)
* [1Password SDKを使用して保管庫とアイテムを一覧表示する](https://developer.1password.com/docs/sdks/list-vaults-items/)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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/load-secrets-using-1password-sdks.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.
