Skip to main content

List sessions / get session messages

GET /api/history                  # all session summaries for the current user
GET /api/history?session_id=<s>   # all messages of a single session

No session_id

Returns all summaries in reverse-time order:
{ "success": true, "code": 0, "msg": "ok",
  "data": { "summaries": [
    {
      "session_id":    "...",
      "timestamp":     "2026-05-22T03:33:00+00:00",
      "summary":       "Show me last week's sleep",
      "query_user_id": "504"
    }
  ] }
}
Known limitation: /api/history does not paginate yet — for users with long history this may return thousands of records. Client guidance:
  • On a list page, show only the most recent N (e.g. 30) by timestamp descending.
  • Cache locally with last_timestamp to do incremental fetch.
  • Pagination will be added in a future version with backward-compatible shape.

With session_id

Returns the chat messages for the session:
{ "success": true, "code": 0, "msg": "ok",
  "data": { "history": [
    {
      "role":      "user",
      "content":   "...",
      "content_dict": [],
      "timestamp": "...",
      "id":        "...",
      "agent":     "App",
      "provider":  "DeepSeekFlash",
      "messageType": "text"
    }
  ] }
}
role is user or assistant. content_dict carries the tool-call step list captured during streaming.

By-person view (family scenario)

GET /api/history_by_person
Returns sessions grouped by each visible user (yourself + authorized family members) — handy for a “switch family member” UI.

Delete a session

POST /api/history/delete
Authorization: Bearer <access_token>
Content-Type: application/json
{ "session_id": "..." }
Idempotent — returns ok even for nonexistent IDs.