Skip to main content

Billing Cycle and Usage Control

Platform Edition is billed at the platform (PlatformId) level: one Tencent Cloud account (UIN) can purchase multiple Platform Edition packages, each identified by a PlatformId. Once an environment belongs to a specific package, its resource usage is metered and deducted from that package's credits. This document explains how to query environment usage, control environment status, and the division of responsibilities between the platform and you, helping you implement "billing cycle + usage" management in your own business.

Responsibility Boundary Between the Platform and You​

CloudBase provides the metering facts and execution APIs, while billing cycle rules, quota judgment, and disposal policies are implemented by you:

LayerResponsible partyCapabilities provided
MeteringCloudBaseUsage statistics, querying package (PlatformId) / environment usage by time range
ExecutionCloudBaseSuspend / resume / destroy APIs (controlled + audited)
NotificationCloudBaseReports environment credit usage to Cloud Monitor, which triggers alarm callbacks (not yet available)
Billing cycleYou (customer)Billing cycle rules (period, quota reset / rollover)
QuotaYou (customer)Quota system (credits / traffic / requests, etc.)
PolicyYou (customer)Threshold judgment, alerts, suspend / resume / destroy decisions
Why the platform does not implement billing cycles

Every customer's business model (free trial, pay-as-you-go, prepaid, enterprise contracts) differs greatly, and the combination space of billing cycle and quota policies is huge (auto-renewal, suspend with retention, downgrade on expiry, overage pay-as-you-go, overdraft, etc.). CloudBase does not "make decisions" on policies for customers. Instead, it provides atomic capabilities that you combine according to your own business rules for maximum flexibility.

Querying Usage​

The platform provides platform (PlatformId)-level and environment-level usage query capabilities, supporting queries of credit usage by specified time range, environment ID, and resource type, which can be used for billing cycle settlement, cost analysis, and quota judgment.

ScopeAPIDescription
Platform (PlatformId)DescribePlatformCreditsUsageGet Platform Edition credit usage
Platform (PlatformId)DescribePlatformCreditsUsageDetailGet Platform Edition credit usage details
Single environmentDescribePlatformEnvUsageQuery the resource usage and details of a single environment under Platform Edition

For the request parameters and response parameters of each API, see the corresponding API documentation.

Usage suggestions:

  • Billing cycle settlement: query cumulative usage by time range at the end of each billing cycle for reconciliation and settlement
  • Cost analysis: query usage by environment and time period to identify high-consumption environments
  • Quota judgment: compare the query results with the quota thresholds you set, and trigger subsequent disposal

Controlling Environment Status​

The platform provides environment-level status control APIs. You can suspend / resume / destroy a single environment according to your business strategy:

OperationAPIDescription
SuspendModifyPlatformEnvThe environment enters a suspended state (with the same effect as isolation); running services stop, data is retained, credits continue to be consumed, and it can be resumed on demand
ResumeModifyPlatformEnvRestore a suspended environment to a normal usable state
DestroyDestroyPlatformEnvDelete the environment (data will be cleared; operate with caution)

For the request parameters and response parameters of each API, see the corresponding API documentation.

Status control notes
  • Suspend / resume only supports manual triggering; it cannot be called when the associated package is in a system suspension state (overrun service suspension / expiry isolation).
  • After suspension, data is retained and credits continue to be consumed.
  • Destruction clears data; please confirm there are no business dependencies before operating.

Usage Notification Methods​

To determine "which environments need disposal", there are two usage notification methods:

MethodTriggerImpact of environment count growth
Scheduled pollingFixed-interval sampling; a threshold crossing is found after the factAPI calls grow linearly with the number of environments
Event callbacksCallback as soon as a threshold is crossedIndependent of environment count

Method 1: Scheduled polling​

You traverse the environment list with scheduled tasks, query usage by each billing cycle, compare with quotas, and issue disposal:

Suitable for scenarios with a small number of environments. When there are many environments, full polling generates a large number of API calls (number of environments × polling frequency).

