Migrate question-level skips and tasks to logic rules

POST /walk-creator/v1/templates/migrate-question-level-rules

Operation id: migrateQuestionLevelRules

Description

Called immediately after a user opens a modern walk template in the Walk Creator (following POST /service/api/v2/template/retrieveTemplateData).

Detects legacy question-level skips (SKIP_HEADER.question_id > 0) and tasks (WALK_VIOLATION_TASK.question_id > 0), creates or updates LOGIC_RULE documents, and resets question_id to 0 so they appear under Logic Rules only.

Preconditions:

  • Template must have IS_MODERN_UI=Y.
  • Caller must have template edit access.

Idempotent: safe to call on every template open. After the first successful run, no question-level records remain and the API returns migrated: false with zero counts.

Authentication: X-reflexis-csrf-token-X required.


Success — no-op

{
  "status": "OK",
  "response": {
    "migrated": false,
    "skips_cleared": 0,
    "tasks_cleared": 0,
    "logic_rules_created": 0,
    "logic_rules_updated": 0
  }
}

Success — migrated

{
  "status": "OK",
  "response": {
    "migrated": true,
    "skips_cleared": 2,
    "tasks_cleared": 1,
    "logic_rules_created": 1,
    "logic_rules_updated": 1
  }
}

Error scenarios

ScenarioHTTP StatusMessage
Missing model_id400model_id is mandatory
Invalid template access200status: ER, Invalid Template Access
Template not found200status: ER, template not found: …
Not a modern template200status: ER, IS_MODERN_UI=Y required

Tags: WalkCreatorTemplateConversion

Security

  • AuthTokenHeader (apiKey)
    • Session authentication token validated server-side against the user session store. Required on every request. Absence returns HTTP 400; invalid/expired token returns HTTP 401.

Responses

200 — Success returns status: OK and migration counts under response.

Application-level failures return HTTP 200 with status: ER.

Content type: application/json

400 — Invalid or missing required request parameter.

Content type: application/json

401 — Missing or invalid X-reflexis-csrf-token-X session token.

Content type: application/json

500 — Unexpected server-side error.

Content type: application/json

Request body

Required: Yes

application/x-www-form-urlencoded

Schema

PropertyTypeRequiredDescription
model_idstringYesWalk template MODEL_ID to migrate.
{
  "type": "object",
  "required": [
    "model_id"
  ],
  "properties": {
    "model_id": {
      "type": "string",
      "description": "Walk template `MODEL_ID` to migrate.",
      "example": "FORM_123"
    }
  }
}

Response models

200 — Success returns status: OK and migration counts under response.

Application-level failures return HTTP 200 with status: ER.

Content type: application/json

Schema

{
  "oneOf": [
    {
      "type": "object",
      "required": [
        "status",
        "response"
      ],
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "OK"
          ]
        },
        "response": {
          "type": "object",
          "description": "Migration summary returned when question-level skips/tasks are normalized to logic rules.\nResponse keys use snake_case in the API envelope.\n",
          "required": [
            "migrated",
            "skips_cleared",
            "tasks_cleared",
            "logic_rules_created",
            "logic_rules_updated"
          ],
          "properties": {
            "migrated": {
              "type": "boolean",
              "description": "`true` only when at least one `LOGIC_RULE` was successfully created or updated and\nthe linked question-level `question_id` values were cleared; `false` for no-op or\nwhen question-level records could not be linked to logic rules.\n"
            },
            "skips_cleared": {
              "type": "integer",
              "description": "Number of `SKIP_HEADER` rows whose `question_id` was reset to `0`."
            },
            "tasks_cleared": {
              "type": "integer",
              "description": "Number of `WALK_VIOLATION_TASK` rows whose `question_id` was reset to `0`."
            },
            "logic_rules_created": {
              "type": "integer",
              "description": "Number of new `LOGIC_RULE` documents inserted."
            },
            "logic_rules_updated": {
              "type": "integer",
              "description": "Number of existing `LOGIC_RULE` documents updated with merged skip/task ids."
            }
          }
        }
      }
    },
    {
      "type": "object",
      "description": "Error envelope shape depends on how the error is produced:\n\n- **HTTP 200** — business or validation failure after the request is accepted:\n  `{ \"status\": \"ER\", \"error\": \"<string or JSON>\" }` (no `errorCode`).\n- **HTTP 4xx/5xx** — structured API error:\n  `{ \"status\": \"ER\", \"errorCode\": \"<code>\", \"response\": \"<localized message>\" }`.\n",
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "ER"
          ]
        },
        "errorCode": {
          "type": "string",
          "description": "Structured error code for HTTP 4xx/5xx responses."
        },
        "response": {
          "type": "string",
          "description": "Human-readable message when `errorCode` is present (HTTP 4xx/5xx responses)."
        },
        "error": {
          "description": "Payload for HTTP 200 error bodies (string, array, or object).",
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {}
            },
            {
              "type": "object"
            }
          ]
        }
      }
    }
  ]
}

400 — Invalid or missing required request parameter.

Content type: application/json

Schema

