Skip to content

onepasswordItemFields uuid [vault-uuid [account-name]]

onepasswordItemFields returns structured data from 1Password using the 1Password CLI (op). uuid is passed to op get item <uuid>, the output from op is parsed as JSON, and each element of details.sections are iterated over and any fields are returned as a map indexed by each field's n. If there is no valid session in the environment, by default you will be interactively prompted to sign in.

Example

The result of

{{ (onepasswordItemFields "abcdefghijklmnopqrstuvwxyz").exampleLabel.v }}

is equivalent to calling

$ op get item abcdefghijklmnopqrstuvwxyz --fields exampleLabel

Example

Given the output from op:

{
  "uuid": "<uuid>",
  "details": {
    "sections": [
      {
        "name": "linked items",
        "title": "Related Items"
      },
      {
        "fields": [
          {
            "k": "string",
            "n": "D4328E0846D2461E8E455D7A07B93397",
            "t": "exampleLabel",
            "v": "exampleValue"
          }
        ],
        "name": "Section_20E0BD380789477D8904F830BFE8A121",
        "title": ""
      }
    ]
  },
}

the return value of onepasswordItemFields will be the map:

{
    "exampleLabel": {
        "k": "string",
        "n": "D4328E0846D2461E8E455D7A07B93397",
        "t": "exampleLabel",
        "v": "exampleValue"
    }
}

Info

If you're using 1Password CLI 2.0, then the structure of the data returned by the onepasswordDetailsFields template function will be different and you will need to update your templates.

Warning

The structure of the data returned will not be finalized until 1Password CLI 2.0 is released.

Back to top