---
schema_version: "1"
id: 3220d9ce9fec90cc47bdd463c51a6c9f9fa115e41e917a7059d647846dfe72af
title: General Use of Commands and Flags
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/exchange/apicat-use-api-catalog-cli.md
canonical_url: https://docs.mulesoft.com/exchange/apicat-use-api-catalog-cli
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 9f73e548226bbc0dd17cf537642e6a5434eeba40eda5f1ff125aa37f79dc7c6d
description: MuleSoft Documentation Site
latest: true
---
---
product: Exchange
---

# General Use of Commands and Flags

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

After you have installed API Catalog CLI and configured permissions, you can use API Catalog CLI
commands to autocatalog your APIs. Several options are available to [authenticate](#authentication)
to Anypoint Platform as you run the commands.

## List of API Catalog Commands

API Catalog CLI includes the following commands:

<table><colgroup><col> <col></colgroup><thead><tr><th>Command</th><th>Description</th></tr></thead><tbody><tr><td><div><div><p><a href="https://docs.mulesoft.com/exchange/apicat-configure-cli-autocomplete#autocomplete-command">api-catalog autocomplete</a></p></div></div></td><td><div><div><p>Configures autocompletion for API Catalog commands</p></div></div></td></tr><tr><td><div><div><p><a href="#conf-command">api-catalog conf</a></p></div></div></td><td><div><div><p>Creates or deletes a credentials configuration file</p></div></div></td></tr><tr><td><div><div><p><a href="https://docs.mulesoft.com/exchange/apicat-create-descriptor-file-cli#create-descriptor-command">api-catalog create-descriptor</a></p></div></div></td><td><div><div><p>Creates a descriptor file</p></div></div></td></tr><tr><td><div><div><p><a href="https://docs.mulesoft.com/exchange/apicat-create-descriptor-file-cli#update-descriptor-command">api-catalog update-descriptor</a></p></div></div></td><td><div><div><p>Updates a descriptor file</p></div></div></td></tr><tr><td><div><div><p><a href="https://docs.mulesoft.com/exchange/apicat-publish-using-api-catalog-cli#publish-asset-command">api-catalog publish-asset</a></p></div></div></td><td><div><div><p>Publishes assets to Exchange</p></div></div></td></tr></tbody></table>

## View Command Help

Use the help option to list the commands or command flags and their descriptions. The following
examples show how to use the help option:

api-catalog help api-catalog create-descriptor --help

## General and Authentication Flags

Following are the general and authentication flags for commands that authenticate to Anypoint
Platform:

<table><colgroup><col> <col></colgroup><thead><tr><th>Flag</th><th>Description</th></tr></thead><tbody><tr><td><div><div><p>--client_id=client_id</p></div><div><p>or</p></div><div><p>ANYPOINT_CLIENT_ID environment variable</p></div></div></td><td><div><div><p>Connected app client ID</p></div><div><p>See <a href="#authentication">Authentication</a>.</p></div></div></td></tr><tr><td><div><div><p>--client_secret</p></div><div><p>or</p></div><div><p>ANYPOINT_CLIENT_SECRET environment variable</p></div></div></td><td><div><div><p>Prompt for the connected app secret for the client ID</p></div><div><p>See <a href="#authentication">Authentication</a>.</p></div></div></td></tr><tr><td><div><div><p>--collectMetrics</p></div><div><p>or</p></div><div><p>COLLECT_METRICS environment variable</p></div></div></td><td><div><div><p>Not currently used</p></div></div></td></tr><tr><td><div><div><p>--environment=environment</p></div><div><p>or</p></div><div><p>ANYPOINT_ENV environment variable</p></div></div></td><td><div><div><p>The name of the Anypoint Platform environment where the APIs are cataloged</p></div></div></td></tr><tr><td><div><div><p>--host=host</p></div><div><p>or</p></div><div><p>ANYPOINT_HOST environment variable</p></div></div></td><td><div><div><p>Default:</p></div><div><div><pre>anypoint.mulesoft.com</pre></div></div><div><p>The Anypoint Platform base URL without the protocol</p></div><div><p>For the US Anypoint Platform, use:</p></div><div><div><pre>anypoint.mulesoft.com</pre></div></div><div><p>For the European Anypoint Platform, use:</p></div><div><div><pre>eu1.anypoint.mulesoft.com</pre></div></div></div></td></tr><tr><td><div><div><p>--organization=organization</p></div><div><p>or</p></div><div><p>ANYPOINT_ORG environment variable</p></div></div></td><td><div><div><p>The ID of the Anypoint Platform organization where the APIs are cataloged</p></div></div></td></tr><tr><td><div><div><p>-o, --output=output</p></div></div></td><td><div><div><p>Not currently used</p></div></div></td></tr><tr><td><div><div><p>-p, --password</p></div><div><p>or</p></div><div><p>ANYPOINT_PASSWORD environment variable</p></div></div></td><td><div><div><p>Anypoint user password</p></div><div><p>See <a href="#authentication">Authentication</a>.</p></div></div></td></tr><tr><td><div><div><p>-u, --username=username</p></div><div><p>or</p></div><div><p>ANYPOINT_USERNAME environment variable</p></div></div></td><td><div><div><p>Anypoint username</p></div><div><p>See <a href="#authentication">Authentication</a>.</p></div></div></td></tr></tbody></table>

## Authentication

To authenticate to Anypoint Platform while running the API Catalog CLI, you must use one of the
following authentication combinations:

- Username and password

- Client ID and client secret

- Bearer token (command line only)

You must also specify host, environment, and organization unless you are logging in to the defaults.

You can pass Anypoint Platform credentials using the following methods:

- [Using single signon (SSO)](#single-signon)

- [Using a credentials configuration file](#credentials-file)

- [Using command line flags](#command-line-options)

- [Using environment variables](#env-variables)

Configuration settings are overridden as follows:

- Command line flags override all other methods.

- Environment variables are used if command line flags are not specified and override any
  credentials configuration file settings.

- Credentials configuration file options are used if no command line flags or environment variables
  are set.

### SSO

If you have configured Anypoint Platform to use SSO with the system on which you are running API
Catalog CLI, when you run an API Catalog CLI command with no authentication flags, the command logs
in to Anypoint Platform through SSO. For information on configuring login through SSO, see
[About Identity Management](https://docs.mulesoft.com/access-management/external-identity).

### Credentials Configuration File

If you are not using SSO, the most secure way to pass credentials to your Anypoint Platform CLI
installation is through the credentials configuration file.

You can authenticate to Anypoint Platform by running the `api-catalog conf` command to add your
credentials to a configuration file. After you have created the configuration file with valid
credentials, you can run the `api-catalog` commands without specifying any credentials flags and the
authentication is done using the configuration file values.

You can set authentication values in the configuration file using a combination of the following
authentication keys:

username password client\_id client\_secret host environment organization

To create your configuration file:

- Run the `api-catalog conf` command with the key value pair you want to use. For example, the
  following command sets the username and password:

  $ api-catalog conf username myuser
    $ api-catalog conf password mypwd

The commands store the credential information in the `config.json` file in the following locations:

- MacOS: `~/Library/Preferences/@mulesoft/api-catalog-cli-nodejs/config.json`

- Windows: `%LOCALAPPDATA%\mycli`

- Unix: `~/.config/mycli`

**Examples:**

- Set a value for a bearer token:

  $ api-catalog conf bearer b71cab22-e5cc-43c4-90ed-5a1124b6ae1f

- Set values for username and password:

  $ api-catalog conf username myuser
    $ api-catalog conf password mypwd

- Set values for a specific host, organization, and environment:

  $ api-catalog conf host myco.anypoint.mulesoft.com
    $ api-catalog conf environment
  ec7d16cb-43fd-4796-8b4f-5cff7294fcf9 $ api-catalog conf organization
  8a840abc-e63a-4f8d-87ad-24052eda3018

- Set values for client ID and client secret:

  $ api-catalog conf client\_id myClientID
    $ api-catalog conf client\_secret myCLientSecret

Example `config.json` contents after running the above commands:

{ "bearer": "b71cab22-e5cc-43c4-90ed-5a1124b6ae1f", "username": "myuser", "password": "mypwd",
"host": "myco.anypoint.mulesoft.com", "environment": "ec7d16cb-43fd-4796-8b4f-5cff7294fcf9",
"organization": "8a840abc-e63a-4f8d-87ad-24052eda3018", "client\_id":
"1787c36ab544466698e380131040faad", "client\_secret": "2dA616efca1E4181A2A77BBF046868BE" }

#### api-catalog conf

Manage authentication credentials in a configuration file (config.json) by adding and removing key
value pairs. Set one key value pair per command execution.

\> api-catalog conf <authkey> <authkeyvalue> \[flags\]

`<authkey>`  
The authentication key name. Possible key names are: username password client\_id client\_secret
host environment organization

`<authkeyvalue>`  
The value for the specified authentication key.

This command accepts the following flags:

<table><colgroup><col> <col></colgroup><thead><tr><th>Flag</th><th>Description</th></tr></thead><tbody><tr><td><div><div><p>-d, --delete</p></div></div></td><td><div><div><p>Deletes the config file entry for the given key</p></div></div></td></tr><tr><td><div><div><p>-h, --help</p></div></div></td><td><div><div><p>Shows the help for this command</p></div></div></td></tr><tr><td><div><div><p>-k, --key=key</p></div></div></td><td><div><div><p>Shows the value that corresponds with the given key</p></div></div></td></tr><tr><td><div><div><p>-v, --value=value</p></div></div></td><td><div><div><p>Shows the key that corresponds with the given value</p></div></div></td></tr></tbody></table>

### Command Line Flags

You can authenticate to Anypoint Platform through the command line by running the `api-catalog`
command with a combination of the following flags:

\--username --password --client\_id --client\_secret --bearer --organization --environment

**Examples:**

- Authenticate on the command line using username and password

  $ api-catalog --username myUserName --password myPassword --organization=myOrgId publish-asset

- Authenticate on the command line using client ID and client secret

  $ api-catalog --client\_id myClientID myClientSecret --organization=myOrgId publish-asset

- Authenticate on the command line using a bearer token

  You can generate a bearer token in Anypoint Platform and pass it to API Catalog CLI directly. When
  you provide a bearer token, API Catalog CLI ignores any provided user or client credentials.

  $ api-catalog --bearer myBearerToken --organization=myOrgId publish-asset

  Your Anypoint Platform session expires when the bearer token expires.

  For information about generating a bearer token, see
  [How to Generate Your Authorization Bearer Token for Anypoint Platform](https://help.salesforce.com/s/articleView?id=001115323&type=1).

### Environment Variables

You can authenticate to Anypoint Platform by setting a combination of the following environment
variables before running an `api-catalog` command:

ANYPOINT\_USERNAME ANYPOINT\_PASSWORD ANYPOINT\_CLIENT\_ID ANYPOINT\_CLIENT\_SECRET ANYPOINT\_ORG
ANYPOINT\_ENV ANYPOINT\_HOST

**Examples:**

- Authenticate by setting the environment variables for username and password

  $ export ANYPOINT\_USERNAME=myUserName
    $ export ANYPOINT\_PASSWORD=myPassword $ export
  ANYPOINT\_ORG=myOrgId

- Authenticate by setting the environment variables for client ID and client secret

  $ export ANYPOINT\_CLIENT\_ID=myClientID
    $ export ANYPOINT\_CLIENT\_SECRET=myCLientSecret $
  export ANYPOINT\_ORG=myOrgId
