# 创建事件单 - CreateCocIncident
#### 功能介绍
创建事件单。
#### 调试
您可以在[API Explorer](https://console.huaweicloud.com/apiexplorer/#/openapi/COC/doc?api=CreateCocIncident)中调试该接口，支持自动认证鉴权。API Explorer可以自动生成SDK代码示例，并提供SDK代码示例调试功能。
#### 授权信息
账号具备所有API的调用权限，如果使用账号下的IAM用户调用当前API，该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权，具体权限要求请参见[权限和授权项](https://support.huaweicloud.com/api-coc/coc_api_06.html)。
- 如果使用身份策略授权，需具备如下身份策略权限。
  
  | 授权项               | 访问级别  | 资源类型（\*为必须） | 条件键 | 别名 | 依赖的授权项 |
  |:---|:---|:---|:---|:---|:---|
  | coc:ticket:create | Write | -           | -   | -  | -      |
     
  
 
#### URI
POST /v1/external/incident/create
#### 请求参数
表1请求Body参数 
| 参数                    | 是否必选 | 参数类型             | 描述                                                                                                                                                                         |
|:---|:---|:---|:---|
| region                | 否    | Array of strings | 区域Code，如果自动拉起WarRoom则为必填，现在只支持1个。                                                                                                                                          |
| enterprise_project    | 否    | Array of strings | 企业项目ID，现在只支持1个。                                                                                                                                                            |
| start_time            | 否    | Long             | 故障发生时间戳。                                                                                                                                                                   |
| current_cloud_service | 否    | Array of strings | 归属应用ID，现在只支持1个。                                                                                                                                                            |
| incident_level        | 是    | String           | 事件级别 参考：枚举 [事件级别](https://support.huaweicloud.com/api-coc/coc_api_04_03_001_006.html) incident_level     |
| is_service_interrupt  | 是    | String           | 业务是否中断，取值：true/false。                                                                                                                                                      |
| incident_type         | 是    | String           | 事件类别 参考：枚举 [事件类别](https://support.huaweicloud.com/api-coc/coc_api_04_03_001_006.html) incident_type      |
| incident_ownership    | 否    | String           | 事件归属 参考：枚举 [事件归属](https://support.huaweicloud.com/api-coc/coc_api_04_03_001_006.html) incident_ownership |
| incident_title        | 是    | String           | 事件标题，最大长度：200。                                                                                                                                                             |
| incident_description  | 否    | String           | 事件描述，最大长度：600。                                                                                                                                                             |
| incident_source       | 是    | String           | 单据来源 参考：枚举 [事件来源](https://support.huaweicloud.com/api-coc/coc_api_04_03_001_006.html) incident_source    |
| incident_assignee     | 否    | Array of strings | 责任人，排班场景和排班角色不能同时为空，现在只支持1个。                                                                                                                                               |
| assignee_scene        | 否    | String           | 排班场景，责任人和排班角色不能同时为空。                                                                                                                                                       |
| assignee_role         | 否    | String           | 排班角色，排班场景和责任人不能同时为空。                                                                                                                                                       |
| creator               | 是    | String           | 创单人。                                                                                                                                                                       |
   
#### 响应参数
**状态码：200**
表2响应Body参数 
| 参数            | 参数类型                                                                                                                                      | 描述                                                                                                                                                                                                                                                                                                                                                                                                                         |
|:---|:---|:---|
| provider_code | String                                                                                                                                    | **参数解释：** 服务标识。 **取值范围：** 不涉及 **默认取值：** 049                                      |
| error_code    | String                                                                                                                                    | **参数解释：** 请求响应代码。 **取值范围：** GOM.00000000\~GOM.00009999999 **默认取值：** GOM.00000000 |
| error_msg     | String                                                                                                                                    | **参数解释：** 请求响应描述。 **取值范围：** 不涉及                                                                                                                                                                                      |
| data          | [CreateExternalIncidentResponseData] object | 创建的工单Id。                                                                                                                                                                                                                                                                                                                                                                                                                   |
   
 表3CreateExternalIncidentResponseData 
| 参数           | 参数类型   | 描述    |
|:---|:---|:---|
| incident_num | String | 事件单号。 |
   
**状态码：400**
表4响应Body参数 
| 参数            | 参数类型   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                         |
|:---|:---|:---|
| provider_code | String | **参数解释：** 服务标识。 **取值范围：** 不涉及 **默认取值：** 049                                      |
| error_code    | String | **参数解释：** 请求响应代码。 **取值范围：** GOM.00000000\~GOM.00009999999 **默认取值：** GOM.00000000 |
| error_msg     | String | **参数解释：** 请求响应描述。 **取值范围：** 不涉及                                                                                                                                                                                      |
   
#### 请求示例
创建事件单。
```
POST https://{Endpoint}/v1/external/incident/create
{
  "incident_type" : "inc_type_p_security_issues",
  "creator" : "9605B67C741D4553887A3462771107D3",
  "current_cloud_service" : [ "app001" ],
  "assignee_scene" : "",
  "is_service_interrupt" : true,
  "enterprise_project" : [ "0" ],
  "incident_description" : "事件描述",
  "incident_assignee" : [ "9605B67C741D4553887A3462771107D3" ],
  "incident_level" : "level_50",
  "assignee_role" : "",
  "incident_title" : "事件标题",
  "incident_source" : "incident_source_manual",
  "region" : [ "OCB_Cloud" ]
}
```
#### 响应示例
**状态码：200**
请求成功。
更多状态码请参考[状态码](https://support.huaweicloud.com/api-coc/coc_api_05_03.html)。
```
{
  "error_code" : "GOM.00000000",
  "error_msg" : null,
  "provider_code" : 4,
  "data" : {
    "incident_num" : "IM202504221434480187641906"
  }
}
```
**状态码：400**
服务器未能处理请求。
更多状态码请参考[状态码](https://support.huaweicloud.com/api-coc/coc_api_05_03.html)。
```
{
  "error_code" : "GOM.00007256",
  "error_msg" : "参数错误",
  "provider_code" : 4,
  "data" : null
}
```
#### 状态码
| 状态码 | 描述                                                                                                                                                      |
|:---|:---|
| 200 | 请求成功。 更多状态码请参考[状态码](https://support.huaweicloud.com/api-coc/coc_api_05_03.html)。      |
| 400 | 服务器未能处理请求。 更多状态码请参考[状态码](https://support.huaweicloud.com/api-coc/coc_api_05_03.html)。 |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-coc/ErrorCode.html)。
