Manage vaults using 1Password SDKs
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.
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.
- Go
- JavaScript
- Python
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.
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.
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.
Get a vault overview
- Go
- JavaScript
- Python
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.
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.
Use the vaults.get_overview() 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 details
- Go
- JavaScript
- Python
Use the Vaults().Get() method with the unique identifier (ID) of a vault to get the vault's full metadata.
The following example gets details for the vault you retrieved in the previous step.
Use the vaults.get() method with the unique identifier (ID) of a vault to get the vault's full metadata.
The following example gets details for the vault you created in the first step.
Use the vaults.get() method with the unique identifier (ID) of a vault to get the vault's full metadata.
Update a vault
- Go
- JavaScript
- Python
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
VaultUpdateParamsstruct 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.
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.
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
VaultUpdateParamsobject 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.
The following example updates the name and description of the vault you created in the first step.
Delete a vault
- Go
- JavaScript
- Python
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.
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.
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.
You can also batch create, get, and delete items from a vault.