Signing back into the Community for the first time? You'll need to reset your password to access your account.  Find out more.

Forum Discussion

Former Member's avatar
Former Member
3 years ago

How to create a 1Pass LOGIN ITEM from CLI (op cli) with an attached files/document

Hello 1Pass!

I'm trying to figure out procedure of creating a 1Pass LOGIN ITEM from CLI (op cli) with a two files attached.

There are some docs in different places and examples like this: https://developer.1password.com/docs/cli/v1/usage

However, at all places I've looked, people EITHER upload a DOCUMENT, or they CREATE AN ITEM. However, I need an ITEM with DOCUMENT included in this item (two documents). From CLI. Ideally, as 1 call. This is due to I don't want to have different records for the same thing. And minimize the time and call amounts. From GUI it's possible...

Additionally, is it possible in the same call to add 2 URLs? So, to sum up:
* 1 login item record, inside of it
* 2 files attached
* 2 URLs attached
* 1 password generated
* 3 tags in the item
* 1 username in the item

Is it possible with CLI and if yes, how? At least the GUI client makes it somehow, so it should be possible in general.

Thanks


1Password Version: 2.3.0
Extension Version: Not Provided
OS Version: Garuda Linux Soaring Talon
Referrer: forum-search:1pass cli file upload

  • Former Member's avatar
    Former Member

    NB: "Document" or "File" or "Attachment" I don't care, it just have to be 2 files attached to the login item record just same way as it's from the GUI.

  • Former Member's avatar
    Former Member

    Can't understand what's the type of attached file (to the "login" record). When I do the following:

    op item get "NAME_OF_THE_RECORD_THAT_HAS_FILE_ATTACHED_TO_IT" --fields type=file

    The result is returned:
    item (...) doesn't have any fields of the following types: "file"

  • Former Member's avatar
    Former Member

    Note of research for myself:

    "sections": [
    {
    "name": "add more",
    "title": "",
    "fields": [
    {
    "t": "",
    "n": "n",
    "k": "file",
    "v": {
    "fileName": "fileName",
    "unencryptedSize": unencryptedSize,
    "encryptedSize": encryptedSize,
    "integrityHash": "integrityHash",
    "nonce": "nonce",
    "encryptionKey": {
    "kty": "oct",
    "kid": "kid",
    "alg": "A256GCM",
    "k": "k",
    "ext": true,
    "key_ops": [
    "encrypt",
    "decrypt"
    ]
    },
    "documentId": "documentId",
    "signingKey": {
    "kty": "oct",
    "kid": "kid",
    "alg": "A256GCM",
    "k": "k",
    "ext": true,
    "key_ops": [
    "encrypt",
    "decrypt"
    ]
    }
    },
    "inputTraits": {
    "autocorrection": "no",
    "autocapitalization": "none"
    }
    },

    Now I need to figure out how to populate all of these fields and send the according to 1Pass...

  • Former Member's avatar
    Former Member


    op item get "ITEMID" --format=json

    Reveals the JSON where it's possible to see the attached files. Now need to figure out how to send it...

  • Former Member's avatar
    Former Member

    Hey @sxiii

    We introduced file fields to 1Password browser and desktop apps last year. Admittedly, op has been a bit behind on that front. op is still not able to attach file fields to items that are not of a document type, but it is currently able to retrieve them. This is why you are able to view the document field types in your item outputs.

    I do have some good news though. It has recently been prioritized and will likely be included in one of the upcoming releases.