All Products
Search
Document Center

PolarDB:CreateBatchConsumer

Last Updated:Dec 03, 2026

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

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

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:

  • 30

  • 50

  • 100

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.