Polyv Help Center

Help Center

Save Full User Level List

Updated: 2026-09-24 12:37:01

API Description

1、全量保存账号的用户等级列表:请求中的等级列表会整体覆盖原有等级,未包含在请求中的等级将被删除,数组顺序即等级顺序
2、(timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、用户等级为账号级配置,账号下所有频道共用同一套等级;直播模板和频道只控制是否展示等级
4、管理后台【用户】→【用户等级】和开放API读写同一份配置,任一入口保存成功后,另一入口查询到相同结果
5、接口支持https协议

API URL

http://api.polyv.net/live/v4/user/viewer-level/save

Online API Call

Request Method

POST

API Constraints

  1. The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls have frequency limits. See details

  2. The target account is determined by appId in the signature. User ID or channel number is not accepted.

  3. Each account must retain at least 1 level and can save up to 100 levels. Level identifiers levelId in the same request cannot be duplicated.

  4. For accounts with Polyv User System enabled, each level must have a points threshold requiredPoints, which must strictly increase in array order (the threshold of a later level must be greater than the previous one).

  5. For accounts without the user system enabled, only display configurations such as level name, icon, background color, and description are saved. The requiredPoints in the request does not take effect: existing levels (matched by levelId) retain their original points threshold, and new levels have a threshold of 0.

  6. It is recommended to first call Query User Level List to get the current configuration, modify it, and then submit the entire list to avoid accidentally deleting levels.

  7. For details on user level functionality, see User Levels.

Request Parameter Description

Parameter Required Type Description
appId true String Account appId See Get Secret
timestamp true Long Current 13-digit millisecond timestamp, valid for 3 minutes
sign true String Signature, a 32-character uppercase MD5 value. The appSecret key used to generate the signature is critical for communication data security. It must not be stored or used directly on the client. All APIs must be called through your own server to relay requests to the POLYV server for response data. See Signature Generation Rules

Request Body Parameter Description

Parameter Required Type Description
levels true Array Level list, array order determines level order. At least 1, up to 100. See levels parameter description

levels Parameter Description

Parameter Required Type Description
levelId true String Level identifier, unique within the account. Must start with a letter or digit. Supports only letters, digits, underscores, and hyphens. Maximum 64 characters.
levelName true String Level name displayed to viewers. Maximum 10 characters.
levelIcon false String Level icon URL. Maximum 512 characters. If not set, the level name and background color are displayed.
levelBgColor false String Level background color. Format: #RGB or #RRGGBB, e.g., #FF6456.
description false String Level description, used only for backend identification and management, not displayed to viewers. Maximum 100 characters.
requiredPoints false Long Points threshold, the minimum cumulative points a viewer needs to obtain this level. Value range: 1–999999.
Required when the user system is enabled, and must strictly increase in array order.
When the user system is not enabled, the passed value does not take effect.

Example

http://api.polyv.net/live/v4/user/viewer-level/save?appId=frlr1zazn3&sign=49428741C1D7BEE8BE1EE545F066ECC7&timestamp=1677167340447

Request body JSON parameters:

{
    "levels": [
        {
            "levelId": "bronze",
            "levelName": "青铜",
            "levelIcon": "https://s1.videocc.net/default-img/level-icon/v1/bronze.png",
            "levelBgColor": "#FF6456",
            "description": "新用户默认等级",
            "requiredPoints": 1
        },
        {
            "levelId": "silver",
            "levelName": "白银",
            "levelBgColor": "#5E81FF",
            "requiredPoints": 1000
        }
    ]
}

Response Parameter Description

Parameter Type Description
code Integer Status code, same as HTTP status code, used to determine the basic response status.
status String Response result, determined by the business. Returns "success" on success, "error" on failure.
success Boolean Whether the response was successful.
requestId String Request ID, a unique UUID generated for each request. Only for troubleshooting and debugging, not to be tied to business logic.
error Object Error information when status code is not 200. See Error parameter description
data Boolean Whether the save was successful. true indicates success.

Error Parameter Description

Parameter Type Description
code Integer Error code, used to identify the specific error reason. See Error Code Description
desc String Error description, corresponding to error.code.

Java Request Example

For quick integration of basic code, download the relevant dependency source code. Click to download source code. After downloading, add it to your own source project. The test cases include HttpUtil.java and LiveSignUtil.java in the downloaded file.

It is strongly recommended to use the Live Java SDK for API integration. The Live Java SDK provides unified encapsulation and optimization for API call logic, exception handling, data signing, and HTTP request thread pooling.

private static final Logger log = LoggerFactory.getLogger(getClass());
/**
* 全量保存用户等级列表
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@Test
public void testViewerLevelSave() throws IOException, NoSuchAlgorithmException {
    //公共参数,填写自己的实际参数
    String appId = super.appId;
    String appSecret = super.appSecret;
    String timestamp = String.valueOf(System.currentTimeMillis());

    //业务参数
    String url = "http://api.polyv.net/live/v4/user/viewer-level/save";
    List<Map<String, Object>> levels = new ArrayList<>();

    Map<String, Object> bronze = new HashMap<>();
    bronze.put("levelId", "bronze");
    bronze.put("levelName", "青铜");
    bronze.put("levelIcon", "https://s1.videocc.net/default-img/level-icon/v1/bronze.png");
    bronze.put("levelBgColor", "#FF6456");
    bronze.put("description", "新用户默认等级");
    bronze.put("requiredPoints", 1);
    levels.add(bronze);

    Map<String, Object> silver = new HashMap<>();
    silver.put("levelId", "silver");
    silver.put("levelName", "白银");
    silver.put("levelBgColor", "#5E81FF");
    silver.put("requiredPoints", 1000);
    levels.add(silver);

    //http 调用逻辑
    Map<String, String> requestMap = new HashMap<>();
    requestMap.put("appId", appId);
    requestMap.put("timestamp", timestamp);

    Map<String, Object> jsonMap = new HashMap<>();
    jsonMap.put("levels", levels);

    requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));

    url = HttpUtil.appendUrl(url, requestMap);
    String response = HttpUtil.postJsonBody(url, JSON.toJSONString(jsonMap), null);

    log.info("测试全量保存用户等级列表,返回值:{}", response);
    //do somethings

}

Response Example

For global error descriptions, see Global Error Description

Success Example

{
    "code": 200,
    "status": "success",
    "requestId": "414afeb28f1c4f0ca17e1c3c1e39d247.71.16771673423081591",
    "data": true,
    "success": true
}

Error Example

{
    "code": 400,
    "status": "error",
    "requestId": "d310b70bc329403f87f77f9203d50f89.128.16360831552223589",
    "error": {
        "code": 25105,
        "desc": "最低积分需大于上一等级的最低积分"
    },
    "success": false
}

Error Code Description

Error Code Error Description Explanation
10001 At least 1 member level must be retained levels not provided, or levels is an empty array.
10001 Maximum of 100 member levels supported levels exceeds 100.
10001 Level identifier cannot be empty levelId not provided.
10001 Level identifier only supports letters, digits, underscores, and hyphens, and must start with a letter or digit levelId format is incorrect or exceeds 64 characters.
10001 Level name cannot be empty levelName not provided.
10001 Level name cannot exceed 10 characters levelName exceeds 10 characters.
10001 Level icon URL is too long levelIcon exceeds 512 characters.
10001 Level color format is incorrect levelBgColor is not in #RGB or #RRGGBB format.
10001 Level description cannot exceed 100 characters description exceeds 100 characters.
10001 Minimum points cannot be less than 1 requiredPoints is less than 1.
10001 Minimum points cannot exceed 999999 requiredPoints exceeds 999999.
25102 Level identifier cannot be duplicated Duplicate levelId exists in levels.
25104 Minimum points must be a non-negative integer When the user system is enabled, a level is missing requiredPoints.
25105 Minimum points must be greater than the previous level's minimum points When the user system is enabled, requiredPoints does not strictly increase in array order.
联系客服,在线咨询
在线咨询