[comment]: # ({b243934a-8961fc33})
# 创建

[comment]: # ({/b243934a-8961fc33})

[comment]: # ({6f72de0e-4ec049c4})
### 描述

`object script.create(object/array scripts)`

此方法允许创建一个新的脚本

[comment]: # ({/6f72de0e-4ec049c4})

[comment]: # ({769f0250-bcb9a453})
### 参数

`(object/array)` Scripts to create.

The method accepts scripts with the [standard script
properties](/manual/api/reference/script/object#script).

[comment]: # ({/769f0250-bcb9a453})

[comment]: # ({61cd4fd4-15216b8d})
### 返回值

`(object)`返回一个对象，该对象包含在`scriptids`属性下创建的脚本的id。返回的id的顺序与通过的脚本的顺序相匹配。

[comment]: # ({/61cd4fd4-15216b8d})

[comment]: # ({c38fd778-b41637d2})
### 示例如下

[comment]: # ({/c38fd778-b41637d2})

[comment]: # ({27f347a6-d394757a})
#### 创建一个脚本

创建一个重启一个server的脚本，这个脚本需要对该主机有写的权限，并且在脚本运行在界面之前会提示一个确认信息。

Request:

``` {.java}
{
    "jsonrpc": "2.0",
    "method": "script.create",
    "params": {
        "name": "Reboot server",
        "command": "reboot server 1",
        "host_access": 3,
        "confirmation": "Are you sure you would like to reboot the server?"
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

Response:

``` {.java}
{
    "jsonrpc": "2.0",
    "result": {
        "scriptids": [
            "3"
        ]
    },
    "id": 1
}
```

[comment]: # ({/27f347a6-d394757a})

[comment]: # ({4b9f26d2-8c09f129})
### 源

CScript::create() in
*frontends/php/include/classes/api/services/CScript.php*.

[comment]: # ({/4b9f26d2-8c09f129})
