The a7 consumer command allows you to manage API7 Enterprise Edition (API7 EE) consumers. You can list, create, update, get, and delete consumers within a specific gateway group using the CLI.
Note: The
--gateway-group(or-g) flag is required for all consumer commands if not specified in your current context.
Lists all consumers in the specified gateway group.
| Flag | Short | Default | Description |
|---|---|---|---|
--gateway-group |
-g |
Target gateway group name (required) | |
--page |
1 |
Page number for pagination | |
--page-size |
20 |
Number of items per page | |
--output |
-o |
table |
Output format (table, json, yaml) |
Examples:
List all consumers in the "default" gateway group:
a7 consumer list -g defaultGets detailed information about a specific consumer by its username.
| Flag | Short | Default | Description |
|---|---|---|---|
--gateway-group |
-g |
Target gateway group name (required) | |
--output |
-o |
yaml |
Output format (json, yaml) |
Examples:
Get consumer by username:
a7 consumer get my-consumer -g defaultCreates a new consumer from a JSON or YAML file.
| Flag | Short | Default | Description |
|---|---|---|---|
--gateway-group |
-g |
Target gateway group name (required) | |
--file |
-f |
Path to the consumer configuration file (required) | |
--output |
-o |
yaml |
Output format (json, yaml) |
Examples:
Create a consumer from a JSON file:
a7 consumer create -g default -f consumer.jsonSample consumer.json:
{
"username": "my-consumer",
"desc": "My API consumer",
"plugins": {
"key-auth": {
"key": "my-secret-key"
}
}
}Updates an existing consumer using a configuration file or JSON Patch.
| Flag | Short | Default | Description |
|---|---|---|---|
--gateway-group |
-g |
Target gateway group name (required) | |
--file |
-f |
Path to the consumer configuration file or JSON Patch file | |
--patch |
-p |
JSON Patch string (RFC 6902) | |
--output |
-o |
yaml |
Output format (json, yaml) |
Examples:
Update consumer "my-consumer" using a file:
a7 consumer update my-consumer -g default -f updated-consumer.jsonDeletes a consumer by its username.
| Flag | Short | Default | Description |
|---|---|---|---|
--gateway-group |
-g |
Target gateway group name (required) | |
--force |
false |
Skip confirmation prompt |
Examples:
Delete consumer without confirmation:
a7 consumer delete my-consumer -g default --forceExports consumers from a gateway group to a file or stdout.
| Flag | Short | Default | Description |
|---|---|---|---|
--gateway-group |
-g |
Target gateway group name (required) | |
--output |
-o |
yaml |
Output format (json, yaml) |
--file |
-f |
Path to save the exported configuration |
Examples:
Export all consumers to a YAML file:
a7 consumer export -g default -f all-consumers.yamlCredential management is handled via the separate credential command, nested under consumers in API7 EE.
Usage: a7 consumer credential [command] -g <gateway-group>
Commands: list, get, create, update, delete.
Key fields in the consumer configuration (sent to /apisix/admin/consumers):
| Field | Type | Description |
|---|---|---|
username |
string | Unique identifier for the consumer |
desc |
string | Human-readable description |
plugins |
object | Plugin configurations (e.g., key-auth, jwt-auth) |
group_id |
string | Reference to a consumer group |
labels |
object | Key-value labels for the consumer |
{
"username": "api-user",
"desc": "API key authenticated user",
"plugins": {
"key-auth": {
"key": "secret-api-key-123"
}
}
}