How to create a secure note via the 1Password CLI?
I'm trying to create a secure note via op create item <category>
, and I saw that "Secure Note" is on the categories list. However, when I try: op create item Secure Note
, the CLI doesn't recognize it. What's the proper syntax?
Thanks!
1Password Version: 0.4.1
Extension Version: Not Provided
OS Version: OS X 10.13.1
Sync Type: Not Provided
Comments
-
Hi @claudiadast ,
Here's a quick example:
$ op get template 'Secure Note' {"notesPlain":"","sections":[]} $ echo '{"notesPlain":"My Note Data","sections":[]}' | op encode eyJub3Rlc1BsYWluIjoiTXkgTm90ZSBEYXRhIiwic2VjdGlvbnMiOltdfQ $ op create item 'Secure Note' 'eyJub3Rlc1BsYWluIjoiTXkgTm90ZSBEYXRhIiwic2VjdGlvbnMiOltdfQ' --title='My Title' --tags='My Tag'
You first get the category template (notice the quotes around 'Secure Note' to protect the space from the shell. Then, you edit that template data to insert your data. Next, you encode that data. Finally, you create the item using the encoded data.
0 -
MrC's is correct. It's a little laborious to create items at the moment, and it's an area that we want to make better. I had a useful post on the forum about secure notes specifically as I had spent a bit of time to write a script to create secure notes from the contents of a file. It was surprisingly difficult to do correctly with taking all of the escaping scenarios into consideration. It looks like that forum post has been lost due to our cleaning up old posts and I don't have the script... but what I remember was that using jq to do the insertion of the text into the json was by far the best way to go about it.
I hope this helps.
Rick
0 -
Thanks for this note. It's not that the process is laborious, its that there is no documentation of the proper schema or form for the JSON. So, I have an additional question... What is the schema for the data in the 'sections:' list? Could I have found it myself somewhere?
0 -
BTW, I use 'spruce merge template.json >file.yaml' to do a JSON to YAML conversion. The YAML is much easier to edit (especially with multi-line strings like certs). And then use 'spruce json file.yaml >file.json' to put the data back into JSON format for 'op' to use.
0 -
@wmeine we are planning to document the item format at some point, but before that we will be revamping the way that items work in the CLI to make them more user-friendly. For now, you can create any kind of item in one of the other apps, and then use
op get item
to inspect its structure and replicate it (only the details portion is needed by the CLI, the rest of the item is generated automatically)0