Manage files in 1Password using 1Password SDKs
You can use 1Password SDKs to read, save, and delete files in your items in 1Password. Before you begin, follow the steps to get started with a 1Password SDK.
See the examples folder in the 1Password Go, JavaScript, or Python SDK GitHub repository for example code you can quickly clone and test in your project.
You can store files in Password in two ways:
- Field file: A file attachment stored as a custom field in any item. You can attach multiple field files to each item.
- Document file: A file stored as a Document item. Document items can only store a single document file.
Read a file
You can read any file saved in 1Password using the Items().Files().Read
function with the file attributes of the file you want to retrieve, and the IDs for the item and vault where the file is stored. 1Password returns the file content as an array of bytes.
You can get the file attributes for a file from its parent item by retrieving it.
- File field
- Document file
- Go
- JavaScript
- Python
- Go
- JavaScript
- Python
Field file operations
Save a file
You can save field files when you create an item or modify an existing item.
To save a file in 1Password as a field file, you'll need to read the file locally then pass the file contents and name using the FileCreateParams
parameter.
Field file parameters include:
Parameter | Description |
---|---|
Name | The name of the file. |
Content | The file contents. |
Section ID | The ID for the custom section where the file will be saved. If the section the ID points to does not exist in the item, a new section will be created. |
Field ID | The ID for the field where the file will be saved. Must be unique within the Fields and Files of the item. |
- Save files in a new item
- Save a file in an existing item
- Go
- JavaScript
- Python
- Go
- JavaScript
- Python
Remove a file
You can delete field files using the Items().Files().Delete
function with the item, section, and field IDs for the file you want to delete. This will remove the file and return the modified item.
- Go
- JavaScript
- Python
Document operations
Save a document
To save a file in 1Password as a new Document item, you'll need to read the file locally then pass the file contents to the item create function using the DocumentCreateParams
parameter. Make sure to specify Document as the item category.
- Go
- JavaScript
- Python
Replace a document
To replace the file in a Document item, read the new file locally then pass the file contents to the replaceDocument
function using the DocumentCreateParams
parameter.
- Go
- JavaScript
- Python
Limitations
1Password SDKs currently have a maximum message size of 50 MB, which impacts the following file operations:
- The
Files().Attach
andFiles().ReplaceDocument
operations can't create files larger than 50 MB. - The
Files().Read
operation can't retrieve file contents exceeding 50 MB. - The
Items().Create
operation can't create items containing more than 50 MB of file content.
Get help
1Password includes 1 GB of storage for individual accounts. Shared plans include:
Plan | Storage |
---|---|
1Password Families | 1 GB per person |
1Password Teams | 1 GB per person |
1Password Business | 5 GB per person |
If you aren't able to save documents in a 1Password Business account, ask your administrator to turn on file storage for team members.