Skip to main content
POST
/
api
/
join_room
Join Room
curl --request POST \
  --url https://api.example.com/api/join_room \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "password": "<string>"
}
'
{
  "message": "<string>",
  "room_id": 123,
  "room_name": "<string>"
}

Overview

Allows an authenticated user to join an existing chat room by name. For private rooms, the correct password must be provided. The user is added to the room’s member list.

Authentication

Requires a valid authentication token in the Authorization header.

Request

Headers

Authorization
string
required
User authentication token

Body Parameters

name
string
required
Name of the room to join. Must match an existing room name exactly.
password
string
Password for private rooms. Required if joining a private room.

Response

message
string
Confirmation message indicating successful join
room_id
integer
The unique ID of the joined room
room_name
string
The name of the joined room

Status Codes

  • 200: Successfully joined the room
  • 400: Missing room name or token
  • 401: Unauthorized - invalid or missing token
  • 403: Password required or wrong password for private room
  • 404: Room not found

Error Responses

Missing Fields

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

Unauthorized

{
  "error": "unauthorized"
}

Room Not Found

{
  "error": "room not found"
}

Password Required

{
  "error": "password required"
}

Wrong Password

{
  "error": "wrong password"
}

Example

Join Public Room

curl -X POST https://api.mirage.com/api/join_room \
  -H "Authorization: your-auth-token" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "General Discussion"
  }'

Join Private Room

curl -X POST https://api.mirage.com/api/join_room \
  -H "Authorization: your-auth-token" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Secret Club",
    "password": "secure-password"
  }'

Success Response

{
  "message": "john_doe joined room \"General Discussion\"",
  "room_id": 42,
  "room_name": "General Discussion"
}

Notes

  • If a user is already a member of the room, their membership is updated with a new joined_at timestamp.
  • Private rooms require the correct password to join.
  • Public rooms can be joined without a password.

Build docs developers (and LLMs) love