- Tools
- API Platform CLI
WSO2 API Platform CLI (AP)¶
ap is a command-line tool for managing and interacting with the WSO2 API Platform.
Supported Short Flags¶
| Flag | Short Flag |
|---|---|
--display-name |
-n |
--server |
-s |
--output |
-o |
--file |
-f |
--version |
-v |
Gateway Sub Commands¶
Note: Each command supports the
--helpflag for detailed usage information.
Prerequisites for Gateway Controller Commands¶
- 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)
1. Add a Gateway¶
CLI Command
Sample Commands
# Add a gateway with no authentication (default)
ap gateway add --display-name dev --server http://localhost:9090
# Add a gateway with basic authentication
ap gateway add --display-name dev --server http://localhost:9090 --auth basic
# Add a gateway with bearer token authentication
ap gateway add --display-name prod --server https://api.example.com --auth bearer
Authentication Setup
For basic authentication, export these environment variables (replace the placeholders with your values):
For bearer authentication, export this environment variable (replace <token> with your token):
Note: Environment variables override credentials stored in the gateway configuration.
2. List Gateways¶
CLI Command
Sample Command
3. Remove a Gateway¶
CLI Command
Sample Command
4. Change the Gateway¶
CLI Command
Sample Command
5. Check the current Gateway¶
CLI Command
Sample Command
6. Returns the health status of the Gateway¶
CLI Command
Sample Command
7. Apply a Resource¶
CLI Command
Sample Command
8. List all APIs¶
CLI Command
Sample Command
9. Get a specific API by name and version or id¶
CLI Command
ap gateway api get --display-name <name> --version <version> --format <json|yaml>
ap gateway api get --id <id> --format <json|yaml>
Sample Command
ap gateway api get --display-name "PetStore API" --version v1.0 --format yaml
ap gateway api get --id sample-1 --format yaml
10. Delete an API¶
CLI Command
Sample Command
11. Build a gateway¶
CLI Command
ap gateway image build \
[--name <gateway-name>] \
[--path <gateway-project-dir>]
[--repository <image-repository>] \
[--version <gateway-version>] \
[--gateway-builder <gateway-builder-image>] \
[--gateway-controller-base-image <gateway-controller-base-image>] \
[--router-base-image <router-base-image>] \
[--push] \
[--no-cache] \
[--platform <platform>] \
[--offline] \
[--output-dir <output_dir>]
Sample Command
Additional Note for Users
Refer to this document for more information.
12. List all MCPs¶
CLI Command
Sample Command
13. Retrieves a specific MCP¶
CLI Command
ap gateway mcp get --display-name <name> --version <version> --format <json|yaml>
ap gateway mcp get --id <id> --format <json|yaml>
Sample Command
ap gateway mcp get --display-name my-mcp --version 1.0.0 --format json
ap gateway mcp get --id sample-id --format json