Merge branch 'feature/bump-elixir-verstion' into 'develop'
[akkoma] / docs / api / admin_api.md
1 # Admin API
2
3 Authentication is required and the user must be an admin.
4
5 ## `/api/pleroma/admin/users`
6
7 ### List users
8
9 - Method `GET`
10 - Query Params:
11 - *optional* `query`: **string** search term (e.g. nickname, domain, nickname@domain)
12 - *optional* `filters`: **string** comma-separated string of filters:
13 - `local`: only local users
14 - `external`: only external users
15 - `active`: only active users
16 - `deactivated`: only deactivated users
17 - `is_admin`: users with admin role
18 - `is_moderator`: users with moderator role
19 - *optional* `page`: **integer** page number
20 - *optional* `page_size`: **integer** number of users per page (default is `50`)
21 - *optional* `tags`: **[string]** tags list
22 - *optional* `name`: **string** user display name
23 - *optional* `email`: **string** user email
24 - 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`
25 - Response:
26
27 ```json
28 {
29 "page_size": integer,
30 "count": integer,
31 "users": [
32 {
33 "deactivated": bool,
34 "id": integer,
35 "nickname": string,
36 "roles": {
37 "admin": bool,
38 "moderator": bool
39 },
40 "local": bool,
41 "tags": array,
42 "avatar": string,
43 "display_name": string
44 },
45 ...
46 ]
47 }
48 ```
49
50 ## `/api/pleroma/admin/users`
51
52 ### Remove a user
53
54 - Method `DELETE`
55 - Params:
56 - `nickname`
57 - Response: User’s nickname
58
59 ### Create a user
60
61 - Method: `POST`
62 - Params:
63 `users`: [
64 {
65 `nickname`,
66 `email`,
67 `password`
68 }
69 ]
70 - Response: User’s nickname
71
72 ## `/api/pleroma/admin/users/follow`
73 ### Make a user follow another user
74
75 - Methods: `POST`
76 - Params:
77 - `follower`: The nickname of the follower
78 - `followed`: The nickname of the followed
79 - Response:
80 - "ok"
81
82 ## `/api/pleroma/admin/users/unfollow`
83 ### Make a user unfollow another user
84
85 - Methods: `POST`
86 - Params:
87 - `follower`: The nickname of the follower
88 - `followed`: The nickname of the followed
89 - Response:
90 - "ok"
91
92 ## `/api/pleroma/admin/users/:nickname/toggle_activation`
93
94 ### Toggle user activation
95
96 - Method: `PATCH`
97 - Params:
98 - `nickname`
99 - Response: User’s object
100
101 ```json
102 {
103 "deactivated": bool,
104 "id": integer,
105 "nickname": string
106 }
107 ```
108
109 ## `/api/pleroma/admin/users/tag`
110
111 ### Tag a list of users
112
113 - Method: `PUT`
114 - Params:
115 - `nicknames` (array)
116 - `tags` (array)
117
118 ### Untag a list of users
119
120 - Method: `DELETE`
121 - Params:
122 - `nicknames` (array)
123 - `tags` (array)
124
125 ## `/api/pleroma/admin/users/:nickname/permission_group`
126
127 ### Get user user permission groups membership
128
129 - Method: `GET`
130 - Params: none
131 - Response:
132
133 ```json
134 {
135 "is_moderator": bool,
136 "is_admin": bool
137 }
138 ```
139
140 ## `/api/pleroma/admin/users/:nickname/permission_group/:permission_group`
141
142 Note: Available `:permission_group` is currently moderator and admin. 404 is returned when the permission group doesn’t exist.
143
144 ### Get user user permission groups membership per permission group
145
146 - Method: `GET`
147 - Params: none
148 - Response:
149
150 ```json
151 {
152 "is_moderator": bool,
153 "is_admin": bool
154 }
155 ```
156
157 ### Add user in permission group
158
159 - Method: `POST`
160 - Params: none
161 - Response:
162 - On failure: `{"error": "…"}`
163 - On success: JSON of the `user.info`
164
165 ### Remove user from permission group
166
167 - Method: `DELETE`
168 - Params: none
169 - Response:
170 - On failure: `{"error": "…"}`
171 - On success: JSON of the `user.info`
172 - Note: An admin cannot revoke their own admin status.
173
174 ## `/api/pleroma/admin/users/:nickname/activation_status`
175
176 ### Active or deactivate a user
177
178 - Method: `PUT`
179 - Params:
180 - `nickname`
181 - `status` BOOLEAN field, false value means deactivation.
182
183 ## `/api/pleroma/admin/users/:nickname_or_id`
184
185 ### Retrive the details of a user
186
187 - Method: `GET`
188 - Params:
189 - `nickname` or `id`
190 - Response:
191 - On failure: `Not found`
192 - On success: JSON of the user
193
194 ## `/api/pleroma/admin/users/:nickname_or_id/statuses`
195
196 ### Retrive user's latest statuses
197
198 - Method: `GET`
199 - Params:
200 - `nickname` or `id`
201 - *optional* `page_size`: number of statuses to return (default is `20`)
202 - *optional* `godmode`: `true`/`false` – allows to see private statuses
203 - Response:
204 - On failure: `Not found`
205 - On success: JSON array of user's latest statuses
206
207 ## `/api/pleroma/admin/relay`
208
209 ### Follow a Relay
210
211 - Methods: `POST`
212 - Params:
213 - `relay_url`
214 - Response:
215 - On success: URL of the followed relay
216
217 ### Unfollow a Relay
218
219 - Methods: `DELETE`
220 - Params:
221 - `relay_url`
222 - Response:
223 - On success: URL of the unfollowed relay
224
225 ## `/api/pleroma/admin/users/invite_token`
226
227 ### Get an account registration invite token
228
229 - Methods: `GET`
230 - Params:
231 - *optional* `invite` => [
232 - *optional* `max_use` (integer)
233 - *optional* `expires_at` (date string e.g. "2019-04-07")
234 ]
235 - Response: invite token (base64 string)
236
237 ## `/api/pleroma/admin/users/invites`
238
239 ### Get a list of generated invites
240
241 - Methods: `GET`
242 - Params: none
243 - Response:
244
245 ```json
246 {
247
248 "invites": [
249 {
250 "id": integer,
251 "token": string,
252 "used": boolean,
253 "expires_at": date,
254 "uses": integer,
255 "max_use": integer,
256 "invite_type": string (possible values: `one_time`, `reusable`, `date_limited`, `reusable_date_limited`)
257 },
258 ...
259 ]
260 }
261 ```
262
263 ## `/api/pleroma/admin/users/revoke_invite`
264
265 ### Revoke invite by token
266
267 - Methods: `POST`
268 - Params:
269 - `token`
270 - Response:
271
272 ```json
273 {
274 "id": integer,
275 "token": string,
276 "used": boolean,
277 "expires_at": date,
278 "uses": integer,
279 "max_use": integer,
280 "invite_type": string (possible values: `one_time`, `reusable`, `date_limited`, `reusable_date_limited`)
281
282 }
283 ```
284
285
286 ## `/api/pleroma/admin/users/email_invite`
287
288 ### Sends registration invite via email
289
290 - Methods: `POST`
291 - Params:
292 - `email`
293 - `name`, optional
294
295 ## `/api/pleroma/admin/users/:nickname/password_reset`
296
297 ### Get a password reset token for a given nickname
298
299 - Methods: `GET`
300 - Params: none
301 - Response: password reset token (base64 string)
302
303 ## `/api/pleroma/admin/reports`
304 ### Get a list of reports
305 - Method `GET`
306 - Params:
307 - `state`: optional, the state of reports. Valid values are `open`, `closed` and `resolved`
308 - `limit`: optional, the number of records to retrieve
309 - `since_id`: optional, returns results that are more recent than the specified id
310 - `max_id`: optional, returns results that are older than the specified id
311 - Response:
312 - On failure: 403 Forbidden error `{"error": "error_msg"}` when requested by anonymous or non-admin
313 - On success: JSON, returns a list of reports, where:
314 - `account`: the user who has been reported
315 - `actor`: the user who has sent the report
316 - `statuses`: list of statuses that have been included to the report
317
318 ```json
319 {
320 "total" : 1,
321 "reports": [
322 {
323 "account": {
324 "acct": "user",
325 "avatar": "https://pleroma.example.org/images/avi.png",
326 "avatar_static": "https://pleroma.example.org/images/avi.png",
327 "bot": false,
328 "created_at": "2019-04-23T17:32:04.000Z",
329 "display_name": "User",
330 "emojis": [],
331 "fields": [],
332 "followers_count": 1,
333 "following_count": 1,
334 "header": "https://pleroma.example.org/images/banner.png",
335 "header_static": "https://pleroma.example.org/images/banner.png",
336 "id": "9i6dAJqSGSKMzLG2Lo",
337 "locked": false,
338 "note": "",
339 "pleroma": {
340 "confirmation_pending": false,
341 "hide_favorites": true,
342 "hide_followers": false,
343 "hide_follows": false,
344 "is_admin": false,
345 "is_moderator": false,
346 "relationship": {},
347 "tags": []
348 },
349 "source": {
350 "note": "",
351 "pleroma": {},
352 "sensitive": false
353 },
354 "tags": ["force_unlisted"],
355 "statuses_count": 3,
356 "url": "https://pleroma.example.org/users/user",
357 "username": "user"
358 },
359 "actor": {
360 "acct": "lain",
361 "avatar": "https://pleroma.example.org/images/avi.png",
362 "avatar_static": "https://pleroma.example.org/images/avi.png",
363 "bot": false,
364 "created_at": "2019-03-28T17:36:03.000Z",
365 "display_name": "Roger Braun",
366 "emojis": [],
367 "fields": [],
368 "followers_count": 1,
369 "following_count": 1,
370 "header": "https://pleroma.example.org/images/banner.png",
371 "header_static": "https://pleroma.example.org/images/banner.png",
372 "id": "9hEkA5JsvAdlSrocam",
373 "locked": false,
374 "note": "",
375 "pleroma": {
376 "confirmation_pending": false,
377 "hide_favorites": false,
378 "hide_followers": false,
379 "hide_follows": false,
380 "is_admin": false,
381 "is_moderator": false,
382 "relationship": {},
383 "tags": []
384 },
385 "source": {
386 "note": "",
387 "pleroma": {},
388 "sensitive": false
389 },
390 "tags": ["force_unlisted"],
391 "statuses_count": 1,
392 "url": "https://pleroma.example.org/users/lain",
393 "username": "lain"
394 },
395 "content": "Please delete it",
396 "created_at": "2019-04-29T19:48:15.000Z",
397 "id": "9iJGOv1j8hxuw19bcm",
398 "state": "open",
399 "statuses": [
400 {
401 "account": { ... },
402 "application": {
403 "name": "Web",
404 "website": null
405 },
406 "bookmarked": false,
407 "card": null,
408 "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>",
409 "created_at": "2019-04-23T19:15:47.000Z",
410 "emojis": [],
411 "favourited": false,
412 "favourites_count": 0,
413 "id": "9i6mQ9uVrrOmOime8m",
414 "in_reply_to_account_id": null,
415 "in_reply_to_id": null,
416 "language": null,
417 "media_attachments": [],
418 "mentions": [
419 {
420 "acct": "lain",
421 "id": "9hEkA5JsvAdlSrocam",
422 "url": "https://pleroma.example.org/users/lain",
423 "username": "lain"
424 },
425 {
426 "acct": "user",
427 "id": "9i6dAJqSGSKMzLG2Lo",
428 "url": "https://pleroma.example.org/users/user",
429 "username": "user"
430 }
431 ],
432 "muted": false,
433 "pinned": false,
434 "pleroma": {
435 "content": {
436 "text/plain": "@lain click on my link https://www.google.com/"
437 },
438 "conversation_id": 28,
439 "in_reply_to_account_acct": null,
440 "local": true,
441 "spoiler_text": {
442 "text/plain": ""
443 }
444 },
445 "reblog": null,
446 "reblogged": false,
447 "reblogs_count": 0,
448 "replies_count": 0,
449 "sensitive": false,
450 "spoiler_text": "",
451 "tags": [],
452 "uri": "https://pleroma.example.org/objects/8717b90f-8e09-4b58-97b0-e3305472b396",
453 "url": "https://pleroma.example.org/notice/9i6mQ9uVrrOmOime8m",
454 "visibility": "direct"
455 }
456 ]
457 }
458 ]
459 }
460 ```
461
462 ## `/api/pleroma/admin/reports/:id`
463 ### Get an individual report
464 - Method `GET`
465 - Params:
466 - `id`
467 - Response:
468 - On failure:
469 - 403 Forbidden `{"error": "error_msg"}`
470 - 404 Not Found `"Not found"`
471 - On success: JSON, Report object (see above)
472
473 ## `/api/pleroma/admin/reports/:id`
474 ### Change the state of the report
475 - Method `PUT`
476 - Params:
477 - `id`
478 - `state`: required, the new state. Valid values are `open`, `closed` and `resolved`
479 - Response:
480 - On failure:
481 - 400 Bad Request `"Unsupported state"`
482 - 403 Forbidden `{"error": "error_msg"}`
483 - 404 Not Found `"Not found"`
484 - On success: JSON, Report object (see above)
485
486 ## `/api/pleroma/admin/reports/:id/respond`
487 ### Respond to a report
488 - Method `POST`
489 - Params:
490 - `id`
491 - `status`: required, the message
492 - Response:
493 - On failure:
494 - 400 Bad Request `"Invalid parameters"` when `status` is missing
495 - 403 Forbidden `{"error": "error_msg"}`
496 - 404 Not Found `"Not found"`
497 - On success: JSON, created Mastodon Status entity
498
499 ```json
500 {
501 "account": { ... },
502 "application": {
503 "name": "Web",
504 "website": null
505 },
506 "bookmarked": false,
507 "card": null,
508 "content": "Your claim is going to be closed",
509 "created_at": "2019-05-11T17:13:03.000Z",
510 "emojis": [],
511 "favourited": false,
512 "favourites_count": 0,
513 "id": "9ihuiSL1405I65TmEq",
514 "in_reply_to_account_id": null,
515 "in_reply_to_id": null,
516 "language": null,
517 "media_attachments": [],
518 "mentions": [
519 {
520 "acct": "user",
521 "id": "9i6dAJqSGSKMzLG2Lo",
522 "url": "https://pleroma.example.org/users/user",
523 "username": "user"
524 },
525 {
526 "acct": "admin",
527 "id": "9hEkA5JsvAdlSrocam",
528 "url": "https://pleroma.example.org/users/admin",
529 "username": "admin"
530 }
531 ],
532 "muted": false,
533 "pinned": false,
534 "pleroma": {
535 "content": {
536 "text/plain": "Your claim is going to be closed"
537 },
538 "conversation_id": 35,
539 "in_reply_to_account_acct": null,
540 "local": true,
541 "spoiler_text": {
542 "text/plain": ""
543 }
544 },
545 "reblog": null,
546 "reblogged": false,
547 "reblogs_count": 0,
548 "replies_count": 0,
549 "sensitive": false,
550 "spoiler_text": "",
551 "tags": [],
552 "uri": "https://pleroma.example.org/objects/cab0836d-9814-46cd-a0ea-529da9db5fcb",
553 "url": "https://pleroma.example.org/notice/9ihuiSL1405I65TmEq",
554 "visibility": "direct"
555 }
556 ```
557
558 ## `/api/pleroma/admin/statuses/:id`
559 ### Change the scope of an individual reported status
560 - Method `PUT`
561 - Params:
562 - `id`
563 - `sensitive`: optional, valid values are `true` or `false`
564 - `visibility`: optional, valid values are `public`, `private` and `unlisted`
565 - Response:
566 - On failure:
567 - 400 Bad Request `"Unsupported visibility"`
568 - 403 Forbidden `{"error": "error_msg"}`
569 - 404 Not Found `"Not found"`
570 - On success: JSON, Mastodon Status entity
571
572 ## `/api/pleroma/admin/statuses/:id`
573 ### Delete an individual reported status
574 - Method `DELETE`
575 - Params:
576 - `id`
577 - Response:
578 - On failure:
579 - 403 Forbidden `{"error": "error_msg"}`
580 - 404 Not Found `"Not found"`
581 - On success: 200 OK `{}`
582
583
584 ## `/api/pleroma/admin/config/migrate_to_db`
585 ### Run mix task pleroma.config migrate_to_db
586 Copy settings on key `:pleroma` to DB.
587 - Method `GET`
588 - Params: none
589 - Response:
590
591 ```json
592 {}
593 ```
594
595 ## `/api/pleroma/admin/config/migrate_from_db`
596 ### Run mix task pleroma.config migrate_from_db
597 Copy all settings from DB to `config/prod.exported_from_db.secret.exs` with deletion from DB.
598 - Method `GET`
599 - Params: none
600 - Response:
601
602 ```json
603 {}
604 ```
605
606 ## `/api/pleroma/admin/config`
607 ### List config settings
608 List config settings only works with `:pleroma => :instance => :dynamic_configuration` setting to `true`.
609 - Method `GET`
610 - Params: none
611 - Response:
612
613 ```json
614 {
615 configs: [
616 {
617 "group": string,
618 "key": string or string with leading `:` for atoms,
619 "value": string or {} or [] or {"tuple": []}
620 }
621 ]
622 }
623 ```
624
625 ## `/api/pleroma/admin/config`
626 ### Update config settings
627 Updating config settings only works with `:pleroma => :instance => :dynamic_configuration` setting to `true`.
628 Module name can be passed as string, which starts with `Pleroma`, e.g. `"Pleroma.Upload"`.
629 Atom keys and values can be passed with `:` in the beginning, e.g. `":upload"`.
630 Tuples can be passed as `{"tuple": ["first_val", Pleroma.Module, []]}`.
631 `{"tuple": ["some_string", "Pleroma.Some.Module", []]}` will be converted to `{"some_string", Pleroma.Some.Module, []}`.
632 Keywords can be passed as lists with 2 child tuples, e.g.
633 `[{"tuple": ["first_val", Pleroma.Module]}, {"tuple": ["second_val", true]}]`.
634
635 If value contains list of settings `[subkey: val1, subkey2: val2, subkey3: val3]`, it's possible to remove only subkeys instead of all settings passing `subkeys` parameter. E.g.:
636 {"group": "pleroma", "key": "some_key", "delete": "true", "subkeys": [":subkey", ":subkey3"]}.
637
638 Compile time settings (need instance reboot):
639 - all settings by this keys:
640 - `:hackney_pools`
641 - `:chat`
642 - `Pleroma.Web.Endpoint`
643 - `Pleroma.Repo`
644 - part settings:
645 - `Pleroma.Captcha` -> `:seconds_valid`
646 - `Pleroma.Upload` -> `:proxy_remote`
647 - `:instance` -> `:upload_limit`
648
649 - Method `POST`
650 - Params:
651 - `configs` => [
652 - `group` (string)
653 - `key` (string or string with leading `:` for atoms)
654 - `value` (string, [], {} or {"tuple": []})
655 - `delete` = true (optional, if parameter must be deleted)
656 - `subkeys` [(string with leading `:` for atoms)] (optional, works only if `delete=true` parameter is passed, otherwise will be ignored)
657 ]
658
659 - Request (example):
660
661 ```json
662 {
663 configs: [
664 {
665 "group": "pleroma",
666 "key": "Pleroma.Upload",
667 "value": [
668 {"tuple": [":uploader", "Pleroma.Uploaders.Local"]},
669 {"tuple": [":filters", ["Pleroma.Upload.Filter.Dedupe"]]},
670 {"tuple": [":link_name", true]},
671 {"tuple": [":proxy_remote", false]},
672 {"tuple": [":proxy_opts", [
673 {"tuple": [":redirect_on_failure", false]},
674 {"tuple": [":max_body_length", 1048576]},
675 {"tuple": [":http": [
676 {"tuple": [":follow_redirect", true]},
677 {"tuple": [":pool", ":upload"]},
678 ]]}
679 ]
680 ]},
681 {"tuple": [":dispatch", {
682 "tuple": ["/api/v1/streaming", "Pleroma.Web.MastodonAPI.WebsocketHandler", []]
683 }]}
684 ]
685 }
686 ]
687 }
688
689 - Response:
690
691 ```json
692 {
693 configs: [
694 {
695 "group": string,
696 "key": string or string with leading `:` for atoms,
697 "value": string or {} or [] or {"tuple": []}
698 }
699 ]
700 }
701 ```
702
703 ## `/api/pleroma/admin/moderation_log`
704 ### Get moderation log
705 - Method `GET`
706 - Params:
707 - *optional* `page`: **integer** page number
708 - *optional* `page_size`: **integer** number of users per page (default is `50`)
709 - Response:
710
711 ```json
712 [
713 {
714 "data": {
715 "actor": {
716 "id": 1,
717 "nickname": "lain"
718 },
719 "action": "relay_follow"
720 },
721 "time": 1502812026, // timestamp
722 "message": "[2017-08-15 15:47:06] @nick0 followed relay: https://example.org/relay" // log message
723 }
724 ]
725 ```