ap is a command-line tool for managing and interacting with the WSO2 API Platform.
| Flag | Short Flag |
|---|---|
--display-name |
-n |
--server |
-s |
--output |
-o |
--file |
-f |
--version |
-v |
Note: Each command supports the
--helpflag for detailed usage information.
- You must first add and/or select a gateway in the CLI using the appropriate gateway-related commands.
- Credentials for a gateway can come from either the gateway configuration (when you add the gateway) or from environment variables. Environment variables take precedence over configuration and will override credentials stored in the config when present.
- Depending on the gateway's authentication type:
- none: No authentication required
- basic: Provide credentials via config or export
WSO2AP_GW_USERNAME=<username>andWSO2AP_GW_PASSWORD=<password>(env vars override config) - bearer: Provide a token via config or export
WSO2AP_GW_TOKEN=<token>(env var overrides config)
ap gateway add --display-name <name> --server <server> [--platform <platform>] [--auth <none|basic|bearer>]# Add a gateway with no authentication (default)
ap gateway add --display-name dev --platform eu --server http://localhost:9090
# Add a gateway with basic authentication
ap gateway add --display-name dev --platform eu --server http://localhost:9090 --auth basic
# Add a gateway with bearer token authentication
ap gateway add --display-name prod --platform eu --server https://api.example.com --auth bearerFor basic authentication, export these environment variables (replace the placeholders with your values):
export WSO2AP_GW_USERNAME=<username>
export WSO2AP_GW_PASSWORD=<password>For bearer authentication, export this environment variable (replace <token> with your token):
export WSO2AP_GW_TOKEN=<token>Note: Environment variables override credentials stored in the gateway configuration.
ap gateway list --platform <platform>ap gateway list --platform euap gateway remove --display-name <name> --platform <platform>ap gateway remove --display-name dev --platform euap gateway use --display-name <name> --platform <platform>ap gateway use --display-name dev --platform euap gateway current --platform <platform>ap gateway current --platform euap gateway health --platform <platform>ap gateway health --platform euCommands that operate against a gateway — apply, rest-api (and rest-api api-key), mcp, subscription-plan, subscription, and image build — are documented in the Gateway CLI Reference.
ap devportal add --display-name <portal-name> --server <url> --platform <platform> --auth <basic|oauth|api-key> [--username <username>] [--password <password>] [--token <token>] [--api-key <api-key>] [--no-interactive]# Add a DevPortal with basic auth
ap devportal add --display-name my-portal --platform eu --server https://devportal.example.com --auth basic
# Add a DevPortal with OAuth auth
ap devportal add --display-name my-portal --platform eu --server https://devportal.example.com --auth oauth
# Add a DevPortal without interactive prompts
ap devportal add --display-name my-portal --platform eu --server https://devportal.example.com --auth api-key --no-interactive --api-key <api-key>For DevPortal authentication, export the environment variables for the configured auth type:
export WSO2AP_DEVPORTAL_USERNAME=<username>
export WSO2AP_DEVPORTAL_PASSWORD=<password>
export WSO2AP_DEVPORTAL_TOKEN=<token>
export WSO2AP_DEVPORTAL_API_KEY=<api-key>Note: The environment variable can be used instead of storing the API key in the CLI configuration.
ap devportal list --platform <platform>ap devportal remove --display-name <portal-name> --platform <platform>ap devportal use --display-name <portal-name> --platform <platform>ap devportal current --platform <platform>ap devportal health --platform <platform>