XUND
Guides

Changing answers and recovering state

Stepping back to change earlier answers, and rebuilding the check after your client loses its local state.

These endpoints sit next to the question-answer loop: they let your UI step back to change earlier answers, and recover after losing local state.

Changing earlier answers

Patients change their minds; three mechanisms let your UI step back without restarting the check:

  • Go back to an earlier question — POST /v1/chatbot/restoreToQuestion with { "questionId": "..." } restores the check's state to that question and clears all answers given after it. The target must be an already-answered question of this check: restoring to the currently asked question is rejected with 400 (QUESTION_NEEDS_TO_BE_ANSWERED_BEFORE_RESTORE), an unknown id with 400 (QUESTION_NOT_FOUND). Success is an empty 200 — then continue the loop with GET /v1/chatbot/question.
  • Deselect an option on an EXTENDING question — DELETE /v1/chatbot/answer with both questionId and answerId as query parameters. It works only for EXTENDING questions, and only for the last asked question; the option must currently be selected. Success is a 204; invalid ids are rejected with 400 (INVALID_QUESTION_ID / INVALID_ANSWER_TO_DELETE).
  • Edit answers from the overview — while the check is at the overview stage, PATCH /v1/chatbot/overview/answer changes the answer of a previously answered question without clearing what came after. See Editing from the overview.

Recovering state

If your client loses its local state mid-check (page reload, app restart), the check itself is untouched on XUND's side — you only need the checkId to rebuild:

  • GET /v1/chatbot/status returns the full state of the check: its type, whether it is closed, the current state, and the list of all questions asked so far (without their options, even where the questions had them).
  • GET /v1/chatbot/question/bulk returns full Question objects — options and isSelected flags included — for previously answered questions. Question ids are passed with array bracket notation, one ids[] parameter per id: /v1/chatbot/question/bulk?ids[]=7e184b14-70a9-4401-b17f-07e0bd0383ba&ids[]=0185daaf-a95c-4d3d-bc0e-f055be5f8d89.
  • GET /v1/chatbot/question?questionId=<id> re-fetches a single recently asked question.

Last updated on

On this page