get template
The get template
command returns the expected JSON formatting for an object:
bsafe get template (item|item.field|item.login|item.login.uri|item.card|item.identity|item.securenote|folder|collection|item-collections|org-collection)
While you can use get template
to output the format to your screen, the most common use case is to pipe the output into a bsafe create
operation, using a command-line JSON processor such as jq
and bsafe encode
(encode) to manipulate the values retrieved from the template, for example:
bsafe get template folder | jq '.name="My First Folder"' | bsafe encode | bsafe create folder
Any item.xxx template should be used as a sub-object to an item template, for example:
bsafe get template item | jq ".name=\"My Login Item\" | .login=$(bsafe get template item.login | jq '.username="jdoe" | .password="myp@ssword123"')" | bsafe encode | bsafe create item
The encode
command Base 64 encodes stdin. This command is typically used in combination with a command-line JSON processor such as jq
when performing create and edit operations, for example:
bsafe get template folder | jq '.name="My First Folder"' | bsafe encode | bsafe create folder
bsafe get item 7ac9cae8-5067-4faf-b6ab-acfd00e2c328 | jq '.login.password="newp@ssw0rd"' | bsafe encode | bsafe edit item 7ac9cae8-5067-4faf-b6ab-acfd00e2c328