{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/cookiy-ai/json-schema/cookiy-ai-v1-quant-survey-create-body-dto-schema.json",
  "title": "V1QuantSurveyCreateBodyDto",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/cookiy-ai-openapi.yml#/components/schemas/V1QuantSurveyCreateBodyDto",
  "type": "object",
  "properties": {
    "survey_title": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "object",
          "propertyNames": {
            "type": "string",
            "minLength": 2,
            "maxLength": 16
          },
          "additionalProperties": {
            "type": "string"
          }
        }
      ],
      "description": "Survey title. Plain string or per-language map (e.g. {\"en\":\"My Survey\",\"zh\":\"我的问卷\"}). Keep within 200 characters per language.",
      "x-nestjs_zod-uses-3-point-1-syntax": true,
      "x-nestjs_zod-empty-type": true
    },
    "languages": {
      "description": "Ordered list of survey languages. First entry is the base language. E.g. [\"en\",\"zh\",\"ja\"]. Defaults to [\"en\"]. Respondents can switch language on the survey page.",
      "minItems": 1,
      "maxItems": 20,
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 2,
        "maxLength": 16
      },
      "x-nestjs_zod-uses-3-point-1-syntax": true
    },
    "survey_format": {
      "description": "G=group by group, A=all on one page, S=single questions (presentation mode).",
      "type": "string",
      "enum": [
        "G",
        "A",
        "S"
      ],
      "x-nestjs_zod-uses-3-point-1-syntax": true
    },
    "activate": {
      "default": true,
      "description": "Whether to activate the survey after creation so respondents can open survey_public_url. Defaults to true; set false only when you intentionally want an inactive draft.",
      "type": "boolean",
      "x-nestjs_zod-uses-3-point-1-syntax": true
    },
    "groups": {
      "minItems": 1,
      "maxItems": 100,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "title": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "propertyNames": {
                  "type": "string",
                  "minLength": 2,
                  "maxLength": 16
                },
                "additionalProperties": {
                  "type": "string"
                }
              }
            ],
            "description": "Question group title. Plain string or per-language map."
          },
          "description": {
            "description": "Group description HTML/text. Plain string or per-language map.",
            "anyOf": [
              {
                "type": "string",
                "maxLength": 8000
              },
              {
                "type": "object",
                "propertyNames": {
                  "type": "string",
                  "minLength": 2,
                  "maxLength": 16
                },
                "additionalProperties": {
                  "type": "string",
                  "maxLength": 8000
                }
              }
            ]
          },
          "relevance": {
            "description": "Optional group-level grelevance (Expression Manager) using existing question codes, for example `Q1 == 'A1'`. This gates the whole group; omit for always show.",
            "type": "string",
            "maxLength": 16000
          },
          "questions": {
            "minItems": 1,
            "maxItems": 200,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 20,
                  "pattern": "^[A-Za-z][A-Za-z0-9]*$",
                  "description": "Unique question code in the questionnaire (for example `Q1` or `G01Q02`). Must start with a letter, use letters/digits only, and stay within 20 characters. Do not use underscores, hyphens, spaces, or other symbols."
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "long_text",
                    "short_text",
                    "list_radio",
                    "list_dropdown",
                    "multiple_choice",
                    "ranking",
                    "yes_no",
                    "numeric",
                    "array_flexible",
                    "boilerplate",
                    "file_upload",
                    "equation"
                  ],
                  "description": "Question kinds (LSQ-backed): list_radio/dropdown/multiple_choice/ranking need options; array_flexible needs array_subrows + array_scale; equation text is Expression Manager / ExpressionScript (bare `if(...)` is auto-wrapped as `{if(...)}` on import for LimeSurvey)."
                },
                "text": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "object",
                      "propertyNames": {
                        "type": "string",
                        "minLength": 2,
                        "maxLength": 16
                      },
                      "additionalProperties": {
                        "type": "string"
                      }
                    }
                  ],
                  "description": "Question wording. Plain string or per-language map (e.g. {\"en\":\"How old?\",\"zh\":\"你多大了？\"}). Equation type: may omit outer `{`…`}`."
                },
                "help": {
                  "description": "Optional help text. Plain string or per-language map.",
                  "anyOf": [
                    {
                      "type": "string",
                      "maxLength": 8000
                    },
                    {
                      "type": "object",
                      "propertyNames": {
                        "type": "string",
                        "minLength": 2,
                        "maxLength": 16
                      },
                      "additionalProperties": {
                        "type": "string",
                        "maxLength": 8000
                      }
                    }
                  ]
                },
                "relevance": {
                  "description": "Optional question relevance expression using existing question codes (for example `Q1 == 'A1'` or `Q2.NAOK == 'Y'`). This controls only this question's visibility; omit for always show (1).",
                  "type": "string",
                  "maxLength": 16000
                },
                "mandatory": {
                  "description": "Whether the question is required.",
                  "type": "boolean"
                },
                "allow_other": {
                  "description": "Only for list_radio: show an \"Other\" text field (other=Y in LSQ).",
                  "type": "boolean"
                },
                "options": {
                  "description": "Required for list_radio, list_dropdown, multiple_choice, ranking (≥2 options).",
                  "maxItems": 200,
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "code": {
                        "description": "Answer code; defaults to A1, A2, … if omitted. Keep within 5 characters for questionnaire backend answer-code limits.",
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 5
                      },
                      "label": {
                        "anyOf": [
                          {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 2000
                          },
                          {
                            "type": "object",
                            "propertyNames": {
                              "type": "string",
                              "minLength": 2,
                              "maxLength": 16
                            },
                            "additionalProperties": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 2000
                            }
                          }
                        ],
                        "description": "Answer label. Plain string or per-language map."
                      }
                    },
                    "required": [
                      "label"
                    ]
                  }
                },
                "array_subrows": {
                  "description": "Required for array_flexible: matrix rows (≥2).",
                  "maxItems": 100,
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "code": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 20,
                        "description": "Subquestion code (row). Keep within 20 characters for questionnaire backend question-code limits."
                      },
                      "label": {
                        "anyOf": [
                          {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 2000
                          },
                          {
                            "type": "object",
                            "propertyNames": {
                              "type": "string",
                              "minLength": 2,
                              "maxLength": 16
                            },
                            "additionalProperties": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 2000
                            }
                          }
                        ],
                        "description": "Row label. Plain string or per-language map."
                      }
                    },
                    "required": [
                      "code",
                      "label"
                    ]
                  }
                },
                "array_scale": {
                  "description": "Required for array_flexible: scale columns (≥2), e.g. Likert 1–5.",
                  "maxItems": 50,
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "code": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 5,
                        "description": "Scale code (column). Keep within 5 characters for questionnaire backend answer-code limits."
                      },
                      "label": {
                        "anyOf": [
                          {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 2000
                          },
                          {
                            "type": "object",
                            "propertyNames": {
                              "type": "string",
                              "minLength": 2,
                              "maxLength": 16
                            },
                            "additionalProperties": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 2000
                            }
                          }
                        ],
                        "description": "Column label. Plain string or per-language map."
                      }
                    },
                    "required": [
                      "code",
                      "label"
                    ]
                  }
                }
              },
              "required": [
                "code",
                "type",
                "text"
              ]
            },
            "description": "Questions in this group, in order."
          }
        },
        "required": [
          "title",
          "questions"
        ]
      },
      "description": "At least one group; each group contains ordered questions. Tool 1: structured creation with schema-enforced types.",
      "x-nestjs_zod-uses-3-point-1-syntax": true
    },
    "quotas": {
      "description": "Optional quotas via the questionnaire backend quota API (quota limits and messaging). Answer-based membership may still need to be completed in the questionnaire admin if the API cannot attach members.",
      "maxItems": 100,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500,
            "description": "Quota name (admin-visible)."
          },
          "limit": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Maximum completed responses for this quota shell. This tool does not edit quota membership rules."
          },
          "active": {
            "description": "Whether the quota shell is active.",
            "type": "boolean"
          },
          "action": {
            "description": "Quota shell action for the questionnaire backend quota API.",
            "type": "string",
            "enum": [
              "terminate",
              "terminate_visible_hidden",
              "terminate_pages",
              "confirm_terminate"
            ]
          },
          "autoload_url": {
            "description": "Auto-redirect when quota triggers (maps to autoload_url).",
            "type": "boolean"
          },
          "message": {
            "description": "Message shown when quota triggers.",
            "type": "string",
            "maxLength": 8000
          },
          "url": {
            "description": "Optional redirect URL for the quota shell (requires message per LS API).",
            "type": "string",
            "maxLength": 8000
          },
          "url_description": {
            "description": "Optional quota-shell URL description (requires message per LS API).",
            "type": "string",
            "maxLength": 500
          }
        },
        "required": [
          "name",
          "limit"
        ],
        "description": "Quota shell definition only. This creates or updates quota limits, actions, and messaging, but not answer-membership logic. Complex quota targeting may still require the questionnaire admin."
      },
      "x-nestjs_zod-uses-3-point-1-syntax": true
    }
  },
  "required": [
    "survey_title",
    "groups"
  ]
}