Skip to content

WSO2 API Controller (APICTL)

The WSO2 API Controller (apictl) is the command-line tool of WSO2 API Manager. This allows you to move APIs, API Products, and Applications across API-M environments and to perform CI/CD operations. It can also be used to perform these same tasks on a Kubernetes deployment. Furthermore, it can be used with the Micro Integrator (WSO2 MI) for monitoring integration artifacts and performing management/administrative tasks from the command line.

Get Started

Follow the steps given below to get started:

  1. Go to the WSO2 API Manager website -> Download -> Tooling, and download the API Controller.

  2. Extract the downloaded distribution and initialize apictl by executing the following command from your terminal.

    apictl init
    
  3. Add environments

    Execute the following command to add API-M or Micro Integrator servers:

    apictl add env <environment-name>
    

    Find out more about the apictl add env option in the APICTL Reference.

  4. Log in

    Execute the following command to log in to the required server environment. You are prompted to enter the username and password.

    apictl login <environment-name>
    

    Alternatively, you can pass the user name and password in a single command:

    Note

    If you are on Windows, you must always log in with the following command.

    apictl login <environment-name> -u <username> -p <password>
    

    To logout from apictl, use the following command:

    apictl logout <environment-name>
    

Once you are logged in, you can use the available options and commands.

APICTL Reference

You can execute the following command to see the available sub commands:

apictl

Listed below are all the apictl commands available.

apictl global flags

The following global flags can be used with all the apictl options and subcommands.

-h, --help Get help for apictl commands and options.
-k, --insecure Allow connections to SSL endpoints without certifications.
--verbose Enable verbose mode.

apictl version

Use the version option to get the version of the running apictl tool.

apictl version

apictl init

Use init to initialize the CLI tool.

apictl init

apictl add

Add a new environment (API-M or MI) and its related endpoints to the configuration file of apictl. This will connect apictl with the added environments.

  • Usage

    apictl add [option] [argument] [flag]
    
  • Option

    env Specifies that a new environment is being added.

  • Argument

    environment name Enter the name of given to the environment.

  • Flags

    --apim Use this flag to add an API-M environment.
    --registration If the --apim flag is not used, use this flag to specify the API-M server url.
    --publisher If the --apim flag is not used, use this flag to specify the API-M Publisher url.
    --devportal If the --apim flag is not used, use this flag to specify the API-M Developer Portal url.
    --admin If the --apim flag is not used, use this flag to specify the API-M Admin Portal url.
    --token If the --apim flag is not used, use this flag to specify the API-M Token url.
    --mi Use this flag to add a Micro Integrator environment.
    --environment This flag is mandatory when passing an environment.
    -e This flag is mandatory when passing an environment.

apictl login

Log in to an API Manager environment using credentials.

  • Usage

    apictl login [argument] [global-flags]
    
  • Arguments

    environment Specify the name of the environment to which you want to log in.

  • Flags

    -u, --username string Username to login.
    -p, ---password string The login password.
    --password-stdin Get the login password from stdin.

apictl logout

Log out from an API Manager environment.

  • Usage

    apictl logout [argument] [global-flags]
    
  • Arguments

    environment Log in to the API-M runtime instance.

apictl get

Displays a list containing all the APIs, all the API Products, applications of a specific user, all the environments or log levels of APIs.

  • Usage

    apictl get [option] [argument] [flag] [argument] 
    
  • Options

    envs Display the list of environments.
    apis Display a list of APIs in an environment.
    api-products Display a list of API Products in an environment.
    apps Display a list of Applications in an environment specific to an owner.
    api-revisions Display a list of Revisions for the API.
    keys Generate access token to invoke the API or API product.
    api-logging Display log level of the API or APIs.
    correlation-logging Display a list of correlation logging components available.

  • Argument

    environment name Enter the name of given to the environment.

  • Flags

    -e Use this flag to specify from which environment to get the APIs, API products, or APPs.
    --environment Use this flag to specify from which environment to get the APIs, API products, or APPs.

apictl import

Import an API, API product, or application to a specific environment.

  • Usage

    apictl import [option] [argument] [flag] [argument] 
    
  • Subcommands

    api Specify an API to import.
    api-product Specify an API product to import.
    app Specify an application to import.

  • Flags

    -f Use this flag to specify file path of the API, API product, or App.

apictl export

Export APIs, API Products, and Applications of a specific user in the specified environment.

  • Usage

    apictl export [option] [argument] [flag] [argument] 
    
  • Options

    api Specifies the API to export.
    apis Specifies the APIs to export.
    api-product Specify an API product to export.
    app Specify an application to export.

  • Flags

    -n Name of the API, API product, or APP to export.
    -v The version of the API you are exporting.
    -r The user role that is assigned.
    -e The environment from which the APIs, API product, or App is being exported.

apictl delete

Delete APIs, API Products, and Applications of a specific user in the specified environment.

  • Usage

    apictl delete [option] [argument] [flag] [argument] 
    
  • Options

    api Specifies the API to delete.
    api-product Specify an API product to delete.
    app Specify an application to delete.

  • Flags

    -n Name of the API, API product, or APP to delete.
    -v The version of the API you are deleting.
    -r The user role that is assigned.
    -e The environment from which the APIs, API product, or App is being deleted.

apictl change-status

