Setting default section title

Options
mkrogh
mkrogh
Community Member

With CLI 2 it seems like you cannot set the section title of the default ID less section, but you can change it in the 1password app (and it was possible in cli v1)

During create if you add a section to the json template it will automatically get a generated ID, you cannot set the id e.g. null or an empty string to name the default section.

Is there any way to set the default section title via the CLI?

Example of json template:

{
  "fields": [
    {
      "id": "notesPlain",
      "type": "STRING",
      "purpose": "NOTES",
      "label": "notesPlain",
      "value": ""
    },
    {
      "id": "console_password",
      "type": "CONCEALED",
      "label": "console_password",
      "value": "a password"
    },
    {
      "id": "key_b64",
      "type": "STRING",
      "label": "key_b64",
      "value": "YSBiYXNlNjQgc3RyaW5nCg=="
    }
  ]
}

Creation is using op item create --vault='some-vault' --category="Server" --title="Test server" --template=opserver2.json

After changing the default section title in the 1password app the op get ID --format=json returns a section field as well:

...
  "sections": [
    {
      "id": "linked items",
      "label": "Related Items"
    },
    {
      "label": "secrets"
    }
  ],
...

1Password Version: 2.7.1
Extension Version: Not Provided
OS Version: macOS 12.6
Browser:_ Not Provided

Comments

  • Hi @mkrogh , I have given this a look and it seems you cannot currently do this with the edit functionality of the cli. However, we have a related solution in the works: enabling piping of json input into the op item edit command. I will take care that this use case is possible in there as well, but I cannot say when this will be out in prod exactly.

    For the creation workflow, you could use a json template and specify the label of the section with a desired title.
    op item create --template 'file.json'

    file.json:

    {
      "title": "Real Login",
      "tags": ["random", "test"],
      "category": "LOGIN",
      "sections": [
        {
          "id": "bt3fx6eqjfpb2yak5f7qrxui7e",
          "label": "MYNAME" <-------------------------------------------------------------- field of interest
         }
      ],
      "fields": [
        {
          "id": "username",
          "type": "STRING",
          "purpose": "USERNAME",
          "label": "username",
          "value": "username"
        },
        {
          "id": "password",
          "type": "CONCEALED",
          "purpose": "PASSWORD",
          "label": "password",
          "value": "password",
          "password_details": {
            "strength": "TERRIBLE"
          }
        },
        {
          "id": "notesPlain",
          "type": "STRING",
          "purpose": "NOTES",
          "label": "notesPlain",
          "value": "this is a test login"
        },
        {
          "id": "go3zgbulw5peqqdszei6yyxfd4",
          "section": {
            "id": "bt3fx6eqjfpb2yak5f7qrxui7e",
            "label": "section-1"
          },
          "type": "STRING",
          "label": "url",
          "value": "https://1password.com"
        },
        {
          "id": "abxnmtlo2thz5wjatuza4nwo6a",
          "section": {
            "id": "bt3fx6eqjfpb2yak5f7qrxui7e",
            "label": "MYNAME"
          },
          "type": "EMAIL",
          "label": "email",
          "value": "wendy.appleseed@1password.com"
        },
      ],
    }
    

    Hope this helps,
    Andi

This discussion has been closed.