Skip to main content

Endpoint

POST /api/interview/sessions/{sessionId}/answers
Submits the user’s answer to the current interview question and returns the next question. The system automatically advances to the next question and may generate intelligent follow-up questions based on the submitted answer.
This endpoint is rate-limited to 10 requests globally to ensure fair usage and prevent abuse.

Path Parameters

sessionId
string
required
The unique session identifier obtained from the create session endpoint.

Request Body

questionIndex
integer
required
The zero-based index of the question being answered. Must match the current question index in the session to prevent out-of-order submissions.
answer
string
required
The user’s answer to the interview question. Cannot be empty.

Response

code
integer
Response status code. 200 indicates success.
message
string
Response message. Returns "success" on successful submission.
data
object
Contains information about the next question or completion status.

Example Request

curl -X POST https://api.example.com/api/interview/sessions/a1b2c3d4-e5f6-4789-g0h1-i2j3k4l5m6n7/answers \
  -H "Content-Type: application/json" \
  -d '{
    "questionIndex": 0,
    "answer": "在电商平台项目中,我们使用Spring Cloud构建了微服务架构。主要包括以下组件:使用Eureka作为服务注册中心,Zuul作为API网关,Feign实现服务间调用,Hystrix提供熔断降级功能。我们将系统拆分为订单服务、商品服务、用户服务等多个微服务,通过配置中心统一管理配置,使用消息队列实现异步解耦。"
  }'

Example Response (Has Next Question)

{
  "code": 200,
  "message": "success",
  "data": {
    "hasNextQuestion": true,
    "nextQuestion": {
      "questionIndex": 1,
      "question": "你提到使用Hystrix实现熔断降级,能具体说说在什么场景下会触发熔断吗?你们是如何配置熔断参数的?",
      "type": "SPRING",
      "category": "Spring",
      "userAnswer": null,
      "score": null,
      "feedback": null,
      "isFollowUp": true,
      "parentQuestionIndex": 0
    },
    "currentIndex": 0,
    "totalQuestions": 8
  }
}

Example Response (Interview Completed)

{
  "code": 200,
  "message": "success",
  "data": {
    "hasNextQuestion": false,
    "nextQuestion": null,
    "currentIndex": 7,
    "totalQuestions": 8
  }
}

Save Answer

Save answer without advancing to next question

Get Current Question

Retrieve the current question without submitting

Generate Report

Get AI evaluation after completing interview

Complete Early

Finish interview before answering all questions

Additional Operations

Save Answer Without Advancing

Save the user’s answer without advancing to the next question. Useful for auto-save functionality or allowing users to edit their answer.
PUT /api/interview/sessions/{sessionId}/answers
sessionId
string
required
The unique session identifier.
questionIndex
integer
required
The zero-based index of the question being answered.
answer
string
required
The user’s answer to save.
Example:
curl -X PUT https://api.example.com/api/interview/sessions/a1b2c3d4-e5f6-4789-g0h1-i2j3k4l5m6n7/answers \
  -H "Content-Type: application/json" \
  -d '{
    "questionIndex": 0,
    "answer": "在电商平台项目中,我们使用Spring Cloud..."
  }'
Response:
{
  "code": 200,
  "message": "success",
  "data": null
}

Get Current Question

Retrieve the current question without submitting an answer. Useful for recovering session state or displaying the current question.
GET /api/interview/sessions/{sessionId}/question
sessionId
string
required
The unique session identifier.
Example:
curl https://api.example.com/api/interview/sessions/a1b2c3d4-e5f6-4789-g0h1-i2j3k4l5m6n7/question
Response:
{
  "code": 200,
  "message": "success",
  "data": {
    "questionIndex": 0,
    "question": "请介绍一下你在电商平台项目中如何使用Spring Cloud构建微服务架构的?",
    "type": "PROJECT",
    "category": "项目经历",
    "totalQuestions": 8,
    "currentQuestionIndex": 0,
    "previousAnswer": null
  }
}

Interview Flow

1

Submit First Answer

Submit the answer to question 0 using POST endpoint. Store the nextQuestion returned in the response.
2

Continue Until Complete

Repeat submission for each question. The system tracks progress automatically using currentIndex.
3

Handle Follow-up Questions

The AI may generate follow-up questions (marked with isFollowUp: true) based on your answers for deeper exploration.
4

Check Completion

When hasNextQuestion returns false, the interview is complete. Proceed to generate the evaluation report.
5

Generate Report

Call the Get Report endpoint to retrieve detailed evaluation, scores, and feedback.

Error Responses

code
integer
Error code. Non-200 values indicate an error.
message
string
Error message describing what went wrong.
data
null
Always null for error responses.

Common Errors

CodeMessageDescription
400会话ID不能为空Session ID is required
400问题索引不能为空Question index is required
400问题索引无效Question index must be >= 0
400答案不能为空Answer cannot be empty
404Session not foundInvalid session ID
400Question index mismatchSubmitted wrong question index
429Rate limit exceededToo many requests
500Server errorInternal server error

Best Practices

Implement auto-save functionality using the PUT endpoint to prevent data loss:
// Auto-save every 30 seconds
const autoSave = debounce(() => {
  fetch(`/api/interview/sessions/${sessionId}/answers`, {
    method: 'PUT',
    body: JSON.stringify({
      questionIndex: currentIndex,
      answer: answerText
    })
  });
}, 30000);

// User typing triggers auto-save
answerInput.addEventListener('input', autoSave);
Display progress to users using currentIndex and totalQuestions:
const progress = (currentIndex / totalQuestions) * 100;
progressBar.style.width = `${progress}%`;
progressText.innerText = `Question ${currentIndex + 1} of ${totalQuestions}`;
Follow-up questions provide deeper insight. Display them with context:
if (nextQuestion.isFollowUp) {
  const parentQ = questions[nextQuestion.parentQuestionIndex];
  showContextBadge(`Follow-up to: ${parentQ.question}`);
}
Always verify you’re submitting the correct question index:
if (submittedIndex !== currentQuestionIndex) {
  console.error('Question index mismatch!');
  // Reload current question
  await getCurrentQuestion(sessionId);
}
Allow users to resume interrupted sessions:
// On page load
const session = await getSession(sessionId);
if (session.status === 'IN_PROGRESS') {
  const currentQ = await getCurrentQuestion(sessionId);
  resumeInterview(currentQ);
}

Answer Quality Tips

For better evaluation results, encourage candidates to:
  • Provide specific examples and scenarios
  • Mention concrete technologies and tools used
  • Explain the reasoning behind technical decisions
  • Include quantitative metrics where applicable
  • Describe challenges faced and solutions implemented

State Transitions

After completion, the session status changes to COMPLETED. Generate the evaluation report immediately to provide feedback while the interview is fresh in the candidate’s mind.

Build docs developers (and LLMs) love