---
allOf:
  - $ref: core-event-schema/state_event.yaml
description: |
  A room may have one of the following designations:
  * `public` - anyone can join the room without any prior action.
  * `invite` - a user must first receive an invite from someone already in the room
    in order to join.
  * `knock` - a user can request an invite to the room. They can be allowed (invited)
    or denied (kicked/banned) access. Otherwise, users need to be invited in. Only
    available in rooms [which support knocking](/rooms/#feature-matrix).
  * `restricted` - anyone able to satisfy at least one of the allow conditions is
    able to join the room without prior action. Otherwise, an invite is required.
    Only available in rooms [which support the join rule](/rooms/#feature-matrix).
  * `knock_restricted` - a user can request an invite using the same functions offered
    by the `knock` join rule, or can attempt to join having satisfied an allow condition
    per the `restricted` join rule. Only available in rooms
    [which support the join rule](/rooms/#feature-matrix).
  * `private` - reserved without implementation. No significant meaning.
properties:
  content:
    properties:
      join_rule:
        description: The type of rules used for users wishing to join this room.
        enum:
          - public
          - knock
          - invite
          - private
          - restricted
          - knock_restricted
        type: string
      allow:
        x-addedInMatrixVersion: "1.2"
        description: |-
          For `restricted` rooms, the conditions the user will be tested against. The
          user needs only to satisfy one of the conditions to join the `restricted`
          room. If the user fails to meet any condition, or the condition is unable
          to be confirmed as satisfied, then the user requires an invite to join the
          room. Improper or no `allow` conditions on a `restricted` join rule imply
          the room is effectively invite-only (no conditions can be satisfied).
        type: array
        items:
          type: object
          title: AllowCondition
          properties:
            type:
              type: string
              description: |-
                The type of condition:
                * `m.room_membership` - the user satisfies the condition if they are
                  joined to the referenced room.
              enum: ['m.room_membership']
            room_id:
              type: string
              description: |-
                Required if `type` is `m.room_membership`. The room ID to check the
                user's membership against. If the user is joined to this room, they
                satisfy the condition and thus are permitted to join the `restricted`
                room.
          required: ['type']
    required:
      - join_rule
    type: object
  state_key:
    description: A zero-length string.
    pattern: '^$'
    type: string
  type:
    enum:
      - m.room.join_rules
    type: string
title: Describes how users are allowed to join the room.
type: object
