#房间 API
#创建房间
POST /_matrix/client/v3/createRoom{
"name": "综合讨论",
"topic": "一般性讨论的房间",
"room_alias_name": "general",
"visibility": "public",
"room_version": "10",
"creation_content": {
"type": "m.space"
},
"initial_state": [
{
"type": "m.room.history_visibility",
"state_key": "",
"content": { "history_visibility": "shared" }
}
],
"invite": ["@bob:localhost"],
"is_direct": false
}通过 creation_content.type = "m.space" 支持空间创建。
#发送消息
PUT /_matrix/client/v3/rooms/{roomId}/send/{eventType}/{txnId}{
"msgtype": "m.text",
"body": "你好,Matrix!"
}#发送状态事件
PUT /_matrix/client/v3/rooms/{roomId}/state/{eventType}/{stateKey}#房间成员
#加入
POST /_matrix/client/v3/join/{roomIdOrAlias}#邀请
POST /_matrix/client/v3/rooms/{roomId}/invite{ "user_id": "@bob:localhost" }#退出
POST /_matrix/client/v3/rooms/{roomId}/leave#封禁
POST /_matrix/client/v3/rooms/{roomId}/ban{ "user_id": "@bob:localhost", "reason": "垃圾信息" }#房间状态
GET /_matrix/client/v3/rooms/{roomId}/state返回所有当前状态事件。
GET /_matrix/client/v3/rooms/{roomId}/state/{eventType}/{stateKey}返回特定的状态事件。
#撤回事件
PUT /_matrix/client/v3/rooms/{roomId}/redact/{eventId}/{txnId}{ "reason": "不当内容" }#已加入的房间
GET /_matrix/client/v3/joined_rooms{ "joined_rooms": ["!abc:localhost", "!def:localhost"] }#公共房间
GET /_matrix/client/v3/publicRooms返回已发布的房间,包含从状态事件填充的名称、话题、头像。
#房间目录
GET /_matrix/client/v3/directory/room/{roomAlias}
PUT /_matrix/client/v3/directory/room/{roomAlias}
DELETE /_matrix/client/v3/directory/room/{roomAlias}#关系(v1)
GET /_matrix/client/v1/rooms/{roomId}/relations/{eventId}
GET /_matrix/client/v1/rooms/{roomId}/relations/{eventId}/{relType}
GET /_matrix/client/v1/rooms/{roomId}/relations/{eventId}/{relType}/{eventType}返回关联事件(线程、批注、编辑),支持分页。
#层级(v1)
GET /_matrix/client/v1/rooms/{roomId}/hierarchy返回空间层级树及房间元数据。