Error envelope shape depends on how the error is produced:

  • HTTP 200 — business or validation failure after the request is accepted: { "status": "ER", "error": "<string or JSON>" } (no errorCode).
  • HTTP 4xx/5xx — structured API error: { "status": "ER", "errorCode": "<code>", "response": "<localized message>" }.
PropertyTypeRequiredDescription
statusstringNo
errorCodestringNoStructured error code for HTTP 4xx/5xx responses.
responsestringNoHuman-readable message when errorCode is present (HTTP 4xx/5xx responses).
erroroneOfNoPayload for HTTP 200 error bodies (string, array, or object).
{
  "type": "object",
  "description": "Error envelope shape depends on how the error is produced:\n\n- **HTTP 200** — business or validation failure after the request is accepted:\n  `{ \"status\": \"ER\", \"error\": \"<string or JSON>\" }` (no `errorCode`).\n- **HTTP 4xx/5xx** — structured API error:\n  `{ \"status\": \"ER\", \"errorCode\": \"<code>\", \"response\": \"<localized message>\" }`.\n",
  "properties": {
    "status": {
      "type": "string",
      "enum": [
        "ER"
      ]
    },
    "errorCode": {
      "type": "string",
      "description": "Structured error code for HTTP 4xx/5xx responses."
    },
    "response": {
      "type": "string",
      "description": "Human-readable message when `errorCode` is present (HTTP 4xx/5xx responses)."
    },
    "error": {
      "description": "Payload for HTTP 200 error bodies (string, array, or object).",
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "array",
          "items": {}
        },
        {
          "type": "object"
        }
      ]
    }
  }
}

Example:

{
  "status": "ER",
  "errorCode": "E110",
  "response": "model_id is mandatory"
}

401 — Missing or invalid X-reflexis-csrf-token-X session token.

Content type: application/json

Schema

Error envelope shape depends on how the error is produced:

  • HTTP 200 — business or validation failure after the request is accepted: { "status": "ER", "error": "<string or JSON>" } (no errorCode).
  • HTTP 4xx/5xx — structured API error: { "status": "ER", "errorCode": "<code>", "response": "<localized message>" }.
PropertyTypeRequiredDescription
statusstringNo
errorCodestringNoStructured error code for HTTP 4xx/5xx responses.
responsestringNoHuman-readable message when errorCode is present (HTTP 4xx/5xx responses).
erroroneOfNoPayload for HTTP 200 error bodies (string, array, or object).
{
  "type": "object",
  "description": "Error envelope shape depends on how the error is produced:\n\n- **HTTP 200** — business or validation failure after the request is accepted:\n  `{ \"status\": \"ER\", \"error\": \"<string or JSON>\" }` (no `errorCode`).\n- **HTTP 4xx/5xx** — structured API error:\n  `{ \"status\": \"ER\", \"errorCode\": \"<code>\", \"response\": \"<localized message>\" }`.\n",
  "properties": {
    "status": {
      "type": "string",
      "enum": [
        "ER"
      ]
    },
    "errorCode": {
      "type": "string",
      "description": "Structured error code for HTTP 4xx/5xx responses."
    },
    "response": {
      "type": "string",
      "description": "Human-readable message when `errorCode` is present (HTTP 4xx/5xx responses)."
    },
    "error": {
      "description": "Payload for HTTP 200 error bodies (string, array, or object).",
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "array",
          "items": {}
        },
        {
          "type": "object"
        }
      ]
    }
  }
}

500 — Unexpected server-side error.

Content type: application/json

Schema

Error envelope shape depends on how the error is produced:

  • HTTP 200 — business or validation failure after the request is accepted: { "status": "ER", "error": "<string or JSON>" } (no errorCode).
  • HTTP 4xx/5xx — structured API error: { "status": "ER", "errorCode": "<code>", "response": "<localized message>" }.
PropertyTypeRequiredDescription
statusstringNo
errorCodestringNoStructured error code for HTTP 4xx/5xx responses.
responsestringNoHuman-readable message when errorCode is present (HTTP 4xx/5xx responses).
erroroneOfNoPayload for HTTP 200 error bodies (string, array, or object).
{
  "type": "object",
  "description": "Error envelope shape depends on how the error is produced:\n\n- **HTTP 200** — business or validation failure after the request is accepted:\n  `{ \"status\": \"ER\", \"error\": \"<string or JSON>\" }` (no `errorCode`).\n- **HTTP 4xx/5xx** — structured API error:\n  `{ \"status\": \"ER\", \"errorCode\": \"<code>\", \"response\": \"<localized message>\" }`.\n",
  "properties": {
    "status": {
      "type": "string",
      "enum": [
        "ER"
      ]
    },
    "errorCode": {
      "type": "string",
      "description": "Structured error code for HTTP 4xx/5xx responses."
    },
    "response": {
      "type": "string",
      "description": "Human-readable message when `errorCode` is present (HTTP 4xx/5xx responses)."
    },
    "error": {
      "description": "Payload for HTTP 200 error bodies (string, array, or object).",
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "array",
          "items": {}
        },
        {
          "type": "object"
        }
      ]
    }
  }
}

Example:

{
  "status": "ER",
  "errorCode": "E500",
  "response": "Unexpected server error."
}