Skip to main content
GET
/
api
/
get_room_messages
Get Room Messages
curl --request GET \
  --url https://api.example.com/api/get_room_messages \
  --header 'Authorization: <authorization>'
{
  "messages": [
    {
      "username": "<string>",
      "message": "<string>",
      "created_at": 123,
      "room_id": 123
    }
  ]
}

Overview

Retrieves all messages for a specific chat room. Only members of the room can access its messages. Messages are automatically filtered by room ID and only non-expired messages are returned.

Authentication

Requires a valid authentication token in the Authorization header.

Request

Headers

Authorization
string
required
User authentication token

Query Parameters

room_id
string
required
The ID of the room to retrieve messages from

Response

messages
array
Array of message objects for the specified room
username
string
The username of the message sender
message
string
The message content
created_at
number
Unix timestamp of when the message was sent
room_id
integer
The room ID (matches the requested room_id)

Status Codes

  • 200: Successfully retrieved messages
  • 400: Missing token or room_id
  • 401: Unauthorized - invalid or missing token
  • 403: User is not a member of the room

Error Responses

Missing Fields

{
  "error": "missing token or room id"
}

Unauthorized

{
  "error": "unauthorized"
}

Not a Room Member

{
  "error": "you are not in this room"
}

Example

curl -X GET "https://api.mirage.com/api/get_room_messages?room_id=42" \
  -H "Authorization: your-auth-token"

Success Response

{
  "messages": [
    {
      "username": "john_doe",
      "message": "Hello everyone!",
      "created_at": 1709481234.567,
      "room_id": 42
    },
    {
      "username": "jane_smith",
      "message": "Hi John!",
      "created_at": 1709481256.789,
      "room_id": 42
    }
  ]
}

Empty Room Response

{
  "messages": []
}

Notes

  • Only messages from the specified room are returned.
  • You must be a member of the room to retrieve its messages.
  • Messages older than 15 hours (54,000 seconds) are automatically expired and will not appear.
  • Messages are returned in the order they were stored.
  • The system maintains a maximum of 100 messages across all rooms.

Build docs developers (and LLMs) love