Getting started with 1Password for your growing team, or refining your setup? Our Secured Success quickstart guide is for you.
Forum Discussion
Former Member
4 years agoHow do I create/attach a File Field to an existing item using the 1Password CLI
Trying to automate a workflow and was wondering how to use the 1Password CLI to attach/upload a File
Field to an existing item. See uploaded picture with the file depicted. Any help would be much appreciated.
I noticed there is a separate item create and a document create. Is there someway to create a document in an item.
1Password Version: Not Provided
Extension Version: Not Provided
OS Version: Not Provided
Referrer: forum-search:https://1password.community/search?Search=How%20do%20I%20create%2Fattach%20a%20File%20Field%20to%20an%20existing%20item%20using%20the%201Password%20CLI
9 Replies
- andi_t_1P
1Password Team
Thanks for your feedback!
- Former Member
For those searching, it is possible to create a document with the
op document create
command, and then edit it withop item edit
to add any fields you require 👍 - 1P_Simon
1Password Team
Awesome, glad to hear it's working for you now, Oliver!
- oliverroosOccasional Contributor
Sorry 1P_Simon , did just copy the example for cli download instead of checking the version in the example first ...
https://developer.1password.com/docs/cli/get-started/Obviously, you're right. With the newest cli installed it works like expected :)
- 1P_Simon
1Password Team
Hi oliverroos, what is the output of
op --version
? It needs to be https://app-updates.agilebits.com/product_history/CLI2#v2050001 or later.You can find https://developer.1password.com/docs/cli/reference/update
- oliverroosOccasional Contributor
Hi 1P_Simon
many thanks for your reply and for file a feature request.
I tried your example, but this will end in the same error as many others i tried before:
echo "Hello from Simon" > hello.txt && op item create --title "Greeting" --vault="demo" --category SecureNote "greeting[file]=hello.txt" && rm hello.txt
will result in a error:
[ERROR] 2022/09/01 12:46:46 Failed to create item: assignment statement number 1 is not formatted correctly - "file" is not a supported field type. Use: [<section>.]<field>[[fieldType]]=<value>
I'm on 1Password version 8.8 if that helps :) - 1P_Simon
1Password Team
Hi oliverroos, you're correct that it is not supported to attach file fields to document type items via the CLI at this time.
Document type items are currently only supported in the separate
op document create
command and adding file fields is only supported inop item create
.I'll file a feature request to add support for attaching file fields to Document type items via the CLI as well. Probably easiest to merge
op document create
andop item create
(and similarly foredit
).In the meantime, here's an example how you can attach file fields to any other type of item:
echo "Hello from Simon" > hello.txt && op item create --title "Greeting" --category SecureNote "greeting[file]=hello.txt" && rm hello.txt
- oliverroosOccasional Contributor
Hey @"Justin.Yoon_1P"
Two questions regarding the file upload feature for 1Password CLI.
1) The docs at https://developer.1password.com/docs/cli/reference/management-commands/item/ provide some information that it should be possible with [file]=/path/to/your/file and I can't find any limitation regarding the document type items. Is it no supported? If yes, could yo provide an example?
2) Do you have an example for uploading files with 1Password CLI to document type items? Can not get it working, also no docs found.
Thanks for your help,
Oliver - Former Member
Hey @dild
We do not yet support attaching file field types to items yet in the CLI (with the exception of document type items) - but it is being tracked in our internal issue board.