Dataopi
Concepts

Questions

The five question types and the JSON schema used to define them.

A survey's questions field is a JSON array of question objects. The shape is a discriminated union on type. Every question shares a few base fields and then adds its own specific options.

Shared fields

FieldTypeDescription
idstringStable identifier within the survey (used in answers and visibility rules)
labelstringQuestion shown to the respondent
descriptionstring?Optional helper text under the label
requiredboolean?When true, the form blocks submission until answered
visibleWhenobject?Conditional visibility — see Conditional follow-ups
followUpsarray?Nested questions that appear once this question is answered

text

Free-form text input.

{
  "id": "comments",
  "type": "text",
  "label": "Anything else you would like to share?"
}

boolean

Yes/no, with customisable labels.

{
  "id": "would-recommend",
  "type": "boolean",
  "label": "Would you recommend us to a friend?",
  "trueLabel": "Yes",
  "falseLabel": "No",
  "required": true
}

select

One option (default) or multiple options when multi: true.

{
  "id": "channel",
  "type": "select",
  "label": "Where did you hear about us?",
  "options": [
    { "value": "search", "label": "Search engine" },
    { "value": "friend", "label": "A friend" },
    { "value": "ads", "label": "Online ads" }
  ]
}

number

Numeric input with optional bounds, step and unit.

{
  "id": "delivery-minutes",
  "type": "number",
  "label": "How many minutes did delivery take?",
  "min": 0,
  "max": 240,
  "step": 1,
  "unit": "min"
}

scale

Discrete scale, useful for NPS and CSAT style ratings.

{
  "id": "nps",
  "type": "scale",
  "label": "How likely are you to recommend us? (0–10)",
  "scale": {
    "min": 0,
    "max": 10,
    "lowLabel": "Not at all likely",
    "highLabel": "Extremely likely"
  }
}

Answer payload

When the respondent submits, each answer is a { questionId, value } object. The accepted value shape depends on the question type:

Question typevalue shape
textstring
booleanboolean
selectstring or string[] (multi)
numbernumber
scalenumber

On this page