Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

user_admin_api.md 28 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001
  1. # User Admin API
  2. ## Query User Account
  3. This API returns information about a specific user account.
  4. The api is:
  5. ```
  6. GET /_synapse/admin/v2/users/<user_id>
  7. ```
  8. To use it, you will need to authenticate by providing an `access_token` for a
  9. server admin: [Admin API](../../usage/administration/admin_api)
  10. It returns a JSON body like the following:
  11. ```json
  12. {
  13. "displayname": "User",
  14. "threepids": [
  15. {
  16. "medium": "email",
  17. "address": "<user_mail_1>"
  18. },
  19. {
  20. "medium": "email",
  21. "address": "<user_mail_2>"
  22. }
  23. ],
  24. "avatar_url": "<avatar_url>",
  25. "admin": 0,
  26. "deactivated": 0,
  27. "shadow_banned": 0,
  28. "password_hash": "$2b$12$p9B4GkqYdRTPGD",
  29. "creation_ts": 1560432506,
  30. "appservice_id": null,
  31. "consent_server_notice_sent": null,
  32. "consent_version": null
  33. }
  34. ```
  35. URL parameters:
  36. - `user_id`: fully-qualified user id: for example, `@user:server.com`.
  37. ## Create or modify Account
  38. This API allows an administrator to create or modify a user account with a
  39. specific `user_id`.
  40. This api is:
  41. ```
  42. PUT /_synapse/admin/v2/users/<user_id>
  43. ```
  44. with a body of:
  45. ```json
  46. {
  47. "password": "user_password",
  48. "displayname": "User",
  49. "threepids": [
  50. {
  51. "medium": "email",
  52. "address": "<user_mail_1>"
  53. },
  54. {
  55. "medium": "email",
  56. "address": "<user_mail_2>"
  57. }
  58. ],
  59. "avatar_url": "<avatar_url>",
  60. "admin": false,
  61. "deactivated": false
  62. }
  63. ```
  64. To use it, you will need to authenticate by providing an `access_token` for a
  65. server admin: [Admin API](../../usage/administration/admin_api)
  66. URL parameters:
  67. - `user_id`: fully-qualified user id: for example, `@user:server.com`.
  68. Body parameters:
  69. - `password`, optional. If provided, the user's password is updated and all
  70. devices are logged out.
  71. - `displayname`, optional, defaults to the value of `user_id`.
  72. - `threepids`, optional, allows setting the third-party IDs (email, msisdn)
  73. belonging to a user.
  74. - `avatar_url`, optional, must be a
  75. [MXC URI](https://matrix.org/docs/spec/client_server/r0.6.0#matrix-content-mxc-uris).
  76. - `admin`, optional, defaults to `false`.
  77. - `deactivated`, optional. If unspecified, deactivation state will be left
  78. unchanged on existing accounts and set to `false` for new accounts.
  79. A user cannot be erased by deactivating with this API. For details on
  80. deactivating users see [Deactivate Account](#deactivate-account).
  81. If the user already exists then optional parameters default to the current value.
  82. In order to re-activate an account `deactivated` must be set to `false`. If
  83. users do not login via single-sign-on, a new `password` must be provided.
  84. ## List Accounts
  85. This API returns all local user accounts.
  86. By default, the response is ordered by ascending user ID.
  87. ```
  88. GET /_synapse/admin/v2/users?from=0&limit=10&guests=false
  89. ```
  90. To use it, you will need to authenticate by providing an `access_token` for a
  91. server admin: [Admin API](../../usage/administration/admin_api)
  92. A response body like the following is returned:
  93. ```json
  94. {
  95. "users": [
  96. {
  97. "name": "<user_id1>",
  98. "is_guest": 0,
  99. "admin": 0,
  100. "user_type": null,
  101. "deactivated": 0,
  102. "shadow_banned": 0,
  103. "displayname": "<User One>",
  104. "avatar_url": null
  105. }, {
  106. "name": "<user_id2>",
  107. "is_guest": 0,
  108. "admin": 1,
  109. "user_type": null,
  110. "deactivated": 0,
  111. "shadow_banned": 0,
  112. "displayname": "<User Two>",
  113. "avatar_url": "<avatar_url>"
  114. }
  115. ],
  116. "next_token": "100",
  117. "total": 200
  118. }
  119. ```
  120. To paginate, check for `next_token` and if present, call the endpoint again
  121. with `from` set to the value of `next_token`. This will return a new page.
  122. If the endpoint does not return a `next_token` then there are no more users
  123. to paginate through.
  124. **Parameters**
  125. The following parameters should be set in the URL:
  126. - `user_id` - Is optional and filters to only return users with user IDs
  127. that contain this value. This parameter is ignored when using the `name` parameter.
  128. - `name` - Is optional and filters to only return users with user ID localparts
  129. **or** displaynames that contain this value.
  130. - `guests` - string representing a bool - Is optional and if `false` will **exclude** guest users.
  131. Defaults to `true` to include guest users.
  132. - `deactivated` - string representing a bool - Is optional and if `true` will **include** deactivated users.
  133. Defaults to `false` to exclude deactivated users.
  134. - `limit` - string representing a positive integer - Is optional but is used for pagination,
  135. denoting the maximum number of items to return in this call. Defaults to `100`.
  136. - `from` - string representing a positive integer - Is optional but used for pagination,
  137. denoting the offset in the returned results. This should be treated as an opaque value and
  138. not explicitly set to anything other than the return value of `next_token` from a previous call.
  139. Defaults to `0`.
  140. - `order_by` - The method by which to sort the returned list of users.
  141. If the ordered field has duplicates, the second order is always by ascending `name`,
  142. which guarantees a stable ordering. Valid values are:
  143. - `name` - Users are ordered alphabetically by `name`. This is the default.
  144. - `is_guest` - Users are ordered by `is_guest` status.
  145. - `admin` - Users are ordered by `admin` status.
  146. - `user_type` - Users are ordered alphabetically by `user_type`.
  147. - `deactivated` - Users are ordered by `deactivated` status.
  148. - `shadow_banned` - Users are ordered by `shadow_banned` status.
  149. - `displayname` - Users are ordered alphabetically by `displayname`.
  150. - `avatar_url` - Users are ordered alphabetically by avatar URL.
  151. - `dir` - Direction of media order. Either `f` for forwards or `b` for backwards.
  152. Setting this value to `b` will reverse the above sort order. Defaults to `f`.
  153. Caution. The database only has indexes on the columns `name` and `created_ts`.
  154. This means that if a different sort order is used (`is_guest`, `admin`,
  155. `user_type`, `deactivated`, `shadow_banned`, `avatar_url` or `displayname`),
  156. this can cause a large load on the database, especially for large environments.
  157. **Response**
  158. The following fields are returned in the JSON response body:
  159. - `users` - An array of objects, each containing information about an user.
  160. User objects contain the following fields:
  161. - `name` - string - Fully-qualified user ID (ex. `@user:server.com`).
  162. - `is_guest` - bool - Status if that user is a guest account.
  163. - `admin` - bool - Status if that user is a server administrator.
  164. - `user_type` - string - Type of the user. Normal users are type `None`.
  165. This allows user type specific behaviour. There are also types `support` and `bot`.
  166. - `deactivated` - bool - Status if that user has been marked as deactivated.
  167. - `shadow_banned` - bool - Status if that user has been marked as shadow banned.
  168. - `displayname` - string - The user's display name if they have set one.
  169. - `avatar_url` - string - The user's avatar URL if they have set one.
  170. - `next_token`: string representing a positive integer - Indication for pagination. See above.
  171. - `total` - integer - Total number of media.
  172. ## Query current sessions for a user
  173. This API returns information about the active sessions for a specific user.
  174. The endpoints are:
  175. ```
  176. GET /_synapse/admin/v1/whois/<user_id>
  177. ```
  178. and:
  179. ```
  180. GET /_matrix/client/r0/admin/whois/<userId>
  181. ```
  182. See also: [Client Server
  183. API Whois](https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-admin-whois-userid).
  184. To use it, you will need to authenticate by providing an `access_token` for a
  185. server admin: [Admin API](../../usage/administration/admin_api)
  186. It returns a JSON body like the following:
  187. ```json
  188. {
  189. "user_id": "<user_id>",
  190. "devices": {
  191. "": {
  192. "sessions": [
  193. {
  194. "connections": [
  195. {
  196. "ip": "1.2.3.4",
  197. "last_seen": 1417222374433,
  198. "user_agent": "Mozilla/5.0 ..."
  199. },
  200. {
  201. "ip": "1.2.3.10",
  202. "last_seen": 1417222374500,
  203. "user_agent": "Dalvik/2.1.0 ..."
  204. }
  205. ]
  206. }
  207. ]
  208. }
  209. }
  210. }
  211. ```
  212. `last_seen` is measured in milliseconds since the Unix epoch.
  213. ## Deactivate Account
  214. This API deactivates an account. It removes active access tokens, resets the
  215. password, and deletes third-party IDs (to prevent the user requesting a
  216. password reset).
  217. It can also mark the user as GDPR-erased. This means messages sent by the
  218. user will still be visible by anyone that was in the room when these messages
  219. were sent, but hidden from users joining the room afterwards.
  220. The api is:
  221. ```
  222. POST /_synapse/admin/v1/deactivate/<user_id>
  223. ```
  224. with a body of:
  225. ```json
  226. {
  227. "erase": true
  228. }
  229. ```
  230. To use it, you will need to authenticate by providing an `access_token` for a
  231. server admin: [Admin API](../../usage/administration/admin_api)
  232. The erase parameter is optional and defaults to `false`.
  233. An empty body may be passed for backwards compatibility.
  234. The following actions are performed when deactivating an user:
  235. - Try to unpind 3PIDs from the identity server
  236. - Remove all 3PIDs from the homeserver
  237. - Delete all devices and E2EE keys
  238. - Delete all access tokens
  239. - Delete the password hash
  240. - Removal from all rooms the user is a member of
  241. - Remove the user from the user directory
  242. - Reject all pending invites
  243. - Remove all account validity information related to the user
  244. The following additional actions are performed during deactivation if `erase`
  245. is set to `true`:
  246. - Remove the user's display name
  247. - Remove the user's avatar URL
  248. - Mark the user as erased
  249. ## Reset password
  250. Changes the password of another user. This will automatically log the user out of all their devices.
  251. The api is:
  252. ```
  253. POST /_synapse/admin/v1/reset_password/<user_id>
  254. ```
  255. with a body of:
  256. ```json
  257. {
  258. "new_password": "<secret>",
  259. "logout_devices": true
  260. }
  261. ```
  262. To use it, you will need to authenticate by providing an `access_token` for a
  263. server admin: [Admin API](../../usage/administration/admin_api)
  264. The parameter `new_password` is required.
  265. The parameter `logout_devices` is optional and defaults to `true`.
  266. ## Get whether a user is a server administrator or not
  267. The api is:
  268. ```
  269. GET /_synapse/admin/v1/users/<user_id>/admin
  270. ```
  271. To use it, you will need to authenticate by providing an `access_token` for a
  272. server admin: [Admin API](../../usage/administration/admin_api)
  273. A response body like the following is returned:
  274. ```json
  275. {
  276. "admin": true
  277. }
  278. ```
  279. ## Change whether a user is a server administrator or not
  280. Note that you cannot demote yourself.
  281. The api is:
  282. ```
  283. PUT /_synapse/admin/v1/users/<user_id>/admin
  284. ```
  285. with a body of:
  286. ```json
  287. {
  288. "admin": true
  289. }
  290. ```
  291. To use it, you will need to authenticate by providing an `access_token` for a
  292. server admin: [Admin API](../../usage/administration/admin_api)
  293. ## List room memberships of a user
  294. Gets a list of all `room_id` that a specific `user_id` is member.
  295. The API is:
  296. ```
  297. GET /_synapse/admin/v1/users/<user_id>/joined_rooms
  298. ```
  299. To use it, you will need to authenticate by providing an `access_token` for a
  300. server admin: [Admin API](../../usage/administration/admin_api)
  301. A response body like the following is returned:
  302. ```json
  303. {
  304. "joined_rooms": [
  305. "!DuGcnbhHGaSZQoNQR:matrix.org",
  306. "!ZtSaPCawyWtxfWiIy:matrix.org"
  307. ],
  308. "total": 2
  309. }
  310. ```
  311. The server returns the list of rooms of which the user and the server
  312. are member. If the user is local, all the rooms of which the user is
  313. member are returned.
  314. **Parameters**
  315. The following parameters should be set in the URL:
  316. - `user_id` - fully qualified: for example, `@user:server.com`.
  317. **Response**
  318. The following fields are returned in the JSON response body:
  319. - `joined_rooms` - An array of `room_id`.
  320. - `total` - Number of rooms.
  321. ## List media of a user
  322. Gets a list of all local media that a specific `user_id` has created.
  323. By default, the response is ordered by descending creation date and ascending media ID.
  324. The newest media is on top. You can change the order with parameters
  325. `order_by` and `dir`.
  326. The API is:
  327. ```
  328. GET /_synapse/admin/v1/users/<user_id>/media
  329. ```
  330. To use it, you will need to authenticate by providing an `access_token` for a
  331. server admin: [Admin API](../../usage/administration/admin_api)
  332. A response body like the following is returned:
  333. ```json
  334. {
  335. "media": [
  336. {
  337. "created_ts": 100400,
  338. "last_access_ts": null,
  339. "media_id": "qXhyRzulkwLsNHTbpHreuEgo",
  340. "media_length": 67,
  341. "media_type": "image/png",
  342. "quarantined_by": null,
  343. "safe_from_quarantine": false,
  344. "upload_name": "test1.png"
  345. },
  346. {
  347. "created_ts": 200400,
  348. "last_access_ts": null,
  349. "media_id": "FHfiSnzoINDatrXHQIXBtahw",
  350. "media_length": 67,
  351. "media_type": "image/png",
  352. "quarantined_by": null,
  353. "safe_from_quarantine": false,
  354. "upload_name": "test2.png"
  355. }
  356. ],
  357. "next_token": 3,
  358. "total": 2
  359. }
  360. ```
  361. To paginate, check for `next_token` and if present, call the endpoint again
  362. with `from` set to the value of `next_token`. This will return a new page.
  363. If the endpoint does not return a `next_token` then there are no more
  364. reports to paginate through.
  365. **Parameters**
  366. The following parameters should be set in the URL:
  367. - `user_id` - string - fully qualified: for example, `@user:server.com`.
  368. - `limit`: string representing a positive integer - Is optional but is used for pagination,
  369. denoting the maximum number of items to return in this call. Defaults to `100`.
  370. - `from`: string representing a positive integer - Is optional but used for pagination,
  371. denoting the offset in the returned results. This should be treated as an opaque value and
  372. not explicitly set to anything other than the return value of `next_token` from a previous call.
  373. Defaults to `0`.
  374. - `order_by` - The method by which to sort the returned list of media.
  375. If the ordered field has duplicates, the second order is always by ascending `media_id`,
  376. which guarantees a stable ordering. Valid values are:
  377. - `media_id` - Media are ordered alphabetically by `media_id`.
  378. - `upload_name` - Media are ordered alphabetically by name the media was uploaded with.
  379. - `created_ts` - Media are ordered by when the content was uploaded in ms.
  380. Smallest to largest. This is the default.
  381. - `last_access_ts` - Media are ordered by when the content was last accessed in ms.
  382. Smallest to largest.
  383. - `media_length` - Media are ordered by length of the media in bytes.
  384. Smallest to largest.
  385. - `media_type` - Media are ordered alphabetically by MIME-type.
  386. - `quarantined_by` - Media are ordered alphabetically by the user ID that
  387. initiated the quarantine request for this media.
  388. - `safe_from_quarantine` - Media are ordered by the status if this media is safe
  389. from quarantining.
  390. - `dir` - Direction of media order. Either `f` for forwards or `b` for backwards.
  391. Setting this value to `b` will reverse the above sort order. Defaults to `f`.
  392. If neither `order_by` nor `dir` is set, the default order is newest media on top
  393. (corresponds to `order_by` = `created_ts` and `dir` = `b`).
  394. Caution. The database only has indexes on the columns `media_id`,
  395. `user_id` and `created_ts`. This means that if a different sort order is used
  396. (`upload_name`, `last_access_ts`, `media_length`, `media_type`,
  397. `quarantined_by` or `safe_from_quarantine`), this can cause a large load on the
  398. database, especially for large environments.
  399. **Response**
  400. The following fields are returned in the JSON response body:
  401. - `media` - An array of objects, each containing information about a media.
  402. Media objects contain the following fields:
  403. - `created_ts` - integer - Timestamp when the content was uploaded in ms.
  404. - `last_access_ts` - integer - Timestamp when the content was last accessed in ms.
  405. - `media_id` - string - The id used to refer to the media.
  406. - `media_length` - integer - Length of the media in bytes.
  407. - `media_type` - string - The MIME-type of the media.
  408. - `quarantined_by` - string - The user ID that initiated the quarantine request
  409. for this media.
  410. - `safe_from_quarantine` - bool - Status if this media is safe from quarantining.
  411. - `upload_name` - string - The name the media was uploaded with.
  412. - `next_token`: integer - Indication for pagination. See above.
  413. - `total` - integer - Total number of media.
  414. ## Login as a user
  415. Get an access token that can be used to authenticate as that user. Useful for
  416. when admins wish to do actions on behalf of a user.
  417. The API is:
  418. ```
  419. POST /_synapse/admin/v1/users/<user_id>/login
  420. {}
  421. ```
  422. An optional `valid_until_ms` field can be specified in the request body as an
  423. integer timestamp that specifies when the token should expire. By default tokens
  424. do not expire.
  425. A response body like the following is returned:
  426. ```json
  427. {
  428. "access_token": "<opaque_access_token_string>"
  429. }
  430. ```
  431. This API does *not* generate a new device for the user, and so will not appear
  432. their `/devices` list, and in general the target user should not be able to
  433. tell they have been logged in as.
  434. To expire the token call the standard `/logout` API with the token.
  435. Note: The token will expire if the *admin* user calls `/logout/all` from any
  436. of their devices, but the token will *not* expire if the target user does the
  437. same.
  438. ## User devices
  439. ### List all devices
  440. Gets information about all devices for a specific `user_id`.
  441. The API is:
  442. ```
  443. GET /_synapse/admin/v2/users/<user_id>/devices
  444. ```
  445. To use it, you will need to authenticate by providing an `access_token` for a
  446. server admin: [Admin API](../../usage/administration/admin_api)
  447. A response body like the following is returned:
  448. ```json
  449. {
  450. "devices": [
  451. {
  452. "device_id": "QBUAZIFURK",
  453. "display_name": "android",
  454. "last_seen_ip": "1.2.3.4",
  455. "last_seen_ts": 1474491775024,
  456. "user_id": "<user_id>"
  457. },
  458. {
  459. "device_id": "AUIECTSRND",
  460. "display_name": "ios",
  461. "last_seen_ip": "1.2.3.5",
  462. "last_seen_ts": 1474491775025,
  463. "user_id": "<user_id>"
  464. }
  465. ],
  466. "total": 2
  467. }
  468. ```
  469. **Parameters**
  470. The following parameters should be set in the URL:
  471. - `user_id` - fully qualified: for example, `@user:server.com`.
  472. **Response**
  473. The following fields are returned in the JSON response body:
  474. - `devices` - An array of objects, each containing information about a device.
  475. Device objects contain the following fields:
  476. - `device_id` - Identifier of device.
  477. - `display_name` - Display name set by the user for this device.
  478. Absent if no name has been set.
  479. - `last_seen_ip` - The IP address where this device was last seen.
  480. (May be a few minutes out of date, for efficiency reasons).
  481. - `last_seen_ts` - The timestamp (in milliseconds since the unix epoch) when this
  482. devices was last seen. (May be a few minutes out of date, for efficiency reasons).
  483. - `user_id` - Owner of device.
  484. - `total` - Total number of user's devices.
  485. ### Delete multiple devices
  486. Deletes the given devices for a specific `user_id`, and invalidates
  487. any access token associated with them.
  488. The API is:
  489. ```
  490. POST /_synapse/admin/v2/users/<user_id>/delete_devices
  491. {
  492. "devices": [
  493. "QBUAZIFURK",
  494. "AUIECTSRND"
  495. ],
  496. }
  497. ```
  498. To use it, you will need to authenticate by providing an `access_token` for a
  499. server admin: [Admin API](../../usage/administration/admin_api)
  500. An empty JSON dict is returned.
  501. **Parameters**
  502. The following parameters should be set in the URL:
  503. - `user_id` - fully qualified: for example, `@user:server.com`.
  504. The following fields are required in the JSON request body:
  505. - `devices` - The list of device IDs to delete.
  506. ### Show a device
  507. Gets information on a single device, by `device_id` for a specific `user_id`.
  508. The API is:
  509. ```
  510. GET /_synapse/admin/v2/users/<user_id>/devices/<device_id>
  511. ```
  512. To use it, you will need to authenticate by providing an `access_token` for a
  513. server admin: [Admin API](../../usage/administration/admin_api)
  514. A response body like the following is returned:
  515. ```json
  516. {
  517. "device_id": "<device_id>",
  518. "display_name": "android",
  519. "last_seen_ip": "1.2.3.4",
  520. "last_seen_ts": 1474491775024,
  521. "user_id": "<user_id>"
  522. }
  523. ```
  524. **Parameters**
  525. The following parameters should be set in the URL:
  526. - `user_id` - fully qualified: for example, `@user:server.com`.
  527. - `device_id` - The device to retrieve.
  528. **Response**
  529. The following fields are returned in the JSON response body:
  530. - `device_id` - Identifier of device.
  531. - `display_name` - Display name set by the user for this device.
  532. Absent if no name has been set.
  533. - `last_seen_ip` - The IP address where this device was last seen.
  534. (May be a few minutes out of date, for efficiency reasons).
  535. - `last_seen_ts` - The timestamp (in milliseconds since the unix epoch) when this
  536. devices was last seen. (May be a few minutes out of date, for efficiency reasons).
  537. - `user_id` - Owner of device.
  538. ### Update a device
  539. Updates the metadata on the given `device_id` for a specific `user_id`.
  540. The API is:
  541. ```
  542. PUT /_synapse/admin/v2/users/<user_id>/devices/<device_id>
  543. {
  544. "display_name": "My other phone"
  545. }
  546. ```
  547. To use it, you will need to authenticate by providing an `access_token` for a
  548. server admin: [Admin API](../../usage/administration/admin_api)
  549. An empty JSON dict is returned.
  550. **Parameters**
  551. The following parameters should be set in the URL:
  552. - `user_id` - fully qualified: for example, `@user:server.com`.
  553. - `device_id` - The device to update.
  554. The following fields are required in the JSON request body:
  555. - `display_name` - The new display name for this device. If not given,
  556. the display name is unchanged.
  557. ### Delete a device
  558. Deletes the given `device_id` for a specific `user_id`,
  559. and invalidates any access token associated with it.
  560. The API is:
  561. ```
  562. DELETE /_synapse/admin/v2/users/<user_id>/devices/<device_id>
  563. {}
  564. ```
  565. To use it, you will need to authenticate by providing an `access_token` for a
  566. server admin: [Admin API](../../usage/administration/admin_api)
  567. An empty JSON dict is returned.
  568. **Parameters**
  569. The following parameters should be set in the URL:
  570. - `user_id` - fully qualified: for example, `@user:server.com`.
  571. - `device_id` - The device to delete.
  572. ## List all pushers
  573. Gets information about all pushers for a specific `user_id`.
  574. The API is:
  575. ```
  576. GET /_synapse/admin/v1/users/<user_id>/pushers
  577. ```
  578. To use it, you will need to authenticate by providing an `access_token` for a
  579. server admin: [Admin API](../../usage/administration/admin_api)
  580. A response body like the following is returned:
  581. ```json
  582. {
  583. "pushers": [
  584. {
  585. "app_display_name":"HTTP Push Notifications",
  586. "app_id":"m.http",
  587. "data": {
  588. "url":"example.com"
  589. },
  590. "device_display_name":"pushy push",
  591. "kind":"http",
  592. "lang":"None",
  593. "profile_tag":"",
  594. "pushkey":"a@example.com"
  595. }
  596. ],
  597. "total": 1
  598. }
  599. ```
  600. **Parameters**
  601. The following parameters should be set in the URL:
  602. - `user_id` - fully qualified: for example, `@user:server.com`.
  603. **Response**
  604. The following fields are returned in the JSON response body:
  605. - `pushers` - An array containing the current pushers for the user
  606. - `app_display_name` - string - A string that will allow the user to identify
  607. what application owns this pusher.
  608. - `app_id` - string - This is a reverse-DNS style identifier for the application.
  609. Max length, 64 chars.
  610. - `data` - A dictionary of information for the pusher implementation itself.
  611. - `url` - string - Required if `kind` is `http`. The URL to use to send
  612. notifications to.
  613. - `format` - string - The format to use when sending notifications to the
  614. Push Gateway.
  615. - `device_display_name` - string - A string that will allow the user to identify
  616. what device owns this pusher.
  617. - `profile_tag` - string - This string determines which set of device specific rules
  618. this pusher executes.
  619. - `kind` - string - The kind of pusher. "http" is a pusher that sends HTTP pokes.
  620. - `lang` - string - The preferred language for receiving notifications
  621. (e.g. 'en' or 'en-US')
  622. - `profile_tag` - string - This string determines which set of device specific rules
  623. this pusher executes.
  624. - `pushkey` - string - This is a unique identifier for this pusher.
  625. Max length, 512 bytes.
  626. - `total` - integer - Number of pushers.
  627. See also the
  628. [Client-Server API Spec on pushers](https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-pushers).
  629. ## Shadow-banning users
  630. Shadow-banning is a useful tool for moderating malicious or egregiously abusive users.
  631. A shadow-banned users receives successful responses to their client-server API requests,
  632. but the events are not propagated into rooms. This can be an effective tool as it
  633. (hopefully) takes longer for the user to realise they are being moderated before
  634. pivoting to another account.
  635. Shadow-banning a user should be used as a tool of last resort and may lead to confusing
  636. or broken behaviour for the client. A shadow-banned user will not receive any
  637. notification and it is generally more appropriate to ban or kick abusive users.
  638. A shadow-banned user will be unable to contact anyone on the server.
  639. The API is:
  640. ```
  641. POST /_synapse/admin/v1/users/<user_id>/shadow_ban
  642. ```
  643. To use it, you will need to authenticate by providing an `access_token` for a
  644. server admin: [Admin API](../../usage/administration/admin_api)
  645. An empty JSON dict is returned.
  646. **Parameters**
  647. The following parameters should be set in the URL:
  648. - `user_id` - The fully qualified MXID: for example, `@user:server.com`. The user must
  649. be local.
  650. ## Override ratelimiting for users
  651. This API allows to override or disable ratelimiting for a specific user.
  652. There are specific APIs to set, get and delete a ratelimit.
  653. ### Get status of ratelimit
  654. The API is:
  655. ```
  656. GET /_synapse/admin/v1/users/<user_id>/override_ratelimit
  657. ```
  658. To use it, you will need to authenticate by providing an `access_token` for a
  659. server admin: [Admin API](../../usage/administration/admin_api)
  660. A response body like the following is returned:
  661. ```json
  662. {
  663. "messages_per_second": 0,
  664. "burst_count": 0
  665. }
  666. ```
  667. **Parameters**
  668. The following parameters should be set in the URL:
  669. - `user_id` - The fully qualified MXID: for example, `@user:server.com`. The user must
  670. be local.
  671. **Response**
  672. The following fields are returned in the JSON response body:
  673. - `messages_per_second` - integer - The number of actions that can
  674. be performed in a second. `0` mean that ratelimiting is disabled for this user.
  675. - `burst_count` - integer - How many actions that can be performed before
  676. being limited.
  677. If **no** custom ratelimit is set, an empty JSON dict is returned.
  678. ```json
  679. {}
  680. ```
  681. ### Set ratelimit
  682. The API is:
  683. ```
  684. POST /_synapse/admin/v1/users/<user_id>/override_ratelimit
  685. ```
  686. To use it, you will need to authenticate by providing an `access_token` for a
  687. server admin: [Admin API](../../usage/administration/admin_api)
  688. A response body like the following is returned:
  689. ```json
  690. {
  691. "messages_per_second": 0,
  692. "burst_count": 0
  693. }
  694. ```
  695. **Parameters**
  696. The following parameters should be set in the URL:
  697. - `user_id` - The fully qualified MXID: for example, `@user:server.com`. The user must
  698. be local.
  699. Body parameters:
  700. - `messages_per_second` - positive integer, optional. The number of actions that can
  701. be performed in a second. Defaults to `0`.
  702. - `burst_count` - positive integer, optional. How many actions that can be performed
  703. before being limited. Defaults to `0`.
  704. To disable users' ratelimit set both values to `0`.
  705. **Response**
  706. The following fields are returned in the JSON response body:
  707. - `messages_per_second` - integer - The number of actions that can
  708. be performed in a second.
  709. - `burst_count` - integer - How many actions that can be performed before
  710. being limited.
  711. ### Delete ratelimit
  712. The API is:
  713. ```
  714. DELETE /_synapse/admin/v1/users/<user_id>/override_ratelimit
  715. ```
  716. To use it, you will need to authenticate by providing an `access_token` for a
  717. server admin: [Admin API](../../usage/administration/admin_api)
  718. An empty JSON dict is returned.
  719. ```json
  720. {}
  721. ```
  722. **Parameters**
  723. The following parameters should be set in the URL:
  724. - `user_id` - The fully qualified MXID: for example, `@user:server.com`. The user must
  725. be local.