Polyv Help Center

Help Center

Create Task Reward Activity

Updated: 2026-02-02 16:50:11

API Description

1、创建任务奖励活动
2、接口支持https协议

API URL

https://api.polyv.net/live/v4/channel/task-reward-activity/save

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

Request Parameter Description

Parameter Required Type Description
appId true String Account appId See details: Get Secret Key
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 the customer's own server to relay requests to the POLYV server for response data. See details: Signature Generation Rules

Request Body Parameter Description

Parameter Required Type Description
channelId true Integer Channel ID
activityName true String Activity name, maximum 64 characters
taskRule true Integer Task rule: 1: Unlock tasks, 2: Parallel tasks
startTime true Long Activity start time
endTime true Long Activity end time
tasks true Array Task rule list See details: tasks field description

tasks Parameter Description

Parameter Required Type Description
sort true Integer Sort order
reachCondition true Object Condition settings See details: reachCondition
rewardSetting true Object Reward settings

reachCondition Parameter Description

Parameter Required Type Description
type true String Condition type (sign: Check-in, online: Online duration, questionnaire: Quiz, custom: Custom)
amount true Integer Target value
templateId false Long Question ID, required when condition type is questionnaire
customEvent false String Custom task event, required when condition type is custom
customEventName false String Custom task name
customIcon false String Custom task icon
customUnit false String Custom task unit
customButtonText false String Custom task button text
customReachText false String Custom task completion text, e.g.: {customEventName} completed: {amount}{customUnit}

rewardSetting Parameter Description

Parameter Required Type Description
type true String cash: Cash, custom: Custom, nothing: No reward, externalPoint: External points
amount false Integer Reward value (when type is cash, the unit is cents; required when type is cash or externalPoint)
limit false Integer Reward limit
customReward false String Custom reward, optional

Example

https://api.polyv.net/live/v4/channel/task-reward-activity/save?appId=frlr1zazn3&sign=012332FBD8DBCFC068AFCB484A2ADECB&timestamp=1670550787318

Request body JSON parameters:

{
    "channelId": 4854808,
    "activityName": "测试活动",
    "activityMode": 1,
    "taskRule": 1,
    "startTime": 1722035312584,
    "endTime": 1722036312584,
    "tasks": [
        {
            "reachCondition": {
                "type": "sign",
                "amount": 10
            },
            "rewardSetting": {
                "type": "cash",
                "amount": 1,
                "limit": 10
            }
        },
        {
            "reachCondition": {
                "type": "sign",
                "amount": 15
            },
            "rewardSetting": {
                "type": "cash",
                "amount": 10,
                "limit": 10
            }
        }
    ]
}

Response body JSON:

{
    "code": 200,
    "status": "success",
    "requestId": "e9eb12f0-5d55-482a-8a47-62863d04772c",
    "data": 10465,
    "success": true
}

Response Parameter Description

Parameter Type Description
code Integer Response status code, 200 for success, non-200 for failure
status String Response result, determined by business logic: success returns "success", failure returns "error"
success Boolean Response result, determined by business logic: success returns true, failure returns false
data Long Task reward activity ID
error Object Error information when status code is non-200 See details: Error field description
requestId String Request ID, a unique UUID generated for each request, used only for troubleshooting and debugging, should not be tied to business logic

Error Parameter Description

Parameter Type Description
code Integer Error code, used to determine the specific error cause
desc String Error description, corresponding to error.code

Java Request Example

For quick integration of the base code, download the relevant dependency source code. Click here to download the source code. After downloading, add it to your own project source code. HttpUtil.java and LiveSignUtil.java in the test cases are included 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 pools.

private final Logger log = LoggerFactory.getLogger(getClass());
/**
 * 新建任务奖励活动
 * @throws IOException
 * @throws NoSuchAlgorithmException
 */
@Test
public void createTaskRewardTest() throws IOException, NoSuchAlgorithmException {
    //公共参数,填写自己的实际参数
    String appId = super.appId;
    String appSecret = super.appSecret;
    String timestamp = String.valueOf(System.currentTimeMillis());
        
    String url = "https://api.polyv.net/live/v4/channel/task-reward-activity/save";
    //业务参数
    Integer channelId = 5004544;
    String activityName = "demoData";
    Integer taskRule = 1;
    Long startTime = 1722035312584;
    Long endTime = 1722036312584;
    List<Task> tasks = new ArrayList();
    
    //http 调用逻辑
    Map<String, String> requestMap = new HashMap<>();
    requestMap.put("appId", appId);
    requestMap.put("timestamp", timestamp);
        
    Map<String, Object> jsonMap = new HashMap<>();
    jsonMap.put("channelId", channelId);
    jsonMap.put("activityName", activityName);
    jsonMap.put("taskRule", taskRule);
    jsonMap.put("startTime", startTime);
    jsonMap.put("endTime", endTime);
    jsonMap.put("tasks", tasks);
    
    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 system error descriptions, see Global Error Description

Success Example

{
    "code": 200,
    "status": "success",
    "requestId": "e9eb12f0-5d55-482a-8a47-62863d04772c",
    "data": 10465,
    "success": true
}

Error Example

{
    "code": 400,
    "status": "error",
    "requestId": "d310b70bc329403f87f77f9203d50f89.128.16360831552223589",
    "error": {
        "code": 20001,
        "desc": "application not found."
    },
    "success": false
}
联系客服,在线咨询
在线咨询