tencent cloud

自动化助手

产品动态
产品简介
产品概述
产品优势
应用场景
访问管理
使用限制
购买指南
快速入门
操作指南
安装自动化助手客户端
免登录执行命令
批量执行命令
查看命令执行状态
故障处理
Windows实例问题诊断及处理
API 文档
History
Introduction
API Category
Making API Requests
Remote Command APIs
Scheduled Execution APIs
Managed Instance APIs
Scenario APIs
Statistics APIs
Data Types
Error Codes
常见问题
联系我们
词汇表
TAT 政策
TAT 隐私协议
TAT 数据处理和安全协议

CreateCommand

PDF
聚焦模式
字号
最后更新时间: 2026-03-05 16:27:17

1. API Description

Domain name for API request: tat.intl.tencentcloudapi.com.

This API is used to create a command.

A maximum of 20 requests can be initiated per second for this API.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common Params. The value used for this API: CreateCommand.
Version Yes String Common Params. The value used for this API: 2020-10-28.
Region Yes String Common Params. For more information, please see the list of regions supported by the product.
CommandName Yes String Command name. The name can be up to 60 bytes, and contain [a-z], [A-Z], [0-9] and [_-.].
Content Yes String Base64-encoded command. The maximum length is 64 KB.
Description No String Command description. The maximum length is 120 characters.
CommandType No String Command type. currently supports SHELL, POWERSHELL, BAT. default: SHELL.
WorkingDirectory No String Command execution path. The default value is /root for SHELL commands and C:\Program Files\qcloud\tat_agent\workdir for POWERSHELL commands.
Timeout No Integer Command timeout period. Default value: 60 seconds. Value range: [1, 86400].
EnableParameter No Boolean Whether to enable the custom parameter feature.
This cannot be modified once created.
Default value: false.
DefaultParameters No String Enable the custom parameter feature. default value of the custom parameter. field type is json encoded string. for example: {"varA": "222"}.
The key is the custom parameter name, and the value is the default. both kv are string-type.
If no parameter value is provided when invoking the command, the default value here will be used to replace it.
Parameters must not be specified simultaneously DefaultParameters and DefaultParameterConfs.
Allow settings only when the EnableParameter parameter is true.
Custom parameters can be up to 20.
The custom parameter name must meet the following standard: the number of characters has a cap of 64, and the optional range is [a-zA-Z0-9-_].
DefaultParameterConfs.N No Array of DefaultParameterConf Custom parameter array.
If no parameter value is provided when invoking the command, the default value here will be used to replace it.
Parameters must not be specified simultaneously DefaultParameters and DefaultParameterConfs.
Allow settings only when the EnableParameter parameter is true.
Custom parameters can be up to 20.
Tags.N No Array of Tag Tags bound to the command. At most 10 tags are allowed.
Username No String The username used to execute the command on the CVM or Lighthouse instance.
The principle of least privilege is the best practice for permission management. We recommend you execute TAT commands as a general user. By default, the root user is used to execute commands on Linux and the System user is used on Windows.
OutputCOSBucketUrl No String The COS bucket URL for uploading logs. The URL must start with https, such as https://BucketName-123454321.cos.ap-beijing.myqcloud.com.
OutputCOSKeyPrefix No String The COS bucket directory where the logs are saved. Check below for the rules of the directory name.
1. It must be a combination of number, letters, and visible characters. Up to 60 characters are allowed.
2. Use a slash (/) to create a subdirectory.
3. Consecutive dots (.) and slashes (/) are not allowed. It can not start with a slash (/).

3. Output Parameters

Parameter Name Type Description
CommandId String Command ID.
RequestId String The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.

4. Example

Example1 Create Command

Input Example

POST / HTTP/1.1
Host: tat.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateCommand
<Common request parameters>

{
    "CommandName": "hello-command",
    "Description": "hello world",
    "Content": "bHM=",
    "CommandType": "SHELL",
    "WorkingDirectory": "/tmp",
    "Timeout": 60
}

Output Example

{
    "Response": {
        "RequestId": "9bea970a-0bab-495f-b0dd-de5eedfdf611",
        "CommandId": "cmd-7efujjs6"
    }
}

5. Developer Resources

SDK

TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

Error Code Description
InternalError Internal error.
InvalidParameter Invalid parameter.
InvalidParameterValue Invalid parameter value.
InvalidParameterValue.CommandContentInvalid Invalid command content.
InvalidParameterValue.CommandNameDuplicated Duplicate command name.
InvalidParameterValue.InvalidCommandName Invalid command name.
InvalidParameterValue.InvalidContent Invalid command.
InvalidParameterValue.InvalidOutputCOSBucketUrl Invalid OutputCOSBucketUrl.
InvalidParameterValue.InvalidOutputCOSKeyPrefix Invalid OutputCOSKeyPrefix.
InvalidParameterValue.InvalidUsername Invalid username.
InvalidParameterValue.InvalidWorkingDirectory Invalid command execution path.
InvalidParameterValue.ParameterDisabled The custom parameter feature is not enabled.
InvalidParameterValue.ParameterInvalidJsonFormat The parameter is not a valid JSON string.
InvalidParameterValue.ParameterKeyContainsInvalidChar The parameter key contains invalid characters.
InvalidParameterValue.ParameterKeyDuplicated Duplicate parameter keys.
InvalidParameterValue.ParameterKeyLenExceeded The parameter key is too long.
InvalidParameterValue.ParameterNumberExceeded Too many parameters.
InvalidParameterValue.ParameterValueNotString The parameter value is not a string.
InvalidParameterValue.Range The parameter value is not in the valid range.
InvalidParameterValue.SupportParametersOnlyIfEnableParameter The custom parameter feature is not enabled.
InvalidParameterValue.TooLong Length limit exceeded.
MissingParameter Missing parameter.
ResourceNotFound.CosBucketNotFoundCode CosBucket does not exist.
ResourceUnavailable.UserHasNoQuotaCode User quota run out.
UnauthorizedOperation.CamAuthFailed CAM authentication failed.
UnauthorizedOperation.InvalidToken Invalid token.
UnauthorizedOperation.MFAExpired The Multi-factor authentication (MFA) code expired.
UnauthorizedOperation.MFANotFound Multi-factor authentication (MFA) does not exist.
UnsupportedOperation The operation is not supported.

帮助和支持

本页内容是否解决了您的问题?

填写满意度调查问卷,共创更好文档体验。

文档反馈