Polyv Help Center

Help Center

Batch Create Questionnaires (Supporting Multi-Channel Simultaneous Creation)

Updated: 2026-06-18 10:39:08

API Description

1、支持批量创建问卷(支持多频道同时创建)
2、(timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议

API URL

http://api.polyv.net/live/v4/channel/questionnaire/create-batch

Online API Call

Request Method

POST

API Constraints

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

Request Parameter Description

Parameter Required Type Description
appId true String Account appId See details on obtaining keys
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 side. All APIs must be called from your own server to relay requests to the POLYV server to obtain response data. See signature generation rules

Request Body Parameter Description

Parameter Required Type Description
questionnaires true Array Questionnaire list (supports creating up to 50 questionnaires at once) See questionnaires field description

questionnaires Field Description

Parameter Required Type Description
questionnaireTitle true String Questionnaire title
questions true Array Question array See questions field description
channelId true Integer Channel ID
customQuestionnaireId false String Custom questionnaire ID
autoPublishTime false String Scheduled auto-publish time for the questionnaire (format: "yyyy-MM-dd HH:mm"; must be at least 1 minute later than current time; required when autoEndTime is provided)
autoEndTime false String Scheduled auto-end time for the questionnaire (format: "yyyy-MM-dd HH:mm"; must be later than autoPublishTime; required when autoPublishTime is provided)
privacyEnabled false String Privacy agreement toggle
privacyContent false String Privacy agreement content
userTags false Array Audience business tag matching conditions for targeted questionnaire display (only effective for externally authorized viewers). If provided, the questionnaire will only be shown to externally authorized viewers carrying any matching tag; if not provided or empty, the original questionnaire display logic applies. Supports up to 10 tags

questions Field Description

Parameter Required Type Description
name true String Question text
type true String Question type
R: Single choice
C: Multiple choice
Q: Q&A
J: True/False
X: Star rating
scoreEnabled false String Whether scoring is required for the question
Y: Required
N: Not required
score false String Score
Required when scoreEnabled is Y
answer false String Answer, only for scored choice questions. Fill in the corresponding option index, e.g., A or AB
required false String Whether the question is mandatory
Y: Mandatory
N: Optional
options false String[] Required for single or multiple choice questions. Option array indices 0-9 correspond to answers A-J

Example

https://api.polyv.net/live/v4/channel/questionnaire/create-batch?appId=frlr1zazn3&sign=439CDA1327558DFCF947F305D03AFA92&timestamp=1621843779393

Request Body Parameters

{
  "questionnaires": [
    {
      "questionnaireTitle": "这里是问卷标题",
      "channelId": 10002,
      "userTags": ["vip", "registered"],
      "autoPublishTime": "2025-04-31 08:00",
      "autoEndTime": "2025-04-31 08:30",
      "questions": [
        {
          "name": "题目名称qwe1",
          "type": "R",
          "answer": "A",
          "required": "Y",
          "options": ["选项1", "选项2", "选项3"]
        }
      ]
    },
    {
      "questionnaireTitle": "这里是问卷标题2",
      "channelId": 10003,
      "questions": [
        {
          "name": "题目名称qwe2",
          "type": "R",
          "answer": "B",
          "required": "Y",
          "scoreEnabled": "Y",
          "score": 10,
          "options": ["选项1", "选项2", "选项3"]
        }
      ]
    }
  ]
}

Response Parameter Description

Parameter Type Description
code Integer Response status code, 200 for success, non-200 for failure See global error description
status String Response status text
message String Response description, provides error details when code is 400 or 500
data Object Questionnaire basic information on success See data field description

data Field Description

Parameter Type Description
questionnaires Array Questionnaire information list See questionnaires field description

questionnaires Field Description

Parameter Type Description
questionnaireId String Questionnaire ID
questionIds String[] Question ID array
channelId Integer Channel ID
questionnaireTitle String Questionnaire title

Java Request Example

For quick integration of basic code, please download the relevant dependency source code. Click here to download the source code. After downloading, add it to your own source code project. 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 pooling.

private static final Logger log = LoggerFactory.getLogger(LiveInteractionTest.class);

/**
 * 设修改频道问卷
 * @throws IOException
 */
@Test
public void testAddEditQuestionnaire() throws IOException, NoSuchAlgorithmException {
    //公共参数,填写自己的实际参数
    String appId=super.appId;
    String appSecret=super.appSecret;
    String userId = super.userId;
    String timestamp=String.valueOf(System.currentTimeMillis());
    //业务参数
    String temp = "https://api.polyv.net/live/v4/channel/questionnaire/create-batch";

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

    String body = "{\"questionnaires\":[{\"questionnaireTitle\":\"这里是问卷标题\",\"channelId\":10002,\"userTags\":[\"vip\",\"registered\"],\"autoPublishTime\":\"2025-04-31 08:00\",\"autoEndTime\":\"2025-04-31 08:30\",\"questions\":[{\"name\":\"题目名称qwe1\",\"type\":\"R\",\"answer\":\"A\",\"required\":\"Y\",\"options\":[\"选项1\",\"选项2\",\"选项3\"]}]},{\"questionnaireTitle\":\"这里是问卷标题2\",\"channelId\":10003,\"questions\":[{\"name\":\"题目名称qwe2\",\"type\":\"R\",\"answer\":\"B\",\"required\":\"Y\",\"scoreEnabled\":\"Y\",\"score\":10,\"options\":[\"选项1\",\"选项2\",\"选项3\"]}]}]}";
    requestMap.put("sign",LiveSignUtil.getSign(requestMap, appSecret));
    String url = HttpUtil.appendUrl(temp,requestMap);
    String response = HttpUtil.postJsonBody(url, body, null);
    log.info("测试批量创建问卷接口返回值:{}",response);
    //do somethings
}

Response Example

See Global Error Description for system-wide error descriptions.

Success Example

{
  "code": 200,
  "status": "success",
  "requestId": "ed721ebb-9add-4469-ad0f-e46db8aac206",
  "data": {
    "questionnaires": [
      {
        "channelId": 10002,
        "questionnaireId": "h6mmyaxze1",
        "questionIds": ["feqfr13ftz"]
      },
      {
        "channelId": 10003,
        "questionnaireId": "h6mmyaxze2",
        "questionIds": ["feqfr13ft1"]
      }
    ]
  },
  "success": true
}

Error Example

{
    "code": 400,
    "status": "error",
    "message": "invalid signature.",
    "data": ""
}
联系客服,在线咨询