Skip to main content

Matrix Rooms

Rooms are the fundamental unit of communication in Matrix.

Room Identifiers

Room ID

Internal, permanent identifier:

!abc123xyz:example.com
  • Starts with !
  • Globally unique
  • Never changes

Room Alias

Human-readable address:

#general:example.com
  • Starts with #
  • Can be changed/deleted
  • Multiple aliases per room

Room Creation

POST /_matrix/client/v3/createRoom

{
"room_version": "11",
"name": "My Room",
"topic": "Discussion topic",
"preset": "private_chat",
"is_direct": false,
"initial_state": [...],
"invite": ["@user:example.com"]
}

Presets

PresetJoin RulesHistoryEncryption
private_chatinvitesharedoptional
trusted_private_chatinvitesharedrecommended
public_chatpublicsharednot set

Room State

State defines room properties:

State EventPurpose
m.room.nameRoom name
m.room.topicRoom topic
m.room.avatarRoom icon
m.room.canonical_aliasMain alias
m.room.join_rulesWho can join
m.room.history_visibilityWho sees history
m.room.guest_accessGuest permissions
m.room.power_levelsPermissions
m.room.encryptionE2EE settings

Join Rules

{
"type": "m.room.join_rules",
"content": {
"join_rule": "invite"
}
}
RuleDescription
publicAnyone can join
inviteMust be invited
knockCan request to join
restrictedSpace members can join
knock_restrictedKnock + restricted

History Visibility

{
"type": "m.room.history_visibility",
"content": {
"history_visibility": "shared"
}
}
SettingDescription
world_readableAnyone (even non-members)
sharedAll members (past and present)
invitedFrom invitation onward
joinedFrom join onward

Spaces

Spaces are rooms with m.space type:

{
"creation_content": {
"type": "m.space"
}
}

Space Children

{
"type": "m.space.child",
"state_key": "!child:example.com",
"content": {
"via": ["example.com"],
"order": "a",
"suggested": true
}
}

Space Parents

{
"type": "m.space.parent",
"state_key": "!parent:example.com",
"content": {
"via": ["example.com"],
"canonical": true
}
}

Room Upgrades

Rooms can be upgraded to new versions:

  1. Create new room with new version
  2. Tombstone old room
  3. Auto-redirect clients

Tombstone event:

{
"type": "m.room.tombstone",
"content": {
"body": "Room upgraded",
"replacement_room": "!newroom:example.com"
}
}

Resources


Next: Hidden Gems