Skip to main content

Authentication and Profiles

Authenticate with a username and password, including two-factor authentication when required, or with an API key. Profiles keep the connection settings for different users and sites separate, so the same machine can run commands against more than one account.

Password Authentication

The CLI App prompts for your site name, username, and password when you sign in. It saves your site and username in the profile and reuses the resulting session until you log out or it expires.

To pre-configure the CLI App with a specific username and password, you can provide the CLI App with information about your Files.com account:

files-cli config set --subdomain="MYSITENAME" --username="MYUSERNAME"

When prompted, enter your password.

If your site has a Custom Domain configured and you want to connect to it rather than the files.com subdomain, specify the fully qualified domain name (FQDN) with the --endpoint flag:

files-cli config set --endpoint="https://files.mycompany.com" --username="MYUSERNAME"

Once you've specified your subdomain or endpoint information and username, you do not need to specify it again for subsequent uses of the CLI App.

For later uses, you can login using the following command, which will prompt you for your password:

files-cli login

If your account requires Two-Factor Authentication, you will be prompted for the second factor after you submit your password. Once you are logged in, subsequent uses of the CLI App will perform those actions using your credentials and permissions until you log out.

API Key Authentication

Use an API key for unattended scripts. API keys follow their own expiration settings, independently of password login sessions. Supply the key through the FILES_API_KEY environment variable, using your scheduler or secret manager to inject its value into the process. This keeps the secret out of script files, shell history, and command arguments.

Create a dedicated profile with the intended site address first. A saved API key takes precedence over FILES_API_KEY, and a saved login session can select session authentication instead. For a profile intended to use an environment-supplied key, clear both saved credential fields:

files-cli config set --subdomain=MYSITENAME --profile=report-job
files-cli config reset --api-key --session --profile=report-job

With the environment variable supplied, run commands using that profile:

files-cli folders list-for /incoming --profile=report-job --non-interactive

The environment variable applies to the process, rather than belonging to a named profile. Supply the key for the intended site on each run. Use the operating system's account permissions to protect the running job and its environment; avoid printing the environment or enabling command tracing around secret setup.

Using an API Key to authenticate will not trigger a Two-Factor Authentication challenge, even if you normally require one to log into the web interface.

A user API key identifies a user; a site-wide API key does not. This matters when a command assigns ownership. For a GPG key import, --user-id=0 selects the authenticated user with a user session or user API key. With a site-wide API key, supply the owner's user ID explicitly.

Logging Out

The CLI App reuses a saved password login session for up to 6 hours from sign-in. Running commands does not restart this period. Sign in again with files-cli login when it expires.

The site's Session Expiration setting controls how long a session can remain idle and can require sign-in sooner. A longer idle timeout does not extend the CLI App's six-hour reuse period.

To manually log out of your session, use:

files-cli logout

Profiles

The Command Line Interface (CLI) App lets you access multiple Files.com accounts by specifying a different profile for each account.

This is useful when you need to access multiple accounts within a single Files.com site or when you have accounts across multiple Files.com sites, such as a Production site, Test site, and Child site.

To set up profiles for your Files.com accounts, use the following commands:

files-cli config set --subdomain="MYFIRSTCOMPANY" --username="FIRSTUSERNAME" --profile="firstaccount"
files-cli config set --subdomain="MYSECONDCOMPANY" --username="SECONDUSERNAME" --profile="secondaccount"

To execute commands for a specific account, use the --profile option in your command. For example:

files-cli folders list-for /path/to/folder/in/account1/ --profile="firstaccount"
files-cli folders list-for /path/to/folder/in/account2/ --profile="secondaccount"

For API-key jobs, use a named profile for connection settings and supply the corresponding key through FILES_API_KEY as described in API Key Authentication.

When you omit the --profile option, configuration and operations use your default profile.

You can view the account profiles that have been configured by using this command:

files-cli config show

Updating Profiles

Use config set to update a profile. Use config reset with a field flag to clear that field instead; for example, files-cli config reset --api-key --profile="firstaccount" clears the saved API key for that profile.

For example, you can update the settings of a named profile using the following command:

files-cli config set --subdomain="UPDATED_SITE_NAME" --username="UPDATED_USERNAME" --profile="firstaccount"

Profile Configuration File

The CLI App stores its configuration within a hidden file on your local system.

The file is located at %HOME%\.config\files-cli on Windows based systems and at $HOME/.config/files-cli on Linux and Mac based systems.

Do not edit this file directly unless directed to by our Support team.

You can factory-reset the CLI App to a blank starting state by deleting, renaming, or moving this configuration file.

Scheduled Jobs

A scheduler starts the CLI; Files.com performs the requested operation with the supplied connection's permissions. Use the scheduler your environment already operates, such as cron, a systemd timer, Windows Task Scheduler, or a managed job service. Configure the job under the operating-system account that owns its CLI profile and can read any local source files or write downloaded files.

For example, a scheduled inventory job can retrieve the contents of /incoming. First configure the report-job profile as above. Save the following Bash script on the job host, replacing the executable path with the CLI's installed location:

#!/usr/bin/env bash
set -euo pipefail
: "${FILES_API_KEY:?Supply FILES_API_KEY through scheduler secret configuration}"
exec /usr/local/bin/files-cli folders list-for /incoming 
  --profile=report-job --non-interactive --use-pager=false --format=json

Have the scheduler inject FILES_API_KEY and capture standard output, standard error, and the exit code. This example writes the inventory to standard output; configure the job's output destination and retention for the system consuming it. Treat a nonzero exit as a failed run and retain its diagnostic message. For a command that changes files, verify the completed stage before repeating it.

Use absolute local paths, an explicit working directory, and the intended time zone. Scheduled processes often have a different environment from an interactive terminal. Prevent overlapping runs when two instances could change the same files, and assign an operator to respond to failed or missing runs. Choose the interval according to the business deadline and listing cost; Notifications can start work from activity instead of frequent folder checks.