Create an attachment in Cli

How to understand this command bw create attachment --file./myfile.csv --itemid 16b15b89...
the --file is not clear to me ,here it means the name of the file ?

First of all, a space character is required after the --file keyword.

Second, the string the comes after this space character is the path to the file, including its name and location. For example, if you have a file named myfile.csv in the current directory, you can specify --file ./myfile.csv; I don’t have the CLI installed to test this, but I believe that for a file in the current directory, you should be able to use --file myfile.csv (without the path specifier ./).

Then it would be like this bw create attachment --file myfile.csv --itemid 16b15b89....

Cannot find file ?

Cannot find file at /Users/star/my_recovery_codes.txt
star@star -iMac documents % /Users/star/bw create folder
? Master password: [hidden]
`requestJson` was not provided.
star@stars-iMac documents % 

RequestJson was not provided - how too proceed from here ?

It’s unclear what you are trying to do.

Did you install the CLI bw executable in the folder /Users/star?

What is your current working directory when you are executing these commands?

Is there a file named my_recovery_codes.txt in the folder /Users/star?

What happens if you execute the following?

cd /Users/star
ls *.txt

Yes there are a file : my_recovery_codes.txt I changed the directory to cd documents and then it worked , so I am trying to create a folder now . As you told me to ommit the ./ command and it worked . But then this message appeared requestJson wans not prowided. CLI bitwarden are installed otherwise I could not logged in into my account from the CLI.I am trying to import my credentials from my FINDER to BITWARDEN CLOUD -but this cannot be done before creating a ( bw).json file or folder .

I tasted

cd /Users/star
ls *.txt 

The ls *.txt command showed all the file endings with txt in documents

the cd /Users/star gave the reply : zsh: no such file or directory: cd/Users/star.

But this is not so easy - I can do this directly - add items via the web interface
but that will take such a longtime .But maybe that is better as I spended a considerable longtime on this CLI already . But what is still more mysterius and is beyond my comprehension that nobody here in Sweden can this or understand this or there are sure people here -but I did not find them as yet . What kind of computer people are adept in this ? Programmers or Software developers or some programming people ? - I met a person here recently and he works for IMB or what it is ,and he could nothing about thesse things - all I met reffered me back to : ask BITWARDEN policy - strange development ,but it is wery much interresting and amusing .

In short : I try to export many credentials and thesse are in the directory in documents . In the beginning I just tried to uppload directly to the bw cloud from the finder - but then this message from the bw web appaers : Your formatting are wrong .Then I saw that bw accepted .csv files from apples key chain and that worked wery well - that was accepted. But since 5 years I am with Bw and a lots of credentials are now just in the FINDER . Thesse are not csv files but .txt and thesse are not accepted by BW . I do not know if it is neccessary to transfer all this credentials to the cloud , but it feels wery safe to uppload them to BW. Since BW I had no any problems with passwords and the passkeys is really extremely handy , But this CLI is not an easy stuff . I think I just miss some easy process . To converting .txt files to .json files is not that simple as I understand . I hope this much explanation maybe gives some idea what I am trying to do .

The CLI is an advanced Bitwarden feature that is generally mostly used by people who have programming skills and who want to accomplish some specialized task that cannot otherwise be done using Bitwarden’s regular apps and browser extensions.

It seems that you have used Bitwarden for 5 years. Besides the CLI, have you installed any of the Bitwarden apps (Web Vault app, desktop apps, mobile apps, browser extensions) that can be downloaded from Bitwarden, and if so, which ones do you feel comfortable using?

Can you please explain what end goals you are actually trying to achieve?

If you are just trying to organize your vault contents (e.g. , by creating folders), or to import passwords from other sources (e.g., Apple Keychain) into your vault, or to upload file attachments to your vault, then using the other apps (e.g., the Web Vault app or the Desktop app) to accomplish these goals will be much, much easier than trying to write a program that executes bw commands.

P.S. It is a bit difficult for me to understand what you are saying in your posted comments. It may be easier to communicate if you respond in your native Swedish :sweden: instead of in English.

Haha do you understand Swedish ? Yes I think it is easier to use the Web app than the CLI - the only benefits with the CLI that it goes wery fast. I tried to import data to my web app vault from the FINDER - but then this message allways appeared :IMPORT ERROR .So that is why I turned to the CLI - unfortunately that was 1000 times more difficult to understand than the Web App . But it is not possible to uppload from the FINDER to the Web App if it is not a .csv file or bw.json . All those .txt files most be converted first to a bw.json folder ( as I understand ) and only then it is possible to transfer thesse folders or files to the web app . All data most me encrypted before uploading it to the cloud - as I understand it. For this bitwarden has this command line : bw create attachment --file … and so on .But to create a .json file I think I my need to download some json library or what it is . I think it is better to create a csv file in the NUMBERS and export it to the FINDER and from there uppload data to bw web ap. Then this copy and paste feels not that good either because of the clipboard.But the csv file is wery small - for more data it needs to be a .json file. But ,but I think by this time I just let it as it is and later I may return to it .I will go to some programming lecturer and see.

