Skip to main content

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

FieldRequiredTypeDescription
RequestIdRequiredStringUnique identifier of the request
EnvListYesArray<EnvItem>Environment array

EnvItem

FieldRequiredTypeDescription
EnvIdYesStringEnvironment ID
SourceRequiredStringSource
AliasYesStringEnvironment alias
StatusRequiredStringEnvironment status
CreateTimeRequiredStringCreation time
UpdateTimeYesStringUpdate time
PackageIdRequiredStringEnvironment package ID
PackageNameRequiredStringPackage name
DatabasesRequiredArrayDatabase resource details
StoragesRequiredArrayStorage resource details
FunctionsRequiredArrayFunction resource details
LogServicesRequiredArrayLog 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

FieldRequiredTypeDescription
DomainsRequiredArray<Domain>List of domains
envIdRequiredStringEnvironment ID

Domain

FieldRequiredTypeDescription
IdRequiredStringDomain ID
DomainRequiredStringDomain
TypeRequiredStringDomain type. Valid values include: system, user
StatusRequiredStringStatus. Valid values include: ENABLE, DISABLE
CreateTimeRequiredStringCreation time
UpdateTimeRequiredStringUpdate 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

FieldRequiredTypeDescription
domainsRequiredArray<String>Array of secure domains

3. Return Results

FieldTypeDescription
RequestIdStringRequest 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

FieldRequiredTypeDescription
domainsRequiredArray<String>Array of secure domains

3. Return Results

FieldRequiredTypeDescription
RequestIdRequiredStringRequest ID
DeletedRequiredNumberNumber 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

FieldRequiredTypeDescription
RequestIdRequiredStringRequest ID
EnvInfoYesEnvItemEnvironment 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

FieldRequiredTypeDescription
aliasYesStringEnvironment alias

3. Return Results

FieldRequiredTypeDescription
RequestIdRequiredStringRequest 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

FieldRequiredTypeDescription
RequestIdRequiredStringRequest ID
ConfigListRequiredArray<ConfigItem>Login configuration list

ConfigItem

FieldRequiredTypeDescription
IdRequiredStringConfiguration ID
PlatformRequiredStringPlatform type
PlatformIdRequiredStringPlatform ID
StatusRequiredStringConfiguration status
UpdateTimeRequiredStringConfiguration update time
CreateTimeRequiredStringConfiguration 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

FieldRequiredTypeDescription
platformRequiredStringPlatform "WECHAT-OPEN", "WECHAT-PUBLIC", "QQ", "ANONYMOUS"
appIdRequiredStringThird-party platform AppID. Note: For anonymous login (platform: ANONYMOUS), enter "anonymous" for appId.
appSecretNoStringThird-party platform AppSecret. Note: For anonymous login (platform: ANONYMOUS), appSecret can be omitted.

3. Return Results

FieldRequiredTypeDescription
RequestIdRequiredStringRequest 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

FieldRequiredTypeDescription
configIdRequiredStringConfiguration record ID
statusRequiredString"ENABLE", "DISABLE"
appIdRequiredStringThird-party platform AppId. For anonymous login, enter "anonymous" for appId.
appSecretNoStringThird-party platform AppSecret. If anonymous login, this field can be omitted.

3. Return Results

FieldRequiredTypeDescription
RequestIdRequiredStringRequest 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

FieldRequiredTypeDescription
DealTypeRequiredStringOrder operation type. Valid values: purchase (purchase), renew (renewal), modify (specification change)
ProductTypeRequiredStringProduct type purchased. Valid values: tcb-baas (baas package), tcb-promotion (promotion package), tcb-package (resource package)
PackageIdRequiredStringID of the target product/package to be ordered
CreateAndPayNoBooleanwhether to pay automatically
TimeSpanNoNumberSubscription duration
TimeUnitNoStringSubscription duration unit. Valid values: d (day), m (month), y (year), p (one-time)
ResourceIdNoStringUnique identifier of the resource
SourceNoStringSource. Valid values: qcloud, miniapp
AliasNoStringResource alias
EnvIdNoStringEnvironment ID
EnableExcessNoBooleanWhether to enable excess limit pay-as-you-go
ModifyPackageIdNoStringID of the target product/package for modification
ExtensionNoStringExtension information (JSON string)
AutoVoucherNoBooleanwhether to automatically use vouchers for payment
ResourceTypesNoString[]Resource type. Resources to be provisioned when purchasing a new environment. Valid values: flexdb, cos, cdn, scf

3. Return Results

FieldRequiredTypeDescription
RequestIdRequiredStringRequest ID
EnvIdYesStringEnvironment ID
TranIdRequiredStringOrder 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

FieldRequiredTypeDescription
TranIdRequiredStringOrder transaction ID
UserClientIpRequiredStringUser client IP
WxAppIdNoStringWeChat AppId (optional)

3. Return Results

FieldRequiredTypeDescription
RequestIdRequiredStringRequest 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

FieldRequiredTypeDescription
RequestIdRequiredStringRequest ID
KeyIDYesStringKey ID
PrivateKeyYesStringPrivate 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>

version tip

This API has been supported since v5.0.0.

2. Input Parameters

