# 批量创建转播子频道接口

### 接口URL

```
http://api.polyv.net/live/v3/channel/transmit/batch-create
```

### 接口说明

```
1、批量创建转播子频道
2、一次性最大支持创建100个子频道，转播子频道上限500个
3、接口支持https
```

### 支持格式

```
JSON
```

### 请求方式

```
POST
```

### 请求数限制

```
TRUE
```

### 请求参数

| 参数名       | 必选 | 类型     | 说明                                                                                                                                                                                                        |
| --------- | -- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| appId     | 是  | string | 从API设置中获取，在直播系统登记的appId                                                                                                                                                                                   |
| timestamp | 是  | long   | 当前13位毫秒级时间戳，3分钟内有效                                                                                                                                                                                        |
| sign      | 是  | String | 签名，为32位大写的MD5值,`生成签名的appSecret密钥作为通信数据安全的关键信息，严禁保存在客户端直接使用，所有API都必须通过客户自己服务器中转调用POLYV服务器获取响应数据`【详见[签名生成规则](https://git.polyv.net/help-center/document-center/-/blob/master/live/api/buildSign/README.md)】 |
| channelId | 是  | int    | 发起转播频道号                                                                                                                                                                                                   |

### 请求体body参数

> 请求body中的参数为字符串数组，字符串名称为将要创建接收转播的频道名称，最多一次创建支持100个频道 上面的请求参数需要放在query或者表单中，请求体参数需要放在请求体中，不支持放在表单或者query参数

```json
[
	"接收转播频道01",
	"接收转播频道02",
	"接收转播频道03",
	"接收转播频道04"
]
```

### 响应成功JSON示例：

```json
{
    "code": 200,
    "status": "success",
    "message": "",
    "data": [
        {
            "channelId": 2041139,
            "name": "接收转播频道01",
            "channelPasswd": "xxxx",
            "authType": "none",
            "streamType": "client",
            "debugEnabled": "N",
            "playBackEnabled": "Y",
            "stream": "ee7fe7fbda1607414643915af33",
            "status": "客户端推流/直播结束",
            "categoryId": 177474,
            "categoryName": "默认分类",
            "isSmallClass": "N",
            "scene": "ppt",
            "createdTime": 1607414644000,
            "appId": null,
            "coverImage": null,
            "type": "receive",
            "startTime": 1598630400000,
            "publisher": "666666",
            "channelLogo": null,
            "splashImg": null,
            "splashEnabled": "Y",
            "pureRtcEnabled": "N",
            "watchTimes": null,
            "roomIds": null
        },
        {
            "channelId": 2041140,
            "name": "接收转播频道02",
            "channelPasswd": "xxxx",
            "authType": "none",
            "streamType": "client",
            "debugEnabled": "N",
            "playBackEnabled": "Y",
            "stream": "ee7fe7fbda160741464391432a6",
            "status": "客户端推流/直播结束",
            "categoryId": 177474,
            "categoryName": "默认分类",
            "isSmallClass": "N",
            "scene": "ppt",
            "createdTime": 1607414644000,
            "appId": null,
            "coverImage": null,
            "type": "receive",
            "startTime": 1598630400000,
            "publisher": "666666",
            "channelLogo": null,
            "splashImg": null,
            "splashEnabled": "Y",
            "pureRtcEnabled": "N",
            "watchTimes": null,
            "roomIds": null
        }
    ]
}
```

### 响应失败JSON示例：

未输入appId

```json
{
    "code": 400,
    "status": "error",
    "message": "appId is required.",
    "data": ""
}
```

appId不正确

```json
{
    "code": 400,
    "status": "error",
    "message": "application not found.",
    "data": ""
}
```

时间戳错误

```json
{
    "code": 400,
    "status": "error",
    "message": "invalid timestamp.",
    "data": ""
}
```

签名错误

```json
{
    "code": 403,
    "status": "error",
    "message": "invalid signature.",
    "data": ""
}
```

非法频道

```json
{
    "code": 403,
    "status": "error",
    "message": "illegal channel id: 1779742",
    "data": ""
}
```

请求体没有参数

```json
{
    "code": 400,
    "status": "error",
    "message": "request body is not empty or lost params",
    "data": ""
}
```

请求体数组超过100

```json
{
    "code": 400,
    "status": "error",
    "message": "param length is incorrect:body array size",
    "data": ""
}
```

转播子频道超过500

```json
{
    "code": 400,
    "status": "error",
    "message": "transmit channel number limit: 500",
    "data": ""
}
```

未开通转播

```json
{
    "code": 400,
    "status": "error",
    "message": "access forbidden",
    "data": ""
}
```

频道数超过上限

```json
{
    "code": 400,
    "status": "error",
    "message": "channel count reached the limit",
    "data": ""
}
```

### 字段说明

| 参数名                      | 类型     | 说明                                               |
| ------------------------ | ------ | ------------------------------------------------ |
| code                     | int    | 响应代码，成功为200，失败为400，签名错误为401，异常错误500              |
| status                   | string | 成功为success，失败为error                              |
| message                  | string | 错误时为错误提示消息                                       |
| data                     | array  | 响应结果集                                            |
| data\[0].channelId       | int    | 频道号                                              |
| data\[0].name            | string | 频道名称                                             |
| data\[0].channelPasswd   | string | 频道密码                                             |
| data\[0].authType        | string | 频道校验类型                                           |
| data\[0].playBackEnabled | string | 频道是否开启回放，Y:开启，N:关闭                               |
| data\[0].streamType      | string | 频道推流方式                                           |
| data\[0].debugEnabled    | string | 频道是否开启调试，Y:开启，N:关闭                               |
| data\[0].stream          | string | 频道流名                                             |
| data\[0].status          | string | 频道状态                                             |
| data\[0].categoryId      | int    | 频道所在目录Id                                         |
| data\[0].categoryName    | string | 频道所在目录名称                                         |
| data\[0].isSmallClass    | string | 频道是否为小班课，Y:开启，N:关闭                               |
| data\[0].scene           | string | 频道场景，ppt:三分屏，alone:活动直播，topclass:大班课,seminar:研讨会 |
| data\[0].createdTime     | long   | 频道创建时间                                           |
| data\[0].appId           | string | 暂时不返回:null                                       |
| data\[0].coverImage      | string | 频道封面图片                                           |
| data\[0].type            | string | 频道类型，transmit：发起转播，normal：普通的频道，receive：接收转播     |
| data\[0].startTime       | long   | 频道开始时间                                           |
| data\[0].publisher       | string | 频道主持人                                            |
| data\[0].channelLogo     | string | 暂时不返回:null                                       |
| data\[0].splashImg       | string | 频道引导图图片地址                                        |
| data\[0].splashEnabled   | string | 频道引导图开关，Y:开启，N:关闭                                |
| data\[0].pureRtcEnabled  | string | 频道无延迟直播开关，Y:开启，N:关闭                              |
| data\[0].watchTimes      | string | 暂时不返回:null                                       |
| data\[0].roomIds         | string | 频道分房间信息，没有为null                                  |

### Java请求示例

```java
public static void main(String[] args) {
        String url = "http://api.polyv.net/live/v3/channel/transmit/batch-create";
        // 用户对应的appId和加密串
        String appId = "xxxxxxxxx";
        String appSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxx";
        Map<String, String> params = new HashMap<>();
		params.put("channelId", "0000000");
        PolyvTool.setLiveSign(params, appId, appSecret);
        // 调用Polyv的httpClient工具类发送请求
        String body = "[\"接收转播频道01\",\"接收转播频道02\"]";
        // 调用Polyv的httpClient工具类发送请求
        String content = HttpClientUtil.getInstance()
                .sendHttpPostJson(url + "?" + PolyvTool.mapJoinNotEncode(params), body, null);
        System.out.println(content);
    }
```