måhända? :upside_down_face:     I was merely suggesting a mode of communication as seen in this example and similar exchanges on this forum, if it makes it easier.

The Finder (to my knowledge) is just a file management system, and not an app that stores passwords or creates any kind of file. Based on the lack of detail in your post, I have to speculate, but I guess that you have some files on your computer, which you wish to safeguard in Bitwarden. Again, it would be super helpful if you could clarify your ultimate goal (instead of just suggesting the methods that you believe will work to achieve your unspecified objectives).

How many such files are there? Are they all .txt files? What is the general nature of their contents?

På Svenska blir det lika svårt att förklara detta. Ja jag vill transportera data från FINDER till BITWARDEN .Det är rätt många .txt filer i FINDER . Dessa filer är från olika web sidor som jag har laddat ner till FINDER innan jag hade BITWARDEN . Innehållet i dessa .txt filer är lösenord och lite större data så som passport och körkort . Ja precis jag har filer i FINDER som jag vill överföra till BITWARDEN - men kanske detta är inte möjligt. Jag tror att det bästa vore är att få veta hur BITWARDEN CLI fungerar i praktiken


You appear to be trying to upload a set of passwords from disk on MacOS (visible in the Finder file manager) into Bitwarden.

The easiest way to do this is by using the Bitwarden app, preferably from the Apple Store. The basic problem will be to ‘condition’ the data into a format Bitwarden expects, and the easiest format for you to manage will be .csv.

I think your idea of using Numbers to organise your data is sound. There will be no need to copy any of it to the Clipboard, and least of all to use CLI.
This page discusses the required format.

Have you have exported your passwords from another password manager, e.g. Keychain on Mac? That produces a .json as I recall, where from iCloud you can get a .csv from which to start. What is your starting point please?

Edit: After posting this I saw your post immediately above. I suggest working on the passwords and entering identity documents and cards separately. This will simplify the problem. I encourage you to stick with the desktop app and avoid CLI. I have done the same imports.


What I am trying to do is to import data from FINDER to BITWARDEN . I tried to do this first through the webb app - then I got that messages ,that the formatting was wrong - and it was this which has lead me into the cli . When you try to uppload data into the web app ,then there you most choose the file extensions .csv .json and so on ,but how to do this? Then I got this advice to create thesse files or maps in the CLI - . The advisor surely did not understood what he advised me .This is a difficult proccess as you see.

So you have files in various formats that contain passwords in some cases, and copies of documents like passports and driver’s licenses in other cases. These files are currently stored on your iMac hard drive, and accessed using the macOS Finder tool. You wish to bring these files into Bitwarden. Have I understood your situation?

You never answered about how many such files that you wish to transfer to Bitwarden. If it is a reasonably small number (say, less than 50, or so), then the best solution may be to manually upload these files into your Bitwarden vault (in the form of file attachments), one at a time, using a Bitwarden app of your choosing (for example, the Web Vault app, which you seem to be familiar with). If you need instructions for how to manually create file attachments, please ask.

In contrast, if you need to transfer hundreds or thousands of files to Bitwarden in the form of attachments, then it may indeed be more efficient to program a Unix script that uses CLI commands to accomplish the task.

A completely separate question is whether, for those text files that contain passwords, you wish to use the Bitwarden features that allow you to easily view, auto-fill, drag-and-drop, or copy-and-paste the passwords. If so, you will need to convert the format of your password file into a format that can be imported into Bitwarden. This requires conversion into a .csv format or a .json format, followed by “conditioning” of the data in the file. If you are interested in pursuing this angle and need our assistance, then you will need to share some information about how the password data are stored inside your text files.

Sorry that I could not answer immediately . Yes I have ,before Bitwarden , loaded down quite a number of documents to iMac hard drive or to the FINDER and now I decided to transfer thesse to the BITWARDEN WEB VAULT .But also some documents I could not directly uppload to BITWARDEN - say the government issued a new driver license -that dokument is downloaded directly from my email to the FINDER or as You say iMac hard driwe , and I cannot choose : download to BITWARDEN or download to FINDER. The files are about 150 or at most 200 - but I shall revisit them and see which one is still have some relevance or not .My heritage document ,driver licenses , company agreements ,and so on are wery important documents . You have understood right -I want to transfer thesse documents to the BITWARDEN WEB VAULT or CLOUD or what it is called from the FINDER. As I was trying to do this ( to upload from the FINDER to the BITWARDEN WEB APP ) ,this message of - WRONG FORMATTING allways appeared - then I wrote to the support , and also the support and the instructions on BITWARDEN webbsite defined that thesse files most be in .csv or .json file before upploading to the VAULT . But this can be done in CLI and this is the problem . Passwords from ICLOUD KEY CHAIN was amazingly fast to uppload to BITWARDEN as thesse are already in a .csv file - all passwords in the KEY CHAIN is easy to uppload to BITWARDEN .But the FINDER is wery difficult .

