# 发送 RCS 消息

### 域名
* https://chat-api.incsapp.com

### 请求路由
* /external/messages/rcs

### 请求方式
* **POST**

### 请求头
* Content-Type: application/json
* certification-code: af92196e-0d07-3c1d-a631-a71c...

### 请求限流
* 单 Sender 最大 **5 rps** (每秒5请求)

### 请求参数
#### 请求参数列表

|参数名|类型| 必填| 描述|
|-|-|-|-|
|to|string|是|收信人手机号，必须是国家码+手机号的纯数字格式，如 "8526841511234"
|type|string|是|消息类型，支持模板消息：template，和普通消息（需要用户回复的24小时内可以发送）：text, image, video, document 
|ttl|string|否|消息失效时间（单位秒，如"60s"，默认24小时-"86400s"，最短设置为"10s"，最长设置为10天-"864000s"）：超过这个时间消息未投递成功（如用户设备不在线等情况），则平台会停止投递消息，并返回"failed"状态回调，失败原因为："TTL_EXPIRATION_REVOKED"

* 每种消息需要的参数见请求示例

#### 请求示例

##### **不包含参数**的模板消息请求示例
```json
{
    "to": "85268411234",
    "type": "template",
    "template": {
        "name": "test_button_reply_1"
    },
    "ttl": "300s"
}
```

##### **包含参数**的模板消息请求示例

* 填写所有模板部位的参数名和参数值
```json
{
    "to": "85268411234",
    "type": "template",
    "template": {
        "name": "test_button_reply_1",
        "parameters": {
            "username": "jack",
            "service_name": "promotion"
        }
    }
}
```

##### text 消息示例
```json
{
    "to": "85268411234",
    "type": "text",
    "text": "Hello"
}
```
##### image 消息示例
```json
{
    "to": "85268411234",
    "type": "image",
    "image": {
        "link": "https://static.incsapp.com/chat/images/header-98403274893.png"
    }
}
```
##### video 消息示例
```json
{
    "to": "85268411234",
    "type": "video",
    "video": {
        "link": "https://static.incsapp.com/chat/videos/abc.mp4"
    }
}
```

##### document 消息示例
* 支持类型：.pdf
```json
{
    "to": "85268411234",
    "type": "document",
    "document": {
        "link": "https://static.incsapp.com/chat/files/template.pdf"
    }
}
```

### 响应
#### 成功响应示例
```json
{
    "status": "success",
    "code": 200,
    "message": "",
    "data": {
        "msg_id": "019b8d8e-c4e7-73fe-b333-470c51e61f9f" // Msg ID
    },
    "error": {}
}
```
#### 失败响应示例
```json
{
    "status": "error",
    "code": 10004,
    "message": "Template with the code [api_4_standalone_image] and bot [Wk3rZWBx435KKATY] received with insufficient custom params", // 模板包含参数与消息传递参数不一致
    "data": {},
    "error": {}
}
```