> For the complete documentation index, see [llms.txt](https://docs.console.zenlayer.com/api-reference/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.console.zenlayer.com/api-reference/security/zos/command/createcommand.md).

# CreateCommand

## 1. API Description

This API (CreateCommand) is used to create a command.

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name  | Required | Type                                                                          | Description                                                                                                                     |
| --------------- | -------- | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| name            | Yes      | String                                                                        | <p>Command name.</p><p>The length should be no more than 64 characters.</p>                                                     |
| content         | Yes      | String                                                                        | <p>Script content. The value must be Base64-encoded.</p><p>The decoded length should be no more than 16K(16384) characters.</p> |
| type            | Yes      | [CommandType](/api-reference/security/zos/datastructure.md#commandtype)       | Script language type.                                                                                                           |
| description     | No       | String                                                                        | <p>Command note.</p><p>The length should be no more than 255 characters.</p>                                                    |
| resourceGroupId | No       | String                                                                        | Resource group ID.                                                                                                              |
| tags            | No       | [TagAssociation](/api-reference/security/zos/datastructure.md#tagassociation) | Bound tags when creating resources.                                                                                             |

## 3. Output Parameters

| Parameter Name | Type   | Description                                                                                                           |
| -------------- | ------ | --------------------------------------------------------------------------------------------------------------------- |
| requestId      | String | <p>The unique request ID, which is returned for each request.</p><p>RequestId is required for locating a problem.</p> |
| commandId      | String | Created command ID.                                                                                                   |

## 4. Code Example

{% tabs %}
{% tab title="Example" %}
**1. Create a command in `Shell` language. `content` must be passed in as the Base64-encoded value of the script content. The `content` in this example is the Base64 encoding of `echo 1`.**

```json
POST /api/v2/zos HTTP/1.1
Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: CreateCommand
<Common Request Params>

Request：
{
  "name": "Test Command",
  "content": "ZWNobyAx",
  "type": "SHELL",
  "tags": {
    "tags": [
      {
        "key": "test",
        "value": "test"
      }
    ]
  }
}

Response：
{
  "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
  "response": {
    "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
    "commandId": "<commandId>"
  }
}
```

**2. Create a multi-line Shell command. The `content` in this example is the Base64 encoding of the script `#!/bin/bash\necho "hello zenlayer" > /tmp/init.log`.**

```json
POST /api/v2/zos HTTP/1.1
Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: CreateCommand
<Common Request Params>

Request：
{
  "name": "Init Script",
  "content": "IyEvYmluL2Jhc2gKZWNobyAiaGVsbG8gemVubGF5ZXIiID4gL3RtcC9pbml0LmxvZwo=",
  "type": "SHELL"
}

Response：
{
  "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
  "response": {
    "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
    "commandId": "<commandId>"
  }
}
```

{% endtab %}
{% endtabs %}

## 5. Developer Resources

Zenlayer Cloud API 2.0 integrates [SDKs](/api-reference/api-introduction/toolkit/api-sdk.md)，to make it easier for you to call APIs. More programming languages will be supported.

## 6. Error Codes

The following only lists the error codes related to the API business logic. For other error codes, see [Common Error Codes](/api-reference/api-introduction/instruction/commonerrorcode.md).

| HTTP Status Code | Error Code                                   | Description                                   |
| ---------------- | -------------------------------------------- | --------------------------------------------- |
| 400              | INVALID\_PARAMETER\_COMMAND\_CONTENT\_EXCEED | The command content exceeds the length limit. |
