Algolia CLI / Get started

Authenticate CLI commands

CLI commands must be authenticated with your Algolia application ID, and an API key with the required permissions to run the command. You can find your application ID and API key in the Algolia dashboard.

To authenticate your CLI commands, you can use the --api-key and --application-id options. This is useful in continuous integration (CI) environments, where you would store your credentials in configuration or environment parameters.

When managing Algolia applications on your local computer, you can create profiles as shortcuts. Profiles are stored in a configuration file in your home directory: ~/.config/algolia/config.toml.

Create profiles

To create a new profile, use the algolia profile add command:

1
2
3
4
algolia profile add \
        --name NAME \
        --application-id APPLICATION_ID \
        --api-key API_KEY

Now, you can use the option --profile NAME to authenticate your commands.

In general, use an API key that has only the minimum required permissions to perform the tasks you want to perform. For example, if you only want to search or browse your indices, use an API key that has the search and browse permissions.

Default profile

The first profile you add is created as default profile. You can omit --profile when using the default profile.

For example, if your default profile is store, and you want to search the products index, you can use one of the following commands:

1
2
3
4
5
6
7
algolia search products --query ""
# This is the same as:
algolia search products --query "" --profile store
# This is the same as:
algolia search products --query "" \
                        --application-id APPLICATION_ID \
                        --api-key API_KEY

To change the default profile, use the algolia profile setdefault command.

Did you find this page helpful?