# CLI

## Installation instructions <a href="#h_ea64278ce1" id="h_ea64278ce1"></a>

### Install NodeJS v20 or above (minimum required version) <a href="#h_de7fc71933" id="h_de7fc71933"></a>

1. * For Windows and MacOS the installer is here: <https://nodejs.org/en/download/>
   * For Linux distros, using built-in package managers, the instructions are here: <https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions>
2. ### Install Filemail CLI using NPM with following command <a href="#h_61533ef830" id="h_61533ef830"></a>

   ```
   npm install -g filemail-cli
   ```

### Test upload of a file with the CLI: <a href="#h_1cb75433eb" id="h_1cb75433eb"></a>

```
filemail upload testFile.txt -u your@email.com
```

### Available commands (run filemail -h to learn more) <a href="#h_a61149e7a8" id="h_a61149e7a8"></a>

```
Usage: filemail [options] [command]

CLI for sending files to Filemail.com.

Options:
  -V, --version                output the version number
  -h, --help                   display help for command

Commands:
  login [options] <username>   Login to Filemail API and get login token.
  logout <logintoken>          Logout from Filemail API and destroy login token.
  upload [options] <files...>  Upload files to Filemail.com.
  help [command]               display help for command
```

### Store password and settings in a json file for safety and convenience <a href="#h_d698b526c5" id="h_d698b526c5"></a>

You can create a json config file to store your password and other settings. Thanks to this you won't need to pass them as arguments. An example json file containing username, password and from parameter value settings:

```
{ 
   "username": "my@login.com", 
   "password": "myS3cretP4ssword", 
   "from": "your@email.com" 
} 
```

You can then use it with CLI passing it with `--config-file` option. For example:\
​`filemail upload testFile.txt --config-file "c:\filemail-config.json"`

### All supported upload options (run filemail upload --help to learn more) <a href="#h_76acf4601f" id="h_76acf4601f"></a>

| Option                                         | Description                                                                                         |
| ---------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| `-g, --config-file <file>`                     | JSON file with configuration to apply.                                                              |
| `-b, --log-file <file>`                        | Log file to save logs to.                                                                           |
| `-r, --api-retry-limit <number>`               | Retry limit for API calls. (default: 3)                                                             |
| `-d, --log-level <string>`                     | Logging level of the file logger. (Choices: Error, Warning, Info, Debug, Trace – default: Info)     |
| `--api-request-total-timeout <ms>`             | Request total timeout in milliseconds. (default: no timeout)                                        |
| `-u, --username <string>`                      | Your username for Filemail.com. Ignored if `--logintoken` option is present.                        |
| `-p, --password <string>`                      | Your password for Filemail.com. If not provided and not in config file, CLI will prompt for it.     |
| `-l, --logintoken <string>`                    | Authentication token from Filemail API.                                                             |
| `-t, --to <string...>`                         | Recipient e-mail addresses (space separated, without quotation marks).                              |
| `--from <string>`                              | Sender’s e-mail address.                                                                            |
| `--subject <string>`                           | Transfer subject.                                                                                   |
| `-m, --message <string>`                       | Transfer message.                                                                                   |
| `-n, --notify <boolean>`                       | Get email notification every time a file is downloaded.                                             |
| `-c, --confirmation <boolean>`                 | Send confirmation when files have been successfully sent.                                           |
| `-d, --days <number>`                          | Number of days files should be available to download. Defaults to account setting if not specified. |
| `--upload-password <string>`                   | Password you want to use to secure the transfer.                                                    |
| `--no-progress-bar`                            | Hide upload progress bar.                                                                           |
| `--no-infinite-retries`                        | Application exits as soon as any chunk’s retry limit exceeds `--chunk-upload-retry-limit`.          |
| `-k, --max-chunks-upload-in-parallel <number>` | Maximum number of chunks to upload simultaneously. (default: 9)                                     |
| `--chunk-upload-retry-limit <number>`          | Retry limit for file chunks upload. (default: 3)                                                    |
| `-e, --e2ee-key <string>`                      | End-to-end encryption key you want to use to encrypt the transfer.                                  |
| `-x, --max-chunk-size <number>`                | Maximum size of a single file chunk in bytes. (default: 5 MB)                                       |
| `--upload-idle-timeout <ms>`                   | Upload idle timeout in milliseconds. Time out inactive connections. (default: 90 sec)               |
| `-h, --help`                                   | Display help for command.                                                                           |

The application will exit with code 0 if transfer was successful, otherwise it failed and you might want to check parameters and retry.

### Example: <a href="#h_85bca2acc9" id="h_85bca2acc9"></a>

This example will send 2 files (`file1.txt` and `log.log`) and a folder (`/myFolder`) to 3 recipients (`patrick@email.com`, `monica@email.com` and `john@email.com`) from the user `nicole@email.com` having set an E2EE key to `superPassword`

```
filemail upload --username nicole@email.com --e2ee-key superPassword --to patrick@email.com monica@email.com john@email.com -- c:\file1.txt c:\log.log c:\myFolder
```

<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.filemail.com/tools/cli.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
