Skip to main content

General Cloud API Calls

v3.0.0+

The tcb api command has been available since v3.0.0.

tcb api is a general Tencent Cloud API entry point. It calls any Tencent Cloud API directly, and the CLI handles authentication and request encapsulation.

Basic Usage​

tcb api <service> <action> [options]

Parameters:

ParameterDescriptionRequired
<service>Tencent Cloud service name, such as tcb, scf, clsYes
<action>API Action name, such as DescribeEnvsYes
--body <json>Request body, a JSON stringNo
--api-version <version>API version, such as 2019-09-24. Uses the service default version when omittedNo
-e, --env-id <envId>CloudBase environment IDNo
--jsonOutput the result in JSON formatNo

Examples​

# List all CloudBase environments
tcb api tcb DescribeEnvs

# Query a specific environment
tcb api tcb DescribeEnvs --body '{"EnvId":"my-env-id"}'

# List cloud functions (requires an environment)
tcb api scf ListFunctions -e my-env-id

# Specify the API version
tcb api tcb DescribeEnvs --api-version 2019-09-24

# Output in JSON format for scripts
tcb api tcb DescribeEnvs --json

--body must be valid JSON. The command fails immediately on a malformed value and sends no request.

Find service and action​

Look them up in the Tencent Cloud API documentation:

  • service is the API domain prefix of the product, such as tcb (CloudBase), scf (Cloud Functions), cls (Cloud Log Service).
  • action is the API name, such as DescribeEnvs, ListFunctions.

tcb api authenticates with the credentials of the current account, so no key configuration is needed. Run tcb login first.

Command Reference​

CommandDescription
tcb api <service> <action>Call a Tencent Cloud API
tcb api <service> <action> --body <json>Call with a request body
tcb api <service> <action> --jsonOutput in JSON format

Notes​

  • A small set of high-risk actions is on a built-in blocklist, for example CynosDB password reset and account deletion actions. The list cannot be disabled
  • The response follows the original Tencent Cloud API schema, check the interface documentation for field meanings