Change the lifecycle status of an API in an environment

  • Usage

    apictl change-status [option] [argument] [flag] [argument] 
    
  • Options

    api Specifies the API for which you want to change the status.

  • Flags

    -a The new status that should apply to the API.
    -n The name of the API for which the new status should apply.
    -v The version of the API you are deleting.
    -r The user role that is assigned.
    -e The environment from which the APIs, API product, or App is being deleted.

apictl bundle

Archive API, Application, or API Product projects to a zip format. The bundle name will have the project name and version.

  • Usage

    apictl bundle [flag] [argument] 
    
  • Flags

    -s The source of the API, or API project directory that should be bundled and archived.
    --source The source of the API, or API product directory that should be bundled and archived.
    --d The destination where the bundled ZIP file of the API/API product director is saved.
    --destination The destination where the bundled ZIP file of the API/API product director is saved.

apictl set

Set configuration parameters. You can use one of the following flags.

  • Usage

    apictl set [flag] [argument] 
    
  • Flags

    --http-request-timeout Specify the request timout in milliseconds.
    --tls-renegotiation-mode Specify the regeneration mode: never, once, or freely.
    --export-directory The directory path where APIs should be saved.
    --vcs-deletion-enabled Enable/Disable project deletion via vcs.
    --vcs-config-path The directory path to the custom vcs configuration file.
    --vcs-deployment-repo-path The directory path to the deployment repo for vcs.
    --vcs-source-repo-path The directory path to the source repo for vcs.

Use api-logging option to set the log level of the API.

apictl set api-logging [flag] [argument]

Use correlation-logging option to set the correlation configs for a correlation logging component.

apictl set correlation-logging [flag] [argument]

apictl k8s

Managing APIs in a Kubernetes API-M environment.

  • Usage

    apictl k8s [subcommand] [option] [argument] [flag] [argument] 
    
  • Subcommands

    add api Add an API to the kubernetes cluster.
    update api Update an API to the kubernetes cluster
    delete api Delete resources related to kubernetes.
    gen Generate deployment directory for K8S operator.

  • Flags

    -n The name of the API that should be added or updated in the K8s environment.
    -f THe file path to the Swagger resource.
    --namespace=[value] The namespace associated with the API that should be added or updated in the K8s environment.

apictl aws

AWS API Gateway related commands such as init. Be sure to install and configure the AWS CLI before executing the aws init command. See the AWS documentation for more information.

  • Usage

    apictl aws [subcommand] [flag] [argument] 
    
  • Subcommands

    init Initialize an API project for an AWS API.

  • Flags

    -n The name of the API project that should be initialized.
    -s The stage of the environment.
    --stage The stage of the environment.

apictl vcs

Checks status and deploys projects to the specified environment. To use this command, 'git' must be installed in the system.'

  • Usage

    apictl vcs [subcommand] [flag] [argument] 
    
  • Subcommands

    init Initializes a GIT repository with API Controller.
    deploy Deploys projects to the specified environment.
    status Shows the list of projects that are ready to deploy.

  • Flags

    -e The environment to which a project should be deployed.

apictl undeploy

Undeploy an API/API Product revision that is available in the specified environment from the specified gateway.

  • Usage

    apictl undeploy [option] [argument] [flag] [argument] 
    
  • Options

    api Specifies the API to be undeployed.

  • Flags

    -n Name of the API, API product, or APP to undeploy.
    -v The version of the API you are undeploying.
    -r The user role that is assigned.
    -rev ....
    -g The APIs matching the listed labels are undeployed.
    -e The environment from which the API is being undeployed.

apictl mi

Use this command to manage Micro Integrator artifacts. You can get, add, update, delete, activate, and deactivate integration artifacts and logs.

  • Usage

    apictl mi [subcommand] [option] [argument] [global-flag]
    
  • Subcommands

    login Login to a Micro Integrator.
    logout Logout from a Micro Integrator.
    get Get information about artifacts deployed in a Micro Integrator instance.
    add Add new users or loggers to a Micro Integrator instance.
    delete Delete users from a Micro Integrator instance.
    update Update log level of Loggers in a Micro Integrator instance.
    activate Activate artifacts deployed in a Micro Integrator instance.
    deactivate Deactivate artifacts deployed in a Micro Integrator instance.

  • Options

    apis Get details of APIs deployed in the Micro Integrator.
    connectors Get details of integration connectors deployed in the Micro Integrator.
    data-services Get details of data services deployed in the Micro Integrator.
    mi get endpoints Get details of endpoints deployed in the Micro Integrator.
    inbound-endpoints Get details of inbound endpoints deployed in the Micro Integrator.
    local-entries Get details of local entries deployed in the Micro Integrator.
    message-processors Use this option with the get or activate subcommands to get details or to activate the status.
    message-stores Get details of message stores deployed in the Micro Integrator.
    proxy-services Get details of proxy services deployed in the Micro Integrator.
    tasks Get details of scheduled tasks deployed in the Micro Integrator.
    templates Get details of templates deployed in the Micro Integrator.
    log-levels Use this option with the mi get, mi add, or mi update commands to manage loggers in the Micro Integrator environment.

apictl secret

Encrypt secrets to be used in the Micro Integrator.

  • Usage

    apictl secret [subcommand] [argument]
    
  • Subcommands

    init Initializes the keystore used for encryption.
    create Encrypt the secrets.