Skip to content

Sessions and Conversations

In the "Maira Integration" tutorial, we saw how to send a query to Maira with POST /v1/maira/iask. In this tutorial, we will see how to show your users their past sessions and messages, and how to manage them.

All endpoints in this tutorial use the same project-key and api-key headers as iAsk. Field-level details and live testing are available in our sandbox.

How the parts fit together

Step What the user does Endpoint
1 Asks a question POST /v1/maira/iask. Omit session_id to start a new session. The response includes the session_id and the conversation_id.
2 Opens their list of sessions GET /v1/gpt/sessions
3 Opens a session POST /v1/gpt/conversations, with the session_id of that session
4 Continues the session POST /v1/maira/iask, with the same session_id
5 Renames the session PATCH /v1/gpt/sessions/{session_id}
6 Gives feedback on a response PUT /v1/gpt/conversations/{conversation_id} (see the "Maira Feedback" tutorial)
7 Deletes a conversation DELETE /v1/gpt/conversations/{conversation_id}

Listing a user's sessions

To show your users their sessions, use GET /v1/gpt/sessions. All filters are optional query parameters.

  • For logged-in users, filter by member_id (see member_id in the "Maira Integration" tutorial).
  • Use start and size to page through the results.

Each session in the response has a session_title to show in the list, and a session_id to send to iAsk when the user continues that session.

Sample request:

GET /v1/gpt/sessions?user_id=a0cc6beb-2909-459b-be55-62196af78ce4&start=0&size=2

Sample response (trimmed to one session):

{
  "detail": {
    "response": {
      "sessions": [
        {
          "session_id": "48b3bc7c-0af1-4fd5-a8c4-b15015f46e44",
          "session_title": "What are your opening hours?",
          "user_id": "a0cc6beb-2909-459b-be55-62196af78ce4",
          "user_name": null,
          "member_id": "df3456tg-2909-459b-be55-62196afedf85",
          "maira_profile_id": "9b2d7c41-6e8a-4f3b-a1d5-2c7e8f90b123",
          "session_url": null,
          "is_session_public": false,
          "session_code": null,
          "session_status": "active",
          "line_uid": null,
          "platform": null,
          "session_closure_reason": null,
          "ip_address": [
            "203.0.113.10"
          ],
          "project_id": "<your-project-id>",
          "created_at": "2026-11-19T11:19:51.881429+09:00",
          "updated_at": "2026-11-19T14:30:27.010684+09:00",
          "last_conversation_at": "2026-11-19T14:30:27.010684+09:00",
          "maira_profile_name": "Customer support"
        }
      ],
      "total_hits": 14,
      "returned_hits": 2,
      "active_count": 14
    }
  }
}

Loading a session's messages

When a user opens a session, use POST /v1/gpt/conversations to load its messages.

  • Put the session_id in query.filters.
  • Use start and size to page through the results.
  • start_date and end_date optionally limit the date range.

Sample request body:

{
  "start_date": "2026-01-01",
  "end_date": "2026-12-31",
  "query": {
    "filters": {
      "session_id": "48b3bc7c-0af1-4fd5-a8c4-b15015f46e44"
    }
  },
  "start": 0,
  "size": 10
}

Each item in conversations is one query and its AI response. To display it, use:

  • request_body.query: the user's message
  • response: the AI response
  • created_at: when the conversation was created

Its conversation_id is the one to use for feedback or deletion.

Sample response (trimmed: request_body also carries the profile's settings, and references lists every retrieved source):

{
  "detail": {
    "response": {
      "matched_conversation": 2,
      "returned_conversation": 2,
      "total_hits": 2,
      "returned_hits": 2,
      "conversations": [
        {
          "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
          "request_body": {
            "user_id": "a0cc6beb-2909-459b-be55-62196af78ce4",
            "member_id": "df3456tg-2909-459b-be55-62196afedf85",
            "user_name": "Taro Yamada",
            "query": "What are your opening hours?",
            "conversation_type": "chat",
            "gpt_profile_id": "9b2d7c41-6e8a-4f3b-a1d5-2c7e8f90b123",
            "session_id": "48b3bc7c-0af1-4fd5-a8c4-b15015f46e44",
            "platform": "WEB",
            "is_streaming": true,
            "sent_at": "2026-11-23T16:54:52.391000+00:00",
            "...": "..."
          },
          "response_status": 200,
          "message_seen": true,
          "created_at": "2026-11-24T01:55:09.754713+09:00",
          "response": "We are open from 9:00 to 18:00 on weekdays. ...",
          "references": [
            {
              "section_id": "b1946ac92492d2347c6235b4d2611184",
              "similarity_score": "100.00",
              "dataset_id": "123456",
              "original_file_name": "faq.csv",
              "reference_url": null,
              "...": "..."
            }
          ],
          "generated_images": [],
          "tokens": 25510,
          "session_id": "48b3bc7c-0af1-4fd5-a8c4-b15015f46e44",
          "conversation_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
          "gpt_profile_id": "9b2d7c41-6e8a-4f3b-a1d5-2c7e8f90b123",
          "run_time": 17.18,
          "updated_at": "2026-11-24T01:55:09.864879+09:00",
          "message_seen_at": "2026-11-23T16:55:09.803000Z"
        },
        {
          "id": "7c1e4b2a-9d3f-4e6b-8a5c-0f2d1e3b4c5d",
          "request_body": {
            "query": "Hello",
            "...": "..."
          },
          "created_at": "2026-11-24T01:54:43.382574+09:00",
          "response": "Hello! How can I help you today?",
          "conversation_id": "7c1e4b2a-9d3f-4e6b-8a5c-0f2d1e3b4c5d",
          "...": "..."
        }
      ]
    }
  }
}

Renaming a session

To let your users rename a session, use PATCH /v1/gpt/sessions/{session_id} with the new session_title. Only the fields sent in the body are updated.

Sample request body:

{
  "session_title": "Opening hours"
}

Refer to the sandbox for details.

Deleting a conversation

To delete a conversation, use DELETE /v1/gpt/conversations/{conversation_id}, with the conversation_id returned by iAsk.