Create

To create a questionnaire the following POST request can be used (available only for ADMIN):

https://pistis-market.eu/srv/intention-analytics/api/questionnaire

Request body

{
  "title": "Questionnaire title",
  "description": "Questionnaire description",
  "creatorId": "d44624d2-5c2f-46a2-8383-96c578b8393a", // should be the user id of the creator
  "isForVerifiedBuyers": true, // true for Verified Buyers, false for General Users
  "isActive": true, // whether it should also activate the newly created questionnaire
  "questions": [
    {
      "title": "Question title",
      "type": "Text",
      "description": "Question description",
      "isRequired": true, // whether the question will be required or not when the user will submit answers
      "options": [
        {
          "text": "Option 1",
          "description": "Option 1 description"
        },
        {
          "text": "Option 2",
          "description": "Option 2 description"
        }
      ]
    }
  ]
}

Request Body Notes

  • If isActive is set to true, the rest of the questionnaires for the selected type (Verified Buyers or not) will be deactivated so that the new one will be set as active.
  • The questions property includes all the questions that are about to be created for the new questionnaire
    • The possible values for the type property are: Text, Checkbox, Radio Button.
    • The options property can be omitted if the question is of type Text.
    • Similarly to the above, the text property can be omitted if the question is of type Checkbox or Radio Button.

Server Response

Upon successful creation, the server will return the newly created questionnaire.

Example of the response:

{
  "id": "ff2b7476-4f19-472a-8f89-faad6f6247be",
  "version": "7",
  "questions": [
    {
      "id": "bf5bdf5e-8d58-4a9b-b0fd-62394ebea655",
      "type": "Text",
      "title": "Question title",
      "description": "Question description",
      "isRequired": true,
      "options": [
        {
          "text": "Option 1",
          "description": "Option 1 description"
        },
        {
          "text": "Option 2",
          "description": "Option 2 description"
        }
      ],
      "questionnaire": {
        "id": "ff2b7476-4f19-472a-8f89-faad6f6247be",
        "version": "7",
        "answers": [],
        "creatorId": "User id of the creator",
        "isForVerifiedBuyers": true,
        "title": "Questionnaire title",
        "description": "Questionnaire description",
        "isActive": true,
        "createdAt": "2024-08-09T07:31:31.374Z",
        "updatedAt": "2024-08-09T07:31:31.374Z"
      },
      "createdAt": "2024-08-09T07:31:31.374Z",
      "updatedAt": "2024-08-09T07:31:31.374Z"
    }
  ],
  "answers": [],
  "creatorId": "User id of the creator",
  "isForVerifiedBuyers": true,
  "title": "Questionnaire title",
  "description": "Questionnaire description",
  "isActive": true,
  "createdAt": "2024-08-09T07:31:31.374Z",
  "updatedAt": "2024-08-09T07:31:31.374Z"
}