Creates API keys in batches.
Operation description
Prerequisites: First, call CreateGwConsumerOrder and specify GatewayId, PackageSpec, KeyCount, RegionId, and ExpireTime to obtain a CreditToken. Then, call this operation to create consumers in bulk. Before calling this operation, call DescribeConsumerGroups by specifying GwClusterId and RegionId to obtain a valid ConsumerGroupId and explicitly pass it in the request.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
polardb:CreateBatchConsumer |
create |
*All Resource
|
None | None |
Request syntax
POST HTTP/1.1
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| GwClusterId |
string |
Yes |
The gateway instance ID. |
pg-xxxxxxxx |
| Count |
integer |
No |
The number of user API keys. |
1 |
| ConsumerGroupId |
string |
No |
The ID of the consumer group. The default auto-selection logic is currently inactive. You must call DescribeConsumerGroups by specifying GwClusterId and RegionId to obtain the ID and explicitly pass it in the request. |
cg-xxxxxx |
| ClientToken |
string |
No |
The client token that is used to ensure the idempotence of the request and prevent duplicate submissions. You can generate the value on the client side. The value must be unique across different requests, case-sensitive, and up to 64 ASCII characters in length. |
6000170000591aed949d0f5******************** |
| CreditToken |
string |
No |
The redemption credential. The standard path does not support omitting this parameter. You must first call CreateGwConsumerOrder to obtain a CreditToken and then pass it in the request. |
"9" |
| Description |
string |
No |
The description prefix of the consumer. |
myapp |
| RegionId |
string |
Yes |
The region ID. |
cn-beijing |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
Schema of Response |
||
| RequestId |
string |
The ID of the request. |
A7E6A8FD-C50B-46B2-BA85-D8B8D3****** |
| TotalRecordCount |
integer |
The total number of records. |
2 |
| PageRecordCount |
integer |
The number of records on the current page. |
1 |
| PageNumber |
integer |
The page number. Default value: 1. |
1 |
| PageSize |
integer |
The number of records per page. Valid values:
Default value: 30. |
30 |
| TotalPages |
integer |
The total number of pages. |
1 |
| Items |
array<object> |
The list of consumer objects. |
|
|
object |
The consumer object. |
||
| ConsumerId |
string |
The ID of the consumer. |
c-mqveroemc*** |
| Name |
string |
The name. |
test |
| ConsumerGroupId |
string |
The ID of the consumer group. |
cg-xxxxxx |
| ConsumerTag |
string |
The consumer tag. |
test |
| ApiKey |
string |
The complete API key. This value is returned only in the current response. |
6c4b1f0317cd4fd7a5b446d3503d** |
| GwClusterId |
string |
The gateway instance ID. |
pg-xxxxxxxxxx |
| ApiStatus |
string |
The status of the API key. Default value: Active. |
Active |
| ApiKeyStatus |
string |
The status of the API key. Default value: Active. |
Active |
| Status |
string |
The status of the consumer. Default value: Enabled. |
Enabled |
| GmtCreated |
string |
The creation time. |
2024-10-16 16:46:20 |
| GmtModified |
string |
The update time. |
2026-01-04T16:09:29+08:00 |
| Description |
string |
The application description or remark. |
myapp |
| ApiKeyMd5 |
string |
The MD5 hash of the API key. |
0769a11c2d474f96fbb527f8e273d3de |
| BudgetPolicyId |
string |
The ID of the budget policy. Each key has an independent policy. |
023aacc1effc4b56bb154bfbec6ba9** |
| BudgetLimit |
integer |
The budget limit, which is equal to the points of a single package. |
3000 |
| BudgetUsed |
integer |
The used quota. |
0 |
| ExpireTime |
string |
The expiration time. The time is displayed in the ISO 8601 standard in the UTC time zone. Format: YYYY-MM-DDTHH:mm:ssZ. |
2025-06-25T09:37:10Z |
| Active |
boolean |
Indicates whether the consumer is active. |
true |
| Expired |
boolean |
Indicates whether the consumer has expired. |
false |
Examples
Success response
JSON format
{
"RequestId": "A7E6A8FD-C50B-46B2-BA85-D8B8D3******",
"TotalRecordCount": 2,
"PageRecordCount": 1,
"PageNumber": 1,
"PageSize": 30,
"TotalPages": 1,
"Items": [
{
"ConsumerId": "c-mqveroemc***",
"Name": "test",
"ConsumerGroupId": "cg-xxxxxx",
"ConsumerTag": "test",
"ApiKey": "6c4b1f0317cd4fd7a5b446d3503d**",
"GwClusterId": "pg-xxxxxxxxxx",
"ApiStatus": "Active",
"ApiKeyStatus": "Active",
"Status": "Enabled",
"GmtCreated": "2024-10-16 16:46:20\n",
"GmtModified": "2026-01-04T16:09:29+08:00",
"Description": "myapp",
"ApiKeyMd5": "0769a11c2d474f96fbb527f8e273d3de",
"BudgetPolicyId": "023aacc1effc4b56bb154bfbec6ba9**",
"BudgetLimit": 3000,
"BudgetUsed": 0,
"ExpireTime": "2025-06-25T09:37:10Z",
"Active": true,
"Expired": false
}
]
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | GatewayApiError | Failed to call gateway Admin API: Not found | The backend implementation for the standard path (without CreditToken) is missing. |
| 500 | BatchCreateRechargeConsumerFailed | Failed to batch create recharge consumers. | Failed to batch create consumers by using the top-up method with a credit token. |
| 404 | InvalidConsumerGroupId.NotFound | The consumer group id provided does not exist in our records. | The ConsumerGroupId parameter is not provided, or the specified group does not exist. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.