Team Chat API
Endpoint: GET/POST /api/team-chat.php
Auth: Session + CSRF
Actions
rooms — List Rooms
GET /api/team-chat.php?action=roomsReturns rooms the user belongs to with participant count, last message, and unread count.
messages — Get Messages
GET /api/team-chat.php?action=messages&room_id=1&limit=50| Parameter | Type | Default | Description |
|---|---|---|---|
room_id | integer | required | Room ID |
before | timestamp | — | Get messages before this time |
limit | integer | 50 | Max messages |
send — Send Message
POST /api/team-chat.php?action=send
Content-Type: application/json
{
"room_id": 1,
"content": "Hello team! @Aurora can you help?"
}If the message contains @Aurora, the AI processing pipeline is triggered automatically.
edit — Edit Message
POST /api/team-chat.php?action=edit
Content-Type: application/json
{
"message_id": 42,
"content": "Updated message content"
}Only the message author can edit.
delete — Delete Message
POST /api/team-chat.php?action=delete
Content-Type: application/json
{
"message_id": 42
}Authors can delete their own messages. Admins can delete any message in rooms they belong to.
poll — Poll for Updates
GET /api/team-chat.php?action=poll&room_id=1&after=2026-02-21T12:00:00ZReturns new messages since the after timestamp, plus typing indicators for the room.
create_room — Create Room
POST /api/team-chat.php?action=create_room
Content-Type: application/json
{
"name": "Project Alpha",
"type": "channel",
"participants": [2, 3, 5]
}| Parameter | Type | Description |
|---|---|---|
name | string | Room display name |
type | string | "channel" or "dm" |
participants | array | User IDs to add |
The creator is automatically added as a participant.
delete_room — Delete Room
POST /api/team-chat.php?action=delete_room
Content-Type: application/json
{
"room_id": 1
}Only the room creator or an admin can delete a room. Cascade deletes:
- All messages
- All participant records
- All shared files (from disk)
react — Toggle Reaction
POST /api/team-chat.php?action=react
Content-Type: application/json
{
"message_id": 42,
"emoji": "👍"
}Toggles the reaction — adds if not present, removes if already reacted.
typing — Send Typing Indicator
POST /api/team-chat.php?action=typing
Content-Type: application/json
{
"room_id": 1
}presence — Update Presence
POST /api/team-chat.php?action=presence
Content-Type: application/json
{
"room_id": 1
}Updates last_active timestamp for the user in the room.
online — Get Online Users
GET /api/team-chat.php?action=onlineReturns users active within the last 2 minutes.
read — Mark Room as Read
POST /api/team-chat.php?action=read
Content-Type: application/json
{
"room_id": 1
}search — Search Messages
GET /api/team-chat.php?action=search&query=meeting&room_id=1Searches messages using ILIKE. If room_id is provided, searches only in that room (membership verified).
users — List All Users
GET /api/team-chat.php?action=usersReturns all users with id, username, display_name, avatar_color.
unread — Get Unread Counts
GET /api/team-chat.php?action=unreadReturns unread message count per room.