summary refs log tree commit diff
path: root/latest/admin_api/rooms.html
blob: 98bcfbf739269b4c31c14393777e3beb57d657db (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
<!DOCTYPE HTML>
<html lang="en" class="sidebar-visible no-js light">
    <head>
        <!-- Book generated using mdBook -->
        <meta charset="UTF-8">
        <title>Rooms - Synapse</title>
        
        


        <!-- Custom HTML head -->
        


        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="theme-color" content="#ffffff" />

        
        <link rel="icon" href="../favicon.svg">
        
        
        <link rel="shortcut icon" href="../favicon.png">
        
        <link rel="stylesheet" href="../css/variables.css">
        <link rel="stylesheet" href="../css/general.css">
        <link rel="stylesheet" href="../css/chrome.css">
        
        <link rel="stylesheet" href="../css/print.css" media="print">
        

        <!-- Fonts -->
        <link rel="stylesheet" href="../FontAwesome/css/font-awesome.css">
        
        <link rel="stylesheet" href="../fonts/fonts.css">
        

        <!-- Highlight.js Stylesheets -->
        <link rel="stylesheet" href="../highlight.css">
        <link rel="stylesheet" href="../tomorrow-night.css">
        <link rel="stylesheet" href="../ayu-highlight.css">

        <!-- Custom theme stylesheets -->
        
        <link rel="stylesheet" href="../docs/website_files/table-of-contents.css">
        
        <link rel="stylesheet" href="../docs/website_files/remove-nav-buttons.css">
        
        <link rel="stylesheet" href="../docs/website_files/indent-section-headers.css">
        

        
    </head>
    <body>
        <!-- Provide site root to javascript -->
        <script type="text/javascript">
            var path_to_root = "../";
            var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "navy" : "light";
        </script>

        <!-- Work around some values being stored in localStorage wrapped in quotes -->
        <script type="text/javascript">
            try {
                var theme = localStorage.getItem('mdbook-theme');
                var sidebar = localStorage.getItem('mdbook-sidebar');
                if (theme.startsWith('"') && theme.endsWith('"')) {
                    localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
                }
                if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
                    localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
                }
            } catch (e) { }
        </script>

        <!-- Set the theme before any content is loaded, prevents flash -->
        <script type="text/javascript">
            var theme;
            try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
            if (theme === null || theme === undefined) { theme = default_theme; }
            var html = document.querySelector('html');
            html.classList.remove('no-js')
            html.classList.remove('light')
            html.classList.add(theme);
            html.classList.add('js');
        </script>

        <!-- Hide / unhide sidebar before it is displayed -->
        <script type="text/javascript">
            var html = document.querySelector('html');
            var sidebar = 'hidden';
            if (document.body.clientWidth >= 1080) {
                try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
                sidebar = sidebar || 'visible';
            }
            html.classList.remove('sidebar-visible');
            html.classList.add("sidebar-" + sidebar);
        </script>

        <nav id="sidebar" class="sidebar" aria-label="Table of contents">
            <div class="sidebar-scrollbox">
                <ol class="chapter"><li class="chapter-item expanded affix "><li class="part-title">Introduction</li><li class="chapter-item expanded "><a href="../welcome_and_overview.html">Welcome and Overview</a></li><li class="chapter-item expanded affix "><li class="part-title">Setup</li><li class="chapter-item expanded "><a href="../setup/installation.html">Installation</a></li><li class="chapter-item expanded "><a href="../postgres.html">Using Postgres</a></li><li class="chapter-item expanded "><a href="../reverse_proxy.html">Configuring a Reverse Proxy</a></li><li class="chapter-item expanded "><a href="../setup/forward_proxy.html">Configuring a Forward/Outbound Proxy</a></li><li class="chapter-item expanded "><a href="../turn-howto.html">Configuring a Turn Server</a></li><li class="chapter-item expanded "><a href="../delegate.html">Delegation</a></li><li class="chapter-item expanded affix "><li class="part-title">Upgrading</li><li class="chapter-item expanded "><a href="../upgrade.html">Upgrading between Synapse Versions</a></li><li class="chapter-item expanded "><a href="../MSC1711_certificates_FAQ.html">Upgrading from pre-Synapse 1.0</a></li><li class="chapter-item expanded affix "><li class="part-title">Usage</li><li class="chapter-item expanded "><a href="../federate.html">Federation</a></li><li class="chapter-item expanded "><a href="../usage/configuration/index.html">Configuration</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="../usage/configuration/homeserver_sample_config.html">Homeserver Sample Config File</a></li><li class="chapter-item expanded "><a href="../usage/configuration/logging_sample_config.html">Logging Sample Config File</a></li><li class="chapter-item expanded "><a href="../structured_logging.html">Structured Logging</a></li><li class="chapter-item expanded "><a href="../templates.html">Templates</a></li><li class="chapter-item expanded "><a href="../usage/configuration/user_authentication/index.html">User Authentication</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="../usage/configuration/user_authentication/single_sign_on/index.html">Single-Sign On</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="../openid.html">OpenID Connect</a></li><li class="chapter-item expanded "><a href="../usage/configuration/user_authentication/single_sign_on/saml.html">SAML</a></li><li class="chapter-item expanded "><a href="../usage/configuration/user_authentication/single_sign_on/cas.html">CAS</a></li><li class="chapter-item expanded "><a href="../sso_mapping_providers.html">SSO Mapping Providers</a></li></ol></li><li class="chapter-item expanded "><a href="../password_auth_providers.html">Password Auth Providers</a></li><li class="chapter-item expanded "><a href="../jwt.html">JSON Web Tokens</a></li></ol></li><li class="chapter-item expanded "><a href="../CAPTCHA_SETUP.html">Registration Captcha</a></li><li class="chapter-item expanded "><a href="../application_services.html">Application Services</a></li><li class="chapter-item expanded "><a href="../server_notices.html">Server Notices</a></li><li class="chapter-item expanded "><a href="../consent_tracking.html">Consent Tracking</a></li><li class="chapter-item expanded "><a href="../development/url_previews.html">URL Previews</a></li><li class="chapter-item expanded "><a href="../user_directory.html">User Directory</a></li><li class="chapter-item expanded "><a href="../message_retention_policies.html">Message Retention Policies</a></li><li class="chapter-item expanded "><a href="../modules/index.html">Pluggable Modules</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="../modules/writing_a_module.html">Writing a module</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="../modules/spam_checker_callbacks.html">Spam checker callbacks</a></li><li class="chapter-item expanded "><a href="../modules/third_party_rules_callbacks.html">Third-party rules callbacks</a></li><li class="chapter-item expanded "><a href="../modules/presence_router_callbacks.html">Presence router callbacks</a></li><li class="chapter-item expanded "><a href="../modules/account_validity_callbacks.html">Account validity callbacks</a></li><li class="chapter-item expanded "><a href="../modules/password_auth_provider_callbacks.html">Password auth provider callbacks</a></li><li class="chapter-item expanded "><a href="../modules/background_update_controller_callbacks.html">Background update controller callbacks</a></li><li class="chapter-item expanded "><a href="../modules/porting_legacy_module.html">Porting a legacy module to the new interface</a></li></ol></li></ol></li><li class="chapter-item expanded "><a href="../workers.html">Workers</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="../synctl_workers.html">Using synctl with Workers</a></li><li class="chapter-item expanded "><a href="../systemd-with-workers/index.html">Systemd</a></li></ol></li></ol></li><li class="chapter-item expanded "><a href="../usage/administration/index.html">Administration</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="../usage/administration/admin_api/index.html">Admin API</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="../admin_api/account_validity.html">Account Validity</a></li><li class="chapter-item expanded "><a href="../usage/administration/admin_api/background_updates.html">Background Updates</a></li><li class="chapter-item expanded "><a href="../admin_api/delete_group.html">Delete Group</a></li><li class="chapter-item expanded "><a href="../admin_api/event_reports.html">Event Reports</a></li><li class="chapter-item expanded "><a href="../admin_api/media_admin_api.html">Media</a></li><li class="chapter-item expanded "><a href="../admin_api/purge_history_api.html">Purge History</a></li><li class="chapter-item expanded "><a href="../admin_api/register_api.html">Register Users</a></li><li class="chapter-item expanded "><a href="../usage/administration/admin_api/registration_tokens.html">Registration Tokens</a></li><li class="chapter-item expanded "><a href="../admin_api/room_membership.html">Manipulate Room Membership</a></li><li class="chapter-item expanded "><a href="../admin_api/rooms.html" class="active">Rooms</a></li><li class="chapter-item expanded "><a href="../admin_api/server_notices.html">Server Notices</a></li><li class="chapter-item expanded "><a href="../admin_api/statistics.html">Statistics</a></li><li class="chapter-item expanded "><a href="../admin_api/user_admin_api.html">Users</a></li><li class="chapter-item expanded "><a href="../admin_api/version_api.html">Server Version</a></li><li class="chapter-item expanded "><a href="../usage/administration/admin_api/federation.html">Federation</a></li></ol></li><li class="chapter-item expanded "><a href="../manhole.html">Manhole</a></li><li class="chapter-item expanded "><a href="../metrics-howto.html">Monitoring</a></li><li class="chapter-item expanded "><a href="../usage/administration/understanding_synapse_through_grafana_graphs.html">Understanding Synapse Through Grafana Graphs</a></li><li class="chapter-item expanded "><a href="../usage/administration/useful_sql_for_admins.html">Useful SQL for Admins</a></li><li class="chapter-item expanded "><a href="../usage/administration/database_maintenance_tools.html">Database Maintenance Tools</a></li><li class="chapter-item expanded "><a href="../usage/administration/state_groups.html">State Groups</a></li><li class="chapter-item expanded "><a href="../usage/administration/request_log.html">Request log format</a></li><li class="chapter-item expanded "><a href="../usage/administration/admin_faq.html">Admin FAQ</a></li><li class="chapter-item expanded "><div>Scripts</div></li></ol></li><li class="chapter-item expanded "><li class="part-title">Development</li><li class="chapter-item expanded "><a href="../development/contributing_guide.html">Contributing Guide</a></li><li class="chapter-item expanded "><a href="../code_style.html">Code Style</a></li><li class="chapter-item expanded "><a href="../development/git.html">Git Usage</a></li><li class="chapter-item expanded "><div>Testing</div></li><li class="chapter-item expanded "><a href="../opentracing.html">OpenTracing</a></li><li class="chapter-item expanded "><a href="../development/database_schema.html">Database Schemas</a></li><li class="chapter-item expanded "><a href="../development/experimental_features.html">Experimental features</a></li><li class="chapter-item expanded "><div>Synapse Architecture</div></li><li><ol class="section"><li class="chapter-item expanded "><a href="../log_contexts.html">Log Contexts</a></li><li class="chapter-item expanded "><a href="../replication.html">Replication</a></li><li class="chapter-item expanded "><a href="../tcp_replication.html">TCP Replication</a></li></ol></li><li class="chapter-item expanded "><a href="../development/internal_documentation/index.html">Internal Documentation</a></li><li><ol class="section"><li class="chapter-item expanded "><div>Single Sign-On</div></li><li><ol class="section"><li class="chapter-item expanded "><a href="../development/saml.html">SAML</a></li><li class="chapter-item expanded "><a href="../development/cas.html">CAS</a></li></ol></li><li class="chapter-item expanded "><a href="../development/room-dag-concepts.html">Room DAG concepts</a></li><li class="chapter-item expanded "><div>State Resolution</div></li><li><ol class="section"><li class="chapter-item expanded "><a href="../auth_chain_difference_algorithm.html">The Auth Chain Difference Algorithm</a></li></ol></li><li class="chapter-item expanded "><a href="../media_repository.html">Media Repository</a></li><li class="chapter-item expanded "><a href="../room_and_user_statistics.html">Room and User Statistics</a></li></ol></li><li class="chapter-item expanded "><div>Scripts</div></li><li class="chapter-item expanded affix "><li class="part-title">Other</li><li class="chapter-item expanded "><a href="../deprecation_policy.html">Dependency Deprecation Policy</a></li><li class="chapter-item expanded "><a href="../other/running_synapse_on_single_board_computers.html">Running Synapse on a Single-Board Computer</a></li></ol>
            </div>
            <div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
        </nav>

        <div id="page-wrapper" class="page-wrapper">

            <div class="page">
                
                <div id="menu-bar-hover-placeholder"></div>
                <div id="menu-bar" class="menu-bar sticky bordered">
                    <div class="left-buttons">
                        <button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
                            <i class="fa fa-bars"></i>
                        </button>
                        <button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
                            <i class="fa fa-paint-brush"></i>
                        </button>
                        <ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
                            <li role="none"><button role="menuitem" class="theme" id="light">Light (default)</button></li>
                            <li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
                            <li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
                            <li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
                            <li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
                        </ul>
                        
                        <button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
                            <i class="fa fa-search"></i>
                        </button>
                        
                    </div>

                    <h1 class="menu-title">Synapse</h1>

                    <div class="right-buttons">
                        
                        <a href="../print.html" title="Print this book" aria-label="Print this book">
                            <i id="print-button" class="fa fa-print"></i>
                        </a>
                        
                        
                        <a href="https://github.com/matrix-org/synapse" title="Git repository" aria-label="Git repository">
                            <i id="git-repository-button" class="fa fa-github"></i>
                        </a>
                        
                        
                        <a href="https://github.com/matrix-org/synapse/edit/develop/docs/admin_api/rooms.md" title="Suggest an edit" aria-label="Suggest an edit">
                            <i id="git-edit-button" class="fa fa-edit"></i>
                        </a>
                        

                    </div>
                </div>

                
                <div id="search-wrapper" class="hidden">
                    <form id="searchbar-outer" class="searchbar-outer">
                        <input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
                    </form>
                    <div id="searchresults-outer" class="searchresults-outer hidden">
                        <div id="searchresults-header" class="searchresults-header"></div>
                        <ul id="searchresults">
                        </ul>
                    </div>
                </div>
                

                <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
                <script type="text/javascript">
                    document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
                    document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
                    Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
                        link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
                    });
                </script>

                <div id="content" class="content">
                    <main>
                        <!-- Page table of contents -->
                        <div class="sidetoc">
                            <nav class="pagetoc"></nav>
                        </div>

                        <h1 id="contents"><a class="header" href="#contents">Contents</a></h1>
