# Affinidi CLI

> Use the Affinidi Command Line Interface (CLI) to manage your projects and integrations directly from the terminal.

Affinidi CLI is a developer tool to easily manage your projects and integrate with Affinidi services using the command line. It empowers developers to use simple commands to improve developer experience when interacting with our different services.

## Before you begin

- Set up Affinidi Vault account. Follow the guide below if you haven’t set it up yet.

        Set up Affinidi Vault

Set up an Affinidi Vault account using the [Web Vault](https://vault.affinidi.com) or install the Mobile Vault (for [Android](https://play.google.com/store/apps/details?id=com.affinidi.vault&pcampaignid=web_share)).

The same setup steps for Mobile Vault.

- 
Click on Get started if you are creating a new account, or click on Restore from Backup if you have an existing backup of your Affinidi Vault. Provide the passphrase to secure your Affinidi Vault.

You have the option to enable Biometrics to unlock your Affinidi Vault easily instead of using passphrase.

GIF 

- Enter your email address to register with the Affinidi Vault. An OTP will be sent to this email for verification.

GIF 

- Enter the OTP sent to the email you have provided for verification to complete the setup.

GIF 

After successfully providing the OTP, you are redirected to the Affinidi Vault dashboard.
Important Note

Remember to keep your passphrase in a secure location. Use the Passphrase Reset feature in Affinidi Vault settings to generate the PDF files and keep them safe, which you can use to recover access to your Affinidi Vault if you forget your passphrase.

- 
Install [NodeJS v18 or higher](https://nodejs.org) on your machine.

- 
Install [Git](https://git-scm.com/) to generate a reference app using [affinidi generate app](/dev-tools/affinidi-cli/generate-app.md) command.

## Installation

Install the latest version of Affinidi CLI to get started.

```Bash
npm install -g @affinidi/cli
```

To remove it from your machine, run the uninstall command.

```Bash
npm uninstall -g @affinidi/cli
```

## How do I use Affinidi CLI?

To access most features, such as creating a Login Configuration, you must authenticate using Affinidi Vault - a secure digital wallet for managing identity and credentials. Run the authentication command to begin.

```Bash
affinidi start
```

If your session expires, re-run the same command to refresh it.

## Understanding Commands

Commands in Affinidi CLI have the following structure:

```Bash
affinidi   [flags]
```

- All commands begin with affinidi.

- Topics represent Affinidi services or domains.

- Commands define the actions to perform.

- Flags provide the required parameters.

- Use affinidi help <topic|command> to view detailed usage information.
### Help

Each command and topic includes a help document with usage, descriptions, flags, and examples. You can access help in three ways:

Use the –help flag, for example: affinidi login create-config --help

Use the help root command: affinidi help login create-config

Search and select a command using: affinidi search

### Flags

All commands support global flags:

--help displays help information.

--json outputs results in JSON format, useful for programmatic use.

--no-color disables coloured output, helpful for accessibility.

--no-input disables interactive prompts, ideal for automation and CI workflows.

Flags can be entered in multiple formats, all of which are valid:

```Bash
affinidi login create-config --file="config.json"
affinidi login create-config --file "config.json"
affinidi login create-config --file=config.json
affinidi login create-config --file config.json
affinidi login create-config -f "config.json"
affinidi login create-config -f="config.json"
affinidi login create-config -f"config.json"
affinidi login create-config -f config.json
affinidi login create-config -f=config.json
affinidi login create-config -fconfig.json
```

### Active Project

Affinidi CLI uses the concept of an “Active Project” to simplify workflows. Commands under the login and iam topics operate within the active project. This avoids the need to specify the project and credentials each time.

To check the current active project, run: [affinidi project get-active-project](/dev-tools/affinidi-cli/manage-projects.md#affinidi-project-get-active-project)

To switch projects, use: [affinidi project select-project](/dev-tools/affinidi-cli/manage-projects.md#affinidi-project-select-project)

### Session and Configuration Files

When you authenticate using affinidi start the CLI creates a credentials file in your home directory:

~/.affinidi/credentials-v2.json stores your session credentials. Keep this file secure, as it grants access to Affinidi services.

To end your session, run affinidi stop. This deletes your session data.

## Affinidi CLI Project

The Affinidi CLI is an [open-source project ](https://github.com/affinidi/affinidi-cli) on GitHub. Visit the repository to contribute, share feedback, or report issues.

## Explore CLI Topics and Commands


## Pages in this section


- [Basic Commands](/dev-tools/affinidi-cli/basic-commands.md): Useful basic commands available to access Affinidi services.


- [Manage Projects](/dev-tools/affinidi-cli/manage-projects.md): Manage projects and switch between them to create related resources.


- [Manage Login](/dev-tools/affinidi-cli/manage-login.md): Manage your Login Configuration, and user groups to integrate Affinidi Login.


- [Manage Token](/dev-tools/affinidi-cli/manage-token.md): Manage your Personal Access Token (PAT) to connect and perform actions on Affinidi services on the user's behalf.


- [Manage IAM](/dev-tools/affinidi-cli/manage-iam.md): Manage your IAM policies to grant access to users and Personal Access Tokens (PATs).


- [Manage Iota](/dev-tools/affinidi-cli/manage-iota.md): Manage Affinidi Iota Framework configurations and data request queries.


- [Manage Issuance](/dev-tools/affinidi-cli/manage-issuance.md): Manage Credential Issuance configurations and integration.


- [Manage Wallets](/dev-tools/affinidi-cli/manage-wallets.md): Manage Affinidi Wallets for signing credentials and request token.


- [Generate App](/dev-tools/affinidi-cli/generate-app.md): Generate sample apps using different programming languages, frameworks, and IAM solutions.



