# 发送工单消息

该接口用于发送工单消息。

## 请求

基本 | &nbsp;
---|---
HTTP URL | https://open.feishu.cn/open-apis/helpdesk/v1/tickets/:ticket_id/messages
HTTP Method | POST
接口频率限制 | [1000 次/分钟、50 次/秒](https://open.feishu.cn/document/ukTMukTMukTM/uUzN04SN3QjL1cDN)
支持的应用类型 | Custom App
权限要求<br>**调用该 API 所需的权限。开启其中任意一项权限即可调用** | 更新服务台资源详情(helpdesk:all)

### 请求头

名称 | 类型 | 必填 | 描述
---|---|---|---
Authorization | string | 是 | `tenant_access_token`<br>**值格式**："Bearer `access_token`"<br>**示例值**："Bearer t-7f1bcd13fc57d46bac21793a18e560"<br>[了解更多：如何选择与获取 access token](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-choose-which-type-of-token-to-use)
Content-Type | string | 是 | **固定值**："application/json; charset=utf-8"

**注意事项**：服务台请求Header中还需添加“服务台token”参数：

Key: X-Lark-Helpdesk-Authorization

Value: base64(helpdesk_id:helpdesk_token)，通过base64加密将helpdesk_id和helpdesk_token用':'连接而成的字符串。

[了解更多：获取与使用服务台token](https://open.feishu.cn/document/ukTMukTMukTM/ugDOyYjL4gjM24CO4IjN)

### 路径参数

名称 | 类型 | 描述
---|---|---
ticket_id | string | 工单ID<br>**示例值**："6948728206392295444"

### 请求体

名称 | 类型 | 必填 | 描述
---|---|---|---
msg_type | string | 是 | 消息类型；text：纯文本；post：富文本<br>**示例值**："post"
content | string | 是 | - 纯文本，参考[发送文本消息](https://open.feishu.cn/document/ukTMukTMukTM/uUjNz4SN2MjL1YzM)中的content；<br>- 富文本，参考[发送富文本消息](https://open.feishu.cn/document/ukTMukTMukTM/uMDMxEjLzATMx4yMwETM)中的content<br>**示例值**："{<br>"msg_type": "post",<br>"content": {<br>"post": {<br>"zh_cn": {<br>"title": "this is title",<br>"content": [<br>[<br>{<br>"tag": "text",<br>"un_escape": true,<br>"text": "第一行&nbsp;:"<br>},<br>{<br>"tag": "a",<br>"text": "超链接",<br>"href": "http://www.feishu.cn"<br>}<br>],<br>[<br>{<br>"tag": "text",<br>"text": "第二行 :"<br>},<br>{<br>"tag": "text",<br>"text": "文本测试"<br>}<br>]<br>]<br>}<br>}<br>}<br>}"

### 请求体示例
```json
{
    "msg_type": "post",
    "content": {
        "post": {
            "zh_cn": {
                "title": "this is title",
                "content": [
                    [
                        {
                            "tag": "text",
                            "un_escape": true,
                            "text": "第一行&nbsp;:"
                        },
                        {
                            "tag": "a",
                            "text": "超链接",
                            "href": "http://www.feishu.cn"
                        }
                    ],
                    [
                        {
                            "tag": "text",
                            "text": "第二行 :"
                        },
                        {
                            "tag": "text",
                            "text": "文本测试"
                        }
                    ]
                ]
            }
        }
    }
}
```

## 响应

### 响应体

名称 | 类型 | 描述
---|---|---
code | int | 错误码，非 0 表示失败
msg | string | 错误描述
data | \- | \-
message_id | string | chat消息open ID

### 响应体示例
```json
{
    "code": 0,
    "msg": "success",
    "data": {
        "message_id": "om_8baa3656c7b41900d29bf9104bf5310b"
    }
}
```

### 错误码

HTTP状态码 | 错误码 | 描述 | 排查建议
---|---|---|---
400 | 154000 | Bad request, please check your request body | 请求不合法，请检查参数
401 | 154001 | Unauthorized, please check you have the correct access | 检查Authorization 和 X-Lark-Helpdesk-Authorization 是否正确，应用和服务台属于同一租户
401 | 154003 | Please check you have the correct access | 检查是否申请正确权限
401 | 154401 | Ticket already be closed | 工单已经被关闭
401 | 154403 | Send message with bad url | 发送的消息内容中存在不合法的url
500 | 155000 | Internal error | 内部错误，请联系我们

