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

  1. 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 or install the Mobile Vault (for Android).

The same setup steps for Mobile Vault.

  1. 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.

GIFAffinidi Vault Setup
  1. Enter your email address to register with the Affinidi Vault. An OTP will be sent to this email for verification.
GIFAffinidi Vault Passphrase
  1. Enter the OTP sent to the email you have provided for verification to complete the setup.
GIFAffinidi Vault Email Verification

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

  1. Install NodeJS v18 or higher on your machine.

  2. Install Git to generate a reference app using affinidi generate app command.

Installation

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.

affinidi start

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

Understanding Commands

Commands in Affinidi CLI have the following structure:

affinidi <topic> <command> [flags]
  1. All commands begin with affinidi.
  2. Topics represent Affinidi services or domains.
  3. Commands define the actions to perform.
  4. Flags provide the required parameters.
  5. 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:

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

To switch projects, use: 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 on GitHub. Visit the repository to contribute, share feedback, or report issues.

Explore CLI Topics and Commands