Method 2: Event callbacks (not yet available)​

CloudBase reports environment-level credit usage to Cloud Monitor, which evaluates your alarm policies and calls back your system through a notification template. You only process the environments that triggered an alarm, instead of traversing every environment.

This capability is not yet available. The setup below describes how it will work once available; until then, use Method 1 (scheduled polling).

Reported metrics​

MetricmetricNameDefinition (pending deductions excluded)Unit
Credit usageresource_point_deducted_usageCredits actually consumed within the billing cycle, including packages, resource bundles, and pay-as-you-gocredits

Metrics are reported per environment. The namespace is qce/tcb, and dimensions always contains the envId key. The metric is a cumulative value within a billing cycle and increases monotonically, and it resets when the cycle switches. Thresholds therefore only need a "greater than N" comparison, with no need to handle value drops.

Credit usage includes the pay-as-you-go part. To determine whether the package has been exceeded, compare this metric with the total credits in the package.

⚠️ After the cycle switches and counters reset, a triggered alarm is delivered once as a recovery (alarmStatus is 0). This is expected behavior; handle it as a recovery event.

Setup steps​

  1. Confirm the metrics are reported: in Cloud Monitor, query the target environment's metrics by namespace qce/tcb and dimension envId.
  2. Create an alarm policy: select the credit usage metric, set the alarm object to environments (a single environment or all of them), and configure an absolute threshold based on your budget plus a statistical period.
  3. Bind a notification template: choose "Interface callback (Webhook)" as the notification channel and provide a public HTTPS URL. A cloud function (intranet delivery) or log service is also available.
  4. Handle the callback: parse the environment ID, metric name, and cumulative value, distinguish alarm from recovery by alarmStatus, and then apply your policy.

Callback fields​

What to readPayload locationDescription
Environment IDalarmObjInfo.dimensions.envIdThe dimension key fixed at reporting time
Metric namealarmPolicyInfo.conditions.metricNameAlways resource_point_deducted_usage
Current cumulative valuealarmPolicyInfo.conditions.currentValueThe cumulative value at trigger time; its meaning depends on the subscribed metric
Configured thresholdalarmPolicyInfo.conditions.calcValueSame unit as currentValue
Alarm or recoveryalarmStatus1 alarm, 0 recovery
First threshold crossing timefirstOccurTimeCombine with durationTime to compute the duration
Account ownershipalarmObjInfo.appId, alarmObjInfo.uinVerify data ownership in multi-tenant scenarios
{
"alarmStatus": 1,
"alarmType": "metric",
"alarmObjInfo": {
"region": "ap-shanghai",
"namespace": "qce/tcb",
"appId": "1250000000",
"uin": "100000000001",
"dimensions": {
"envId": "prod-1a2b3c"
}
},
"alarmPolicyInfo": {
"policyName": "Environment credit usage alarm",
"conditions": {
"metricName": "resource_point_deducted_usage",
"calcType": ">",
"calcValue": "1000000",
"currentValue": "1048576"
}
},
"firstOccurTime": "2026-11-10 15:00:00",
"recoverTime": "0"
}

⚠️ The receiver must return HTTP 200 within 5 seconds. A timeout or non-200 response counts as a failed delivery; Cloud Monitor retries at most 3 times and then discards the message. Keep the receiver to parsing and persistence, and run policy judgment asynchronously.

Alarms fire per alarm object: one notification per environment, and separately for each metric subscribed on the same environment. The receiver must process each dimensions.envId independently.

Recommended Implementation Flow​

  1. Purchase the package and create environments: see Purchase and Initialization and Create Environments
  2. Deliver API Keys: see Manage API Keys
  3. Build a billing cycle engine: define billing cycle rules (period, quota reset / rollover) and a quota system (credits / traffic / requests)
  4. Integrate usage notification: obtain usage for each environment via scheduled polling (event callbacks are not yet available; see Usage Notification Methods)
  5. Implement disposal policies: compare usage with quotas and trigger suspend / resume / destroy / alert actions

Next Steps​