Forum Discussion

stopsineman's avatar
stopsineman
New Contributor
4 years ago

How can I retrieve the file referenced by a 'Document' Item via the V2 CLI?

I have several 'document' Items stored in a Vault that I'd like to reference dynamically from the command line rather than having to download them from the 1Password App and reference them on my filesystem. Is there a way to do that? I can see the file in the output of


op item get --vault '<vault>' '<item nam>' --format json | jq '.files[0].content_tpath'

but I can't actually get the file itself in anyway that I can tell.


$ op --version
2.2.0


1Password Version: 8.8.0
Extension Version: Not Provided
OS Version: Not Provided
Browser:_ Not Provided

3 Replies

  • andi_t_1P's avatar
    andi_t_1P
    Icon for 1Password Team rank1Password Team

    Thanks! Glad we could help. Let us know how this works out!

  • stopsineman's avatar
    stopsineman
    New Contributor

    Neat! I'll give this a try on Monday after I figure out why I'm stuck on 2.2.0… :)

  • Former Member's avatar
    Former Member

    Hey stopsineman,

    Starting with 1Password CLI 2.5.0, files within document-type items can also be referenced by the means of secret references.
    Have a look at https://developer.1password.com/docs/cli/secrets-reference-syntax for more details.
    So a string such as op://<vault-name>/<item-name>/<file-name> would be a reference to the underlying document, which can be resolved using, for instance, op read:

    op read op://<vault-name>/<item-name>/<file-name>
    <your-file-content>

    You can find more information about our secret provisioning commands here: https://developer.1password.com/docs/cli/secret-references

    Let us know if this helps!
    Best,
    Horia