Create survey

POST /api/sync/v1/surveys

Operation id: createOrEditSurvey

Description

This API will create or edit a survey. It will attach the created survey with the mentioned taskId (id of the to-do generated from CREATE To-Do API).

For Creating a survey, survey Id should not be passed. The taskId for to-do is mandatory. The surveyType value should be CHECKLIST to create a Checklist, which is currently supported.

To edit a survey, both surveyId and taskId are mandatory.

The displayType supported values: CHECKLIST value parameter would be the description of the checklist item that needs to be provided validation:required parameter would allow the user to mention whether the question is mandatory to complete or not. order parameter within questionOptions is mandatory and it should be in a sequence. Questions cannot have the same order. Discard value is false or true. if the question is to be removed, set the parameter as true.

Attachment metadata parameters are optional.

language parameter should be set as the language you want the questions to be in. Default language code value is en.

The following parameters should be ignored:

  1. surveyVersion parameters
  2. questionOptions
  3. createdFromQuestionId

Tags: Survey APIs

Security

  • Bearer (http / bearer)
    • enter the client service token value.

Responses

200 — Survey created or edited successfully

Content type: application/json

400 — Bad Request

500 — Internal Server Error

Request body

Required: Yes

application/json

Schema

PropertyTypeRequiredDescription
surveyIdinteger (int32)No
taskIdinteger (int32)Yes
namestringNo
surveyTypestringNo
questionsarrayNo
deletedQuestionIdsarrayNo
surveyVersionobjectNo
languagestringNo
{
  "type": "object",
  "required": [
    "taskId"
  ],
  "properties": {
    "surveyId": {
      "type": "integer",
      "format": "int32"
    },
    "taskId": {
      "type": "integer",
      "format": "int32"
    },
    "name": {
      "type": "string"
    },
    "surveyType": {
      "type": "string",
      "enum": [
        "SURVEY",
        "CHECKLIST"
      ]
    },
    "questions": {
      "type": "array",
      "items": {
        "type": "object",
        "description": "New version of Question DTO with updated attachment payload",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32"
          },
          "dataType": {
            "type": "string",
            "enum": [
              "INTEGER",
              "DECIMAL",
              "STRING",
              "BOOLEAN",
              "JSON",
              "DATE",
              "TIMESTAMP"
            ]
          },
          "displayType": {
            "type": "string",
            "enum": [
              "INPUTBOX",
              "DATEPICKER",
              "NUMBER_SCROLLER",
              "DROPDOWN",
              "MULTISELECT",
              "CHECKBOX",
              "RADIO",
              "CONFIRM_WITH_PHOTO"
            ]
          },
          "value": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "order": {
            "type": "integer",
            "format": "int32"
          },
          "validation": {
            "type": "object",
            "properties": {
              "required": {
                "type": "boolean"
              },
              "min": {
                "type": "integer",
                "format": "int32"
              },
              "max": {
                "type": "integer",
                "format": "int32"
              }
            }
          },
          "questionOptions": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "attachments": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "fileHash"
              ]
            }
          },
          "discard": {
            "type": "boolean"
          },
          "createdFromQuestionId": {
            "type": "integer",
            "format": "int32"
          }
        }
      }
    },
    "deletedQuestionIds": {
      "type": "array",
      "items": {
        "type": "integer",
        "format": "int32"
      }
    },
    "surveyVersion": {
      "type": "object",
      "properties": {
        "surveyVersionId": {
          "type": "integer",
          "format": "int32"
        },
        "surveyId": {
          "type": "integer",
          "format": "int32"
        },
        "version": {
          "type": "integer",
          "format": "int32"
        }
      }
    },
    "language": {
      "type": "string"
    }
  }
}

Response models

200 — Survey created or edited successfully

Content type: application/json

Schema

PropertyTypeRequiredDescription
surveyIdinteger (int32)No
taskIdinteger (int32)Yes
namestringNo
surveyTypestringNo
questionsarrayNo
deletedQuestionIdsarrayNo
surveyVersionobjectNo
languagestringNo
{
  "type": "object",
  "required": [
    "taskId"
  ],
  "properties": {
    "surveyId": {
      "type": "integer",
      "format": "int32"
    },
    "taskId": {
      "type": "integer",
      "format": "int32"
    },
    "name": {
      "type": "string"
    },
    "surveyType": {
      "type": "string",
      "enum": [
        "SURVEY",
        "CHECKLIST"
      ]
    },
    "questions": {
      "type": "array",
      "items": {
        "type": "object",
        "description": "New version of Question DTO with updated attachment payload",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32"
          },
          "dataType": {
            "type": "string",
            "enum": [
              "INTEGER",
              "DECIMAL",
              "STRING",
              "BOOLEAN",
              "JSON",
              "DATE",
              "TIMESTAMP"
            ]
          },
          "displayType": {
            "type": "string",
            "enum": [
              "INPUTBOX",
              "DATEPICKER",
              "NUMBER_SCROLLER",
              "DROPDOWN",
              "MULTISELECT",
              "CHECKBOX",
              "RADIO",
              "CONFIRM_WITH_PHOTO"
            ]
          },
          "value": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "order": {
            "type": "integer",
            "format": "int32"
          },
          "validation": {
            "type": "object",
            "properties": {
              "required": {
                "type": "boolean"
              },
              "min": {
                "type": "integer",
                "format": "int32"
              },
              "max": {
                "type": "integer",
                "format": "int32"
              }
            }
          },
          "questionOptions": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "attachments": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "fileHash"
              ]
            }
          },
          "discard": {
            "type": "boolean"
          },
          "createdFromQuestionId": {
            "type": "integer",
            "format": "int32"
          }
        }
      }
    },
    "deletedQuestionIds": {
      "type": "array",
      "items": {
        "type": "integer",
        "format": "int32"
      }
    },
    "surveyVersion": {
      "type": "object",
      "properties": {
        "surveyVersionId": {
          "type": "integer",
          "format": "int32"
        },
        "surveyId": {
          "type": "integer",
          "format": "int32"
        },
        "version": {
          "type": "integer",
          "format": "int32"
        }
      }
    },
    "language": {
      "type": "string"
    }
  }
}