Update Application Global Quota Consumption Settings
Calling this interface can update whether the application (Application) is allowed to use the global account balance for consumption. When the application's own quota is exhausted, if this option is enabled, the system will automatically deduct fees from the user's global balance.
¶ Prerequisites
- Register and log in to the Ace Data Cloud platform.
- Obtain the Platform Token, for details please refer to the Platform Token Documentation.
- Have an application (Application) already.
¶ Interface Description
- Request Method: POST
- Request URL:
https://platform.acedata.cloud/api/v1/applications/{id}/update-allow-consume-global/ - Request Headers:
- accept:
application/json - authorization:
Bearer {token} - content-type:
application/json
- accept:
Where {id} is the UUID of the application, and {token} is the Platform Token.
¶ Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
allow_consume_global |
boolean | Yes | Whether to allow consumption using the global balance. true means allowed, false means not allowed |
¶ CURL Request Example
curl -X POST \
-H "accept: application/json" \
-H "authorization: Bearer {token}" \
-H "content-type: application/json" \
-d '{"allow_consume_global": true}' \
"https://platform.acedata.cloud/api/v1/applications/{id}/update-allow-consume-global/"
¶ Response Result Example
{
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"service": {
"id": "xxxx-xxxx-xxxx",
"name": "ChatGPT",
"alias": "chatgpt"
},
"scope": "Individual",
"type": "Usage",
"remaining_amount": "50.00",
"used_amount": "150.00",
"allow_consume_global": true,
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:35:00Z"
}
¶ Quota Consumption Mechanism
When the API request reaches the platform gateway, the system deducts fees according to the following priority:
- Application's Own Quota: First, deduct from the Application's
remaining_amount. - Global Balance (Optional): If the application's own quota is exhausted, and
allow_consume_globalistrue, then deduct from the user's global Balance. - Insufficient Balance: If both are insufficient, return a 402 error.
Suggestion: For services that require flexible usage (such as ChatGPT), it is recommended to enable global balance consumption to avoid service interruption due to the exhaustion of application quota.
¶ Code Example
Python:
import requests
token = "your-platform-token"
app_id = "your-application-id"
url = f"https://platform.acedata.cloud/api/v1/applications/{app_id}/update-allow-consume-global/"
headers = {
"accept": "application/json",
"authorization": f"Bearer {token}",
"content-type": "application/json",
}
data = {"allow_consume_global": True}
response = requests.post(url, json=data, headers=headers)
result = response.json()
print(f"Global balance consumption has been {'enabled' if result['allow_consume_global'] else 'disabled'}")
