user_admin_api.html 75 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316
  1. <!DOCTYPE HTML>
  2. <html lang="en" class="sidebar-visible no-js light">
  3. <head>
  4. <!-- Book generated using mdBook -->
  5. <meta charset="UTF-8">
  6. <title>Users - Synapse</title>
  7. <!-- Custom HTML head -->
  8. <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  9. <meta name="description" content="">
  10. <meta name="viewport" content="width=device-width, initial-scale=1">
  11. <meta name="theme-color" content="#ffffff" />
  12. <link rel="icon" href="../favicon.svg">
  13. <link rel="shortcut icon" href="../favicon.png">
  14. <link rel="stylesheet" href="../css/variables.css">
  15. <link rel="stylesheet" href="../css/general.css">
  16. <link rel="stylesheet" href="../css/chrome.css">
  17. <link rel="stylesheet" href="../css/print.css" media="print">
  18. <!-- Fonts -->
  19. <link rel="stylesheet" href="../FontAwesome/css/font-awesome.css">
  20. <link rel="stylesheet" href="../fonts/fonts.css">
  21. <!-- Highlight.js Stylesheets -->
  22. <link rel="stylesheet" href="../highlight.css">
  23. <link rel="stylesheet" href="../tomorrow-night.css">
  24. <link rel="stylesheet" href="../ayu-highlight.css">
  25. <!-- Custom theme stylesheets -->
  26. <link rel="stylesheet" href="../docs/website_files/table-of-contents.css">
  27. <link rel="stylesheet" href="../docs/website_files/remove-nav-buttons.css">
  28. <link rel="stylesheet" href="../docs/website_files/indent-section-headers.css">
  29. <link rel="stylesheet" href="../docs/website_files/version-picker.css">
  30. </head>
  31. <body>
  32. <!-- Provide site root to javascript -->
  33. <script type="text/javascript">
  34. var path_to_root = "../";
  35. var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "navy" : "light";
  36. </script>
  37. <!-- Work around some values being stored in localStorage wrapped in quotes -->
  38. <script type="text/javascript">
  39. try {
  40. var theme = localStorage.getItem('mdbook-theme');
  41. var sidebar = localStorage.getItem('mdbook-sidebar');
  42. if (theme.startsWith('"') && theme.endsWith('"')) {
  43. localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
  44. }
  45. if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
  46. localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
  47. }
  48. } catch (e) { }
  49. </script>
  50. <!-- Set the theme before any content is loaded, prevents flash -->
  51. <script type="text/javascript">
  52. var theme;
  53. try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
  54. if (theme === null || theme === undefined) { theme = default_theme; }
  55. var html = document.querySelector('html');
  56. html.classList.remove('no-js')
  57. html.classList.remove('light')
  58. html.classList.add(theme);
  59. html.classList.add('js');
  60. </script>
  61. <!-- Hide / unhide sidebar before it is displayed -->
  62. <script type="text/javascript">
  63. var html = document.querySelector('html');
  64. var sidebar = 'hidden';
  65. if (document.body.clientWidth >= 1080) {
  66. try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
  67. sidebar = sidebar || 'visible';
  68. }
  69. html.classList.remove('sidebar-visible');
  70. html.classList.add("sidebar-" + sidebar);
  71. </script>
  72. <nav id="sidebar" class="sidebar" aria-label="Table of contents">
  73. <div class="sidebar-scrollbox">
  74. <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><ol class="section"><li class="chapter-item expanded "><a href="../setup/turn/coturn.html">coturn TURN server</a></li><li class="chapter-item expanded "><a href="../setup/turn/eturnal.html">eturnal TURN server</a></li></ol></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 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/config_documentation.html">Configuration Manual</a></li><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><li class="chapter-item expanded "><a href="../usage/configuration/user_authentication/refresh_tokens.html">Refresh 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="../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/account_data_callbacks.html">Account data 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/event_reports.html">Event Reports</a></li><li class="chapter-item expanded "><a href="../admin_api/experimental_features.html">Experimental Features</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">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" class="active">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><ol class="section"><li class="chapter-item expanded "><a href="../usage/administration/monitoring/reporting_homeserver_usage_statistics.html">Reporting Homeserver Usage Statistics</a></li></ol></li><li class="chapter-item expanded "><a href="../usage/administration/monthly_active_users.html">Monthly Active Users</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/reviews.html">Reviewing Code</a></li><li class="chapter-item expanded "><a href="../development/releases.html">Release Cycle</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><ol class="section"><li class="chapter-item expanded "><a href="../development/demo.html">Demo scripts</a></li></ol></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 "><a href="../development/dependencies.html">Dependency management</a></li><li class="chapter-item expanded "><div>Synapse Architecture</div></li><li><ol class="section"><li class="chapter-item expanded "><a href="../development/synapse_architecture/cancellation.html">Cancellation</a></li><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="../development/synapse_architecture/streams.html">Streams</a></li><li class="chapter-item expanded "><a href="../tcp_replication.html">TCP Replication</a></li><li class="chapter-item expanded "><a href="../development/synapse_architecture/faster_joins.html">Faster remote joins</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>
  75. </div>
  76. <div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
  77. </nav>
  78. <div id="page-wrapper" class="page-wrapper">
  79. <div class="page">
  80. <div id="menu-bar-hover-placeholder"></div>
  81. <div id="menu-bar" class="menu-bar sticky bordered">
  82. <div class="left-buttons">
  83. <button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
  84. <i class="fa fa-bars"></i>
  85. </button>
  86. <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">
  87. <i class="fa fa-paint-brush"></i>
  88. </button>
  89. <ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
  90. <li role="none"><button role="menuitem" class="theme" id="light">Light (default)</button></li>
  91. <li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
  92. <li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
  93. <li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
  94. <li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
  95. </ul>
  96. <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">
  97. <i class="fa fa-search"></i>
  98. </button>
  99. <div class="version-picker">
  100. <div class="dropdown">
  101. <div class="select">
  102. <span></span>
  103. <i class="fa fa-chevron-down"></i>
  104. </div>
  105. <input type="hidden" name="version">
  106. <ul class="dropdown-menu">
  107. <!-- Versions will be added dynamically in version-picker.js -->
  108. </ul>
  109. </div>
  110. </div>
  111. </div>
  112. <h1 class="menu-title">Synapse</h1>
  113. <div class="right-buttons">
  114. <a href="../print.html" title="Print this book" aria-label="Print this book">
  115. <i id="print-button" class="fa fa-print"></i>
  116. </a>
  117. <a href="https://github.com/matrix-org/synapse" title="Git repository" aria-label="Git repository">
  118. <i id="git-repository-button" class="fa fa-github"></i>
  119. </a>
  120. <a href="https://github.com/matrix-org/synapse/edit/develop/docs/admin_api/user_admin_api.md" title="Suggest an edit" aria-label="Suggest an edit">
  121. <i id="git-edit-button" class="fa fa-edit"></i>
  122. </a>
  123. </div>
  124. </div>
  125. <div id="search-wrapper" class="hidden">
  126. <form id="searchbar-outer" class="searchbar-outer">
  127. <input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
  128. </form>
  129. <div id="searchresults-outer" class="searchresults-outer hidden">
  130. <div id="searchresults-header" class="searchresults-header"></div>
  131. <ul id="searchresults">
  132. </ul>
  133. </div>
  134. </div>
  135. <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
  136. <script type="text/javascript">
  137. document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
  138. document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
  139. Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
  140. link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
  141. });
  142. </script>
  143. <div id="content" class="content">
  144. <main>
  145. <!-- Page table of contents -->
  146. <div class="sidetoc">
  147. <nav class="pagetoc"></nav>
  148. </div>
  149. <h1 id="user-admin-api"><a class="header" href="#user-admin-api">User Admin API</a></h1>
  150. <p>To use it, you will need to authenticate by providing an <code>access_token</code>
  151. for a server admin: see <a href="../usage/administration/admin_api/">Admin API</a>.</p>
  152. <h2 id="query-user-account"><a class="header" href="#query-user-account">Query User Account</a></h2>
  153. <p>This API returns information about a specific user account.</p>
  154. <p>The api is:</p>
  155. <pre><code>GET /_synapse/admin/v2/users/&lt;user_id&gt;
  156. </code></pre>
  157. <p>It returns a JSON body like the following:</p>
  158. <pre><code class="language-jsonc">{
  159. &quot;name&quot;: &quot;@user:example.com&quot;,
  160. &quot;displayname&quot;: &quot;User&quot;, // can be null if not set
  161. &quot;threepids&quot;: [
  162. {
  163. &quot;medium&quot;: &quot;email&quot;,
  164. &quot;address&quot;: &quot;&lt;user_mail_1&gt;&quot;,
  165. &quot;added_at&quot;: 1586458409743,
  166. &quot;validated_at&quot;: 1586458409743
  167. },
  168. {
  169. &quot;medium&quot;: &quot;email&quot;,
  170. &quot;address&quot;: &quot;&lt;user_mail_2&gt;&quot;,
  171. &quot;added_at&quot;: 1586458409743,
  172. &quot;validated_at&quot;: 1586458409743
  173. }
  174. ],
  175. &quot;avatar_url&quot;: &quot;&lt;avatar_url&gt;&quot;, // can be null if not set
  176. &quot;is_guest&quot;: 0,
  177. &quot;admin&quot;: 0,
  178. &quot;deactivated&quot;: 0,
  179. &quot;erased&quot;: false,
  180. &quot;shadow_banned&quot;: 0,
  181. &quot;creation_ts&quot;: 1560432506,
  182. &quot;appservice_id&quot;: null,
  183. &quot;consent_server_notice_sent&quot;: null,
  184. &quot;consent_version&quot;: null,
  185. &quot;consent_ts&quot;: null,
  186. &quot;external_ids&quot;: [
  187. {
  188. &quot;auth_provider&quot;: &quot;&lt;provider1&gt;&quot;,
  189. &quot;external_id&quot;: &quot;&lt;user_id_provider_1&gt;&quot;
  190. },
  191. {
  192. &quot;auth_provider&quot;: &quot;&lt;provider2&gt;&quot;,
  193. &quot;external_id&quot;: &quot;&lt;user_id_provider_2&gt;&quot;
  194. }
  195. ],
  196. &quot;user_type&quot;: null
  197. }
  198. </code></pre>
  199. <p>URL parameters:</p>
  200. <ul>
  201. <li><code>user_id</code>: fully-qualified user id: for example, <code>@user:server.com</code>.</li>
  202. </ul>
  203. <h2 id="create-or-modify-account"><a class="header" href="#create-or-modify-account">Create or modify account</a></h2>
  204. <p>This API allows an administrator to create or modify a user account with a
  205. specific <code>user_id</code>.</p>
  206. <p>This api is:</p>
  207. <pre><code>PUT /_synapse/admin/v2/users/&lt;user_id&gt;
  208. </code></pre>
  209. <p>with a body of:</p>
  210. <pre><code class="language-json">{
  211. &quot;password&quot;: &quot;user_password&quot;,
  212. &quot;logout_devices&quot;: false,
  213. &quot;displayname&quot;: &quot;Alice Marigold&quot;,
  214. &quot;avatar_url&quot;: &quot;mxc://example.com/abcde12345&quot;,
  215. &quot;threepids&quot;: [
  216. {
  217. &quot;medium&quot;: &quot;email&quot;,
  218. &quot;address&quot;: &quot;alice@example.com&quot;
  219. },
  220. {
  221. &quot;medium&quot;: &quot;email&quot;,
  222. &quot;address&quot;: &quot;alice@domain.org&quot;
  223. }
  224. ],
  225. &quot;external_ids&quot;: [
  226. {
  227. &quot;auth_provider&quot;: &quot;example&quot;,
  228. &quot;external_id&quot;: &quot;12345&quot;
  229. },
  230. {
  231. &quot;auth_provider&quot;: &quot;example2&quot;,
  232. &quot;external_id&quot;: &quot;abc54321&quot;
  233. }
  234. ],
  235. &quot;admin&quot;: false,
  236. &quot;deactivated&quot;: false,
  237. &quot;user_type&quot;: null
  238. }
  239. </code></pre>
  240. <p>Returns HTTP status code:</p>
  241. <ul>
  242. <li><code>201</code> - When a new user object was created.</li>
  243. <li><code>200</code> - When a user was modified.</li>
  244. </ul>
  245. <p>URL parameters:</p>
  246. <ul>
  247. <li><code>user_id</code> - A fully-qualified user id. For example, <code>@user:server.com</code>.</li>
  248. </ul>
  249. <p>Body parameters:</p>
  250. <ul>
  251. <li>
  252. <p><code>password</code> - <strong>string</strong>, optional. If provided, the user's password is updated and all
  253. devices are logged out, unless <code>logout_devices</code> is set to <code>false</code>.</p>
  254. </li>
  255. <li>
  256. <p><code>logout_devices</code> - <strong>bool</strong>, optional, defaults to <code>true</code>. If set to <code>false</code>, devices aren't
  257. logged out even when <code>password</code> is provided.</p>
  258. </li>
  259. <li>
  260. <p><code>displayname</code> - <strong>string</strong>, optional. If set to an empty string (<code>&quot;&quot;</code>), the user's display name
  261. will be removed.</p>
  262. </li>
  263. <li>
  264. <p><code>avatar_url</code> - <strong>string</strong>, optional. Must be a
  265. <a href="https://matrix.org/docs/spec/client_server/r0.6.0#matrix-content-mxc-uris">MXC URI</a>.
  266. If set to an empty string (<code>&quot;&quot;</code>), the user's avatar is removed.</p>
  267. </li>
  268. <li>
  269. <p><code>threepids</code> - <strong>array</strong>, optional. If provided, the user's third-party IDs (email, msisdn) are
  270. entirely replaced with the given list. Each item in the array is an object with the following
  271. fields:</p>
  272. <ul>
  273. <li><code>medium</code> - <strong>string</strong>, required. The type of third-party ID, either <code>email</code> or <code>msisdn</code> (phone number).</li>
  274. <li><code>address</code> - <strong>string</strong>, required. The third-party ID itself, e.g. <code>alice@example.com</code> for <code>email</code> or
  275. <code>447470274584</code> (for a phone number with country code &quot;44&quot;) and <code>19254857364</code> (for a phone number
  276. with country code &quot;1&quot;) for <code>msisdn</code>.
  277. Note: If a threepid is removed from a user via this option, Synapse will also attempt to remove
  278. that threepid from any identity servers it is aware has a binding for it.</li>
  279. </ul>
  280. </li>
  281. <li>
  282. <p><code>external_ids</code> - <strong>array</strong>, optional. Allow setting the identifier of the external identity
  283. provider for SSO (Single sign-on). More details are in the configuration manual under the
  284. sections <a href="../usage/configuration/config_documentation.html#sso">sso</a> and <a href="../usage/configuration/config_documentation.html#oidc_providers">oidc_providers</a>.</p>
  285. <ul>
  286. <li><code>auth_provider</code> - <strong>string</strong>, required. The unique, internal ID of the external identity provider.
  287. The same as <code>idp_id</code> from the homeserver configuration. Note that no error is raised if the
  288. provided value is not in the homeserver configuration.</li>
  289. <li><code>external_id</code> - <strong>string</strong>, required. An identifier for the user in the external identity provider.
  290. When the user logs in to the identity provider, this must be the unique ID that they map to.</li>
  291. </ul>
  292. </li>
  293. <li>
  294. <p><code>admin</code> - <strong>bool</strong>, optional, defaults to <code>false</code>. Whether the user is a homeserver administrator,
  295. granting them access to the Admin API, among other things.</p>
  296. </li>
  297. <li>
  298. <p><code>deactivated</code> - <strong>bool</strong>, optional. If unspecified, deactivation state will be left unchanged.</p>
  299. </li>
  300. <li>
  301. <p><code>locked</code> - <strong>bool</strong>, optional. If unspecified, locked state will be left unchanged.</p>
  302. <p>Note: the <code>password</code> field must also be set if both of the following are true:</p>
  303. <ul>
  304. <li><code>deactivated</code> is set to <code>false</code> and the user was previously deactivated (you are reactivating this user)</li>
  305. <li>Users are allowed to set their password on this homeserver (both <code>password_config.enabled</code> and
  306. <code>password_config.localdb_enabled</code> config options are set to <code>true</code>).
  307. Users' passwords are wiped upon account deactivation, hence the need to set a new one here.</li>
  308. </ul>
  309. <p>Note: a user cannot be erased with this API. For more details on
  310. deactivating and erasing users see <a href="#deactivate-account">Deactivate Account</a>.</p>
  311. </li>
  312. <li>
  313. <p><code>user_type</code> - <strong>string</strong> or null, optional. If not provided, the user type will be
  314. not be changed. If <code>null</code> is given, the user type will be cleared.
  315. Other allowed options are: <code>bot</code> and <code>support</code>.</p>
  316. </li>
  317. </ul>
  318. <h2 id="list-accounts"><a class="header" href="#list-accounts">List Accounts</a></h2>
  319. <p>This API returns all local user accounts.
  320. By default, the response is ordered by ascending user ID.</p>
  321. <pre><code>GET /_synapse/admin/v2/users?from=0&amp;limit=10&amp;guests=false
  322. </code></pre>
  323. <p>A response body like the following is returned:</p>
  324. <pre><code class="language-json">{
  325. &quot;users&quot;: [
  326. {
  327. &quot;name&quot;: &quot;&lt;user_id1&gt;&quot;,
  328. &quot;is_guest&quot;: 0,
  329. &quot;admin&quot;: 0,
  330. &quot;user_type&quot;: null,
  331. &quot;deactivated&quot;: 0,
  332. &quot;erased&quot;: false,
  333. &quot;shadow_banned&quot;: 0,
  334. &quot;displayname&quot;: &quot;&lt;User One&gt;&quot;,
  335. &quot;avatar_url&quot;: null,
  336. &quot;creation_ts&quot;: 1560432668000
  337. }, {
  338. &quot;name&quot;: &quot;&lt;user_id2&gt;&quot;,
  339. &quot;is_guest&quot;: 0,
  340. &quot;admin&quot;: 1,
  341. &quot;user_type&quot;: null,
  342. &quot;deactivated&quot;: 0,
  343. &quot;erased&quot;: false,
  344. &quot;shadow_banned&quot;: 0,
  345. &quot;displayname&quot;: &quot;&lt;User Two&gt;&quot;,
  346. &quot;avatar_url&quot;: &quot;&lt;avatar_url&gt;&quot;,
  347. &quot;creation_ts&quot;: 1561550621000
  348. }
  349. ],
  350. &quot;next_token&quot;: &quot;100&quot;,
  351. &quot;total&quot;: 200
  352. }
  353. </code></pre>
  354. <p>To paginate, check for <code>next_token</code> and if present, call the endpoint again
  355. with <code>from</code> set to the value of <code>next_token</code>. This will return a new page.</p>
  356. <p>If the endpoint does not return a <code>next_token</code> then there are no more users
  357. to paginate through.</p>
  358. <p><strong>Parameters</strong></p>
  359. <p>The following parameters should be set in the URL:</p>
  360. <ul>
  361. <li>
  362. <p><code>user_id</code> - Is optional and filters to only return users with user IDs
  363. that contain this value. This parameter is ignored when using the <code>name</code> parameter.</p>
  364. </li>
  365. <li>
  366. <p><code>name</code> - Is optional and filters to only return users with user ID localparts
  367. <strong>or</strong> displaynames that contain this value.</p>
  368. </li>
  369. <li>
  370. <p><code>guests</code> - string representing a bool - Is optional and if <code>false</code> will <strong>exclude</strong> guest users.
  371. Defaults to <code>true</code> to include guest users. This parameter is not supported when MSC3861 is enabled. <a href="https://github.com/matrix-org/synapse/pull/15582">See #15582</a></p>
  372. </li>
  373. <li>
  374. <p><code>admins</code> - Optional flag to filter admins. If <code>true</code>, only admins are queried. If <code>false</code>, admins are excluded from
  375. the query. When the flag is absent (the default), <strong>both</strong> admins and non-admins are included in the search results.</p>
  376. </li>
  377. <li>
  378. <p><code>deactivated</code> - string representing a bool - Is optional and if <code>true</code> will <strong>include</strong> deactivated users.
  379. Defaults to <code>false</code> to exclude deactivated users.</p>
  380. </li>
  381. <li>
  382. <p><code>limit</code> - string representing a positive integer - Is optional but is used for pagination,
  383. denoting the maximum number of items to return in this call. Defaults to <code>100</code>.</p>
  384. </li>
  385. <li>
  386. <p><code>from</code> - string representing a positive integer - Is optional but used for pagination,
  387. denoting the offset in the returned results. This should be treated as an opaque value and
  388. not explicitly set to anything other than the return value of <code>next_token</code> from a previous call.
  389. Defaults to <code>0</code>.</p>
  390. </li>
  391. <li>
  392. <p><code>order_by</code> - The method by which to sort the returned list of users.
  393. If the ordered field has duplicates, the second order is always by ascending <code>name</code>,
  394. which guarantees a stable ordering. Valid values are:</p>
  395. <ul>
  396. <li><code>name</code> - Users are ordered alphabetically by <code>name</code>. This is the default.</li>
  397. <li><code>is_guest</code> - Users are ordered by <code>is_guest</code> status.</li>
  398. <li><code>admin</code> - Users are ordered by <code>admin</code> status.</li>
  399. <li><code>user_type</code> - Users are ordered alphabetically by <code>user_type</code>.</li>
  400. <li><code>deactivated</code> - Users are ordered by <code>deactivated</code> status.</li>
  401. <li><code>shadow_banned</code> - Users are ordered by <code>shadow_banned</code> status.</li>
  402. <li><code>displayname</code> - Users are ordered alphabetically by <code>displayname</code>.</li>
  403. <li><code>avatar_url</code> - Users are ordered alphabetically by avatar URL.</li>
  404. <li><code>creation_ts</code> - Users are ordered by when the users was created in ms.</li>
  405. <li><code>last_seen_ts</code> - Users are ordered by when the user was lastly seen in ms.</li>
  406. </ul>
  407. </li>
  408. <li>
  409. <p><code>dir</code> - Direction of media order. Either <code>f</code> for forwards or <code>b</code> for backwards.
  410. Setting this value to <code>b</code> will reverse the above sort order. Defaults to <code>f</code>.</p>
  411. </li>
  412. <li>
  413. <p><code>not_user_type</code> - Exclude certain user types, such as bot users, from the request.
  414. Can be provided multiple times. Possible values are <code>bot</code>, <code>support</code> or &quot;empty string&quot;.
  415. &quot;empty string&quot; here means to exclude users without a type.</p>
  416. </li>
  417. </ul>
  418. <p>Caution. The database only has indexes on the columns <code>name</code> and <code>creation_ts</code>.
  419. This means that if a different sort order is used (<code>is_guest</code>, <code>admin</code>,
  420. <code>user_type</code>, <code>deactivated</code>, <code>shadow_banned</code>, <code>avatar_url</code> or <code>displayname</code>),
  421. this can cause a large load on the database, especially for large environments.</p>
  422. <p><strong>Response</strong></p>
  423. <p>The following fields are returned in the JSON response body:</p>
  424. <ul>
  425. <li>
  426. <p><code>users</code> - An array of objects, each containing information about an user.
  427. User objects contain the following fields:</p>
  428. <ul>
  429. <li><code>name</code> - string - Fully-qualified user ID (ex. <code>@user:server.com</code>).</li>
  430. <li><code>is_guest</code> - bool - Status if that user is a guest account.</li>
  431. <li><code>admin</code> - bool - Status if that user is a server administrator.</li>
  432. <li><code>user_type</code> - string - Type of the user. Normal users are type <code>None</code>.
  433. This allows user type specific behaviour. There are also types <code>support</code> and <code>bot</code>. </li>
  434. <li><code>deactivated</code> - bool - Status if that user has been marked as deactivated.</li>
  435. <li><code>erased</code> - bool - Status if that user has been marked as erased.</li>
  436. <li><code>shadow_banned</code> - bool - Status if that user has been marked as shadow banned.</li>
  437. <li><code>displayname</code> - string - The user's display name if they have set one.</li>
  438. <li><code>avatar_url</code> - string - The user's avatar URL if they have set one.</li>
  439. <li><code>creation_ts</code> - integer - The user's creation timestamp in ms.</li>
  440. <li><code>last_seen_ts</code> - integer - The user's last activity timestamp in ms.</li>
  441. </ul>
  442. </li>
  443. <li>
  444. <p><code>next_token</code>: string representing a positive integer - Indication for pagination. See above.</p>
  445. </li>
  446. <li>
  447. <p><code>total</code> - integer - Total number of media.</p>
  448. </li>
  449. </ul>
  450. <h2 id="query-current-sessions-for-a-user"><a class="header" href="#query-current-sessions-for-a-user">Query current sessions for a user</a></h2>
  451. <p>This API returns information about the active sessions for a specific user.</p>
  452. <p>The endpoints are:</p>
  453. <pre><code>GET /_synapse/admin/v1/whois/&lt;user_id&gt;
  454. </code></pre>
  455. <p>and:</p>
  456. <pre><code>GET /_matrix/client/r0/admin/whois/&lt;userId&gt;
  457. </code></pre>
  458. <p>See also: <a href="https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-admin-whois-userid">Client Server
  459. API Whois</a>.</p>
  460. <p>It returns a JSON body like the following:</p>
  461. <pre><code class="language-json">{
  462. &quot;user_id&quot;: &quot;&lt;user_id&gt;&quot;,
  463. &quot;devices&quot;: {
  464. &quot;&quot;: {
  465. &quot;sessions&quot;: [
  466. {
  467. &quot;connections&quot;: [
  468. {
  469. &quot;ip&quot;: &quot;1.2.3.4&quot;,
  470. &quot;last_seen&quot;: 1417222374433,
  471. &quot;user_agent&quot;: &quot;Mozilla/5.0 ...&quot;
  472. },
  473. {
  474. &quot;ip&quot;: &quot;1.2.3.10&quot;,
  475. &quot;last_seen&quot;: 1417222374500,
  476. &quot;user_agent&quot;: &quot;Dalvik/2.1.0 ...&quot;
  477. }
  478. ]
  479. }
  480. ]
  481. }
  482. }
  483. }
  484. </code></pre>
  485. <p><code>last_seen</code> is measured in milliseconds since the Unix epoch.</p>
  486. <h2 id="deactivate-account"><a class="header" href="#deactivate-account">Deactivate Account</a></h2>
  487. <p>This API deactivates an account. It removes active access tokens, resets the
  488. password, and deletes third-party IDs (to prevent the user requesting a
  489. password reset).</p>
  490. <p>It can also mark the user as GDPR-erased. This means messages sent by the
  491. user will still be visible by anyone that was in the room when these messages
  492. were sent, but hidden from users joining the room afterwards.</p>
  493. <p>The api is:</p>
  494. <pre><code>POST /_synapse/admin/v1/deactivate/&lt;user_id&gt;
  495. </code></pre>
  496. <p>with a body of:</p>
  497. <pre><code class="language-json">{
  498. &quot;erase&quot;: true
  499. }
  500. </code></pre>
  501. <p>The erase parameter is optional and defaults to <code>false</code>.
  502. An empty body may be passed for backwards compatibility.</p>
  503. <p>The following actions are performed when deactivating an user:</p>
  504. <ul>
  505. <li>Try to unbind 3PIDs from the identity server</li>
  506. <li>Remove all 3PIDs from the homeserver</li>
  507. <li>Delete all devices and E2EE keys</li>
  508. <li>Delete all access tokens</li>
  509. <li>Delete all pushers</li>
  510. <li>Delete the password hash</li>
  511. <li>Removal from all rooms the user is a member of</li>
  512. <li>Remove the user from the user directory</li>
  513. <li>Reject all pending invites</li>
  514. <li>Remove all account validity information related to the user</li>
  515. <li>Remove the arbitrary data store known as <em>account data</em>. For example, this includes:
  516. <ul>
  517. <li>list of ignored users;</li>
  518. <li>push rules;</li>
  519. <li>secret storage keys; and</li>
  520. <li>cross-signing keys.</li>
  521. </ul>
  522. </li>
  523. </ul>
  524. <p>The following additional actions are performed during deactivation if <code>erase</code>
  525. is set to <code>true</code>:</p>
  526. <ul>
  527. <li>Remove the user's display name</li>
  528. <li>Remove the user's avatar URL</li>
  529. <li>Mark the user as erased</li>
  530. </ul>
  531. <p>The following actions are <strong>NOT</strong> performed. The list may be incomplete.</p>
  532. <ul>
  533. <li>Remove mappings of SSO IDs</li>
  534. <li><a href="#delete-media-uploaded-by-a-user">Delete media uploaded</a> by user (included avatar images)</li>
  535. <li>Delete sent and received messages</li>
  536. <li>Remove the user's creation (registration) timestamp</li>
  537. <li><a href="#override-ratelimiting-for-users">Remove rate limit overrides</a></li>
  538. <li>Remove from monthly active users</li>
  539. <li>Remove user's consent information (consent version and timestamp)</li>
  540. </ul>
  541. <h2 id="reset-password"><a class="header" href="#reset-password">Reset password</a></h2>
  542. <p><strong>Note:</strong> This API is disabled when MSC3861 is enabled. <a href="https://github.com/matrix-org/synapse/pull/15582">See #15582</a></p>
  543. <p>Changes the password of another user. This will automatically log the user out of all their devices.</p>
  544. <p>The api is:</p>
  545. <pre><code>POST /_synapse/admin/v1/reset_password/&lt;user_id&gt;
  546. </code></pre>
  547. <p>with a body of:</p>
  548. <pre><code class="language-json">{
  549. &quot;new_password&quot;: &quot;&lt;secret&gt;&quot;,
  550. &quot;logout_devices&quot;: true
  551. }
  552. </code></pre>
  553. <p>The parameter <code>new_password</code> is required.
  554. The parameter <code>logout_devices</code> is optional and defaults to <code>true</code>.</p>
  555. <h2 id="get-whether-a-user-is-a-server-administrator-or-not"><a class="header" href="#get-whether-a-user-is-a-server-administrator-or-not">Get whether a user is a server administrator or not</a></h2>
  556. <p><strong>Note:</strong> This API is disabled when MSC3861 is enabled. <a href="https://github.com/matrix-org/synapse/pull/15582">See #15582</a></p>
  557. <p>The api is:</p>
  558. <pre><code>GET /_synapse/admin/v1/users/&lt;user_id&gt;/admin
  559. </code></pre>
  560. <p>A response body like the following is returned:</p>
  561. <pre><code class="language-json">{
  562. &quot;admin&quot;: true
  563. }
  564. </code></pre>
  565. <h2 id="change-whether-a-user-is-a-server-administrator-or-not"><a class="header" href="#change-whether-a-user-is-a-server-administrator-or-not">Change whether a user is a server administrator or not</a></h2>
  566. <p><strong>Note:</strong> This API is disabled when MSC3861 is enabled. <a href="https://github.com/matrix-org/synapse/pull/15582">See #15582</a></p>
  567. <p>Note that you cannot demote yourself.</p>
  568. <p>The api is:</p>
  569. <pre><code>PUT /_synapse/admin/v1/users/&lt;user_id&gt;/admin
  570. </code></pre>
  571. <p>with a body of:</p>
  572. <pre><code class="language-json">{
  573. &quot;admin&quot;: true
  574. }
  575. </code></pre>
  576. <h2 id="list-room-memberships-of-a-user"><a class="header" href="#list-room-memberships-of-a-user">List room memberships of a user</a></h2>
  577. <p>Gets a list of all <code>room_id</code> that a specific <code>user_id</code> is member.</p>
  578. <p>The API is:</p>
  579. <pre><code>GET /_synapse/admin/v1/users/&lt;user_id&gt;/joined_rooms
  580. </code></pre>
  581. <p>A response body like the following is returned:</p>
  582. <pre><code class="language-json"> {
  583. &quot;joined_rooms&quot;: [
  584. &quot;!DuGcnbhHGaSZQoNQR:matrix.org&quot;,
  585. &quot;!ZtSaPCawyWtxfWiIy:matrix.org&quot;
  586. ],
  587. &quot;total&quot;: 2
  588. }
  589. </code></pre>
  590. <p>The server returns the list of rooms of which the user and the server
  591. are member. If the user is local, all the rooms of which the user is
  592. member are returned.</p>
  593. <p><strong>Parameters</strong></p>
  594. <p>The following parameters should be set in the URL:</p>
  595. <ul>
  596. <li><code>user_id</code> - fully qualified: for example, <code>@user:server.com</code>.</li>
  597. </ul>
  598. <p><strong>Response</strong></p>
  599. <p>The following fields are returned in the JSON response body:</p>
  600. <ul>
  601. <li><code>joined_rooms</code> - An array of <code>room_id</code>.</li>
  602. <li><code>total</code> - Number of rooms.</li>
  603. </ul>
  604. <h2 id="account-data"><a class="header" href="#account-data">Account Data</a></h2>
  605. <p>Gets information about account data for a specific <code>user_id</code>.</p>
  606. <p>The API is:</p>
  607. <pre><code>GET /_synapse/admin/v1/users/&lt;user_id&gt;/accountdata
  608. </code></pre>
  609. <p>A response body like the following is returned:</p>
  610. <pre><code class="language-json">{
  611. &quot;account_data&quot;: {
  612. &quot;global&quot;: {
  613. &quot;m.secret_storage.key.LmIGHTg5W&quot;: {
  614. &quot;algorithm&quot;: &quot;m.secret_storage.v1.aes-hmac-sha2&quot;,
  615. &quot;iv&quot;: &quot;fwjNZatxg==&quot;,
  616. &quot;mac&quot;: &quot;eWh9kNnLWZUNOgnc=&quot;
  617. },
  618. &quot;im.vector.hide_profile&quot;: {
  619. &quot;hide_profile&quot;: true
  620. },
  621. &quot;org.matrix.preview_urls&quot;: {
  622. &quot;disable&quot;: false
  623. },
  624. &quot;im.vector.riot.breadcrumb_rooms&quot;: {
  625. &quot;rooms&quot;: [
  626. &quot;!LxcBDAsDUVAfJDEo:matrix.org&quot;,
  627. &quot;!MAhRxqasbItjOqxu:matrix.org&quot;
  628. ]
  629. },
  630. &quot;m.accepted_terms&quot;: {
  631. &quot;accepted&quot;: [
  632. &quot;https://example.org/somewhere/privacy-1.2-en.html&quot;,
  633. &quot;https://example.org/somewhere/terms-2.0-en.html&quot;
  634. ]
  635. },
  636. &quot;im.vector.setting.breadcrumbs&quot;: {
  637. &quot;recent_rooms&quot;: [
  638. &quot;!MAhRxqasbItqxuEt:matrix.org&quot;,
  639. &quot;!ZtSaPCawyWtxiImy:matrix.org&quot;
  640. ]
  641. }
  642. },
  643. &quot;rooms&quot;: {
  644. &quot;!GUdfZSHUJibpiVqHYd:matrix.org&quot;: {
  645. &quot;m.fully_read&quot;: {
  646. &quot;event_id&quot;: &quot;$156334540fYIhZ:matrix.org&quot;
  647. }
  648. },
  649. &quot;!tOZwOOiqwCYQkLhV:matrix.org&quot;: {
  650. &quot;m.fully_read&quot;: {
  651. &quot;event_id&quot;: &quot;$xjsIyp4_NaVl2yPvIZs_k1Jl8tsC_Sp23wjqXPno&quot;
  652. }
  653. }
  654. }
  655. }
  656. }
  657. </code></pre>
  658. <p><strong>Parameters</strong></p>
  659. <p>The following parameters should be set in the URL:</p>
  660. <ul>
  661. <li><code>user_id</code> - fully qualified: for example, <code>@user:server.com</code>.</li>
  662. </ul>
  663. <p><strong>Response</strong></p>
  664. <p>The following fields are returned in the JSON response body:</p>
  665. <ul>
  666. <li><code>account_data</code> - A map containing the account data for the user
  667. <ul>
  668. <li><code>global</code> - A map containing the global account data for the user</li>
  669. <li><code>rooms</code> - A map containing the account data per room for the user</li>
  670. </ul>
  671. </li>
  672. </ul>
  673. <h2 id="user-media"><a class="header" href="#user-media">User media</a></h2>
  674. <h3 id="list-media-uploaded-by-a-user"><a class="header" href="#list-media-uploaded-by-a-user">List media uploaded by a user</a></h3>
  675. <p>Gets a list of all local media that a specific <code>user_id</code> has created.
  676. These are media that the user has uploaded themselves
  677. (<a href="../media_repository.html#local-media">local media</a>), as well as
  678. <a href="../media_repository.html#url-previews">URL preview images</a> requested by the user if the
  679. <a href="../usage/configuration/config_documentation.html#url_preview_enabled">feature is enabled</a>.</p>
  680. <p>By default, the response is ordered by descending creation date and ascending media ID.
  681. The newest media is on top. You can change the order with parameters
  682. <code>order_by</code> and <code>dir</code>.</p>
  683. <p>The API is:</p>
  684. <pre><code>GET /_synapse/admin/v1/users/&lt;user_id&gt;/media
  685. </code></pre>
  686. <p>A response body like the following is returned:</p>
  687. <pre><code class="language-json">{
  688. &quot;media&quot;: [
  689. {
  690. &quot;created_ts&quot;: 100400,
  691. &quot;last_access_ts&quot;: null,
  692. &quot;media_id&quot;: &quot;qXhyRzulkwLsNHTbpHreuEgo&quot;,
  693. &quot;media_length&quot;: 67,
  694. &quot;media_type&quot;: &quot;image/png&quot;,
  695. &quot;quarantined_by&quot;: null,
  696. &quot;safe_from_quarantine&quot;: false,
  697. &quot;upload_name&quot;: &quot;test1.png&quot;
  698. },
  699. {
  700. &quot;created_ts&quot;: 200400,
  701. &quot;last_access_ts&quot;: null,
  702. &quot;media_id&quot;: &quot;FHfiSnzoINDatrXHQIXBtahw&quot;,
  703. &quot;media_length&quot;: 67,
  704. &quot;media_type&quot;: &quot;image/png&quot;,
  705. &quot;quarantined_by&quot;: null,
  706. &quot;safe_from_quarantine&quot;: false,
  707. &quot;upload_name&quot;: &quot;test2.png&quot;
  708. }
  709. ],
  710. &quot;next_token&quot;: 3,
  711. &quot;total&quot;: 2
  712. }
  713. </code></pre>
  714. <p>To paginate, check for <code>next_token</code> and if present, call the endpoint again
  715. with <code>from</code> set to the value of <code>next_token</code>. This will return a new page.</p>
  716. <p>If the endpoint does not return a <code>next_token</code> then there are no more
  717. reports to paginate through.</p>
  718. <p><strong>Parameters</strong></p>
  719. <p>The following parameters should be set in the URL:</p>
  720. <ul>
  721. <li>
  722. <p><code>user_id</code> - string - fully qualified: for example, <code>@user:server.com</code>.</p>
  723. </li>
  724. <li>
  725. <p><code>limit</code>: string representing a positive integer - Is optional but is used for pagination,
  726. denoting the maximum number of items to return in this call. Defaults to <code>100</code>.</p>
  727. </li>
  728. <li>
  729. <p><code>from</code>: string representing a positive integer - Is optional but used for pagination,
  730. denoting the offset in the returned results. This should be treated as an opaque value and
  731. not explicitly set to anything other than the return value of <code>next_token</code> from a previous call.
  732. Defaults to <code>0</code>.</p>
  733. </li>
  734. <li>
  735. <p><code>order_by</code> - The method by which to sort the returned list of media.
  736. If the ordered field has duplicates, the second order is always by ascending <code>media_id</code>,
  737. which guarantees a stable ordering. Valid values are:</p>
  738. <ul>
  739. <li><code>media_id</code> - Media are ordered alphabetically by <code>media_id</code>.</li>
  740. <li><code>upload_name</code> - Media are ordered alphabetically by name the media was uploaded with.</li>
  741. <li><code>created_ts</code> - Media are ordered by when the content was uploaded in ms.
  742. Smallest to largest. This is the default.</li>
  743. <li><code>last_access_ts</code> - Media are ordered by when the content was last accessed in ms.
  744. Smallest to largest.</li>
  745. <li><code>media_length</code> - Media are ordered by length of the media in bytes.
  746. Smallest to largest.</li>
  747. <li><code>media_type</code> - Media are ordered alphabetically by MIME-type.</li>
  748. <li><code>quarantined_by</code> - Media are ordered alphabetically by the user ID that
  749. initiated the quarantine request for this media.</li>
  750. <li><code>safe_from_quarantine</code> - Media are ordered by the status if this media is safe
  751. from quarantining.</li>
  752. </ul>
  753. </li>
  754. <li>
  755. <p><code>dir</code> - Direction of media order. Either <code>f</code> for forwards or <code>b</code> for backwards.
  756. Setting this value to <code>b</code> will reverse the above sort order. Defaults to <code>f</code>.</p>
  757. </li>
  758. </ul>
  759. <p>If neither <code>order_by</code> nor <code>dir</code> is set, the default order is newest media on top
  760. (corresponds to <code>order_by</code> = <code>created_ts</code> and <code>dir</code> = <code>b</code>).</p>
  761. <p>Caution. The database only has indexes on the columns <code>media_id</code>,
  762. <code>user_id</code> and <code>created_ts</code>. This means that if a different sort order is used
  763. (<code>upload_name</code>, <code>last_access_ts</code>, <code>media_length</code>, <code>media_type</code>,
  764. <code>quarantined_by</code> or <code>safe_from_quarantine</code>), this can cause a large load on the
  765. database, especially for large environments.</p>
  766. <p><strong>Response</strong></p>
  767. <p>The following fields are returned in the JSON response body:</p>
  768. <ul>
  769. <li><code>media</code> - An array of objects, each containing information about a media.
  770. Media objects contain the following fields:
  771. <ul>
  772. <li><code>created_ts</code> - integer - Timestamp when the content was uploaded in ms.</li>
  773. <li><code>last_access_ts</code> - integer - Timestamp when the content was last accessed in ms.</li>
  774. <li><code>media_id</code> - string - The id used to refer to the media. Details about the format
  775. are documented under
  776. <a href="../media_repository.html">media repository</a>.</li>
  777. <li><code>media_length</code> - integer - Length of the media in bytes.</li>
  778. <li><code>media_type</code> - string - The MIME-type of the media.</li>
  779. <li><code>quarantined_by</code> - string - The user ID that initiated the quarantine request
  780. for this media.</li>
  781. <li><code>safe_from_quarantine</code> - bool - Status if this media is safe from quarantining.</li>
  782. <li><code>upload_name</code> - string - The name the media was uploaded with.</li>
  783. </ul>
  784. </li>
  785. <li><code>next_token</code>: integer - Indication for pagination. See above.</li>
  786. <li><code>total</code> - integer - Total number of media.</li>
  787. </ul>
  788. <h3 id="delete-media-uploaded-by-a-user"><a class="header" href="#delete-media-uploaded-by-a-user">Delete media uploaded by a user</a></h3>
  789. <p>This API deletes the <em>local</em> media from the disk of your own server
  790. that a specific <code>user_id</code> has created. This includes any local thumbnails.</p>
  791. <p>This API will not affect media that has been uploaded to external
  792. media repositories (e.g https://github.com/turt2live/matrix-media-repo/).</p>
  793. <p>By default, the API deletes media ordered by descending creation date and ascending media ID.
  794. The newest media is deleted first. You can change the order with parameters
  795. <code>order_by</code> and <code>dir</code>. If no <code>limit</code> is set the API deletes <code>100</code> files per request.</p>
  796. <p>The API is:</p>
  797. <pre><code>DELETE /_synapse/admin/v1/users/&lt;user_id&gt;/media
  798. </code></pre>
  799. <p>A response body like the following is returned:</p>
  800. <pre><code class="language-json">{
  801. &quot;deleted_media&quot;: [
  802. &quot;abcdefghijklmnopqrstuvwx&quot;
  803. ],
  804. &quot;total&quot;: 1
  805. }
  806. </code></pre>
  807. <p>The following fields are returned in the JSON response body:</p>
  808. <ul>
  809. <li><code>deleted_media</code>: an array of strings - List of deleted <code>media_id</code></li>
  810. <li><code>total</code>: integer - Total number of deleted <code>media_id</code></li>
  811. </ul>
  812. <p><strong>Note</strong>: There is no <code>next_token</code>. This is not useful for deleting media, because
  813. after deleting media the remaining media have a new order.</p>
  814. <p><strong>Parameters</strong></p>
  815. <p>This API has the same parameters as
  816. <a href="#list-media-uploaded-by-a-user">List media uploaded by a user</a>.
  817. With the parameters you can for example limit the number of files to delete at once or
  818. delete largest/smallest or newest/oldest files first.</p>
  819. <h2 id="login-as-a-user"><a class="header" href="#login-as-a-user">Login as a user</a></h2>
  820. <p><strong>Note:</strong> This API is disabled when MSC3861 is enabled. <a href="https://github.com/matrix-org/synapse/pull/15582">See #15582</a></p>
  821. <p>Get an access token that can be used to authenticate as that user. Useful for
  822. when admins wish to do actions on behalf of a user.</p>
  823. <p>The API is:</p>
  824. <pre><code>POST /_synapse/admin/v1/users/&lt;user_id&gt;/login
  825. {}
  826. </code></pre>
  827. <p>An optional <code>valid_until_ms</code> field can be specified in the request body as an
  828. integer timestamp that specifies when the token should expire. By default tokens
  829. do not expire. Note that this API does not allow a user to login as themselves
  830. (to create more tokens).</p>
  831. <p>A response body like the following is returned:</p>
  832. <pre><code class="language-json">{
  833. &quot;access_token&quot;: &quot;&lt;opaque_access_token_string&gt;&quot;
  834. }
  835. </code></pre>
  836. <p>This API does <em>not</em> generate a new device for the user, and so will not appear
  837. their <code>/devices</code> list, and in general the target user should not be able to
  838. tell they have been logged in as.</p>
  839. <p>To expire the token call the standard <code>/logout</code> API with the token.</p>
  840. <p>Note: The token will expire if the <em>admin</em> user calls <code>/logout/all</code> from any
  841. of their devices, but the token will <em>not</em> expire if the target user does the
  842. same.</p>
  843. <h2 id="user-devices"><a class="header" href="#user-devices">User devices</a></h2>
  844. <h3 id="list-all-devices"><a class="header" href="#list-all-devices">List all devices</a></h3>
  845. <p>Gets information about all devices for a specific <code>user_id</code>.</p>
  846. <p>The API is:</p>
  847. <pre><code>GET /_synapse/admin/v2/users/&lt;user_id&gt;/devices
  848. </code></pre>
  849. <p>A response body like the following is returned:</p>
  850. <pre><code class="language-json">{
  851. &quot;devices&quot;: [
  852. {
  853. &quot;device_id&quot;: &quot;QBUAZIFURK&quot;,
  854. &quot;display_name&quot;: &quot;android&quot;,
  855. &quot;last_seen_ip&quot;: &quot;1.2.3.4&quot;,
  856. &quot;last_seen_user_agent&quot;: &quot;Mozilla/5.0 (X11; Linux x86_64; rv:103.0) Gecko/20100101 Firefox/103.0&quot;,
  857. &quot;last_seen_ts&quot;: 1474491775024,
  858. &quot;user_id&quot;: &quot;&lt;user_id&gt;&quot;
  859. },
  860. {
  861. &quot;device_id&quot;: &quot;AUIECTSRND&quot;,
  862. &quot;display_name&quot;: &quot;ios&quot;,
  863. &quot;last_seen_ip&quot;: &quot;1.2.3.5&quot;,
  864. &quot;last_seen_user_agent&quot;: &quot;Mozilla/5.0 (X11; Linux x86_64; rv:103.0) Gecko/20100101 Firefox/103.0&quot;,
  865. &quot;last_seen_ts&quot;: 1474491775025,
  866. &quot;user_id&quot;: &quot;&lt;user_id&gt;&quot;
  867. }
  868. ],
  869. &quot;total&quot;: 2
  870. }
  871. </code></pre>
  872. <p><strong>Parameters</strong></p>
  873. <p>The following parameters should be set in the URL:</p>
  874. <ul>
  875. <li><code>user_id</code> - fully qualified: for example, <code>@user:server.com</code>.</li>
  876. </ul>
  877. <p><strong>Response</strong></p>
  878. <p>The following fields are returned in the JSON response body:</p>
  879. <ul>
  880. <li>
  881. <p><code>devices</code> - An array of objects, each containing information about a device.
  882. Device objects contain the following fields:</p>
  883. <ul>
  884. <li><code>device_id</code> - Identifier of device.</li>
  885. <li><code>display_name</code> - Display name set by the user for this device.
  886. Absent if no name has been set.</li>
  887. <li><code>last_seen_ip</code> - The IP address where this device was last seen.
  888. (May be a few minutes out of date, for efficiency reasons).</li>
  889. <li><code>last_seen_user_agent</code> - The user agent of the device when it was last seen.
  890. (May be a few minutes out of date, for efficiency reasons).</li>
  891. <li><code>last_seen_ts</code> - The timestamp (in milliseconds since the unix epoch) when this
  892. devices was last seen. (May be a few minutes out of date, for efficiency reasons).</li>
  893. <li><code>user_id</code> - Owner of device.</li>
  894. </ul>
  895. </li>
  896. <li>
  897. <p><code>total</code> - Total number of user's devices.</p>
  898. </li>
  899. </ul>
  900. <h3 id="create-a-device"><a class="header" href="#create-a-device">Create a device</a></h3>
  901. <p>Creates a new device for a specific <code>user_id</code> and <code>device_id</code>. Does nothing if the <code>device_id</code>
  902. exists already.</p>
  903. <p>The API is:</p>
  904. <pre><code>POST /_synapse/admin/v2/users/&lt;user_id&gt;/devices
  905. {
  906. &quot;device_id&quot;: &quot;QBUAZIFURK&quot;
  907. }
  908. </code></pre>
  909. <p>An empty JSON dict is returned.</p>
  910. <p><strong>Parameters</strong></p>
  911. <p>The following parameters should be set in the URL:</p>
  912. <ul>
  913. <li><code>user_id</code> - fully qualified: for example, <code>@user:server.com</code>.</li>
  914. </ul>
  915. <p>The following fields are required in the JSON request body:</p>
  916. <ul>
  917. <li><code>device_id</code> - The device ID to create.</li>
  918. </ul>
  919. <h3 id="delete-multiple-devices"><a class="header" href="#delete-multiple-devices">Delete multiple devices</a></h3>
  920. <p>Deletes the given devices for a specific <code>user_id</code>, and invalidates
  921. any access token associated with them.</p>
  922. <p>The API is:</p>
  923. <pre><code>POST /_synapse/admin/v2/users/&lt;user_id&gt;/delete_devices
  924. {
  925. &quot;devices&quot;: [
  926. &quot;QBUAZIFURK&quot;,
  927. &quot;AUIECTSRND&quot;
  928. ]
  929. }
  930. </code></pre>
  931. <p>An empty JSON dict is returned.</p>
  932. <p><strong>Parameters</strong></p>
  933. <p>The following parameters should be set in the URL:</p>
  934. <ul>
  935. <li><code>user_id</code> - fully qualified: for example, <code>@user:server.com</code>.</li>
  936. </ul>
  937. <p>The following fields are required in the JSON request body:</p>
  938. <ul>
  939. <li><code>devices</code> - The list of device IDs to delete.</li>
  940. </ul>
  941. <h3 id="show-a-device"><a class="header" href="#show-a-device">Show a device</a></h3>
  942. <p>Gets information on a single device, by <code>device_id</code> for a specific <code>user_id</code>.</p>
  943. <p>The API is:</p>
  944. <pre><code>GET /_synapse/admin/v2/users/&lt;user_id&gt;/devices/&lt;device_id&gt;
  945. </code></pre>
  946. <p>A response body like the following is returned:</p>
  947. <pre><code class="language-json">{
  948. &quot;device_id&quot;: &quot;&lt;device_id&gt;&quot;,
  949. &quot;display_name&quot;: &quot;android&quot;,
  950. &quot;last_seen_ip&quot;: &quot;1.2.3.4&quot;,
  951. &quot;last_seen_user_agent&quot;: &quot;Mozilla/5.0 (X11; Linux x86_64; rv:103.0) Gecko/20100101 Firefox/103.0&quot;,
  952. &quot;last_seen_ts&quot;: 1474491775024,
  953. &quot;user_id&quot;: &quot;&lt;user_id&gt;&quot;
  954. }
  955. </code></pre>
  956. <p><strong>Parameters</strong></p>
  957. <p>The following parameters should be set in the URL:</p>
  958. <ul>
  959. <li><code>user_id</code> - fully qualified: for example, <code>@user:server.com</code>.</li>
  960. <li><code>device_id</code> - The device to retrieve.</li>
  961. </ul>
  962. <p><strong>Response</strong></p>
  963. <p>The following fields are returned in the JSON response body:</p>
  964. <ul>
  965. <li><code>device_id</code> - Identifier of device.</li>
  966. <li><code>display_name</code> - Display name set by the user for this device.
  967. Absent if no name has been set.</li>
  968. <li><code>last_seen_ip</code> - The IP address where this device was last seen.
  969. (May be a few minutes out of date, for efficiency reasons).
  970. <ul>
  971. <li><code>last_seen_user_agent</code> - The user agent of the device when it was last seen.
  972. (May be a few minutes out of date, for efficiency reasons).</li>
  973. </ul>
  974. </li>
  975. <li><code>last_seen_ts</code> - The timestamp (in milliseconds since the unix epoch) when this
  976. devices was last seen. (May be a few minutes out of date, for efficiency reasons).</li>
  977. <li><code>user_id</code> - Owner of device.</li>
  978. </ul>
  979. <h3 id="update-a-device"><a class="header" href="#update-a-device">Update a device</a></h3>
  980. <p>Updates the metadata on the given <code>device_id</code> for a specific <code>user_id</code>.</p>
  981. <p>The API is:</p>
  982. <pre><code>PUT /_synapse/admin/v2/users/&lt;user_id&gt;/devices/&lt;device_id&gt;
  983. {
  984. &quot;display_name&quot;: &quot;My other phone&quot;
  985. }
  986. </code></pre>
  987. <p>An empty JSON dict is returned.</p>
  988. <p><strong>Parameters</strong></p>
  989. <p>The following parameters should be set in the URL:</p>
  990. <ul>
  991. <li><code>user_id</code> - fully qualified: for example, <code>@user:server.com</code>.</li>
  992. <li><code>device_id</code> - The device to update.</li>
  993. </ul>
  994. <p>The following fields are required in the JSON request body:</p>
  995. <ul>
  996. <li><code>display_name</code> - The new display name for this device. If not given,
  997. the display name is unchanged.</li>
  998. </ul>
  999. <h3 id="delete-a-device"><a class="header" href="#delete-a-device">Delete a device</a></h3>
  1000. <p>Deletes the given <code>device_id</code> for a specific <code>user_id</code>,
  1001. and invalidates any access token associated with it.</p>
  1002. <p>The API is:</p>
  1003. <pre><code>DELETE /_synapse/admin/v2/users/&lt;user_id&gt;/devices/&lt;device_id&gt;
  1004. {}
  1005. </code></pre>
  1006. <p>An empty JSON dict is returned.</p>
  1007. <p><strong>Parameters</strong></p>
  1008. <p>The following parameters should be set in the URL:</p>
  1009. <ul>
  1010. <li><code>user_id</code> - fully qualified: for example, <code>@user:server.com</code>.</li>
  1011. <li><code>device_id</code> - The device to delete.</li>
  1012. </ul>
  1013. <h2 id="list-all-pushers"><a class="header" href="#list-all-pushers">List all pushers</a></h2>
  1014. <p>Gets information about all pushers for a specific <code>user_id</code>.</p>
  1015. <p>The API is:</p>
  1016. <pre><code>GET /_synapse/admin/v1/users/&lt;user_id&gt;/pushers
  1017. </code></pre>
  1018. <p>A response body like the following is returned:</p>
  1019. <pre><code class="language-json">{
  1020. &quot;pushers&quot;: [
  1021. {
  1022. &quot;app_display_name&quot;:&quot;HTTP Push Notifications&quot;,
  1023. &quot;app_id&quot;:&quot;m.http&quot;,
  1024. &quot;data&quot;: {
  1025. &quot;url&quot;:&quot;example.com&quot;
  1026. },
  1027. &quot;device_display_name&quot;:&quot;pushy push&quot;,
  1028. &quot;kind&quot;:&quot;http&quot;,
  1029. &quot;lang&quot;:&quot;None&quot;,
  1030. &quot;profile_tag&quot;:&quot;&quot;,
  1031. &quot;pushkey&quot;:&quot;a@example.com&quot;
  1032. }
  1033. ],
  1034. &quot;total&quot;: 1
  1035. }
  1036. </code></pre>
  1037. <p><strong>Parameters</strong></p>
  1038. <p>The following parameters should be set in the URL:</p>
  1039. <ul>
  1040. <li><code>user_id</code> - fully qualified: for example, <code>@user:server.com</code>.</li>
  1041. </ul>
  1042. <p><strong>Response</strong></p>
  1043. <p>The following fields are returned in the JSON response body:</p>
  1044. <ul>
  1045. <li>
  1046. <p><code>pushers</code> - An array containing the current pushers for the user</p>
  1047. <ul>
  1048. <li>
  1049. <p><code>app_display_name</code> - string - A string that will allow the user to identify
  1050. what application owns this pusher.</p>
  1051. </li>
  1052. <li>
  1053. <p><code>app_id</code> - string - This is a reverse-DNS style identifier for the application.
  1054. Max length, 64 chars.</p>
  1055. </li>
  1056. <li>
  1057. <p><code>data</code> - A dictionary of information for the pusher implementation itself.</p>
  1058. <ul>
  1059. <li>
  1060. <p><code>url</code> - string - Required if <code>kind</code> is <code>http</code>. The URL to use to send
  1061. notifications to.</p>
  1062. </li>
  1063. <li>
  1064. <p><code>format</code> - string - The format to use when sending notifications to the
  1065. Push Gateway.</p>
  1066. </li>
  1067. </ul>
  1068. </li>
  1069. <li>
  1070. <p><code>device_display_name</code> - string - A string that will allow the user to identify
  1071. what device owns this pusher.</p>
  1072. </li>
  1073. <li>
  1074. <p><code>profile_tag</code> - string - This string determines which set of device specific rules
  1075. this pusher executes.</p>
  1076. </li>
  1077. <li>
  1078. <p><code>kind</code> - string - The kind of pusher. &quot;http&quot; is a pusher that sends HTTP pokes.</p>
  1079. </li>
  1080. <li>
  1081. <p><code>lang</code> - string - The preferred language for receiving notifications
  1082. (e.g. 'en' or 'en-US')</p>
  1083. </li>
  1084. <li>
  1085. <p><code>profile_tag</code> - string - This string determines which set of device specific rules
  1086. this pusher executes.</p>
  1087. </li>
  1088. <li>
  1089. <p><code>pushkey</code> - string - This is a unique identifier for this pusher.
  1090. Max length, 512 bytes.</p>
  1091. </li>
  1092. </ul>
  1093. </li>
  1094. <li>
  1095. <p><code>total</code> - integer - Number of pushers.</p>
  1096. </li>
  1097. </ul>
  1098. <p>See also the
  1099. <a href="https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-pushers">Client-Server API Spec on pushers</a>.</p>
  1100. <h2 id="controlling-whether-a-user-is-shadow-banned"><a class="header" href="#controlling-whether-a-user-is-shadow-banned">Controlling whether a user is shadow-banned</a></h2>
  1101. <p>Shadow-banning is a useful tool for moderating malicious or egregiously abusive users.
  1102. A shadow-banned users receives successful responses to their client-server API requests,
  1103. but the events are not propagated into rooms. This can be an effective tool as it
  1104. (hopefully) takes longer for the user to realise they are being moderated before
  1105. pivoting to another account.</p>
  1106. <p>Shadow-banning a user should be used as a tool of last resort and may lead to confusing
  1107. or broken behaviour for the client. A shadow-banned user will not receive any
  1108. notification and it is generally more appropriate to ban or kick abusive users.
  1109. A shadow-banned user will be unable to contact anyone on the server.</p>
  1110. <p>To shadow-ban a user the API is:</p>
  1111. <pre><code>POST /_synapse/admin/v1/users/&lt;user_id&gt;/shadow_ban
  1112. </code></pre>
  1113. <p>To un-shadow-ban a user the API is:</p>
  1114. <pre><code>DELETE /_synapse/admin/v1/users/&lt;user_id&gt;/shadow_ban
  1115. </code></pre>
  1116. <p>An empty JSON dict is returned in both cases.</p>
  1117. <p><strong>Parameters</strong></p>
  1118. <p>The following parameters should be set in the URL:</p>
  1119. <ul>
  1120. <li><code>user_id</code> - The fully qualified MXID: for example, <code>@user:server.com</code>. The user must
  1121. be local.</li>
  1122. </ul>
  1123. <h2 id="override-ratelimiting-for-users"><a class="header" href="#override-ratelimiting-for-users">Override ratelimiting for users</a></h2>
  1124. <p>This API allows to override or disable ratelimiting for a specific user.
  1125. There are specific APIs to set, get and delete a ratelimit.</p>
  1126. <h3 id="get-status-of-ratelimit"><a class="header" href="#get-status-of-ratelimit">Get status of ratelimit</a></h3>
  1127. <p>The API is:</p>
  1128. <pre><code>GET /_synapse/admin/v1/users/&lt;user_id&gt;/override_ratelimit
  1129. </code></pre>
  1130. <p>A response body like the following is returned:</p>
  1131. <pre><code class="language-json">{
  1132. &quot;messages_per_second&quot;: 0,
  1133. &quot;burst_count&quot;: 0
  1134. }
  1135. </code></pre>
  1136. <p><strong>Parameters</strong></p>
  1137. <p>The following parameters should be set in the URL:</p>
  1138. <ul>
  1139. <li><code>user_id</code> - The fully qualified MXID: for example, <code>@user:server.com</code>. The user must
  1140. be local.</li>
  1141. </ul>
  1142. <p><strong>Response</strong></p>
  1143. <p>The following fields are returned in the JSON response body:</p>
  1144. <ul>
  1145. <li><code>messages_per_second</code> - integer - The number of actions that can
  1146. be performed in a second. <code>0</code> mean that ratelimiting is disabled for this user.</li>
  1147. <li><code>burst_count</code> - integer - How many actions that can be performed before
  1148. being limited.</li>
  1149. </ul>
  1150. <p>If <strong>no</strong> custom ratelimit is set, an empty JSON dict is returned.</p>
  1151. <pre><code class="language-json">{}
  1152. </code></pre>
  1153. <h3 id="set-ratelimit"><a class="header" href="#set-ratelimit">Set ratelimit</a></h3>
  1154. <p>The API is:</p>
  1155. <pre><code>POST /_synapse/admin/v1/users/&lt;user_id&gt;/override_ratelimit
  1156. </code></pre>
  1157. <p>A response body like the following is returned:</p>
  1158. <pre><code class="language-json">{
  1159. &quot;messages_per_second&quot;: 0,
  1160. &quot;burst_count&quot;: 0
  1161. }
  1162. </code></pre>
  1163. <p><strong>Parameters</strong></p>
  1164. <p>The following parameters should be set in the URL:</p>
  1165. <ul>
  1166. <li><code>user_id</code> - The fully qualified MXID: for example, <code>@user:server.com</code>. The user must
  1167. be local.</li>
  1168. </ul>
  1169. <p>Body parameters:</p>
  1170. <ul>
  1171. <li><code>messages_per_second</code> - positive integer, optional. The number of actions that can
  1172. be performed in a second. Defaults to <code>0</code>.</li>
  1173. <li><code>burst_count</code> - positive integer, optional. How many actions that can be performed
  1174. before being limited. Defaults to <code>0</code>.</li>
  1175. </ul>
  1176. <p>To disable users' ratelimit set both values to <code>0</code>.</p>
  1177. <p><strong>Response</strong></p>
  1178. <p>The following fields are returned in the JSON response body:</p>
  1179. <ul>
  1180. <li><code>messages_per_second</code> - integer - The number of actions that can
  1181. be performed in a second.</li>
  1182. <li><code>burst_count</code> - integer - How many actions that can be performed before
  1183. being limited.</li>
  1184. </ul>
  1185. <h3 id="delete-ratelimit"><a class="header" href="#delete-ratelimit">Delete ratelimit</a></h3>
  1186. <p>The API is:</p>
  1187. <pre><code>DELETE /_synapse/admin/v1/users/&lt;user_id&gt;/override_ratelimit
  1188. </code></pre>
  1189. <p>An empty JSON dict is returned.</p>
  1190. <pre><code class="language-json">{}
  1191. </code></pre>
  1192. <p><strong>Parameters</strong></p>
  1193. <p>The following parameters should be set in the URL:</p>
  1194. <ul>
  1195. <li><code>user_id</code> - The fully qualified MXID: for example, <code>@user:server.com</code>. The user must
  1196. be local.</li>
  1197. </ul>
  1198. <h2 id="check-username-availability"><a class="header" href="#check-username-availability">Check username availability</a></h2>
  1199. <p>Checks to see if a username is available, and valid, for the server. See <a href="https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-register-available">the client-server
  1200. API</a>
  1201. for more information.</p>
  1202. <p>This endpoint will work even if registration is disabled on the server, unlike
  1203. <code>/_matrix/client/r0/register/available</code>.</p>
  1204. <p>The API is:</p>
  1205. <pre><code>GET /_synapse/admin/v1/username_available?username=$localpart
  1206. </code></pre>
  1207. <p>The request and response format is the same as the
  1208. <a href="https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-register-available">/_matrix/client/r0/register/available</a> API.</p>
  1209. <h2 id="find-a-user-based-on-their-id-in-an-auth-provider"><a class="header" href="#find-a-user-based-on-their-id-in-an-auth-provider">Find a user based on their ID in an auth provider</a></h2>
  1210. <p>The API is:</p>
  1211. <pre><code>GET /_synapse/admin/v1/auth_providers/$provider/users/$external_id
  1212. </code></pre>
  1213. <p>When a user matched the given ID for the given provider, an HTTP code <code>200</code> with a response body like the following is returned:</p>
  1214. <pre><code class="language-json">{
  1215. &quot;user_id&quot;: &quot;@hello:example.org&quot;
  1216. }
  1217. </code></pre>
  1218. <p><strong>Parameters</strong></p>
  1219. <p>The following parameters should be set in the URL:</p>
  1220. <ul>
  1221. <li><code>provider</code> - The ID of the authentication provider, as advertised by the <a href="https://spec.matrix.org/latest/client-server-api/#post_matrixclientv3login"><code>GET /_matrix/client/v3/login</code></a> API in the <code>m.login.sso</code> authentication method.</li>
  1222. <li><code>external_id</code> - The user ID from the authentication provider. Usually corresponds to the <code>sub</code> claim for OIDC providers, or to the <code>uid</code> attestation for SAML2 providers.</li>
  1223. </ul>
  1224. <p>The <code>external_id</code> may have characters that are not URL-safe (typically <code>/</code>, <code>:</code> or <code>@</code>), so it is advised to URL-encode those parameters.</p>
  1225. <p><strong>Errors</strong></p>
  1226. <p>Returns a <code>404</code> HTTP status code if no user was found, with a response body like this:</p>
  1227. <pre><code class="language-json">{
  1228. &quot;errcode&quot;:&quot;M_NOT_FOUND&quot;,
  1229. &quot;error&quot;:&quot;User not found&quot;
  1230. }
  1231. </code></pre>
  1232. <p><em>Added in Synapse 1.68.0.</em></p>
  1233. <h2 id="find-a-user-based-on-their-third-party-id-threepid-or-3pid"><a class="header" href="#find-a-user-based-on-their-third-party-id-threepid-or-3pid">Find a user based on their Third Party ID (ThreePID or 3PID)</a></h2>
  1234. <p>The API is:</p>
  1235. <pre><code>GET /_synapse/admin/v1/threepid/$medium/users/$address
  1236. </code></pre>
  1237. <p>When a user matched the given address for the given medium, an HTTP code <code>200</code> with a response body like the following is returned:</p>
  1238. <pre><code class="language-json">{
  1239. &quot;user_id&quot;: &quot;@hello:example.org&quot;
  1240. }
  1241. </code></pre>
  1242. <p><strong>Parameters</strong></p>
  1243. <p>The following parameters should be set in the URL:</p>
  1244. <ul>
  1245. <li><code>medium</code> - Kind of third-party ID, either <code>email</code> or <code>msisdn</code>.</li>
  1246. <li><code>address</code> - Value of the third-party ID.</li>
  1247. </ul>
  1248. <p>The <code>address</code> may have characters that are not URL-safe, so it is advised to URL-encode those parameters.</p>
  1249. <p><strong>Errors</strong></p>
  1250. <p>Returns a <code>404</code> HTTP status code if no user was found, with a response body like this:</p>
  1251. <pre><code class="language-json">{
  1252. &quot;errcode&quot;:&quot;M_NOT_FOUND&quot;,
  1253. &quot;error&quot;:&quot;User not found&quot;
  1254. }
  1255. </code></pre>
  1256. <p><em>Added in Synapse 1.72.0.</em></p>
  1257. </main>
  1258. <nav class="nav-wrapper" aria-label="Page navigation">
  1259. <!-- Mobile navigation buttons -->
  1260. <a rel="prev" href="../admin_api/statistics.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
  1261. <i class="fa fa-angle-left"></i>
  1262. </a>
  1263. <a rel="next" href="../admin_api/version_api.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
  1264. <i class="fa fa-angle-right"></i>
  1265. </a>
  1266. <div style="clear: both"></div>
  1267. </nav>
  1268. </div>
  1269. </div>
  1270. <nav class="nav-wide-wrapper" aria-label="Page navigation">
  1271. <a rel="prev" href="../admin_api/statistics.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
  1272. <i class="fa fa-angle-left"></i>
  1273. </a>
  1274. <a rel="next" href="../admin_api/version_api.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
  1275. <i class="fa fa-angle-right"></i>
  1276. </a>
  1277. </nav>
  1278. </div>
  1279. <script type="text/javascript">
  1280. window.playground_copyable = true;
  1281. </script>
  1282. <script src="../elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
  1283. <script src="../mark.min.js" type="text/javascript" charset="utf-8"></script>
  1284. <script src="../searcher.js" type="text/javascript" charset="utf-8"></script>
  1285. <script src="../clipboard.min.js" type="text/javascript" charset="utf-8"></script>
  1286. <script src="../highlight.js" type="text/javascript" charset="utf-8"></script>
  1287. <script src="../book.js" type="text/javascript" charset="utf-8"></script>
  1288. <!-- Custom JS scripts -->
  1289. <script type="text/javascript" src="../docs/website_files/table-of-contents.js"></script>
  1290. <script type="text/javascript" src="../docs/website_files/version-picker.js"></script>
  1291. <script type="text/javascript" src="../docs/website_files/version.js"></script>
  1292. </body>
  1293. </html>