Yes to create file attachments I need help with .They are not so many - I will look at them closely ,there will be at last 120 as I think.But creating file attachments that most be done through the CLI ? This needs the conditioning of the file to .csv or .json file ? Or can this be done in other way?
This question is not clear : how the password data are stored inside your text files ?
I hope I wrote something more understandable .

Sorry that I could not answer immediately.Yes that is true - I want to transfer documents from the MacOS disk to the BITWARDEN WEB VAULT . Yes the biggest problem is this conditioning. First I was thinking that I am in no need to know thesse things ,but that is not the case - sooner or later I have to work with tesse things . Some documents I receive is not possible to download directly to BITWARDEN ,and as years pass by they will be numerous.The MacOs as I looked at does not produce .json file ,not as an inbuilt system - to do so I may need to download those .json programs to the computer or it may does -I did not find any possibility for that . Passwords are ok to create a .csv file ,bigger documents needs to be in .json
I exported from the KEY CHAIN some of the passwords to BITWARDEN WEB APP and it was wery fast .

The NUMBERS shows only .CSV to export but not .JSON

Yes the CLI is just wery brothersome - the best would be is to just in some way easily create a csv or a .json file . But this email procedure is also wery brothersome - by receiving an important document it says .: DOWNLOAD - of course this ( DOWNLOAD ) will be found later in FINDER - I cannot choose to : DOWNLOAD TO BITWARDEN - So there is no any way that documents directly downloaded to BITWARDEN .

So there are not any simple process to do this - not as I know about it .

I am starting to think that you would be better served by using a completely different tool and approach, which would work better for your purpose than trying to upload the data to Bitwarden.

  • How frequently will you need to view the contents of your “important documents”?

  • Will you need to access and view the important documents from multiple different devices (e.g., computer, laptop, iPad, iPhone, etc.), or always from your one iMac?

I believe that you are basically looking for a way to restrict access to your documents (by making them encrypted and password protected), and to back up these documents in case something happens to your computer.

Bitwarden could be used for this purpose (by simply attaching the files to one or more vault items, as explained below), but it is probably not going to be the best tool for this job. For example, in Bitwarden, no file attachment can be larger than 500 MB in size, and you have to pay extra if the combined size of all files is in excess of 1 GB total. It is also inconvenient to view the file contents, because for most file types, you will need to first download the file from Bitwarden to your computer before you can open the file.

Some alternatives would be: you could use an encrypted cloud storage account (e.g., Proton drive) to store the files, or encrypt your files locally (e.g., using Veracrypt or Cryptomator) and then transfer the encrypted files to a regular (non-encrypted) cloud account (e.g., Dropbox), or use a tool that automates this process (e.g., Rclone). Then you would just need Bitwarden to store the passwords for the file encryption and for the cloud storage account.

If you still think that uploading your files to Bitwarden is the best option for you, then this is the method that you would use, if you are logged in to the Web Vault app:

  1. Click New in the upper right corner, then select :earth_africa: Item.
  2. On the “New Item” screen, change the value of What type of item is this? to “Secure Note”, and type an item name in the Name field (for example, “Viktiga Saker”).
  3. Click Save.
  4. Find the newly created item in your vault, and click on the three-dots icon (⋮) to the right of the item listing; this opens a dropdown menu with various options.
  5. In the dropdown menu, select :paperclip: Attachments.
  6. In the Attachments panel, click Choose File, then use the Open File dialog to choose the file that you wish to attach.
  7. Click Save.

You can either attach multiple files to the same vault item (by repeating Steps 5–7 in the above instructions), or create a new vault item for each file attachment (by starting over at Step 1).

I see. I have this GPG SUITE downloaded to my computer ,that may come handy and then save the passwords to BITWARDEN as you told .

This I did not tought of . But then once I encrypted a file it will still remain in the MacOs hard drive and this may can be a problem.

I do not need to visit thesse documents so often and accessing them through the phone and my computer is quite enough for me and BITWARDEN synkronises this wery nicely.

Yes you have right - I need to keep thesse files in restricted ,encrypted forms. This can be done with GPG SUITE . THen the passwords or keys are in BITWARDEN .

Some documents I may need to wiev more often , in this case yes downloading them all the time is a chore too.
Encrypting files locally is yes is a wery good way - but then what to do if something happens to my computer? I see , so you mean encrypting the files locally and then uppload them to pCloud ? Yes that is a good idea a wery good idea .

I want to know this : Say I have used GPG SUITE and locally encrypted a file and upploaded this file to pCloud or Proton Driwe ,then say my Mac goes belly upp ( it will not ,but just in case) then will the encrypted file remain on Proton driwe or on pCloud ? I mean do my Mac somehow delete the uploaded encrypted files from pCloud or from Proton ? If not then that is a great way to go .

Encrypting locally and uppload all data to pCloud ,this sounds appealling ,or to proton drive.But then also GPG SUITE may go belly up and the passwords become dead forewer ,files are lost forewer .Altså this trusting other systems all the time is also a big headache . But your idea is wery good .Now I have to rethink .