How do I create/attach a File Field to an existing item using the 1Password CLI

Community Member

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:How do I create/attach a File Field to an existing item using the 1Password CLI


  • Justin.Yoon_1PJustin.Yoon_1P

    Team 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.

  • oliverroosoliverroos
    Community Member

    Hey @Justin.Yoon_1P

    Two questions regarding the file upload feature for 1Password CLI.

    1) The docs at 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,

  • simon_1Psimon_1P

    Team Member
    edited August 31

    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 in op 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 and op item create (and similarly for edit).

    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
  • oliverroosoliverroos
    Community Member

    Hi @simon_1P
    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 :)

  • simon_1Psimon_1P

    Team Member

    Hi @oliverroos, what is the output of op --version? It needs to be 2.5.0 or later.

    You can find update instructions in the 1Password CLI docs

  • oliverroosoliverroos
    Community Member

    Sorry @simon_1P , did just copy the example for cli download instead of checking the version in the example first ...

    Obviously, you're right. With the newest cli installed it works like expected :)

  • simon_1Psimon_1P

    Team Member

    Awesome, glad to hear it's working for you now, Oliver!

  • bbeckfordbbeckford
    Community Member

    For those searching, it is possible to create a document with the op document create command, and then edit it with op item edit to add any fields you require 👍

  • andi.t_1Pandi.t_1P

    Team Member

    Thanks for your feedback!

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file