Environment Management
listEnvs
1. API Description
API feature: obtains all environment information
API declaration: listEnvs(): Promise<Object>
2. Input Parameters
N/A
3. Return Results
| Field | Required | Type | Description |
|---|---|---|---|
| RequestId | Required | String | Unique identifier of the request |
| EnvList | Yes | Array<EnvItem> | Environment array |
EnvItem
| Field | Required | Type | Description |
|---|---|---|---|
| EnvId | Yes | String | Environment ID |
| Source | Required | String | Source |
| Alias | Yes | String | Environment alias |
| Status | Required | String | Environment status |
| CreateTime | Required | String | Creation time |
| UpdateTime | Yes | String | Update time |
| PackageId | Required | String | Environment package ID |
| PackageName | Required | String | Package name |
| Databases | Required | Array | Database resource details |
| Storages | Required | Array | Storage resource details |
| Functions | Required | Array | Function resource details |
| LogServices | Required | Array | Log resource details |
4. Sample Code
import CloudBase from '@cloudbase/manager-node'
const { env } = new CloudBase({
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId' // TCB environment ID, which can be obtained from the Tencent Cloud TCB console
})
async function test() {
const res = await env.listEnvs()
const { EnvList } = res
for (let env in EnvList) {
// Iterate through envList
console.log(env)
}
}
test()
getEnvAuthDomains
1. API Description
API feature: obtains the list of legal domains
API declaration: getEnvAuthDomains(): Promise<Object>
2. Input Parameters
N/A
3. Return Results
| Field | Required | Type | Description |
|---|---|---|---|
| Domains | Required | Array<Domain> | List of domains |
| envId | Required | String | Environment ID |
Domain
| Field | Required | Type | Description |
|---|---|---|---|
| Id | Required | String | Domain ID |
| Domain | Required | String | Domain |
| Type | Required | String | Domain type. Valid values include: system, user |
| Status | Required | String | Status. Valid values include: ENABLE, DISABLE |
| CreateTime | Required | String | Creation time |
| UpdateTime | Required | String | Update time |
4. Sample Code
import CloudBase from '@cloudbase/manager-node'
const { env } = new CloudBase({
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId' // TCB environment ID, which can be obtained from the Tencent Cloud TCB console
})
async function test() {
const res = await env.getEnvAuthDomains()
const { Domains } = res
for (let domain in Domains) {
console.log(domain)
}
}
test()
createEnvDomain
1. API Description
API feature: Add environment security domain name
API declaration: createEnvDomain(domains: string[]): Promise<Object>
2. Input Parameters
| Field | Required | Type | Description |
|---|---|---|---|
| domains | Required | Array<String> | Array of secure domains |
3. Return Results
| Field | Type | Description |
|---|---|---|
| RequestId | String | Request ID |
4. Sample Code
import CloudBase from '@cloudbase/manager-node'
const { env } = new CloudBase({
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId' // TCB environment ID, which can be obtained from the Tencent Cloud TCB console
})
async function test() {
const res = await env.createEnvDomain(['luke.com'])
console.log(res)
}
test()
deleteEnvDomain
1. API Description
API feature: Delete environment security domain
API declaration: deleteEnvDomain(domains: string[]): Promise<Object>
2. Input Parameters
| Field | Required | Type | Description |
|---|---|---|---|
| domains | Required | Array<String> | Array of secure domains |
3. Return Results
| Field | Required | Type | Description |
|---|---|---|---|
| RequestId | Required | String | Request ID |
| Deleted | Required | Number | Number of successfully deleted domains |
4. Sample Code
import CloudBase from '@cloudbase/manager-node'
const { env } = new CloudBase({
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId' // TCB environment ID, which can be obtained from the Tencent Cloud TCB console
})
async function test() {
const res = await env.deleteEnvDomain(['luke.com'])
const { Deleted } = res
console.log(Deleted) // Number of deleted domains
}
test()
getEnvInfo
1. API Description
API feature: obtain environment information
API declaration: getEnvInfo(): Promise<Object>
2. Input Parameters
N/A
3. Return Results
| Field | Required | Type | Description |
|---|---|---|---|
| RequestId | Required | String | Request ID |
| EnvInfo | Yes | EnvItem | Environment information |
4. Sample Code
import CloudBase from '@cloudbase/manager-node'
const { env } = new CloudBase({
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId' // TCB environment ID, which can be obtained from the Tencent Cloud TCB console
})
async function test() {
const res = await env.getEnvInfo()
const { EnvInfo } = res
console.log(EnvInfo)
}
test()
updateEnvInfo
1. API Description
API feature: modify environment alias
API declaration: updateEnvInfo(alias: string): Promise<Object>
2. Input Parameters
| Field | Required | Type | Description |
|---|---|---|---|
| alias | Yes | String | Environment alias |
3. Return Results
| Field | Required | Type | Description |
|---|---|---|---|
| RequestId | Required | String | Request ID |
4. Sample Code
import CloudBase from '@cloudbase/manager-node'
const { env } = new CloudBase({
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId' // TCB environment ID, which can be obtained from the Tencent Cloud TCB console
})
async function test() {
const res = await env.updateEnvInfo('lukemodify')
console.log(res)
}
test()
getLoginConfigList
1. API Description
API feature: Pull login configuration list
API declaration: getLoginConfigList(): Promise<Object>
2. Input Parameters
N/A
3. Return Results
| Field | Required | Type | Description |
|---|---|---|---|
| RequestId | Required | String | Request ID |
| ConfigList | Required | Array<ConfigItem> | Login configuration list |
ConfigItem
| Field | Required | Type | Description |
|---|---|---|---|
| Id | Required | String | Configuration ID |
| Platform | Required | String | Platform type |
| PlatformId | Required | String | Platform ID |
| Status | Required | String | Configuration status |
| UpdateTime | Required | String | Configuration update time |
| CreateTime | Required | String | Configuration creation time |
4. Sample Code
import CloudBase from '@cloudbase/manager-node'
const { env } = new CloudBase({
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId' // TCB environment ID, which can be obtained from the Tencent Cloud TCB console
})
async function test() {
const res = await env.getLoginConfigList()
const { ConfigList } = res
for (let config in ConfigList) {
console.log(config)
}
}
test()
createLoginConfig
1. API Description
API feature: Create login method
API declaration: createLoginConfig(platform, appId, appSecret): Promise<Object>
2. Input Parameters
| Field | Required | Type | Description |
|---|---|---|---|
| platform | Required | String | Platform "WECHAT-OPEN", "WECHAT-PUBLIC", "QQ", "ANONYMOUS" |
| appId | Required | String | Third-party platform AppID. Note: For anonymous login (platform: ANONYMOUS), enter "anonymous" for appId. |
| appSecret | No | String | Third-party platform AppSecret. Note: For anonymous login (platform: ANONYMOUS), appSecret can be omitted. |
3. Return Results
| Field | Required | Type | Description |
|---|---|---|---|
| RequestId | Required | String | Request ID |
4. Sample Code
import CloudBase from '@cloudbase/manager-node'
const { env } = new CloudBase({
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId' // TCB environment ID, which can be obtained from the Tencent Cloud TCB console
})
async function test() {
await env.createLoginConfig('WECHAT-OPEN', 'appId', 'appSecret')
}
test()
updateLoginConfig
1. API Description
API feature: Update login method configuration
API declaration: updateLoginConfig(configId, status, appId, appSecret): Promise<Object>
2. Input Parameters
| Field | Required | Type | Description |
|---|---|---|---|
| configId | Required | String | Configuration record ID |
| status | Required | String | "ENABLE", "DISABLE" |
| appId | Required | String | Third-party platform AppId. For anonymous login, enter "anonymous" for appId. |
| appSecret | No | String | Third-party platform AppSecret. If anonymous login, this field can be omitted. |
3. Return Results
| Field | Required | Type | Description |
|---|---|---|---|
| RequestId | Required | String | Request ID |
4. Sample Code
import CloudBase from '@cloudbase/manager-node'
const { env } = new CloudBase({
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId' // TCB environment ID, which can be obtained from the Tencent Cloud TCB console
})
async function test() {
const loginConfigRes = await env.getLoginConfigList()
await env.updateLoginConfig(
loginConfigRes.ConfigList[0].Id,
'ENABLE',
'appId',
'appSecret'
)
}
test()
createBillingDeal
1. API Description
API feature: create environment billing order
API declaration: createBillingDeal(params: CreateBillingDealParams): Promise<Object>
2. Input Parameters
| Field | Required | Type | Description |
|---|---|---|---|
| DealType | Required | String | Order operation type. Valid values: purchase (purchase), renew (renewal), modify (specification change) |
| ProductType | Required | String | Product type purchased. Valid values: tcb-baas (baas package), tcb-promotion (promotion package), tcb-package (resource package) |
| PackageId | Required | String | ID of the target product/package to be ordered |
| CreateAndPay | No | Boolean | whether to pay automatically |
| TimeSpan | No | Number | Subscription duration |
| TimeUnit | No | String | Subscription duration unit. Valid values: d (day), m (month), y (year), p (one-time) |
| ResourceId | No | String | Unique identifier of the resource |
| Source | No | String | Source. Valid values: qcloud, miniapp |
| Alias | No | String | Resource alias |
| EnvId | No | String | Environment ID |
| EnableExcess | No | Boolean | Whether to enable excess limit pay-as-you-go |
| ModifyPackageId | No | String | ID of the target product/package for modification |
| Extension | No | String | Extension information (JSON string) |
| AutoVoucher | No | Boolean | whether to automatically use vouchers for payment |
| ResourceTypes | No | String[] | Resource type. Resources to be provisioned when purchasing a new environment. Valid values: flexdb, cos, cdn, scf |
3. Return Results
| Field | Required | Type | Description |
|---|---|---|---|
| RequestId | Required | String | Request ID |
| EnvId | Yes | String | Environment ID |
| TranId | Required | String | Order transaction ID |
4. Sample Code
import CloudBase from '@cloudbase/manager-node'
const { env } = new CloudBase({
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId' // TCB environment ID, which can be obtained from the Tencent Cloud TCB console
})
async function test() {
const res = await env.createBillingDeal({
DealType: 'purchase',
ProductType: 'tcb-baas',
PackageId: 'baas_personal',
CreateAndPay: false,
TimeSpan: 1,
TimeUnit: 'm',
Alias: 'test',
EnvId: 'test-12345'
})
console.log(res.TranId) // Order transaction ID
}
test()
cancelDeal
1. API Description
API feature: Cancel unpaid orders
API declaration: cancelDeal(params: Object): Promise<Object>
2. Input Parameters
| Field | Required | Type | Description |
|---|---|---|---|
| TranId | Required | String | Order transaction ID |
| UserClientIp | Required | String | User client IP |
| WxAppId | No | String | WeChat AppId (optional) |
3. Return Results
| Field | Required | Type | Description |
|---|---|---|---|
| RequestId | Required | String | Request ID |
4. Sample Code
import CloudBase from '@cloudbase/manager-node'
const { env } = new CloudBase({
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId' // TCB environment ID, which can be obtained from the Tencent Cloud TCB console
})
async function test() {
// First, create an order
const dealRes = await env.createBillingDeal({
DealType: 'purchase',
ProductType: 'tcb-baas',
PackageId: 'baas_personal',
CreateAndPay: false,
TimeSpan: 1,
TimeUnit: 'm',
Alias: 'test',
EnvId: 'test-12345'
})
// Cancel the order
const res = await env.cancelDeal({
TranId: dealRes.TranId,
UserClientIp: '127.0.0.1'
})
console.log(res)
}
test()
createCustomLoginKeys
1. API Description
API feature: Create custom login key
API declaration: createCustomLoginKeys(): Promise<Object>
2. Input Parameters
N/A
3. Return Results
| Field | Required | Type | Description |
|---|---|---|---|
| RequestId | Required | String | Request ID |
| KeyID | Yes | String | Key ID |
| PrivateKey | Yes | String | Private Key |
4. Sample Code
import CloudBase from '@cloudbase/manager-node'
const { env } = new CloudBase({
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId' // TCB environment ID, which can be obtained from the Tencent Cloud TCB console
})
async function test() {
const res = await env.createCustomLoginKeys()
const { KeyID, PrivateKey } = res
console.log(KeyID, PrivateKey)
}
test()
destroyEnvWithParams
1. API Description
API feature: Destroy the specified environment, supporting options such as forced deletion and bypassing resource checks
API declaration: app.env.destroyEnvWithParams(params): Promise<Object>
This API has been supported since v5.0.0.
2. Input Parameters
| Field | Required | Type | Description |
|---|---|---|---|
| EnvId | Yes | String | Environment ID |
| IsForce | No | Boolean | Whether to force deletion (for environments in prepaid isolation), default false |
| BypassCheck | No | Boolean | whether to bypass resource data checks and delete directly, default false |
3. Return Results
| Field | Type | Description |
|---|---|---|
| RequestId | String | Unique identifier of the request |
describeEnvs
1. API Description
API feature: Queries the list of TCB environments under an account, supporting multi-dimensional filtering.
API declaration: app.env.describeEnvs(params): Promise<Object>
This API has been supported since v5.0.0.
2. Input Parameters
| Field | Required | Type | Description |
|---|---|---|---|
| EnvId | No | String | Filter by Environment ID |
| WxAppId | No | String | WeChat AppId (required for WeChat channel) |
| IsVisible | No | Boolean | Used in conjunction with Channels to control the filtering direction for visible/invisible channels |
| Channels | No | String[] | Channel list, such as ["ide","qc_console"] |
| EnvType | No | String | Environment type: baas / run / weda / hosting |
| EnvTypes | No | String[] | List of environment types (takes precedence over EnvType) |
| Limit | No | Number | Page size |
| Offset | No | Number | Pagination offset |
3. Return Results
| Field | Type | Description |
|---|---|---|
| EnvList | Array | Environment list |
| RequestId | String | Unique identifier of the request |
4. Sample Code
const CloudBase = require('@cloudbase/manager-node')
const app = new CloudBase({ secretId: 'Your SecretId', secretKey: 'Your SecretKey', envId: 'your-env-id' })
async function test() {
const { EnvList } = await app.env.describeEnvs({ EnvType: 'baas' })
EnvList.forEach(e => console.log(e.EnvId, e.Alias))
}
test()
createEnv
1. API Description
API feature: Creates a new TCB environment
API declaration: app.env.createEnv(params): Promise<Object>
This API has been supported since v5.0.0.
2. Input Parameters
| Field | Required | Type | Description |
|---|---|---|---|
| Alias | Required | String | Environment alias, consisting of lowercase letters/digits/hyphens, cannot start or end with a hyphen, with a maximum length of 20 characters |
| PackageId | Required | String | Package ID, can be obtained via describeBaasPackageList |
| Resources | Required | String[] | Resources to be provisioned: flexdb / storage / function |
| Period | No | Number | Subscription duration (months), default is 1 |
| AutoVoucher | No | Boolean | whether to automatically use vouchers |
| RenewFlag | No | String | Renewal policy: NOTIFY_AND_AUTO_RENEW / NOTIFY_AND_MANUAL_RENEW |
3. Return Results
| Field | Type | Description |
|---|---|---|
| EnvId | String | ID of the newly created environment |
| RequestId | String | Unique identifier of the request |
describeBaasPackageList
1. API Description
API feature: Query the TCB package list, used to obtain optional packages before create/modify/renew.
API declaration: app.env.describeBaasPackageList(params): Promise<Object>
This API has been supported since v5.0.0.
2. Input Parameters
| Field | Required | Type | Description |
|---|---|---|---|
| PackageName | No | String | Package ID. If not filled, all data will be returned. |
| EnvId | No | String | Environment ID |
| Source | No | String | Package owner. Valid values: miniapp / qcloud. Default: miniapp |
| TargetAction | No | String | Purpose: new (new purchase) / modify (modification) / renew (renewal) |
| GroupName | No | String | Package group: calculation / flux / capacity |
| InternationalPackage | No | Boolean | Whether to query international edition packages |
3. Return Results
| Field | Type | Description |
|---|---|---|
| PackageList | BaasPackageInfo[] | Package List |
| RequestId | String | Unique identifier of the request |
modifyEnvPlan
1. API Description
API feature: Modify the package of the specified environment (upgrade/downgrade)
API declaration: app.env.modifyEnvPlan(params): Promise<Object>
This API has been supported since v5.0.0.
2. Input Parameters
| Field | Required | Type | Description |
|---|---|---|---|
| EnvId | Yes | String | Environment ID |
| PackageId | Required | String | Target Package ID |
| AutoVoucher | No | Boolean | whether to automatically use vouchers |
3. Return Results
| Field | Type | Description |
|---|---|---|
| RequestId | String | Unique identifier of the request |
renewEnv
1. API Description
API feature: renew the specified environment
API declaration: app.env.renewEnv(params): Promise<Object>
This API has been supported since v5.0.0.
2. Input Parameters
| Field | Required | Type | Description |
|---|---|---|---|
| EnvId | Yes | String | Environment ID |
| Period | No | Number | Renewal duration (months), default is 1 |
| AutoVoucher | No | Boolean | whether to automatically use vouchers |
3. Return Results
| Field | Type | Description |
|---|---|---|
| RequestId | String | Unique identifier of the request |
calculatePackageCreatePrice
1. API Description
API feature: Calculate the estimated price for a new purchase package.
API declaration: app.env.calculatePackageCreatePrice(params): Promise<Object>
This API has been supported since v5.0.0.
2. Input Parameters
| Field | Required | Type | Description |
|---|---|---|---|
| packageId | Required | String | Package ID |
| region | Required | String | Region, such as ap-shanghai |
| period | No | Number | Subscription duration (months) |
| currency | No | String | Currency: CNY or USD |
3. Return Results
Returns the result of the price calculation, including fields such as the original price and discounted price.
calculatePackageRenewPrice
1. API Description
API feature: Calculate the estimated price for a renewal package.
API declaration: app.env.calculatePackageRenewPrice(params): Promise<Object>
This API has been supported since v5.0.0.
2. Input Parameters
| Field | Required | Type | Description |
|---|---|---|---|
| envId | Required | String | Environment ID |
| period | No | Number | Renewal duration (months) |
| currency | No | String | Currency: CNY or USD |
3. Return Results
Returns the result of the price calculation, including fields such as the original price and discounted price.
calculatePackageModifyPrice
1. API Description
API feature: Calculate the estimated price for a change package.
API declaration: app.env.calculatePackageModifyPrice(params): Promise<Object>
This API has been supported since v5.0.0.
2. Input Parameters
| Field | Required | Type | Description |
|---|---|---|---|
| envId | Required | String | Environment ID |
| packageId | Required | String | Target Package ID |
| currency | No | String | Currency: CNY or USD |
3. Return Results
Returns the result of the price calculation, including fields such as the original price and discounted price.
describeBillingInfo
1. API Description
API feature: query the billing information of the specified environment
API declaration: app.env.describeBillingInfo(params): Promise<Object>
This API has been supported since v5.0.0.
2. Input Parameters
| Field | Required | Type | Description |
|---|---|---|---|
| EnvId | No | String | Environment ID. If not passed, query all data. |
3. Return Results
Returns the billing details of the environment (including package, expiration time, billing status, etc., with specific structure subject to backend implementation).
describeEnvAccountCircle
1. API Description
API feature: query the billing cycle information of the environment (current and historical cycles)
API declaration: app.env.describeEnvAccountCircle(params): Promise<Object>
This API has been supported since v5.0.0.
2. Input Parameters
| Field | Required | Type | Description |
|---|---|---|---|
| EnvId | Yes | String | Environment ID |
| WxAppId | No | String | WeChat AppId |
| WithHistoryCircle | No | Boolean | Whether to return the previous and the one before the previous billing cycle, default false |
3. Return Results
| Field | Type | Description |
|---|---|---|
| StartTime | String | current billing cycle start time |
| EndTime | String | current billing cycle end time |
| HistoryTime | Array | Historical cycle list (including start/end times) |
| RequestId | String | Unique identifier of the request |
describeCreditsUsageDetail
1. API Description
API feature: query the usage details of environment resource points, supports filtering by module and date.
API declaration: app.env.describeCreditsUsageDetail(params): Promise<Object>
This API has been supported since v5.0.0.
2. Input Parameters
| Field | Required | Type | Description |
|---|---|---|---|
| EnvId | Yes | String | Environment ID |
| Modules | Yes | String[] | Module list, optional: EKS / Database / SCF / COS / AI / HOSTING / Auth / Other |
| StartDate | Yes | String | Start date, format: YYYY-MM-DD |
| EndDate | Yes | String | End date, format: YYYY-MM-DD |
| NeedUsageDetails | Yes | Boolean | whether to return daily usage details |
3. Return Results
Returns the usage details of resource points for each module (specific structure subject to backend implementation).
4. Sample Code
const CloudBase = require('@cloudbase/manager-node')
const app = new CloudBase({ secretId: 'Your SecretId', secretKey: 'Your SecretKey', envId: 'your-env-id' })
async function test() {
const res = await app.env.describeCreditsUsageDetail({
EnvId: 'your-env-id',
Modules: ['SCF', 'Database', 'COS'],
StartDate: '2025-01-01',
EndDate: '2025-01-31',
NeedUsageDetails: true
})
console.log(JSON.stringify(res, null, 2))
}
test()