curl -sS -X PUT 'https://matrix.example.com/_matrix/client/v3/rooms/!abc123:example.com/state/m.room.join_rules' -H "Authorization: Bearer $ACCESS_TOKEN" -d '{"join_rule":"invite"}'

Category: Matrix & Synapse

curl -sS -X PUT 'https://matrix.example.com/_matrix/client/v3/rooms/!abc123:example.com/state/m.room.join_rules' -H "Authorization: Bearer $ACCESS_TOKEN" -d '{"join_rule":"invite"}'

Set a room's join rule to invite-only

Changes how people can enter the room: invite means only invited users join, public means anyone can, knock lets users request entry, and restricted allows membership from specific spaces. Setting invite is the usual way to lock down a room that was public. Room state changes apply immediately to all members. The admin state endpoint can do the same without membership.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.