AddGatewayQuotaRule
Creates a gateway quota throttling rule.
Operation description
Creates a consumer-based quota rule for an AI gateway. Takes effect only on AI gateways of version 2.1.19 or later.
Recommended call logic:
-
Step 1: Perform a dry run to check for rule conflicts.
-
-
Set dryRun to true.
-
-
-
The response contains a conflictHash value in the conflict preview.
-
-
Step 2: Submit the request after confirmation.
-
-
No conflicts: Set dryRun to false and overwrite to false.
-
-
-
Conflicts exist and you confirm the overwrite: Set dryRun to false and overwrite to true, and set conflictHash to the value returned in the previous step.
-
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
apig:AddGatewayQuotaRule |
none |
*Gateway
|
None | None |
Request syntax
POST /v1/gateways/{gatewayId}/quota-rules HTTP/1.1
Path Parameters
|
Parameter |
Type |
Required |
Description |
Example |
| gatewayId |
string |
No |
The unique identifier of the gateway. |
gw-d8ki1xxxxxxxxxxxxxxx |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| body |
object |
No |
The request body. |
{'key': 'value'} |
| ruleName |
string |
Yes |
The name of the rule. |
团队规则 |
| quotaDimension |
string |
Yes |
The quota dimension. Only token is currently supported. |
token |
| quotaLimit |
integer |
Yes |
The total available quota per period. |
1000 |
| windowAlignment |
string |
No |
The reset period alignment type. Only calendar is currently supported. |
calendar |
| periodType |
string |
Yes |
The period type. Valid values: day (calendar day), week (calendar week), and month (calendar month). |
week |
| periodMultiplier |
integer |
No |
The number of periods after which the quota resets. |
10 |
| timezone |
string |
No |
The time zone for the calendar period, in UTC+x format. |
UTC+8 |
consumerGroupIds
deprecated
|
array |
No |
The list of consumer group IDs. This parameter is not supported. |
group1,group2 |
|
string |
No |
The consumer group ID. |
consumer-group-001 |
|
| consumerIds |
array |
No |
The list of consumer IDs to bind to the rule. |
1001,1002,1003 |
|
string |
No |
The consumer ID. |
cs-xxxxxx |
|
| dryRun |
boolean |
No |
Whether to perform a dry run without persisting or applying the configuration. A dry run checks whether bound consumers have conflicting rules. A consumer cannot have two calendar-period quota rules with the same period type. For example, a consumer with a daily quota rule cannot have another daily quota rule. |
false |
| overwrite |
boolean |
No |
Whether to overwrite conflicting rules. If enabled, conflicting consumers are unbound from the old rule and bound to the new rule. |
false |
| conflictHash |
string |
No |
The conflict snapshot hash that prevents concurrent dirty overwrites. Retrieved from the response of a previous dry run (dryRun=true). Not required when no conflicts exist, during a dry run (dryRun=true), or when overwrite is false. If dryRun is false and overwrite is true but this parameter is missing or expired, the backend returns accepted=false with a new conflict preview. Perform a new dry run to confirm the updated conflicts. |
f8f44dc6cf369a017d56b7197eb4fb5ac4bbb6b09a92b9b41999541fxxxxxxxx |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The response schema. |
||
| requestId |
string |
The request ID. |
1234567890 |
| code |
string |
The status code or error code. |
200, 404, 500 |
| message |
string |
The message content. |
你好,世界! |
| data |
object |
The response data. |
{'key': 'value'} |
| ruleId |
string |
The rule ID. |
qr-xxxxx |
| dryRun |
boolean |
Whether the request is a dry run. |
false |
| accepted |
boolean |
Whether the write request was accepted. A value of false typically indicates a retryable scenario, such as an unconfirmed conflict overwrite. |
true |
| conflictPreview |
object |
The conflict preview. |
|
| totalConflictCount |
integer |
2 |
|
| conflictHash |
string |
f8f44dc6cf369a017d56b7197eb4fb5ac4bbb6b09a92b9b41999541fxxxxxxxx |
|
| items |
array<object> |
||
|
object |
|||
| consumerId |
string |
cs-xxxxxx |
|
| consumerName |
string |
consumer-a |
|
| conflictType |
string |
calendar |
|
| conflictPeriodType |
string |
week |
Examples
Success response
JSON format
{
"requestId": "1234567890",
"code": "200, 404, 500",
"message": "你好,世界!",
"data": {
"ruleId": "qr-xxxxx",
"dryRun": false,
"accepted": true,
"conflictPreview": {
"totalConflictCount": 2,
"conflictHash": "f8f44dc6cf369a017d56b7197eb4fb5ac4bbb6b09a92b9b41999541fxxxxxxxx",
"items": [
{
"consumerId": "cs-xxxxxx",
"consumerName": "consumer-a",
"conflictType": "calendar",
"conflictPeriodType": "week"
}
]
}
}
}
Error codes
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.