<ul>
<li><a href="#list-room-api">List Room API</a></li>
<li><a href="#room-details-api">Room Details API</a></li>
<li><a href="#room-members-api">Room Members API</a></li>
<li><a href="#room-state-api">Room State API</a></li>
<li><a href="#block-room-api">Block Room API</a></li>
<li><a href="#delete-room-api">Delete Room API</a>
<ul>
<li><a href="#version-1-old-version">Version 1 (old version)</a></li>
<li><a href="#version-2-new-version">Version 2 (new version)</a></li>
<li><a href="#status-of-deleting-rooms">Status of deleting rooms</a></li>
<li><a href="#undoing-room-shutdowns">Undoing room shutdowns</a></li>
</ul>
</li>
<li><a href="#make-room-admin-api">Make Room Admin API</a></li>
<li><a href="#forward-extremities-admin-api">Forward Extremities Admin API</a></li>
<li><a href="#event-context-api">Event Context API</a></li>
</ul>
<h1 id="list-room-api"><a class="header" href="#list-room-api">List Room API</a></h1>
<p>The List Room admin API allows server admins to get a list of rooms on their
server. There are various parameters available that allow for filtering and
sorting the returned list. This API supports pagination.</p>
<p><strong>Parameters</strong></p>
<p>The following query parameters are available:</p>
<ul>
<li>
<p><code>from</code> - Offset in the returned list. Defaults to <code>0</code>.</p>
</li>
<li>
<p><code>limit</code> - Maximum amount of rooms to return. Defaults to <code>100</code>.</p>
</li>
<li>
<p><code>order_by</code> - The method in which to sort the returned list of rooms. Valid values are:</p>
<ul>
<li><code>alphabetical</code> - Same as <code>name</code>. This is deprecated.</li>
<li><code>size</code> - Same as <code>joined_members</code>. This is deprecated.</li>
<li><code>name</code> - Rooms are ordered alphabetically by room name. This is the default.</li>
<li><code>canonical_alias</code> - Rooms are ordered alphabetically by main alias address of the room.</li>
<li><code>joined_members</code> - Rooms are ordered by the number of members. Largest to smallest.</li>
<li><code>joined_local_members</code> - Rooms are ordered by the number of local members. Largest to smallest.</li>
<li><code>version</code> - Rooms are ordered by room version. Largest to smallest.</li>
<li><code>creator</code> - Rooms are ordered alphabetically by creator of the room.</li>
<li><code>encryption</code> - Rooms are ordered alphabetically by the end-to-end encryption algorithm.</li>
<li><code>federatable</code> - Rooms are ordered by whether the room is federatable.</li>
<li><code>public</code> - Rooms are ordered by visibility in room list.</li>
<li><code>join_rules</code> - Rooms are ordered alphabetically by join rules of the room.</li>
<li><code>guest_access</code> - Rooms are ordered alphabetically by guest access option of the room.</li>
<li><code>history_visibility</code> - Rooms are ordered alphabetically by visibility of history of the room.</li>
<li><code>state_events</code> - Rooms are ordered by number of state events. Largest to smallest.</li>
</ul>
</li>
<li>
<p><code>dir</code> - Direction of room order. Either <code>f</code> for forwards or <code>b</code> for backwards. Setting
this value to <code>b</code> will reverse the above sort order. Defaults to <code>f</code>.</p>
</li>
<li>
<p><code>search_term</code> - Filter rooms by their room name, canonical alias and room id.
Specifically, rooms are selected if the search term is contained in</p>
<ul>
<li>the room's name,</li>
<li>the local part of the room's canonical alias, or</li>
<li>the complete (local and server part) room's id (case sensitive).</li>
</ul>
<p>Defaults to no filtering.</p>
</li>
</ul>
<p><strong>Response</strong></p>
<p>The following fields are possible in the JSON response body:</p>
<ul>
<li><code>rooms</code> - An array of objects, each containing information about a room.
<ul>
<li>Room objects contain the following fields:
<ul>
<li><code>room_id</code> - The ID of the room.</li>
<li><code>name</code> - The name of the room.</li>
<li><code>canonical_alias</code> - The canonical (main) alias address of the room.</li>
<li><code>joined_members</code> - How many users are currently in the room.</li>
<li><code>joined_local_members</code> - How many local users are currently in the room.</li>
<li><code>version</code> - The version of the room as a string.</li>
<li><code>creator</code> - The <code>user_id</code> of the room creator.</li>
<li><code>encryption</code> - Algorithm of end-to-end encryption of messages. Is <code>null</code> if encryption is not active.</li>
<li><code>federatable</code> - Whether users on other servers can join this room.</li>
<li><code>public</code> - Whether the room is visible in room directory.</li>
<li><code>join_rules</code> - The type of rules used for users wishing to join this room. One of: [&quot;public&quot;, &quot;knock&quot;, &quot;invite&quot;, &quot;private&quot;].</li>
<li><code>guest_access</code> - Whether guests can join the room. One of: [&quot;can_join&quot;, &quot;forbidden&quot;].</li>
<li><code>history_visibility</code> - Who can see the room history. One of: [&quot;invited&quot;, &quot;joined&quot;, &quot;shared&quot;, &quot;world_readable&quot;].</li>
<li><code>state_events</code> - Total number of state_events of a room. Complexity of the room.</li>
</ul>
</li>
</ul>
</li>
<li><code>offset</code> - The current pagination offset in rooms. This parameter should be
used instead of <code>next_token</code> for room offset as <code>next_token</code> is
not intended to be parsed.</li>
<li><code>total_rooms</code> - The total number of rooms this query can return. Using this
and <code>offset</code>, you have enough information to know the current
progression through the list.</li>
<li><code>next_batch</code> - If this field is present, we know that there are potentially
more rooms on the server that did not all fit into this response.
We can use <code>next_batch</code> to get the &quot;next page&quot; of results. To do
so, simply repeat your request, setting the <code>from</code> parameter to
the value of <code>next_batch</code>.</li>
<li><code>prev_batch</code> - If this field is present, it is possible to paginate backwards.
Use <code>prev_batch</code> for the <code>from</code> value in the next request to
get the &quot;previous page&quot; of results.</li>
</ul>
<p>The API is:</p>
<p>A standard request with no filtering:</p>
<pre><code>GET /_synapse/admin/v1/rooms
</code></pre>
<p>A response body like the following is returned:</p>
<pre><code class="language-json">{
  &quot;rooms&quot;: [
    {
      &quot;room_id&quot;: &quot;!OGEhHVWSdvArJzumhm:matrix.org&quot;,
      &quot;name&quot;: &quot;Matrix HQ&quot;,
      &quot;canonical_alias&quot;: &quot;#matrix:matrix.org&quot;,
      &quot;joined_members&quot;: 8326,
      &quot;joined_local_members&quot;: 2,
      &quot;version&quot;: &quot;1&quot;,
      &quot;creator&quot;: &quot;@foo:matrix.org&quot;,
      &quot;encryption&quot;: null,
      &quot;federatable&quot;: true,
      &quot;public&quot;: true,
      &quot;join_rules&quot;: &quot;invite&quot;,
      &quot;guest_access&quot;: null,
      &quot;history_visibility&quot;: &quot;shared&quot;,
      &quot;state_events&quot;: 93534
    },
    ... (8 hidden items) ...
    {
      &quot;room_id&quot;: &quot;!xYvNcQPhnkrdUmYczI:matrix.org&quot;,
      &quot;name&quot;: &quot;This Week In Matrix (TWIM)&quot;,
      &quot;canonical_alias&quot;: &quot;#twim:matrix.org&quot;,
      &quot;joined_members&quot;: 314,
      &quot;joined_local_members&quot;: 20,
      &quot;version&quot;: &quot;4&quot;,
      &quot;creator&quot;: &quot;@foo:matrix.org&quot;,
      &quot;encryption&quot;: &quot;m.megolm.v1.aes-sha2&quot;,
      &quot;federatable&quot;: true,
      &quot;public&quot;: false,
      &quot;join_rules&quot;: &quot;invite&quot;,
      &quot;guest_access&quot;: null,
      &quot;history_visibility&quot;: &quot;shared&quot;,
      &quot;state_events&quot;: 8345
    }
  ],
  &quot;offset&quot;: 0,
  &quot;total_rooms&quot;: 10
}
</code></pre>
<p>Filtering by room name:</p>
<pre><code>GET /_synapse/admin/v1/rooms?search_term=TWIM
</code></pre>
<p>A response body like the following is returned:</p>
<pre><code class="language-json">{
  &quot;rooms&quot;: [
    {
      &quot;room_id&quot;: &quot;!xYvNcQPhnkrdUmYczI:matrix.org&quot;,
      &quot;name&quot;: &quot;This Week In Matrix (TWIM)&quot;,
      &quot;canonical_alias&quot;: &quot;#twim:matrix.org&quot;,
      &quot;joined_members&quot;: 314,
      &quot;joined_local_members&quot;: 20,
      &quot;version&quot;: &quot;4&quot;,
      &quot;creator&quot;: &quot;@foo:matrix.org&quot;,
      &quot;encryption&quot;: &quot;m.megolm.v1.aes-sha2&quot;,
      &quot;federatable&quot;: true,
      &quot;public&quot;: false,
      &quot;join_rules&quot;: &quot;invite&quot;,
      &quot;guest_access&quot;: null,
      &quot;history_visibility&quot;: &quot;shared&quot;,
      &quot;state_events&quot;: 8
    }
  ],
  &quot;offset&quot;: 0,
  &quot;total_rooms&quot;: 1
}
</code></pre>
<p>Paginating through a list of rooms:</p>
<pre><code>GET /_synapse/admin/v1/rooms?order_by=size
</code></pre>
<p>A response body like the following is returned:</p>
<pre><code class="language-json">{
  &quot;rooms&quot;: [
    {
      &quot;room_id&quot;: &quot;!OGEhHVWSdvArJzumhm:matrix.org&quot;,
      &quot;name&quot;: &quot;Matrix HQ&quot;,
      &quot;canonical_alias&quot;: &quot;#matrix:matrix.org&quot;,
      &quot;joined_members&quot;: 8326,
      &quot;joined_local_members&quot;: 2,
      &quot;version&quot;: &quot;1&quot;,
      &quot;creator&quot;: &quot;@foo:matrix.org&quot;,
      &quot;encryption&quot;: null,
      &quot;federatable&quot;: true,
      &quot;public&quot;: true,
      &quot;join_rules&quot;: &quot;invite&quot;,
      &quot;guest_access&quot;: null,
      &quot;history_visibility&quot;: &quot;shared&quot;,
      &quot;state_events&quot;: 93534
    },
    ... (98 hidden items) ...
    {
      &quot;room_id&quot;: &quot;!xYvNcQPhnkrdUmYczI:matrix.org&quot;,
      &quot;name&quot;: &quot;This Week In Matrix (TWIM)&quot;,
      &quot;canonical_alias&quot;: &quot;#twim:matrix.org&quot;,
      &quot;joined_members&quot;: 314,
      &quot;joined_local_members&quot;: 20,
      &quot;version&quot;: &quot;4&quot;,
      &quot;creator&quot;: &quot;@foo:matrix.org&quot;,
      &quot;encryption&quot;: &quot;m.megolm.v1.aes-sha2&quot;,
      &quot;federatable&quot;: true,
      &quot;public&quot;: false,
      &quot;join_rules&quot;: &quot;invite&quot;,
      &quot;guest_access&quot;: null,
      &quot;history_visibility&quot;: &quot;shared&quot;,
      &quot;state_events&quot;: 8345
    }
  ],
  &quot;offset&quot;: 0,
  &quot;total_rooms&quot;: 150,
  &quot;next_token&quot;: 100
}
</code></pre>
<p>The presence of the <code>next_token</code> parameter tells us that there are more rooms
than returned in this request, and we need to make another request to get them.
To get the next batch of room results, we repeat our request, setting the <code>from</code>
parameter to the value of <code>next_token</code>.</p>
<pre><code>GET /_synapse/admin/v1/rooms?order_by=size&amp;from=100
</code></pre>
<p>A response body like the following is returned:</p>
<pre><code class="language-json">{
  &quot;rooms&quot;: [
    {
      &quot;room_id&quot;: &quot;!mscvqgqpHYjBGDxNym:matrix.org&quot;,
      &quot;name&quot;: &quot;Music Theory&quot;,
      &quot;canonical_alias&quot;: &quot;#musictheory:matrix.org&quot;,
      &quot;joined_members&quot;: 127,
      &quot;joined_local_members&quot;: 2,
      &quot;version&quot;: &quot;1&quot;,
      &quot;creator&quot;: &quot;@foo:matrix.org&quot;,
      &quot;encryption&quot;: null,
      &quot;federatable&quot;: true,
      &quot;public&quot;: true,
      &quot;join_rules&quot;: &quot;invite&quot;,
      &quot;guest_access&quot;: null,
      &quot;history_visibility&quot;: &quot;shared&quot;,
      &quot;state_events&quot;: 93534
    },
    ... (48 hidden items) ...
    {
      &quot;room_id&quot;: &quot;!twcBhHVdZlQWuuxBhN:termina.org.uk&quot;,
      &quot;name&quot;: &quot;weechat-matrix&quot;,
      &quot;canonical_alias&quot;: &quot;#weechat-matrix:termina.org.uk&quot;,
      &quot;joined_members&quot;: 137,
      &quot;joined_local_members&quot;: 20,
      &quot;version&quot;: &quot;4&quot;,
      &quot;creator&quot;: &quot;@foo:termina.org.uk&quot;,
      &quot;encryption&quot;: null,
      &quot;federatable&quot;: true,
      &quot;public&quot;: true,
      &quot;join_rules&quot;: &quot;invite&quot;,
      &quot;guest_access&quot;: null,
      &quot;history_visibility&quot;: &quot;shared&quot;,
      &quot;state_events&quot;: 8345
    }
  ],
  &quot;offset&quot;: 100,
  &quot;prev_batch&quot;: 0,
  &quot;total_rooms&quot;: 150
}
</code></pre>
<p>Once the <code>next_token</code> parameter is no longer present, we know we've reached the
end of the list.</p>
<h1 id="room-details-api"><a class="header" href="#room-details-api">Room Details API</a></h1>
<p>The Room Details admin API allows server admins to get all details of a room.</p>
<p>The following fields are possible in the JSON response body:</p>
<ul>
<li><code>room_id</code> - The ID of the room.</li>
<li><code>name</code> - The name of the room.</li>
<li><code>topic</code> - The topic of the room.</li>
<li><code>avatar</code> - The <code>mxc</code> URI to the avatar of the room.</li>
<li><code>canonical_alias</code> - The canonical (main) alias address of the room.</li>
<li><code>joined_members</code> - How many users are currently in the room.</li>
<li><code>joined_local_members</code> - How many local users are currently in the room.</li>
<li><code>joined_local_devices</code> - How many local devices are currently in the room.</li>
<li><code>version</code> - The version of the room as a string.</li>
<li><code>creator</code> - The <code>user_id</code> of the room creator.</li>
<li><code>encryption</code> - Algorithm of end-to-end encryption of messages. Is <code>null</code> if encryption is not active.</li>
<li><code>federatable</code> - Whether users on other servers can join this room.</li>
<li><code>public</code> - Whether the room is visible in room directory.</li>
<li><code>join_rules</code> - The type of rules used for users wishing to join this room. One of: [&quot;public&quot;, &quot;knock&quot;, &quot;invite&quot;, &quot;private&quot;].</li>
<li><code>guest_access</code> - Whether guests can join the room. One of: [&quot;can_join&quot;, &quot;forbidden&quot;].</li>
<li><code>history_visibility</code> - Who can see the room history. One of: [&quot;invited&quot;, &quot;joined&quot;, &quot;shared&quot;, &quot;world_readable&quot;].</li>
<li><code>state_events</code> - Total number of state_events of a room. Complexity of the room.</li>
</ul>
<p>The API is:</p>
<pre><code>GET /_synapse/admin/v1/rooms/&lt;room_id&gt;
</code></pre>
<p>A response body like the following is returned:</p>
<pre><code class="language-json">{
  &quot;room_id&quot;: &quot;!mscvqgqpHYjBGDxNym:matrix.org&quot;,
  &quot;name&quot;: &quot;Music Theory&quot;,
  &quot;avatar&quot;: &quot;mxc://matrix.org/AQDaVFlbkQoErdOgqWRgiGSV&quot;,
  &quot;topic&quot;: &quot;Theory, Composition, Notation, Analysis&quot;,
  &quot;canonical_alias&quot;: &quot;#musictheory:matrix.org&quot;,
  &quot;joined_members&quot;: 127,
  &quot;joined_local_members&quot;: 2,
  &quot;joined_local_devices&quot;: 2,
  &quot;version&quot;: &quot;1&quot;,
  &quot;creator&quot;: &quot;@foo:matrix.org&quot;,
  &quot;encryption&quot;: null,
  &quot;federatable&quot;: true,
  &quot;public&quot;: true,
  &quot;join_rules&quot;: &quot;invite&quot;,
  &quot;guest_access&quot;: null,
  &quot;history_visibility&quot;: &quot;shared&quot;,
  &quot;state_events&quot;: 93534
}
</code></pre>
<h1 id="room-members-api"><a class="header" href="#room-members-api">Room Members API</a></h1>
<p>The Room Members admin API allows server admins to get a list of all members of a room.</p>
<p>The response includes the following fields:</p>
<ul>
<li><code>members</code> - A list of all the members that are present in the room, represented by their ids.</li>
<li><code>total</code> - Total number of members in the room.</li>
</ul>
<p>The API is:</p>
<pre><code>GET /_synapse/admin/v1/rooms/&lt;room_id&gt;/members
</code></pre>
<p>A response body like the following is returned:</p>
<pre><code class="language-json">{
  &quot;members&quot;: [
    &quot;@foo:matrix.org&quot;,
    &quot;@bar:matrix.org&quot;,
    &quot;@foobar:matrix.org&quot;
  ],
  &quot;total&quot;: 3
}
</code></pre>
<h1 id="room-state-api"><a class="header" href="#room-state-api">Room State API</a></h1>
<p>The Room State admin API allows server admins to get a list of all state events in a room.</p>
<p>The response includes the following fields:</p>
<ul>
<li><code>state</code> - The current state of the room at the time of request.</li>
</ul>
<p>The API is:</p>
<pre><code>GET /_synapse/admin/v1/rooms/&lt;room_id&gt;/state
</code></pre>
<p>A response body like the following is returned:</p>
<pre><code class="language-json">{
  &quot;state&quot;: [
    {&quot;type&quot;: &quot;m.room.create&quot;, &quot;state_key&quot;: &quot;&quot;, &quot;etc&quot;: true},
    {&quot;type&quot;: &quot;m.room.power_levels&quot;, &quot;state_key&quot;: &quot;&quot;, &quot;etc&quot;: true},
    {&quot;type&quot;: &quot;m.room.name&quot;, &quot;state_key&quot;: &quot;&quot;, &quot;etc&quot;: true}
  ]
}
</code></pre>
<h1 id="block-room-api"><a class="header" href="#block-room-api">Block Room API</a></h1>
<p>The Block Room admin API allows server admins to block and unblock rooms,
and query to see if a given room is blocked.
This API can be used to pre-emptively block a room, even if it's unknown to this
homeserver. Users will be prevented from joining a blocked room.</p>
<h2 id="block-or-unblock-a-room"><a class="header" href="#block-or-unblock-a-room">Block or unblock a room</a></h2>
<p>The API is:</p>
<pre><code>PUT /_synapse/admin/v1/rooms/&lt;room_id&gt;/block
</code></pre>
<p>with a body of:</p>
<pre><code class="language-json">{
    &quot;block&quot;: true
}
</code></pre>
<p>A response body like the following is returned:</p>
<pre><code class="language-json">{
    &quot;block&quot;: true
}
</code></pre>
<p><strong>Parameters</strong></p>
<p>The following parameters should be set in the URL:</p>
<ul>
<li><code>room_id</code> - The ID of the room.</li>
</ul>
<p>The following JSON body parameters are available:</p>
<ul>
<li><code>block</code> - If <code>true</code> the room will be blocked and if <code>false</code> the room will be unblocked.</li>
</ul>
<p><strong>Response</strong></p>
<p>The following fields are possible in the JSON response body:</p>
<ul>
<li><code>block</code> - A boolean. <code>true</code> if the room is blocked, otherwise <code>false</code></li>
</ul>
<h2 id="get-block-status"><a class="header" href="#get-block-status">Get block status</a></h2>
<p>The API is:</p>
<pre><code>GET /_synapse/admin/v1/rooms/&lt;room_id&gt;/block
</code></pre>
<p>A response body like the following is returned:</p>
<pre><code class="language-json">{
    &quot;block&quot;: true,
    &quot;user_id&quot;: &quot;&lt;user_id&gt;&quot;
}
</code></pre>
<p><strong>Parameters</strong></p>
<p>The following parameters should be set in the URL:</p>
<ul>
<li><code>room_id</code> - The ID of the room.</li>
</ul>
<p><strong>Response</strong></p>
<p>The following fields are possible in the JSON response body:</p>
<ul>
<li><code>block</code> - A boolean. <code>true</code> if the room is blocked, otherwise <code>false</code></li>
<li><code>user_id</code> - An optional string. If the room is blocked (<code>block</code> is <code>true</code>) shows
the user who has add the room to blocking list. Otherwise it is not displayed.</li>
</ul>
<h1 id="delete-room-api"><a class="header" href="#delete-room-api">Delete Room API</a></h1>
<p>The Delete Room admin API allows server admins to remove rooms from the server
and block these rooms.</p>
<p>Shuts down a room. Moves all local users and room aliases automatically to a
new room if <code>new_room_user_id</code> is set. Otherwise local users only
leave the room without any information.</p>
<p>The new room will be created with the user specified by the <code>new_room_user_id</code> parameter
as room administrator and will contain a message explaining what happened. Users invited
to the new room will have power level <code>-10</code> by default, and thus be unable to speak.</p>
<p>If <code>block</code> is <code>true</code>, users will be prevented from joining the old room.
This option can in <a href="#version-1-old-version">Version 1</a> also be used to pre-emptively
block a room, even if it's unknown to this homeserver. In this case, the room will be
blocked, and no further action will be taken. If <code>block</code> is <code>false</code>, attempting to
delete an unknown room is invalid and will be rejected as a bad request.</p>
<p>This API will remove all trace of the old room from your database after removing
all local users. If <code>purge</code> is <code>true</code> (the default), all traces of the old room will
be removed from your database after removing all local users. If you do not want
this to happen, set <code>purge</code> to <code>false</code>.
Depending on the amount of history being purged, a call to the API may take
several minutes or longer.</p>
<p>The local server will only have the power to move local user and room aliases to
the new room. Users on other servers will be unaffected.</p>
<p>To use it, you will need to authenticate by providing an <code>access_token</code> for a
server admin: see <a href="../usage/administration/admin_api">Admin API</a>.</p>
<h2 id="version-1-old-version"><a class="header" href="#version-1-old-version">Version 1 (old version)</a></h2>
<p>This version works synchronously. That means you only get the response once the server has
finished the action, which may take a long time. If you request the same action
a second time, and the server has not finished the first one, the second request will block.
This is fixed in version 2 of this API. The parameters are the same in both APIs.
This API will become deprecated in the future.</p>
<p>The API is:</p>
<pre><code>DELETE /_synapse/admin/v1/rooms/&lt;room_id&gt;
</code></pre>
<p>with a body of:</p>
<pre><code class="language-json">{
    &quot;new_room_user_id&quot;: &quot;@someuser:example.com&quot;,
    &quot;room_name&quot;: &quot;Content Violation Notification&quot;,
    &quot;message&quot;: &quot;Bad Room has been shutdown due to content violations on this server. Please review our Terms of Service.&quot;,
    &quot;block&quot;: true,
    &quot;purge&quot;: true
}
</code></pre>
<p>A response body like the following is returned:</p>
<pre><code class="language-json">{
    &quot;kicked_users&quot;: [
        &quot;@foobar:example.com&quot;
    ],
    &quot;failed_to_kick_users&quot;: [],
    &quot;local_aliases&quot;: [
        &quot;#badroom:example.com&quot;,
        &quot;#evilsaloon:example.com&quot;
    ],
    &quot;new_room_id&quot;: &quot;!newroomid:example.com&quot;
}
</code></pre>
<p>The parameters and response values have the same format as
<a href="#version-2-new-version">version 2</a> of the API.</p>
<h2 id="version-2-new-version"><a class="header" href="#version-2-new-version">Version 2 (new version)</a></h2>
<p><strong>Note</strong>: This API is new, experimental and &quot;subject to change&quot;.</p>
<p>This version works asynchronously, meaning you get the response from server immediately
while the server works on that task in background. You can then request the status of the action
to check if it has completed.</p>
<p>The API is:</p>
<pre><code>DELETE /_synapse/admin/v2/rooms/&lt;room_id&gt;
</code></pre>
<p>with a body of:</p>
<pre><code class="language-json">{
    &quot;new_room_user_id&quot;: &quot;@someuser:example.com&quot;,
    &quot;room_name&quot;: &quot;Content Violation Notification&quot;,
    &quot;message&quot;: &quot;Bad Room has been shutdown due to content violations on this server. Please review our Terms of Service.&quot;,
    &quot;block&quot;: true,
    &quot;purge&quot;: true
}
</code></pre>
<p>The API starts the shut down and purge running, and returns immediately with a JSON body with
a purge id:</p>
<pre><code class="language-json">{
    &quot;delete_id&quot;: &quot;&lt;opaque id&gt;&quot;
}
</code></pre>
<p><strong>Parameters</strong></p>
<p>The following parameters should be set in the URL:</p>
<ul>
<li><code>room_id</code> - The ID of the room.</li>
</ul>
<p>The following JSON body parameters are available:</p>
<ul>
<li><code>new_room_user_id</code> - Optional. If set, a new room will be created with this user ID
as the creator and admin, and all users in the old room will be moved into that
room. If not set, no new room will be created and the users will just be removed
from the old room. The user ID must be on the local server, but does not necessarily
have to belong to a registered user.</li>
<li><code>room_name</code> - Optional. A string representing the name of the room that new users will be
invited to. Defaults to <code>Content Violation Notification</code></li>
<li><code>message</code> - Optional. A string containing the first message that will be sent as
<code>new_room_user_id</code> in the new room. Ideally this will clearly convey why the
original room was shut down. Defaults to <code>Sharing illegal content on this server is not permitted and rooms in violation will be blocked.</code></li>
<li><code>block</code> - Optional. If set to <code>true</code>, this room will be added to a blocking list,
preventing future attempts to join the room. Rooms can be blocked
even if they're not yet known to the homeserver (only with
<a href="#version-1-old-version">Version 1</a> of the API). Defaults to <code>false</code>.</li>
<li><code>purge</code> - Optional. If set to <code>true</code>, it will remove all traces of the room from your database.
Defaults to <code>true</code>.</li>
<li><code>force_purge</code> - Optional, and ignored unless <code>purge</code> is <code>true</code>. If set to <code>true</code>, it
will force a purge to go ahead even if there are local users still in the room. Do not
use this unless a regular <code>purge</code> operation fails, as it could leave those users'
clients in a confused state.</li>
</ul>
<p>The JSON body must not be empty. The body must be at least <code>{}</code>.</p>
<h2 id="status-of-deleting-rooms"><a class="header" href="#status-of-deleting-rooms">Status of deleting rooms</a></h2>
<p><strong>Note</strong>: This API is new, experimental and &quot;subject to change&quot;.</p>
<p>It is possible to query the status of the background task for deleting rooms.
The status can be queried up to 24 hours after completion of the task,
or until Synapse is restarted (whichever happens first).</p>
<h3 id="query-by-room_id"><a class="header" href="#query-by-room_id">Query by <code>room_id</code></a></h3>
<p>With this API you can get the status of all active deletion tasks, and all those completed in the last 24h,
for the given <code>room_id</code>.</p>
<p>The API is:</p>
<pre><code>GET /_synapse/admin/v2/rooms/&lt;room_id&gt;/delete_status
</code></pre>
<p>A response body like the following is returned:</p>
<pre><code class="language-json">{
    &quot;results&quot;: [
        {
            &quot;delete_id&quot;: &quot;delete_id1&quot;,
            &quot;status&quot;: &quot;failed&quot;,
            &quot;error&quot;: &quot;error message&quot;,
            &quot;shutdown_room&quot;: {
                &quot;kicked_users&quot;: [],
                &quot;failed_to_kick_users&quot;: [],
                &quot;local_aliases&quot;: [],
                &quot;new_room_id&quot;: null
            }
        }, {
            &quot;delete_id&quot;: &quot;delete_id2&quot;,
            &quot;status&quot;: &quot;purging&quot;,
            &quot;shutdown_room&quot;: {
                &quot;kicked_users&quot;: [
                    &quot;@foobar:example.com&quot;
                ],
                &quot;failed_to_kick_users&quot;: [],
                &quot;local_aliases&quot;: [
                    &quot;#badroom:example.com&quot;,
                    &quot;#evilsaloon:example.com&quot;
                ],
                &quot;new_room_id&quot;: &quot;!newroomid:example.com&quot;
            }
        }
    ]
}
</code></pre>
<p><strong>Parameters</strong></p>
<p>The following parameters should be set in the URL:</p>
<ul>
<li><code>room_id</code> - The ID of the room.</li>
</ul>
<h3 id="query-by-delete_id"><a class="header" href="#query-by-delete_id">Query by <code>delete_id</code></a></h3>
<p>With this API you can get the status of one specific task by <code>delete_id</code>.</p>
<p>The API is:</p>
<pre><code>GET /_synapse/admin/v2/rooms/delete_status/&lt;delete_id&gt;
</code></pre>
<p>A response body like the following is returned:</p>
<pre><code class="language-json">{
    &quot;status&quot;: &quot;purging&quot;,
    &quot;shutdown_room&quot;: {
        &quot;kicked_users&quot;: [
            &quot;@foobar:example.com&quot;
        ],
        &quot;failed_to_kick_users&quot;: [],
        &quot;local_aliases&quot;: [
            &quot;#badroom:example.com&quot;,
            &quot;#evilsaloon:example.com&quot;
        ],
        &quot;new_room_id&quot;: &quot;!newroomid:example.com&quot;
    }
}
</code></pre>
<p><strong>Parameters</strong></p>
<p>The following parameters should be set in the URL:</p>
<ul>
<li><code>delete_id</code> - The ID for this delete.</li>
</ul>
<h3 id="response"><a class="header" href="#response">Response</a></h3>
<p>The following fields are returned in the JSON response body:</p>
<ul>
<li><code>results</code> - An array of objects, each containing information about one task.
This field is omitted from the result when you query by <code>delete_id</code>.
Task objects contain the following fields:
<ul>
<li><code>delete_id</code> - The ID for this purge if you query by <code>room_id</code>.</li>
<li><code>status</code> - The status will be one of:
<ul>
<li><code>shutting_down</code> - The process is removing users from the room.</li>
<li><code>purging</code> - The process is purging the room and event data from database.</li>
<li><code>complete</code> - The process has completed successfully.</li>
<li><code>failed</code> - The process is aborted, an error has occurred.</li>
</ul>
</li>
<li><code>error</code> - A string that shows an error message if <code>status</code> is <code>failed</code>.
Otherwise this field is hidden.</li>
<li><code>shutdown_room</code> - An object containing information about the result of shutting down the room.
<em>Note:</em> The result is shown after removing the room members.
The delete process can still be running. Please pay attention to the <code>status</code>.
<ul>
<li><code>kicked_users</code> - An array of users (<code>user_id</code>) that were kicked.</li>
<li><code>failed_to_kick_users</code> - An array of users (<code>user_id</code>) that that were not kicked.</li>
<li><code>local_aliases</code> - An array of strings representing the local aliases that were
migrated from the old room to the new.</li>
<li><code>new_room_id</code> - A string representing the room ID of the new room, or <code>null</code> if
no such room was created.</li>
</ul>
</li>
</ul>
</li>
</ul>
<h2 id="undoing-room-deletions"><a class="header" href="#undoing-room-deletions">Undoing room deletions</a></h2>
<p><em>Note</em>: This guide may be outdated by the time you read it. By nature of room deletions being performed at the database level,
the structure can and does change without notice.</p>
<p>First, it's important to understand that a room deletion is very destructive. Undoing a deletion is not as simple as pretending it
never happened - work has to be done to move forward instead of resetting the past. In fact, in some cases it might not be possible
to recover at all:</p>
<ul>
<li>If the room was invite-only, your users will need to be re-invited.</li>
<li>If the room no longer has any members at all, it'll be impossible to rejoin.</li>
<li>The first user to rejoin will have to do so via an alias on a different
server (or receive an invite from a user on a different server).</li>
</ul>
<p>With all that being said, if you still want to try and recover the room:</p>
<ol>
<li>
<p>If the room was <code>block</code>ed, you must unblock it on your server. This can be
accomplished as follows:</p>
<ol>
<li>For safety reasons, shut down Synapse.</li>
<li>In the database, run <code>DELETE FROM blocked_rooms WHERE room_id = '!example:example.org';</code>
<ul>
<li>For caution: it's recommended to run this in a transaction: <code>BEGIN; DELETE ...;</code>, verify you got 1 result, then <code>COMMIT;</code>.</li>
<li>The room ID is the same one supplied to the delete room API, not the Content Violation room.</li>
</ul>
</li>
<li>Restart Synapse.</li>
</ol>
<p>This step is unnecessary if <code>block</code> was not set.</p>
</li>
<li>
<p>Any room aliases on your server that pointed to the deleted room may have
been deleted, or redirected to the Content Violation room. These will need
to be restored manually.</p>
</li>
<li>
<p>Users on your server that were in the deleted room will have been kicked
from the room. Consider whether you want to update their membership
(possibly via the <a href="room_membership.html">Edit Room Membership API</a>) or let
them handle rejoining themselves.</p>
</li>
<li>
<p>If <code>new_room_user_id</code> was given, a 'Content Violation' will have been
created. Consider whether you want to delete that roomm.</p>
</li>
</ol>
<h1 id="make-room-admin-api"><a class="header" href="#make-room-admin-api">Make Room Admin API</a></h1>
<p>Grants another user the highest power available to a local user who is in the room.
If the user is not in the room, and it is not publicly joinable, then invite the user.</p>
<p>By default the server admin (the caller) is granted power, but another user can
optionally be specified, e.g.:</p>
<pre><code>POST /_synapse/admin/v1/rooms/&lt;room_id_or_alias&gt;/make_room_admin
{
    &quot;user_id&quot;: &quot;@foo:example.com&quot;
}
</code></pre>
<h1 id="forward-extremities-admin-api"><a class="header" href="#forward-extremities-admin-api">Forward Extremities Admin API</a></h1>
<p>Enables querying and deleting forward extremities from rooms. When a lot of forward
extremities accumulate in a room, performance can become degraded. For details, see
<a href="https://github.com/matrix-org/synapse/issues/1760">#1760</a>.</p>
<h2 id="check-for-forward-extremities"><a class="header" href="#check-for-forward-extremities">Check for forward extremities</a></h2>
<p>To check the status of forward extremities for a room:</p>
<pre><code>GET /_synapse/admin/v1/rooms/&lt;room_id_or_alias&gt;/forward_extremities
</code></pre>
<p>A response as follows will be returned:</p>
<pre><code class="language-json">{
  &quot;count&quot;: 1,
  &quot;results&quot;: [
    {
      &quot;event_id&quot;: &quot;$M5SP266vsnxctfwFgFLNceaCo3ujhRtg_NiiHabcdefgh&quot;,
      &quot;state_group&quot;: 439,
      &quot;depth&quot;: 123,
      &quot;received_ts&quot;: 1611263016761
    }
  ]
}
</code></pre>
<h2 id="deleting-forward-extremities"><a class="header" href="#deleting-forward-extremities">Deleting forward extremities</a></h2>
<p><strong>WARNING</strong>: Please ensure you know what you're doing and have read
the related issue <a href="https://github.com/matrix-org/synapse/issues/1760">#1760</a>.
Under no situations should this API be executed as an automated maintenance task!</p>
<p>If a room has lots of forward extremities, the extra can be
deleted as follows:</p>
<pre><code>DELETE /_synapse/admin/v1/rooms/&lt;room_id_or_alias&gt;/forward_extremities
</code></pre>
<p>A response as follows will be returned, indicating the amount of forward extremities
that were deleted.</p>
<pre><code class="language-json">{
  &quot;deleted&quot;: 1
}
</code></pre>
<h1 id="event-context-api"><a class="header" href="#event-context-api">Event Context API</a></h1>
<p>This API lets a client find the context of an event. This is designed primarily to investigate abuse reports.</p>
<pre><code>GET /_synapse/admin/v1/rooms/&lt;room_id&gt;/context/&lt;event_id&gt;
</code></pre>
<p>This API mimmicks <a href="https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-rooms-roomid-context-eventid">GET /_matrix/client/r0/rooms/{roomId}/context/{eventId}</a>. Please refer to the link for all details on parameters and reseponse.</p>
<p>Example response:</p>
<pre><code class="language-json">{
  &quot;end&quot;: &quot;t29-57_2_0_2&quot;,
  &quot;events_after&quot;: [
    {
      &quot;content&quot;: {
        &quot;body&quot;: &quot;This is an example text message&quot;,
        &quot;msgtype&quot;: &quot;m.text&quot;,
        &quot;format&quot;: &quot;org.matrix.custom.html&quot;,
        &quot;formatted_body&quot;: &quot;&lt;b&gt;This is an example text message&lt;/b&gt;&quot;
      },
      &quot;type&quot;: &quot;m.room.message&quot;,
      &quot;event_id&quot;: &quot;$143273582443PhrSn:example.org&quot;,
      &quot;room_id&quot;: &quot;!636q39766251:example.com&quot;,
      &quot;sender&quot;: &quot;@example:example.org&quot;,
      &quot;origin_server_ts&quot;: 1432735824653,
      &quot;unsigned&quot;: {
        &quot;age&quot;: 1234
      }
    }
  ],
  &quot;event&quot;: {
    &quot;content&quot;: {
      &quot;body&quot;: &quot;filename.jpg&quot;,
      &quot;info&quot;: {
        &quot;h&quot;: 398,
        &quot;w&quot;: 394,
        &quot;mimetype&quot;: &quot;image/jpeg&quot;,
        &quot;size&quot;: 31037
      },
      &quot;url&quot;: &quot;mxc://example.org/JWEIFJgwEIhweiWJE&quot;,
      &quot;msgtype&quot;: &quot;m.image&quot;
    },
    &quot;type&quot;: &quot;m.room.message&quot;,
    &quot;event_id&quot;: &quot;$f3h4d129462ha:example.com&quot;,
    &quot;room_id&quot;: &quot;!636q39766251:example.com&quot;,
    &quot;sender&quot;: &quot;@example:example.org&quot;,
    &quot;origin_server_ts&quot;: 1432735824653,
    &quot;unsigned&quot;: {
      &quot;age&quot;: 1234
    }
  },
  &quot;events_before&quot;: [
    {
      &quot;content&quot;: {
        &quot;body&quot;: &quot;something-important.doc&quot;,
        &quot;filename&quot;: &quot;something-important.doc&quot;,
        &quot;info&quot;: {
          &quot;mimetype&quot;: &quot;application/msword&quot;,
          &quot;size&quot;: 46144
        },
        &quot;msgtype&quot;: &quot;m.file&quot;,
        &quot;url&quot;: &quot;mxc://example.org/FHyPlCeYUSFFxlgbQYZmoEoe&quot;
      },
      &quot;type&quot;: &quot;m.room.message&quot;,
      &quot;event_id&quot;: &quot;$143273582443PhrSn:example.org&quot;,
      &quot;room_id&quot;: &quot;!636q39766251:example.com&quot;,
      &quot;sender&quot;: &quot;@example:example.org&quot;,
      &quot;origin_server_ts&quot;: 1432735824653,
      &quot;unsigned&quot;: {
        &quot;age&quot;: 1234
      }
    }
  ],
  &quot;start&quot;: &quot;t27-54_2_0_2&quot;,
  &quot;state&quot;: [
    {
      &quot;content&quot;: {
        &quot;creator&quot;: &quot;@example:example.org&quot;,
        &quot;room_version&quot;: &quot;1&quot;,
        &quot;m.federate&quot;: true,
        &quot;predecessor&quot;: {
          &quot;event_id&quot;: &quot;$something:example.org&quot;,
          &quot;room_id&quot;: &quot;!oldroom:example.org&quot;
        }
      },
      &quot;type&quot;: &quot;m.room.create&quot;,
      &quot;event_id&quot;: &quot;$143273582443PhrSn:example.org&quot;,
      &quot;room_id&quot;: &quot;!636q39766251:example.com&quot;,
      &quot;sender&quot;: &quot;@example:example.org&quot;,
      &quot;origin_server_ts&quot;: 1432735824653,
      &quot;unsigned&quot;: {
        &quot;age&quot;: 1234
      },
      &quot;state_key&quot;: &quot;&quot;
    },
    {
      &quot;content&quot;: {
        &quot;membership&quot;: &quot;join&quot;,
        &quot;avatar_url&quot;: &quot;mxc://example.org/SEsfnsuifSDFSSEF&quot;,
        &quot;displayname&quot;: &quot;Alice Margatroid&quot;
      },
      &quot;type&quot;: &quot;m.room.member&quot;,
      &quot;event_id&quot;: &quot;$143273582443PhrSn:example.org&quot;,
      &quot;room_id&quot;: &quot;!636q39766251:example.com&quot;,
      &quot;sender&quot;: &quot;@example:example.org&quot;,
      &quot;origin_server_ts&quot;: 1432735824653,
      &quot;unsigned&quot;: {
        &quot;age&quot;: 1234
      },
      &quot;state_key&quot;: &quot;@alice:example.org&quot;
    }
  ]
}
</code></pre>

                    </main>

                    <nav class="nav-wrapper" aria-label="Page navigation">
                        <!-- Mobile navigation buttons -->
                        
                            <a rel="prev" href="../admin_api/room_membership.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
                                <i class="fa fa-angle-left"></i>
                            </a>
                        

                        
                            <a rel="next" href="../admin_api/server_notices.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
                                <i class="fa fa-angle-right"></i>
                            </a>
                        

                        <div style="clear: both"></div>
                    </nav>
                </div>
            </div>

            <nav class="nav-wide-wrapper" aria-label="Page navigation">
                
                    <a rel="prev" href="../admin_api/room_membership.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
                        <i class="fa fa-angle-left"></i>
                    </a>
                

                
                    <a rel="next" href="../admin_api/server_notices.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
                        <i class="fa fa-angle-right"></i>
                    </a>
                
            </nav>

        </div>

        

        

        

        
        <script type="text/javascript">
            window.playground_copyable = true;
        </script>
        

        

        
        <script src="../elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="../mark.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="../searcher.js" type="text/javascript" charset="utf-8"></script>
        

        <script src="../clipboard.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="../highlight.js" type="text/javascript" charset="utf-8"></script>
        <script src="../book.js" type="text/javascript" charset="utf-8"></script>

        <!-- Custom JS scripts -->
        
        <script type="text/javascript" src="../docs/website_files/table-of-contents.js"></script>
        

        

    </body>
</html>