Save the user's answer
POST
/session-records/messagesSaves the user's answer for one Q&A round. Image messages and model messages used for replay go through the same endpoint.
Request URL
text
POST https://open-api.habitaxx.com/v1/ms-ai-fast/session-records/messagesRequest headers
http
Authorization: Bearer <ACCESS_TOKEN>
Content-Type: application/jsonRequest fields
| Field | Type | Required | Description |
|---|---|---|---|
session_id | string | Yes | Session ID. |
role | string | Yes | user, assistant, or system; any other value returns 400. |
content | string | Yes | The user's answer text; a JSON string is also accepted. |
module_type | integer | No | 1 for Smart Consultation, 5 for image recognition; when omitted it is derived from the session record. |
content_type | integer | No | 1 text (default), 2 image, 3 JSON. |
stage | integer | No | Business stage; consultation answers normally send 2. |
parent_session | string/null | No | Parent session ID. |
image | string/null | No | Image URL for image messages; use the exact url returned by /oss/images. |
extra_json | object/null | No | Extended payload. |
is_hidden | integer | No | Whether the message is hidden; defaults to 0. |
Request body: text answer
json
{
"session_id": "<SESSION_ID>",
"role": "user",
"content": "最近没有更换食物。",
"module_type": 1,
"content_type": 1,
"stage": 2
}Request body: image message
json
{
"session_id": "<SESSION_ID>",
"role": "user",
"content": "用户补充了一张图片",
"module_type": 1,
"content_type": 2,
"image": "<UPLOAD_RESPONSE_DATA_URL>"
}Response example
json
{
"code": 200,
"message": "success",
"data": {
"id": 2,
"created_at": "2026-09-14T10:05:00+08:00",
"updated_at": "2026-09-14T10:05:00+08:00",
"session_id": "<SESSION_ID>",
"user_uuid": "<USER_UUID>",
"module_type": 1,
"role": "user",
"content": "最近没有更换食物。",
"content_type": 1,
"stage": 2,
"parent_session": null,
"image": null,
"evaluation": null,
"extra_json": null,
"is_hidden": 0
}
}Response fields
| Field | Type | Description |
|---|---|---|
id | integer | Message ID. |
session_id | string | Session ID. |
role | string | user, assistant, or system. |
content | string | Message text or a JSON string. |
content_type | integer | 1 text, 2 image, 3 JSON. |
module_type | integer | 1 consultation, 5 image recognition. |
stage | integer/null | Business stage. |
parent_session | string/null | Parent session ID. |
image | string/null | Image URL for image messages. |
extra_json | object/null | Extended payload. |
is_hidden | integer | Whether the message is hidden: 0 no, 1 yes. |
evaluation | object/null | Evaluation payload; null when not evaluated. |
created_at / updated_at | datetime | Creation and update time. |
user_uuid | string | Platform-internal user identifier; do not use externally. |
Common errors
HTTP / code | message | Trigger |
|---|---|---|
400 | role 仅支持 user/assistant/system | role has any other value. |
404 | 会话不存在 | session_id does not exist or belongs to another user. |
422 | Field required | session_id, role, or content is missing. |
Notes
- Save each round's answer once; do not repeat the call on a client retry.
- After a successful save, call Decide whether to continue asking or start the next round.