Skip to main content

Overview

Chat messages enable communication between tourists and guides within chat threads. Messages support different types (text, system, file) and track delivery and read status.

Create Chat Message

curl -X POST http://localhost:8080/api/chat_messages \
  -H "Content-Type: application/json" \
  -d '{
    "threadId": 42,
    "senderUserId": 10,
    "body": "Hello! I have a question about the tour schedule.",
    "messageType": "TEXT",
    "sentAt": "2026-03-11T14:35:00",
    "readAt": null
  }'
Send a new message within a chat thread.

Request Body

threadId
integer
required
The ID of the chat thread this message belongs to
senderUserId
integer
required
The user ID of the message sender
body
string
required
The content of the message
messageType
string
required
Type of message. Valid values: TEXT, SYSTEM, FILE
sentAt
string
Timestamp when the message was sent in ISO 8601 format (e.g., 2026-03-11T14:35:00)
readAt
string
Timestamp when the message was read in ISO 8601 format. Null if unread.

Response

messageId
integer
Unique identifier for the message
threadId
integer
The chat thread ID this message belongs to
senderUserId
integer
The sender’s user ID
body
string
The message content
messageType
string
Message type (TEXT, SYSTEM, or FILE)
sentAt
string
Timestamp when the message was sent
readAt
string
Timestamp when the message was read (null if unread)
{
  "messageId": 123,
  "threadId": 42,
  "senderUserId": 10,
  "body": "Hello! I have a question about the tour schedule.",
  "messageType": "TEXT",
  "sentAt": "2026-03-11T14:35:00",
  "readAt": null
}

Get All Chat Messages

curl -X GET http://localhost:8080/api/chat_messages \
  -H "Content-Type: application/json"
Retrieve a list of all chat messages across all threads.

Response

Returns an array of chat message objects.
[
  {
    "messageId": 123,
    "threadId": 42,
    "senderUserId": 10,
    "body": "Hello! I have a question about the tour schedule.",
    "messageType": "TEXT",
    "sentAt": "2026-03-11T14:35:00",
    "readAt": "2026-03-11T14:40:00"
  },
  {
    "messageId": 124,
    "threadId": 42,
    "senderUserId": 5,
    "body": "Of course! The tour starts at 9 AM and lasts approximately 3 hours.",
    "messageType": "TEXT",
    "sentAt": "2026-03-11T14:42:00",
    "readAt": null
  }
]

Get Chat Message by ID

curl -X GET http://localhost:8080/api/chat_messages/123 \
  -H "Content-Type: application/json"
Retrieve a specific chat message by its ID.

Path Parameters

id
integer
required
The unique identifier of the chat message

Response

{
  "messageId": 123,
  "threadId": 42,
  "senderUserId": 10,
  "body": "Hello! I have a question about the tour schedule.",
  "messageType": "TEXT",
  "sentAt": "2026-03-11T14:35:00",
  "readAt": "2026-03-11T14:40:00"
}

Update Chat Message

curl -X PUT http://localhost:8080/api/chat_messages/123 \
  -H "Content-Type: application/json" \
  -d '{
    "threadId": 42,
    "senderUserId": 10,
    "body": "Hello! I have a question about the tour schedule.",
    "messageType": "TEXT",
    "sentAt": "2026-03-11T14:35:00",
    "readAt": "2026-03-11T14:40:00"
  }'
Update an existing chat message. Commonly used to mark messages as read by updating the readAt timestamp.

Path Parameters

id
integer
required
The unique identifier of the chat message to update

Request Body

threadId
integer
The ID of the chat thread this message belongs to
senderUserId
integer
The user ID of the message sender
body
string
The content of the message
messageType
string
Type of message. Valid values: TEXT, SYSTEM, FILE
sentAt
string
Timestamp when the message was sent in ISO 8601 format
readAt
string
Timestamp when the message was read in ISO 8601 format. Set this to mark a message as read.

Response

{
  "messageId": 123,
  "threadId": 42,
  "senderUserId": 10,
  "body": "Hello! I have a question about the tour schedule.",
  "messageType": "TEXT",
  "sentAt": "2026-03-11T14:35:00",
  "readAt": "2026-03-11T14:40:00"
}

Delete Chat Message

curl -X DELETE http://localhost:8080/api/chat_messages/123 \
  -H "Content-Type: application/json"
Permanently delete a chat message from a thread.

Path Parameters

id
integer
required
The unique identifier of the chat message to delete

Response

Returns a success status code (typically 204 No Content) if the deletion was successful.

Message Types

Chat messages can have one of the following types:
  • TEXT: Standard text message sent by users
  • SYSTEM: Automated system message (e.g., “Booking confirmed”, “Tour started”)
  • FILE: Message containing a file attachment

Read Status

Messages track their read status through the readAt field:
  • Unread: readAt is null
  • Read: readAt contains the timestamp when the message was read
To mark a message as read, send a PUT request with the current timestamp in the readAt field.

Build docs developers (and LLMs) love