Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

admin_api.md 13KB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. # Admin API
  2. Authentication is required and the user must be an admin.
  3. ## `/api/pleroma/admin/users`
  4. ### List users
  5. - Method `GET`
  6. - Query Params:
  7. - *optional* `query`: **string** search term (e.g. nickname, domain, nickname@domain)
  8. - *optional* `filters`: **string** comma-separated string of filters:
  9. - `local`: only local users
  10. - `external`: only external users
  11. - `active`: only active users
  12. - `deactivated`: only deactivated users
  13. - `is_admin`: users with admin role
  14. - `is_moderator`: users with moderator role
  15. - *optional* `page`: **integer** page number
  16. - *optional* `page_size`: **integer** number of users per page (default is `50`)
  17. - *optional* `tags`: **[string]** tags list
  18. - *optional* `name`: **string** user display name
  19. - *optional* `email`: **string** user email
  20. - Example: `https://mypleroma.org/api/pleroma/admin/users?query=john&filters=local,active&page=1&page_size=10&tags[]=some_tag&tags[]=another_tag&name=display_name&email=email@example.com`
  21. - Response:
  22. ```json
  23. {
  24. "page_size": integer,
  25. "count": integer,
  26. "users": [
  27. {
  28. "deactivated": bool,
  29. "id": integer,
  30. "nickname": string,
  31. "roles": {
  32. "admin": bool,
  33. "moderator": bool
  34. },
  35. "local": bool,
  36. "tags": array
  37. },
  38. ...
  39. ]
  40. }
  41. ```
  42. ## `/api/pleroma/admin/users`
  43. ### Remove a user
  44. - Method `DELETE`
  45. - Params:
  46. - `nickname`
  47. - Response: User’s nickname
  48. ### Create a user
  49. - Method: `POST`
  50. - Params:
  51. - `nickname`
  52. - `email`
  53. - `password`
  54. - Response: User’s nickname
  55. ## `/api/pleroma/admin/users/follow`
  56. ### Make a user follow another user
  57. - Methods: `POST`
  58. - Params:
  59. - `follower`: The nickname of the follower
  60. - `followed`: The nickname of the followed
  61. - Response:
  62. - "ok"
  63. ## `/api/pleroma/admin/users/unfollow`
  64. ### Make a user unfollow another user
  65. - Methods: `POST`
  66. - Params:
  67. - `follower`: The nickname of the follower
  68. - `followed`: The nickname of the followed
  69. - Response:
  70. - "ok"
  71. ## `/api/pleroma/admin/users/:nickname/toggle_activation`
  72. ### Toggle user activation
  73. - Method: `PATCH`
  74. - Params:
  75. - `nickname`
  76. - Response: User’s object
  77. ```json
  78. {
  79. "deactivated": bool,
  80. "id": integer,
  81. "nickname": string
  82. }
  83. ```
  84. ## `/api/pleroma/admin/users/tag`
  85. ### Tag a list of users
  86. - Method: `PUT`
  87. - Params:
  88. - `nicknames` (array)
  89. - `tags` (array)
  90. ### Untag a list of users
  91. - Method: `DELETE`
  92. - Params:
  93. - `nicknames` (array)
  94. - `tags` (array)
  95. ## `/api/pleroma/admin/users/:nickname/permission_group`
  96. ### Get user user permission groups membership
  97. - Method: `GET`
  98. - Params: none
  99. - Response:
  100. ```json
  101. {
  102. "is_moderator": bool,
  103. "is_admin": bool
  104. }
  105. ```
  106. ## `/api/pleroma/admin/users/:nickname/permission_group/:permission_group`
  107. Note: Available `:permission_group` is currently moderator and admin. 404 is returned when the permission group doesn’t exist.
  108. ### Get user user permission groups membership per permission group
  109. - Method: `GET`
  110. - Params: none
  111. - Response:
  112. ```json
  113. {
  114. "is_moderator": bool,
  115. "is_admin": bool
  116. }
  117. ```
  118. ### Add user in permission group
  119. - Method: `POST`
  120. - Params: none
  121. - Response:
  122. - On failure: `{"error": "…"}`
  123. - On success: JSON of the `user.info`
  124. ### Remove user from permission group
  125. - Method: `DELETE`
  126. - Params: none
  127. - Response:
  128. - On failure: `{"error": "…"}`
  129. - On success: JSON of the `user.info`
  130. - Note: An admin cannot revoke their own admin status.
  131. ## `/api/pleroma/admin/users/:nickname/activation_status`
  132. ### Active or deactivate a user
  133. - Method: `PUT`
  134. - Params:
  135. - `nickname`
  136. - `status` BOOLEAN field, false value means deactivation.
  137. ## `/api/pleroma/admin/users/:nickname`
  138. ### Retrive the details of a user
  139. - Method: `GET`
  140. - Params:
  141. - `nickname`
  142. - Response:
  143. - On failure: `Not found`
  144. - On success: JSON of the user
  145. ## `/api/pleroma/admin/relay`
  146. ### Follow a Relay
  147. - Methods: `POST`
  148. - Params:
  149. - `relay_url`
  150. - Response:
  151. - On success: URL of the followed relay
  152. ### Unfollow a Relay
  153. - Methods: `DELETE`
  154. - Params:
  155. - `relay_url`
  156. - Response:
  157. - On success: URL of the unfollowed relay
  158. ## `/api/pleroma/admin/users/invite_token`
  159. ### Get an account registration invite token
  160. - Methods: `GET`
  161. - Params:
  162. - *optional* `invite` => [
  163. - *optional* `max_use` (integer)
  164. - *optional* `expires_at` (date string e.g. "2019-04-07")
  165. ]
  166. - Response: invite token (base64 string)
  167. ## `/api/pleroma/admin/users/invites`
  168. ### Get a list of generated invites
  169. - Methods: `GET`
  170. - Params: none
  171. - Response:
  172. ```json
  173. {
  174. "invites": [
  175. {
  176. "id": integer,
  177. "token": string,
  178. "used": boolean,
  179. "expires_at": date,
  180. "uses": integer,
  181. "max_use": integer,
  182. "invite_type": string (possible values: `one_time`, `reusable`, `date_limited`, `reusable_date_limited`)
  183. },
  184. ...
  185. ]
  186. }
  187. ```
  188. ## `/api/pleroma/admin/users/revoke_invite`
  189. ### Revoke invite by token
  190. - Methods: `POST`
  191. - Params:
  192. - `token`
  193. - Response:
  194. ```json
  195. {
  196. "id": integer,
  197. "token": string,
  198. "used": boolean,
  199. "expires_at": date,
  200. "uses": integer,
  201. "max_use": integer,
  202. "invite_type": string (possible values: `one_time`, `reusable`, `date_limited`, `reusable_date_limited`)
  203. }
  204. ```
  205. ## `/api/pleroma/admin/users/email_invite`
  206. ### Sends registration invite via email
  207. - Methods: `POST`
  208. - Params:
  209. - `email`
  210. - `name`, optional
  211. ## `/api/pleroma/admin/users/:nickname/password_reset`
  212. ### Get a password reset token for a given nickname
  213. - Methods: `GET`
  214. - Params: none
  215. - Response: password reset token (base64 string)
  216. ## `/api/pleroma/admin/reports`
  217. ### Get a list of reports
  218. - Method `GET`
  219. - Params:
  220. - `state`: optional, the state of reports. Valid values are `open`, `closed` and `resolved`
  221. - `limit`: optional, the number of records to retrieve
  222. - `since_id`: optional, returns results that are more recent than the specified id
  223. - `max_id`: optional, returns results that are older than the specified id
  224. - Response:
  225. - On failure: 403 Forbidden error `{"error": "error_msg"}` when requested by anonymous or non-admin
  226. - On success: JSON, returns a list of reports, where:
  227. - `account`: the user who has been reported
  228. - `actor`: the user who has sent the report
  229. - `statuses`: list of statuses that have been included to the report
  230. ```json
  231. {
  232. "reports": [
  233. {
  234. "account": {
  235. "acct": "user",
  236. "avatar": "https://pleroma.example.org/images/avi.png",
  237. "avatar_static": "https://pleroma.example.org/images/avi.png",
  238. "bot": false,
  239. "created_at": "2019-04-23T17:32:04.000Z",
  240. "display_name": "User",
  241. "emojis": [],
  242. "fields": [],
  243. "followers_count": 1,
  244. "following_count": 1,
  245. "header": "https://pleroma.example.org/images/banner.png",
  246. "header_static": "https://pleroma.example.org/images/banner.png",
  247. "id": "9i6dAJqSGSKMzLG2Lo",
  248. "locked": false,
  249. "note": "",
  250. "pleroma": {
  251. "confirmation_pending": false,
  252. "hide_favorites": true,
  253. "hide_followers": false,
  254. "hide_follows": false,
  255. "is_admin": false,
  256. "is_moderator": false,
  257. "relationship": {},
  258. "tags": []
  259. },
  260. "source": {
  261. "note": "",
  262. "pleroma": {},
  263. "sensitive": false
  264. },
  265. "statuses_count": 3,
  266. "url": "https://pleroma.example.org/users/user",
  267. "username": "user"
  268. },
  269. "actor": {
  270. "acct": "lain",
  271. "avatar": "https://pleroma.example.org/images/avi.png",
  272. "avatar_static": "https://pleroma.example.org/images/avi.png",
  273. "bot": false,
  274. "created_at": "2019-03-28T17:36:03.000Z",
  275. "display_name": "Roger Braun",
  276. "emojis": [],
  277. "fields": [],
  278. "followers_count": 1,
  279. "following_count": 1,
  280. "header": "https://pleroma.example.org/images/banner.png",
  281. "header_static": "https://pleroma.example.org/images/banner.png",
  282. "id": "9hEkA5JsvAdlSrocam",
  283. "locked": false,
  284. "note": "",
  285. "pleroma": {
  286. "confirmation_pending": false,
  287. "hide_favorites": false,
  288. "hide_followers": false,
  289. "hide_follows": false,
  290. "is_admin": false,
  291. "is_moderator": false,
  292. "relationship": {},
  293. "tags": []
  294. },
  295. "source": {
  296. "note": "",
  297. "pleroma": {},
  298. "sensitive": false
  299. },
  300. "statuses_count": 1,
  301. "url": "https://pleroma.example.org/users/lain",
  302. "username": "lain"
  303. },
  304. "content": "Please delete it",
  305. "created_at": "2019-04-29T19:48:15.000Z",
  306. "id": "9iJGOv1j8hxuw19bcm",
  307. "state": "open",
  308. "statuses": [
  309. {
  310. "account": { ... },
  311. "application": {
  312. "name": "Web",
  313. "website": null
  314. },
  315. "bookmarked": false,
  316. "card": null,
  317. "content": "<span class=\"h-card\"><a data-user=\"9hEkA5JsvAdlSrocam\" class=\"u-url mention\" href=\"https://pleroma.example.org/users/lain\">@<span>lain</span></a></span> click on my link <a href=\"https://www.google.com/\">https://www.google.com/</a>",
  318. "created_at": "2019-04-23T19:15:47.000Z",
  319. "emojis": [],
  320. "favourited": false,
  321. "favourites_count": 0,
  322. "id": "9i6mQ9uVrrOmOime8m",
  323. "in_reply_to_account_id": null,
  324. "in_reply_to_id": null,
  325. "language": null,
  326. "media_attachments": [],
  327. "mentions": [
  328. {
  329. "acct": "lain",
  330. "id": "9hEkA5JsvAdlSrocam",
  331. "url": "https://pleroma.example.org/users/lain",
  332. "username": "lain"
  333. },
  334. {
  335. "acct": "user",
  336. "id": "9i6dAJqSGSKMzLG2Lo",
  337. "url": "https://pleroma.example.org/users/user",
  338. "username": "user"
  339. }
  340. ],
  341. "muted": false,
  342. "pinned": false,
  343. "pleroma": {
  344. "content": {
  345. "text/plain": "@lain click on my link https://www.google.com/"
  346. },
  347. "conversation_id": 28,
  348. "in_reply_to_account_acct": null,
  349. "local": true,
  350. "spoiler_text": {
  351. "text/plain": ""
  352. }
  353. },
  354. "reblog": null,
  355. "reblogged": false,
  356. "reblogs_count": 0,
  357. "replies_count": 0,
  358. "sensitive": false,
  359. "spoiler_text": "",
  360. "tags": [],
  361. "uri": "https://pleroma.example.org/objects/8717b90f-8e09-4b58-97b0-e3305472b396",
  362. "url": "https://pleroma.example.org/notice/9i6mQ9uVrrOmOime8m",
  363. "visibility": "direct"
  364. }
  365. ]
  366. }
  367. ]
  368. }
  369. ```
  370. ## `/api/pleroma/admin/reports/:id`
  371. ### Get an individual report
  372. - Method `GET`
  373. - Params:
  374. - `id`
  375. - Response:
  376. - On failure:
  377. - 403 Forbidden `{"error": "error_msg"}`
  378. - 404 Not Found `"Not found"`
  379. - On success: JSON, Report object (see above)
  380. ## `/api/pleroma/admin/reports/:id`
  381. ### Change the state of the report
  382. - Method `PUT`
  383. - Params:
  384. - `id`
  385. - `state`: required, the new state. Valid values are `open`, `closed` and `resolved`
  386. - Response:
  387. - On failure:
  388. - 400 Bad Request `"Unsupported state"`
  389. - 403 Forbidden `{"error": "error_msg"}`
  390. - 404 Not Found `"Not found"`
  391. - On success: JSON, Report object (see above)
  392. ## `/api/pleroma/admin/reports/:id/respond`
  393. ### Respond to a report
  394. - Method `POST`
  395. - Params:
  396. - `id`
  397. - `status`: required, the message
  398. - Response:
  399. - On failure:
  400. - 400 Bad Request `"Invalid parameters"` when `status` is missing
  401. - 403 Forbidden `{"error": "error_msg"}`
  402. - 404 Not Found `"Not found"`
  403. - On success: JSON, created Mastodon Status entity
  404. ```json
  405. {
  406. "account": { ... },
  407. "application": {
  408. "name": "Web",
  409. "website": null
  410. },
  411. "bookmarked": false,
  412. "card": null,
  413. "content": "Your claim is going to be closed",
  414. "created_at": "2019-05-11T17:13:03.000Z",
  415. "emojis": [],
  416. "favourited": false,
  417. "favourites_count": 0,
  418. "id": "9ihuiSL1405I65TmEq",
  419. "in_reply_to_account_id": null,
  420. "in_reply_to_id": null,
  421. "language": null,
  422. "media_attachments": [],
  423. "mentions": [
  424. {
  425. "acct": "user",
  426. "id": "9i6dAJqSGSKMzLG2Lo",
  427. "url": "https://pleroma.example.org/users/user",
  428. "username": "user"
  429. },
  430. {
  431. "acct": "admin",
  432. "id": "9hEkA5JsvAdlSrocam",
  433. "url": "https://pleroma.example.org/users/admin",
  434. "username": "admin"
  435. }
  436. ],
  437. "muted": false,
  438. "pinned": false,
  439. "pleroma": {
  440. "content": {
  441. "text/plain": "Your claim is going to be closed"
  442. },
  443. "conversation_id": 35,
  444. "in_reply_to_account_acct": null,
  445. "local": true,
  446. "spoiler_text": {
  447. "text/plain": ""
  448. }
  449. },
  450. "reblog": null,
  451. "reblogged": false,
  452. "reblogs_count": 0,
  453. "replies_count": 0,
  454. "sensitive": false,
  455. "spoiler_text": "",
  456. "tags": [],
  457. "uri": "https://pleroma.example.org/objects/cab0836d-9814-46cd-a0ea-529da9db5fcb",
  458. "url": "https://pleroma.example.org/notice/9ihuiSL1405I65TmEq",
  459. "visibility": "direct"
  460. }
  461. ```
  462. ## `/api/pleroma/admin/statuses/:id`
  463. ### Change the scope of an individual reported status
  464. - Method `PUT`
  465. - Params:
  466. - `id`
  467. - `sensitive`: optional, valid values are `true` or `false`
  468. - `visibility`: optional, valid values are `public`, `private` and `unlisted`
  469. - Response:
  470. - On failure:
  471. - 400 Bad Request `"Unsupported visibility"`
  472. - 403 Forbidden `{"error": "error_msg"}`
  473. - 404 Not Found `"Not found"`
  474. - On success: JSON, Mastodon Status entity
  475. ## `/api/pleroma/admin/statuses/:id`
  476. ### Delete an individual reported status
  477. - Method `DELETE`
  478. - Params:
  479. - `id`
  480. - Response:
  481. - On failure:
  482. - 403 Forbidden `{"error": "error_msg"}`
  483. - 404 Not Found `"Not found"`
  484. - On success: 200 OK `{}`