2016-06-22 12:03:02 +02:00
---
2025-08-27 08:39:05 +02:00
$schema : https://json-schema.org/draft/2020-12/schema
2016-06-22 12:03:02 +02:00
allOf :
- $ref : core-event-schema/state_event.yaml
description : |-
2025-04-22 16:48:50 +02:00
Adjusts the membership state for a user in a room. It is preferable to use the membership APIs
(`/rooms/<room id>/invite` etc) when performing membership actions rather than adjusting the
state directly as there are a restricted set of valid transformations. For example, user A cannot
force user B to join a room, and trying to force this state change directly will fail.
2016-06-22 12:03:02 +02:00
The following membership states are specified :
2025-04-22 16:48:50 +02:00
- `invite` - The user has been invited to join a room, but has not yet joined it. They may not
participate in the room until they join.
- `join` - The user has joined the room (possibly after accepting an invite), and may participate
in it.
- `leave` - The user was once joined to the room, but has since left (possibly by choice, or
possibly by being kicked).
- `ban` - The user has been banned from the room, and is no longer allowed to join it until they
are un-banned from the room (by having their membership state set to a value other than `ban`).
- `knock` - The user has knocked on the room, requesting permission to participate. They may not
participate in the room until they join.
2016-06-22 12:03:02 +02:00
2025-04-22 16:48:50 +02:00
The `third_party_invite` property will be set if this invite is an `invite` event and is the
successor of an [`m.room.third_party_invite`](/client-server-api/#mroomthird_party_invite) event,
and absent otherwise.
2016-06-22 12:03:02 +02:00
2021-01-27 21:14:31 +01:00
This event may also include an `invite_room_state` key inside the event's `unsigned` data.
2022-01-05 18:57:59 +01:00
If present, this contains an array of [stripped state events](/client-server-api/#stripped-state)
to assist the receiver in identifying the room.
2019-05-30 05:44:50 +02:00
2021-01-27 21:14:31 +01:00
The user for which a membership applies is represented by the `state_key`. Under some conditions,
the `sender` and `state_key` may not match - this may be interpreted as the `sender` affecting
the membership state of the `state_key` user.
2019-05-30 05:44:50 +02:00
2021-01-27 21:14:31 +01:00
The `membership` for a given user can change over time. The table below represents the various changes
2019-05-30 05:44:50 +02:00
over time and how clients and servers must interpret those changes. Previous membership can be retrieved
2021-01-27 21:14:31 +01:00
from the `prev_content` object on an event. If not present, the user's previous membership must be assumed
as `leave`.
2019-05-30 05:44:50 +02:00
2022-02-22 18:30:37 +01:00
| | to `invite` | to `join` | to `leave` | to `ban` | to `knock` |
|-------------------|----------------------|----------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|----------------------|
| **from `invite`** | No change. | User joined the room. | If the `state_key` is the same as the `sender`, the user rejected the invite. Otherwise, the `state_key` user had their invite revoked. | User was banned. | User is re-knocking. |
| **from `join`** | Must never happen. | `displayname` or `avatar_url` changed. | If the `state_key` is the same as the `sender`, the user left. Otherwise, the `state_key` user was kicked. | User was kicked and banned. | Must never happen. |
| **from `leave`** | New invitation sent. | User joined. | No change. | User was banned. | User is knocking. |
| **from `ban`** | Must never happen. | Must never happen. | User was unbanned. | No change. | Must never happen. |
| **from `knock`** | Knock accepted. | Must never happen. | If the `state_key` is the same as the `sender`, the user retracted the knock. Otherwise, the `state_key` user had their knock denied. | User was banned. | No change. |
2019-05-30 05:44:50 +02:00
2016-06-22 12:03:02 +02:00
properties :
content :
properties :
avatar_url :
2020-05-25 17:42:54 +02:00
description : 'The avatar URL for this user, if any.'
2016-06-22 12:03:02 +02:00
type : string
2021-08-09 08:54:34 +02:00
format : uri
2016-06-22 12:03:02 +02:00
displayname :
2020-05-25 17:42:54 +02:00
description : 'The display name for this user, if any.'
2016-06-22 12:03:02 +02:00
type :
2016-06-22 18:32:01 +02:00
- "string"
2016-06-22 12:03:02 +02:00
- "null"
membership :
description : The membership state of the user.
enum :
- invite
- join
- knock
- leave
- ban
type : string
2016-10-03 18:33:45 +02:00
is_direct :
2025-04-22 16:48:50 +02:00
description : |-
Flag indicating if the room containing this event was created with the intention of being
a direct chat. See [Direct Messaging](/client-server-api/#direct-messaging).
2016-10-03 18:33:45 +02:00
type : boolean
2022-01-18 17:55:34 +01:00
join_authorised_via_users_server :
x-addedInMatrixVersion : "1.2"
type : string
description : |-
2025-04-22 16:48:50 +02:00
Usually found on `join` events, this field is used to denote which homeserver (through
representation of a user with sufficient power level) authorised the user's join. More
information about this field can be found in the [Restricted Rooms Specification](/client-server-api/#restricted-rooms).
2022-01-18 17:55:34 +01:00
2025-04-22 16:48:50 +02:00
Client and server implementations should be aware of the [signing implications](/rooms/v8/#authorization-rules)
of including this field in further events : in particular, the event must be signed by the
server which owns the user ID in the field. When copying the membership event's `content`
(for profile updates and similar) it is therefore encouraged to exclude this field in the
copy, as otherwise the event might fail event authorization.
2020-09-30 21:43:56 +02:00
reason :
2021-10-14 21:23:04 +02:00
x-addedInMatrixVersion : "1.1"
2020-09-30 21:43:56 +02:00
type : string
description : |-
2025-04-22 16:48:50 +02:00
Optional user-supplied text for why their membership has changed. For kicks and bans,
this is typically the reason for the kick or ban. For other membership changes, this is a
way for the user to communicate their intent without having to send a message to the
room, such as in a case where Bob rejects an invite from Alice about an upcoming concert,
but can't make it that day.
2020-09-30 21:43:56 +02:00
2025-04-22 16:48:50 +02:00
Clients are not recommended to show this reason to users when receiving an invite due to
the potential for spam and abuse. Hiding the reason behind a button or other component is
recommended.
2016-06-22 12:03:02 +02:00
third_party_invite :
2025-04-22 16:48:50 +02:00
title : ThirdPartyInvite
description : |-
A third-party invite, if this `m.room.member` is the successor to an
[ `m.room.third_party_invite`](/client-server-api/#mroomthird_party_invite)
event.
type : object
2016-06-22 12:03:02 +02:00
properties :
display_name :
2025-04-22 16:48:50 +02:00
description : |-
A name which can be displayed to represent the user instead of their
third-party identifier
2016-06-22 12:03:02 +02:00
type : string
signed :
2025-04-22 16:48:50 +02:00
$ref : components/signed_third_party_invite.yaml
2016-06-22 12:03:02 +02:00
required :
- display_name
- signed
required :
- membership
title : EventContent
type : object
state_key :
2018-08-28 21:06:52 +02:00
description : |-
2021-01-27 21:14:31 +01:00
The `user_id` this membership event relates to. In all cases except for when `membership` is
`join`, the user ID sending the event does not need to match the user ID in the `state_key`,
2018-08-28 21:06:52 +02:00
unlike other events. Regular authorisation rules still apply.
2016-06-22 12:03:02 +02:00
type : string
type :
enum :
- m.room.member
type : string
2020-06-01 05:37:18 +02:00
unsigned :
2020-06-01 05:41:29 +02:00
allOf :
- $ref : "core-event-schema/unsigned_prop.yaml"
- type : object
properties :
invite_room_state :
2025-09-12 21:47:13 +02:00
x-changedInMatrixVersion :
"1.16": |
`m.room.create` was made a required event type for stripped state.
2021-04-29 03:50:13 +02:00
description : |-
A subset of the state of the room at the time of the invite, if `membership` is `invite`.
Note that this state is informational, and SHOULD NOT be trusted; once the client has
joined the room, it SHOULD fetch the live state from the server and discard the
invite_room_state. Also, clients must not rely on any particular state being present here;
they SHOULD behave properly (with possibly a degraded but not a broken experience) in
the absence of any particular events here. If they are set on the room, at least the
state for `m.room.avatar`, `m.room.canonical_alias`, `m.room.join_rules`, and `m.room.name`
2025-09-12 21:47:13 +02:00
SHOULD be included. The `m.room.create` event MUST be included, though MAY be missing if
the server hasn't updated to support the Matrix 1.16 specification.
2021-04-29 03:50:13 +02:00
items :
2022-01-05 18:57:59 +01:00
$ref : "core-event-schema/stripped_state.yaml"
2021-04-29 03:50:13 +02:00
type : array
knock_room_state :
2025-09-12 21:47:13 +02:00
x-changedInMatrixVersion :
"1.16": |
`m.room.create` was made a required event type for stripped state.
2021-04-29 03:50:13 +02:00
description : |-
A subset of the state of the room at the time of the knock, if `membership` is `knock`.
This has the same restrictions as `invite_room_state`. If they are set on the room, at least
the state for `m.room.avatar`, `m.room.canonical_alias`, `m.room.join_rules`, `m.room.name`,
2025-09-12 21:47:13 +02:00
and `m.room.encryption` SHOULD be included. The `m.room.create` event MUST be included,
though MAY be missing if the server hasn't updated to support the Matrix 1.16 specification.
2020-06-01 05:41:29 +02:00
items :
2022-01-05 18:57:59 +01:00
$ref : "core-event-schema/stripped_state.yaml"
2020-06-01 05:41:29 +02:00
type : array
2016-06-22 12:03:02 +02:00
title : The current membership state of a user in the room.
type : object