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.
You can use 1Password SDKs to manage vaults in 1Password. You can only get information about vaults the authenticated user has access to, and you can only manage vaults where you have the Manage Vault permission.
We recommend authenticating with the 1Password desktop app to manage vaults. Service accounts are scoped to specific vaults, and must have explicit permission to create new vaults. Service accounts can’t update existing vaults and can only delete vaults created by the service account.
Before you get started
Before you begin, follow the steps to get started with a 1Password SDK. The examples on this page assume you have an initialized client instance. For example:
package main
import (
"context"
"github.com/1password/onepassword-sdk-go"
)
func main() {
// TODO: Initialize client using your preferred authentication method (see Overview > Get started)
client, err := onepassword.NewClient(context.Background(),
)
if err != nil {
panic(err)
}
// Your code here
}
import sdk from "@1password/sdk";
async function main() {
const client = await sdk.createClient({
// TODO: Initialize client using your preferred authentication method (see Overview > Get started)
});
// Your code here
}
main().catch(console.error);
const sdk = require("@1password/sdk");
async function main() {
const client = await sdk.createClient({
// TODO: Initialize client using your preferred authentication method (see Overview > Get started)
});
// Your code here
}
main().catch(console.error);
import asyncio
from onepassword import Client # Also import DesktopAuth for desktop app authentication.
async def main():
# TODO: Initialize client using your preferred authentication method (see Overview > Get started)
client = await Client.authenticate(...)
# Your code here
asyncio.run(main())
See the examples folder in the 1Password Go, JavaScript, or Python SDK GitHub repository for full example code you can quickly clone and test in your project.
Create a vault
If you’re authenticating with a service account, make sure the service account has permission to create vaults. If it doesn’t have permission to create vaults, you’ll need to create a new service account with this permission or authenticate using the 1Password desktop app.
Use the Vaults().Create() method to create a new vault. This method requires a VaultCreateParams struct with the following fields:
Title: The name of the vault.
Description: An optional pointer to a string containing the vault’s description.
Returns: A Vault struct.description := "This vault was created with the Go SDK."
// Create a vault with a description
createParams := onepassword.VaultCreateParams{
Title: "Go SDK Vault",
Description: &description,
}
createdVault, err := client.Vaults().Create(context.Background(), createParams)
if err != nil {
panic(err)
}
fmt.Printf("Created vault with description: %v\\n", createdVault)
Use the vaults.create() method to create a new vault. This method requires an options object with the following properties:
title: The name of the vault.
description: An optional description for the vault.
Returns: A Promise that resolves to a Vault object.// Create a vault
createdVault = await client.vaults.create({
title: "JS SDK Vault",
description: "A vault created via the JS SDK",
});
console.log(
"Created vault",
createdVault.title,
"(" + createdVault.id + ")",
);
Use the vaults.create() method to create a new vault. This method requires a VaultCreateParams object with the following parameters:
title: The name of the vault.
description: An optional description for the vault.
allow_admins_access: A boolean that determines whether people who belong to the Administrators group can access the vault.
Returns: A Vault object.from onepassword import VaultCreateParams
# Create a vault
vault_create_params = VaultCreateParams(
title="Python SDK Vault",
description="A description",
allow_admins_access=False,
)
created_vault = await client.vaults.create(vault_create_params)
print(f"Created vault: {created_vault.id} - {created_vault.title}")
Get a vault overview
Use the Vaults().GetOverview() method with the unique identifier (ID) of a vault to retrieve high-level metadata about the vault.The following example gets the overview for the vault you created in the previous step.// Get vault overview
vaultOverview, err := client.Vaults().GetOverview(context.Background(), createdVault.ID)
if err != nil {
panic(err)
}
fmt.Printf("Vault overview: %v\\n", vaultOverview)
Use the vaults.getOverview() method with the unique identifier (ID) of a vault to retrieve high-level metadata about the vault.The following example gets the overview for the vault you created in the previous step.// Get vault overview
const vaultOverview = await client.vaults.getOverview(createdVault.id);
console.log(JSON.stringify(vaultOverview));
Use the vaults.get_overview() method with the unique identifier (ID) of a vault to retrieve high-level metadata about the vault.# Get a vault overview
vault_overview = await client.vaults.get_overview("your-vault-id")
print(vault_overview)
Get vault details
Use the Vaults().Get() method with the unique identifier (ID) of a vault to get details about the vault.The following example gets details for the vault you retrieved in the previous step.// Get vault details
vault, err := client.Vaults().Get(context.Background(), vaultOverview.ID, onepassword.VaultGetParams{})
if err != nil {
panic(err)
}
fmt.Printf("Vault details: %v\\n", vault)
Use the vaults.get() method with the unique identifier (ID) of a vault to get details about the vault.The following example gets details for the vault you created in the first step.// Get vault details
const vault = await client.vaults.get(createdVault.id, { accessors: false });
console.log(JSON.stringify(vault));
Use the vaults.get() method with the unique identifier (ID) of a vault to get details about the vault. For example, to get a vault’s ID and name:from onepassword import VaultGetParams
# Get a vault
get_params = VaultGetParams(
accessors=True,
)
vault = await client.vaults.get("your-vault-id", get_params)
print(f"Retrieved vault: {vault.id} - {vault.title}")
Update a vault
Use the Vaults().Update() method to modify the details of an existing vault. This method requires the following:
vaultID: The unique identifier of the vault you want to update.
- A
VaultUpdateParams struct that contains the new vault details:
Title: The new name for the vault.
Description: An updated description for the vault.
Returns: The updated Vault struct.The following example updates the name and description of the vault you created in the first step.// Update a vault
updateParams := onepassword.VaultUpdateParams{
Title: nil,
Description: nil,
}
name := "Go SDK Updated Vault"
description = "Updated description from Go SDK"
updateParams.Title = &name
updateParams.Description = &description
// Update the vault
updatedVault, err := client.Vaults().Update(context.Background(), createdVault.ID, updateParams)
if err != nil {
panic(err)
}
fmt.Println("Updated Vault: ", updatedVault.Title)
Use the vaults.update() method to modify the details of an existing vault. This method requires the following:
vaultId: The unique identifier of the vault you want to update.
- An object that contains the new vault details:
title: The new name for the vault.
description: An updated description for the vault.
Returns: A Promise that resolves to the updated Vault object.The following example updates the name and description of the vault you created in the first step.// Update vault
await client.vaults.update(createdVault.id, {
title: "JS SDK Vault Updated",
description: "An updated vault created via the SDK",
});
console.log("Updated vault", createdVault.id);
Use the vaults.update() method to modify the details of an existing vault. This method requires the following:
vault_id: The unique identifier of the vault you want to update.
- A
VaultUpdateParams object that contains the new vault details:
title: The new name for the vault.
description: An updated description for the vault.
Returns: The updated Vault object.from onepassword import VaultUpdateParams
vault_id = "your-vault-id"
# Update a vault
update_params = VaultUpdateParams(
title="Python SDK Updated Name",
description="Updated description",
)
updated_vault = await client.vaults.update(vault_id, update_params)
print(
f'Updated vault "{updated_vault.title}" ({updated_vault.id}): '
f'{updated_vault.description!r}'
)
Delete a vault
To delete a vault, use the Vaults().Delete() method with the unique identifier of the vault you want to delete.The following example deletes the vault you created in the first step.// Delete vault
err = client.Vaults().Delete(context.Background(), createdVault.ID)
if err != nil {
panic(err)
}
fmt.Println("Deleted vault.")
To delete a vault, use the vaults.delete() method with the unique identifier of the vault you want to delete.The following example deletes the vault you created in the first step.// Delete vault
await client.vaults.delete(createdVault.id);
console.log("Deleted vault", createdVault.id);
To delete a vault, use the vaults.delete() method with the unique identifier of the vault you want to delete.vault_id = "your-vault-id"
# Delete a vault
await client.vaults.delete(vault_id)
print(f"Vault {vault_id} successfully deleted.")
Learn more