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.
- 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
- Go
- JavaScript
- Python
You can read any file saved in 1Password using the
Items().Files().Read method with the 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
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 theFileCreateParams 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
You can add files to a new item when you create the item by including them in the
ItemCreateParams struct.Remove a file
- Go
- JavaScript
- Python
You can delete field files using the
Items().Files().Delete() method with the item, section, and field IDs for the file you want to delete. This will remove the file and return the modified item.Document operations
Save a document
- Go
- JavaScript
- Python
To save a file in 1Password as a new Document item, read the file locally then pass the file contents to the
Items().Create() method using the DocumentCreateParams struct. Make sure to specify Document as the item category.Replace a document
- Go
- JavaScript
- Python
To replace the file in a Document item, read the new file locally then pass the file contents to the
Items().Files().ReplaceDocument() method using the DocumentCreateParams struct.Limitations
1Password SDKs currently have a maximum message size of 50 MB, which impacts the following file operations:- The SDK can’t create files larger than 50 MB.
- The SDK can’t retrieve file contents exceeding 50 MB.
- The SDK 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 |