# 发送 Viber 消息

### 域名
* https://chat-api.incsapp.com

### 请求路由
* /external/messages/viber

### 请求方式
* **POST**

### 请求头
* Content-Type: application/json
* certification-code: af92196e-0d07-3c1d-a631-a71c...

### 请求参数
#### 请求参数列表

|参数名|类型| 必填| 描述|
|-|-|-|-|
|to|string|是|收信人手机号，必须是国家码+手机号的纯数字格式，如 "8526841511234"
|type|string|是|消息类型，支持 otp 和普通消息：text, image, video, document 

* 每种消息需要的参数见请求示例

#### 请求示例

##### OTP 消息请求示例
```json
{
    "to": "85268411234",
    "type": "otp",
    "otp": {
        "code": "123456", // 验证码
        "language": "en", // 语言
        "code_expiration_minutes": 3 // 验证码失效时间
    }
}
```

##### text 消息示例
* 最大长度 1000 个字符
```json
{
    "to": "85268411234",
    "type": "text",
    "text": "Hello"
}
```
##### image 消息示例
* 支持类型：png, jpeg, jpg, gif
* 最大 200 MB
```json
{
    "to": "85268411234",
    "type": "image",
    "image": {
        "link": "https://incs-saas.oss-ap-southeast-1.aliyuncs.com/chat/images/header-98403274893.png"
    }
}
```
##### video 消息示例
* 支持类型：mp4
* 最大 200 MB
* 最长 10 分钟
* 视频链接响应头必须包含 'Content-Length' 参数
```json
{
    "to": "85268411234",
    "type": "video",
    "video": {
        "link": "https://incs-saas.oss-ap-southeast-1.aliyuncs.com/chat/videos/687710788353f.mp4"
    }
}
```

##### document 消息示例
* 支持类型：doc(x), xls(x), csv, pdf
* 最大 200 MB
```json
{
    "to": "85268411234",
    "type": "document",
    "document": {
        "link": "https://incs-saas.oss-ap-southeast-1.aliyuncs.com/chat/files/template.xls"
    }
}
```

### 响应
#### 成功响应示例
```json
{
    "status": "success",
    "code": 200,
    "message": "",
    "data": {
        "msg_id": "02cda2a2-2cb2-3c47-861c-ab91f5c9872e"
    },
    "error": {}
}
```
#### 失败响应示例
```json
{
    "status": "error",
    "code": 10003,
    "message": "Message failed \u2013 detailed reason unknown",
    "data": {},
    "error": {}
}
```