FieldRequiredTypeDescription
EnvIdYesStringEnvironment ID
IsForceNoBooleanWhether to force deletion (for environments in prepaid isolation), default false
BypassCheckNoBooleanwhether to bypass resource data checks and delete directly, default false

3. Return Results

FieldTypeDescription
RequestIdStringUnique 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>

version tip

This API has been supported since v5.0.0.

2. Input Parameters

FieldRequiredTypeDescription
EnvIdNoStringFilter by Environment ID
WxAppIdNoStringWeChat AppId (required for WeChat channel)
IsVisibleNoBooleanUsed in conjunction with Channels to control the filtering direction for visible/invisible channels
ChannelsNoString[]Channel list, such as ["ide","qc_console"]
EnvTypeNoStringEnvironment type: baas / run / weda / hosting
EnvTypesNoString[]List of environment types (takes precedence over EnvType)
LimitNoNumberPage size
OffsetNoNumberPagination offset

3. Return Results

FieldTypeDescription
EnvListArrayEnvironment list
RequestIdStringUnique 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>

version tip

This API has been supported since v5.0.0.

2. Input Parameters

FieldRequiredTypeDescription
AliasRequiredStringEnvironment alias, consisting of lowercase letters/digits/hyphens, cannot start or end with a hyphen, with a maximum length of 20 characters
PackageIdRequiredStringPackage ID, can be obtained via describeBaasPackageList
ResourcesRequiredString[]Resources to be provisioned: flexdb / storage / function
PeriodNoNumberSubscription duration (months), default is 1
AutoVoucherNoBooleanwhether to automatically use vouchers
RenewFlagNoStringRenewal policy: NOTIFY_AND_AUTO_RENEW / NOTIFY_AND_MANUAL_RENEW

3. Return Results

FieldTypeDescription
EnvIdStringID of the newly created environment
RequestIdStringUnique 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>

version tip

This API has been supported since v5.0.0.

2. Input Parameters

FieldRequiredTypeDescription
PackageNameNoStringPackage ID. If not filled, all data will be returned.
EnvIdNoStringEnvironment ID
SourceNoStringPackage owner. Valid values: miniapp / qcloud. Default: miniapp
TargetActionNoStringPurpose: new (new purchase) / modify (modification) / renew (renewal)
GroupNameNoStringPackage group: calculation / flux / capacity
InternationalPackageNoBooleanWhether to query international edition packages

3. Return Results

FieldTypeDescription
PackageListBaasPackageInfo[]Package List
RequestIdStringUnique 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>

version tip

This API has been supported since v5.0.0.

2. Input Parameters

FieldRequiredTypeDescription
EnvIdYesStringEnvironment ID
PackageIdRequiredStringTarget Package ID
AutoVoucherNoBooleanwhether to automatically use vouchers

3. Return Results

FieldTypeDescription
RequestIdStringUnique identifier of the request

renewEnv

1. API Description

API feature: renew the specified environment

API declaration: app.env.renewEnv(params): Promise<Object>

version tip

This API has been supported since v5.0.0.

2. Input Parameters

FieldRequiredTypeDescription
EnvIdYesStringEnvironment ID
PeriodNoNumberRenewal duration (months), default is 1
AutoVoucherNoBooleanwhether to automatically use vouchers

3. Return Results

FieldTypeDescription
RequestIdStringUnique 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>

version tip

This API has been supported since v5.0.0.

2. Input Parameters

FieldRequiredTypeDescription
packageIdRequiredStringPackage ID
regionRequiredStringRegion, such as ap-shanghai
periodNoNumberSubscription duration (months)
currencyNoStringCurrency: 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>

version tip

This API has been supported since v5.0.0.

2. Input Parameters

FieldRequiredTypeDescription
envIdRequiredStringEnvironment ID
periodNoNumberRenewal duration (months)
currencyNoStringCurrency: 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>

version tip

This API has been supported since v5.0.0.

2. Input Parameters

FieldRequiredTypeDescription
envIdRequiredStringEnvironment ID
packageIdRequiredStringTarget Package ID
currencyNoStringCurrency: 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>

version tip

This API has been supported since v5.0.0.

2. Input Parameters

FieldRequiredTypeDescription
EnvIdNoStringEnvironment 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>

version tip

This API has been supported since v5.0.0.

2. Input Parameters

FieldRequiredTypeDescription
EnvIdYesStringEnvironment ID
WxAppIdNoStringWeChat AppId
WithHistoryCircleNoBooleanWhether to return the previous and the one before the previous billing cycle, default false

3. Return Results

FieldTypeDescription
StartTimeStringcurrent billing cycle start time
EndTimeStringcurrent billing cycle end time
HistoryTimeArrayHistorical cycle list (including start/end times)
RequestIdStringUnique 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>

version tip

This API has been supported since v5.0.0.

2. Input Parameters

FieldRequiredTypeDescription
EnvIdYesStringEnvironment ID
ModulesYesString[]Module list, optional: EKS / Database / SCF / COS / AI / HOSTING / Auth / Other
StartDateYesStringStart date, format: YYYY-MM-DD
EndDateYesStringEnd date, format: YYYY-MM-DD
NeedUsageDetailsYesBooleanwhether 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()