Merge remote-tracking branch 'remotes/origin/develop' into feature/object-hashtags...
[akkoma] / docs / development / API / admin_api.md
1 # Admin API
2
3 Authentication is required and the user must be an admin.
4
5 ## `GET /api/pleroma/admin/users`
6
7 ### List users
8
9 - Query Params:
10 - *optional* `query`: **string** search term (e.g. nickname, domain, nickname@domain)
11 - *optional* `filters`: **string** comma-separated string of filters:
12 - `local`: only local users
13 - `external`: only external users
14 - `active`: only active users
15 - `need_approval`: only unapproved users
16 - `unconfirmed`: only unconfirmed users
17 - `deactivated`: only deactivated users
18 - `is_admin`: users with admin role
19 - `is_moderator`: users with moderator role
20 - *optional* `page`: **integer** page number
21 - *optional* `page_size`: **integer** number of users per page (default is `50`)
22 - *optional* `tags`: **[string]** tags list
23 - *optional* `actor_types`: **[string]** actor type list (`Person`, `Service`, `Application`)
24 - *optional* `name`: **string** user display name
25 - *optional* `email`: **string** user email
26 - 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`
27 - Response:
28
29 ```json
30 {
31 "page_size": integer,
32 "count": integer,
33 "users": [
34 {
35 "deactivated": bool,
36 "id": integer,
37 "nickname": string,
38 "roles": {
39 "admin": bool,
40 "moderator": bool
41 },
42 "local": bool,
43 "tags": array,
44 "avatar": string,
45 "display_name": string,
46 "confirmation_pending": bool,
47 "approval_pending": bool,
48 "registration_reason": string,
49 },
50 ...
51 ]
52 }
53 ```
54
55 ## DEPRECATED `DELETE /api/pleroma/admin/users`
56
57 ### Remove a user
58
59 - Params:
60 - `nickname`
61 - Response: User’s nickname
62
63 ## `DELETE /api/pleroma/admin/users`
64
65 ### Remove a user
66
67 - Params:
68 - `nicknames`
69 - Response: Array of user nicknames
70
71 ### Create a user
72
73 - Method: `POST`
74 - Params:
75 `users`: [
76 {
77 `nickname`,
78 `email`,
79 `password`
80 }
81 ]
82 - Response: User’s nickname
83
84 ## `POST /api/pleroma/admin/users/follow`
85
86 ### Make a user follow another user
87
88 - Params:
89 - `follower`: The nickname of the follower
90 - `followed`: The nickname of the followed
91 - Response:
92 - "ok"
93
94 ## `POST /api/pleroma/admin/users/unfollow`
95
96 ### Make a user unfollow another user
97
98 - Params:
99 - `follower`: The nickname of the follower
100 - `followed`: The nickname of the followed
101 - Response:
102 - "ok"
103
104 ## `PATCH /api/pleroma/admin/users/:nickname/toggle_activation`
105
106 ### Toggle user activation
107
108 - Params:
109 - `nickname`
110 - Response: User’s object
111
112 ```json
113 {
114 "deactivated": bool,
115 "id": integer,
116 "nickname": string
117 }
118 ```
119
120 ## `PUT /api/pleroma/admin/users/tag`
121
122 ### Tag a list of users
123
124 - Params:
125 - `nicknames` (array)
126 - `tags` (array)
127
128 ## `DELETE /api/pleroma/admin/users/tag`
129
130 ### Untag a list of users
131
132 - Params:
133 - `nicknames` (array)
134 - `tags` (array)
135
136 ## `GET /api/pleroma/admin/users/:nickname/permission_group`
137
138 ### Get user user permission groups membership
139
140 - Params: none
141 - Response:
142
143 ```json
144 {
145 "is_moderator": bool,
146 "is_admin": bool
147 }
148 ```
149
150 ## `GET /api/pleroma/admin/users/:nickname/permission_group/:permission_group`
151
152 Note: Available `:permission_group` is currently moderator and admin. 404 is returned when the permission group doesn’t exist.
153
154 ### Get user user permission groups membership per permission group
155
156 - Params: none
157 - Response:
158
159 ```json
160 {
161 "is_moderator": bool,
162 "is_admin": bool
163 }
164 ```
165
166 ## DEPRECATED `POST /api/pleroma/admin/users/:nickname/permission_group/:permission_group`
167
168 ### Add user to permission group
169
170 - Params: none
171 - Response:
172 - On failure: `{"error": "…"}`
173 - On success: JSON of the user
174
175 ## `POST /api/pleroma/admin/users/permission_group/:permission_group`
176
177 ### Add users to permission group
178
179 - Params:
180 - `nicknames`: nicknames array
181 - Response:
182 - On failure: `{"error": "…"}`
183 - On success: JSON of the user
184
185 ## DEPRECATED `DELETE /api/pleroma/admin/users/:nickname/permission_group/:permission_group`
186
187 ## `DELETE /api/pleroma/admin/users/:nickname/permission_group/:permission_group`
188
189 ### Remove user from permission group
190
191 - Params: none
192 - Response:
193 - On failure: `{"error": "…"}`
194 - On success: JSON of the user
195 - Note: An admin cannot revoke their own admin status.
196
197 ## `DELETE /api/pleroma/admin/users/permission_group/:permission_group`
198
199 ### Remove users from permission group
200
201 - Params:
202 - `nicknames`: nicknames array
203 - Response:
204 - On failure: `{"error": "…"}`
205 - On success: JSON of the user
206 - Note: An admin cannot revoke their own admin status.
207
208 ## `PATCH /api/pleroma/admin/users/activate`
209
210 ### Activate user
211
212 - Params:
213 - `nicknames`: nicknames array
214 - Response:
215
216 ```json
217 {
218 users: [
219 {
220 // user object
221 }
222 ]
223 }
224 ```
225
226 ## `PATCH /api/pleroma/admin/users/deactivate`
227
228 ### Deactivate user
229
230 - Params:
231 - `nicknames`: nicknames array
232 - Response:
233
234 ```json
235 {
236 users: [
237 {
238 // user object
239 }
240 ]
241 }
242 ```
243
244 ## `PATCH /api/pleroma/admin/users/approve`
245
246 ### Approve user
247
248 - Params:
249 - `nicknames`: nicknames array
250 - Response:
251
252 ```json
253 {
254 users: [
255 {
256 // user object
257 }
258 ]
259 }
260 ```
261
262 ## `GET /api/pleroma/admin/users/:nickname_or_id`
263
264 ### Retrive the details of a user
265
266 - Params:
267 - `nickname` or `id`
268 - Response:
269 - On failure: `Not found`
270 - On success: JSON of the user
271
272 ## `GET /api/pleroma/admin/users/:nickname_or_id/statuses`
273
274 ### Retrive user's latest statuses
275
276 - Params:
277 - `nickname` or `id`
278 - *optional* `page_size`: number of statuses to return (default is `20`)
279 - *optional* `godmode`: `true`/`false` – allows to see private statuses
280 - *optional* `with_reblogs`: `true`/`false` – allows to see reblogs (default is false)
281 - Response:
282 - On failure: `Not found`
283 - On success: JSON, where:
284 - `total`: total count of the statuses for the user
285 - `activities`: list of the statuses for the user
286
287 ```json
288 {
289 "total" : 1,
290 "activities": [
291 // activities list
292 ]
293 }
294 ```
295
296 ## `GET /api/pleroma/admin/instances/:instance/statuses`
297
298 ### Retrive instance's latest statuses
299
300 - Params:
301 - `instance`: instance name
302 - *optional* `page_size`: number of statuses to return (default is `20`)
303 - *optional* `godmode`: `true`/`false` – allows to see private statuses
304 - *optional* `with_reblogs`: `true`/`false` – allows to see reblogs (default is false)
305 - Response:
306 - On failure: `Not found`
307 - On success: JSON, where:
308 - `total`: total count of the statuses for the instance
309 - `activities`: list of the statuses for the instance
310
311 ```json
312 {
313 "total" : 1,
314 "activities": [
315 // activities list
316 ]
317 }
318 ```
319
320 ## `GET /api/pleroma/admin/statuses`
321
322 ### Retrives all latest statuses
323
324 - Params:
325 - *optional* `page_size`: number of statuses to return (default is `20`)
326 - *optional* `local_only`: excludes remote statuses
327 - *optional* `godmode`: `true`/`false` – allows to see private statuses
328 - *optional* `with_reblogs`: `true`/`false` – allows to see reblogs (default is false)
329 - Response:
330 - On failure: `Not found`
331 - On success: JSON array of user's latest statuses
332
333 ## `GET /api/pleroma/admin/relay`
334
335 ### List Relays
336
337 Params: none
338 Response:
339
340 * On success: JSON array of relays
341
342 ```json
343 [
344 {"actor": "https://example.com/relay", "followed_back": true},
345 {"actor": "https://example2.com/relay", "followed_back": false}
346 ]
347 ```
348
349 ## `POST /api/pleroma/admin/relay`
350
351 ### Follow a Relay
352
353 Params:
354
355 * `relay_url`
356
357 Response:
358
359 * On success: relay json object
360
361 ```json
362 {"actor": "https://example.com/relay", "followed_back": true}
363 ```
364
365 ## `DELETE /api/pleroma/admin/relay`
366
367 ### Unfollow a Relay
368
369 - Params:
370 - `relay_url`
371 - *optional* `force`: forcefully unfollow a relay even when the relay is not available. (default is `false`)
372
373 Response:
374
375 * On success: URL of the unfollowed relay
376
377 ```json
378 {"https://example.com/relay"}
379 ```
380
381 ## `POST /api/pleroma/admin/users/invite_token`
382
383 ### Create an account registration invite token
384
385 - Params:
386 - *optional* `max_use` (integer)
387 - *optional* `expires_at` (date string e.g. "2019-04-07")
388 - Response:
389
390 ```json
391 {
392 "id": integer,
393 "token": string,
394 "used": boolean,
395 "expires_at": date,
396 "uses": integer,
397 "max_use": integer,
398 "invite_type": string (possible values: `one_time`, `reusable`, `date_limited`, `reusable_date_limited`)
399 }
400 ```
401
402 ## `GET /api/pleroma/admin/users/invites`
403
404 ### Get a list of generated invites
405
406 - Params: none
407 - Response:
408
409 ```json
410 {
411
412 "invites": [
413 {
414 "id": integer,
415 "token": string,
416 "used": boolean,
417 "expires_at": date,
418 "uses": integer,
419 "max_use": integer,
420 "invite_type": string (possible values: `one_time`, `reusable`, `date_limited`, `reusable_date_limited`)
421 },
422 ...
423 ]
424 }
425 ```
426
427 ## `POST /api/pleroma/admin/users/revoke_invite`
428
429 ### Revoke invite by token
430
431 - Params:
432 - `token`
433 - Response:
434
435 ```json
436 {
437 "id": integer,
438 "token": string,
439 "used": boolean,
440 "expires_at": date,
441 "uses": integer,
442 "max_use": integer,
443 "invite_type": string (possible values: `one_time`, `reusable`, `date_limited`, `reusable_date_limited`)
444
445 }
446 ```
447
448 ## `POST /api/pleroma/admin/users/email_invite`
449
450 ### Sends registration invite via email
451
452 - Params:
453 - `email`
454 - `name`, optional
455
456 - Response:
457 - On success: `204`, empty response
458 - On failure:
459 - 400 Bad Request, JSON:
460
461 ```json
462 [
463 {
464 "error": "Appropriate error message here"
465 }
466 ]
467 ```
468
469 ## `GET /api/pleroma/admin/users/:nickname/password_reset`
470
471 ### Get a password reset token for a given nickname
472
473
474 - Params: none
475 - Response:
476
477 ```json
478 {
479 "token": "base64 reset token",
480 "link": "https://pleroma.social/api/pleroma/password_reset/url-encoded-base64-token"
481 }
482 ```
483
484 ## `PATCH /api/pleroma/admin/users/force_password_reset`
485
486 ### Force passord reset for a user with a given nickname
487
488 - Params:
489 - `nicknames`
490 - Response: none (code `204`)
491
492 ## PUT `/api/pleroma/admin/users/disable_mfa`
493
494 ### Disable mfa for user's account.
495
496 - Params:
497 - `nickname`
498 - Response: User’s nickname
499
500 ## `GET /api/pleroma/admin/users/:nickname/credentials`
501
502 ### Get the user's email, password, display and settings-related fields
503
504 - Params:
505 - `nickname`
506
507 - Response:
508
509 ```json
510 {
511 "actor_type": "Person",
512 "allow_following_move": true,
513 "avatar": "https://pleroma.social/media/7e8e7508fd545ef580549b6881d80ec0ff2c81ed9ad37b9bdbbdf0e0d030159d.jpg",
514 "background": "https://pleroma.social/media/4de34c0bd10970d02cbdef8972bef0ebbf55f43cadc449554d4396156162fe9a.jpg",
515 "banner": "https://pleroma.social/media/8d92ba2bd244b613520abf557dd448adcd30f5587022813ee9dd068945986946.jpg",
516 "bio": "bio",
517 "default_scope": "public",
518 "discoverable": false,
519 "email": "user@example.com",
520 "fields": [
521 {
522 "name": "example",
523 "value": "<a href=\"https://example.com\" rel=\"ugc\">https://example.com</a>"
524 }
525 ],
526 "hide_favorites": false,
527 "hide_followers": false,
528 "hide_followers_count": false,
529 "hide_follows": false,
530 "hide_follows_count": false,
531 "id": "9oouHaEEUR54hls968",
532 "locked": true,
533 "name": "user",
534 "no_rich_text": true,
535 "pleroma_settings_store": {},
536 "raw_fields": [
537 {
538 "id": 1,
539 "name": "example",
540 "value": "https://example.com"
541 },
542 ],
543 "show_role": true,
544 "skip_thread_containment": false
545 }
546 ```
547
548 ## `PATCH /api/pleroma/admin/users/:nickname/credentials`
549
550 ### Change the user's email, password, display and settings-related fields
551
552 * Params:
553 * `email`
554 * `password`
555 * `name`
556 * `bio`
557 * `avatar`
558 * `locked`
559 * `no_rich_text`
560 * `default_scope`
561 * `banner`
562 * `hide_follows`
563 * `hide_followers`
564 * `hide_followers_count`
565 * `hide_follows_count`
566 * `hide_favorites`
567 * `allow_following_move`
568 * `background`
569 * `show_role`
570 * `skip_thread_containment`
571 * `fields`
572 * `is_discoverable`
573 * `actor_type`
574
575 * Responses:
576
577 Status: 200
578
579 ```json
580 {"status": "success"}
581 ```
582
583 Status: 400
584
585 ```json
586 {"errors":
587 {"actor_type": "is invalid"},
588 {"email": "has invalid format"},
589 ...
590 }
591 ```
592
593 Status: 404
594
595 ```json
596 {"error": "Not found"}
597 ```
598
599 ## `GET /api/pleroma/admin/reports`
600
601 ### Get a list of reports
602
603 - Params:
604 - *optional* `state`: **string** the state of reports. Valid values are `open`, `closed` and `resolved`
605 - *optional* `limit`: **integer** the number of records to retrieve
606 - *optional* `page`: **integer** page number
607 - *optional* `page_size`: **integer** number of log entries per page (default is `50`)
608 - Response:
609 - On failure: 403 Forbidden error `{"error": "error_msg"}` when requested by anonymous or non-admin
610 - On success: JSON, returns a list of reports, where:
611 - `account`: the user who has been reported
612 - `actor`: the user who has sent the report
613 - `statuses`: list of statuses that have been included to the report
614
615 ```json
616 {
617 "total" : 1,
618 "reports": [
619 {
620 "account": {
621 "acct": "user",
622 "avatar": "https://pleroma.example.org/images/avi.png",
623 "avatar_static": "https://pleroma.example.org/images/avi.png",
624 "bot": false,
625 "created_at": "2019-04-23T17:32:04.000Z",
626 "display_name": "User",
627 "emojis": [],
628 "fields": [],
629 "followers_count": 1,
630 "following_count": 1,
631 "header": "https://pleroma.example.org/images/banner.png",
632 "header_static": "https://pleroma.example.org/images/banner.png",
633 "id": "9i6dAJqSGSKMzLG2Lo",
634 "locked": false,
635 "note": "",
636 "pleroma": {
637 "confirmation_pending": false,
638 "hide_favorites": true,
639 "hide_followers": false,
640 "hide_follows": false,
641 "is_admin": false,
642 "is_moderator": false,
643 "relationship": {},
644 "tags": []
645 },
646 "source": {
647 "note": "",
648 "pleroma": {},
649 "sensitive": false
650 },
651 "tags": ["force_unlisted"],
652 "statuses_count": 3,
653 "url": "https://pleroma.example.org/users/user",
654 "username": "user"
655 },
656 "actor": {
657 "acct": "lain",
658 "avatar": "https://pleroma.example.org/images/avi.png",
659 "avatar_static": "https://pleroma.example.org/images/avi.png",
660 "bot": false,
661 "created_at": "2019-03-28T17:36:03.000Z",
662 "display_name": "Roger Braun",
663 "emojis": [],
664 "fields": [],
665 "followers_count": 1,
666 "following_count": 1,
667 "header": "https://pleroma.example.org/images/banner.png",
668 "header_static": "https://pleroma.example.org/images/banner.png",
669 "id": "9hEkA5JsvAdlSrocam",
670 "locked": false,
671 "note": "",
672 "pleroma": {
673 "confirmation_pending": false,
674 "hide_favorites": false,
675 "hide_followers": false,
676 "hide_follows": false,
677 "is_admin": false,
678 "is_moderator": false,
679 "relationship": {},
680 "tags": []
681 },
682 "source": {
683 "note": "",
684 "pleroma": {},
685 "sensitive": false
686 },
687 "tags": ["force_unlisted"],
688 "statuses_count": 1,
689 "url": "https://pleroma.example.org/users/lain",
690 "username": "lain"
691 },
692 "content": "Please delete it",
693 "created_at": "2019-04-29T19:48:15.000Z",
694 "id": "9iJGOv1j8hxuw19bcm",
695 "state": "open",
696 "statuses": [
697 {
698 "account": { ... },
699 "application": {
700 "name": "Web",
701 "website": null
702 },
703 "bookmarked": false,
704 "card": null,
705 "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>",
706 "created_at": "2019-04-23T19:15:47.000Z",
707 "emojis": [],
708 "favourited": false,
709 "favourites_count": 0,
710 "id": "9i6mQ9uVrrOmOime8m",
711 "in_reply_to_account_id": null,
712 "in_reply_to_id": null,
713 "language": null,
714 "media_attachments": [],
715 "mentions": [
716 {
717 "acct": "lain",
718 "id": "9hEkA5JsvAdlSrocam",
719 "url": "https://pleroma.example.org/users/lain",
720 "username": "lain"
721 },
722 {
723 "acct": "user",
724 "id": "9i6dAJqSGSKMzLG2Lo",
725 "url": "https://pleroma.example.org/users/user",
726 "username": "user"
727 }
728 ],
729 "muted": false,
730 "pinned": false,
731 "pleroma": {
732 "content": {
733 "text/plain": "@lain click on my link https://www.google.com/"
734 },
735 "conversation_id": 28,
736 "in_reply_to_account_acct": null,
737 "local": true,
738 "spoiler_text": {
739 "text/plain": ""
740 }
741 },
742 "reblog": null,
743 "reblogged": false,
744 "reblogs_count": 0,
745 "replies_count": 0,
746 "sensitive": false,
747 "spoiler_text": "",
748 "tags": [],
749 "uri": "https://pleroma.example.org/objects/8717b90f-8e09-4b58-97b0-e3305472b396",
750 "url": "https://pleroma.example.org/notice/9i6mQ9uVrrOmOime8m",
751 "visibility": "direct"
752 }
753 ]
754 }
755 ]
756 }
757 ```
758
759 ## `GET /api/pleroma/admin/grouped_reports`
760
761 ### Get a list of reports, grouped by status
762
763 - Params: none
764 - On success: JSON, returns a list of reports, where:
765 - `date`: date of the latest report
766 - `account`: the user who has been reported (see `/api/pleroma/admin/reports` for reference)
767 - `status`: reported status (see `/api/pleroma/admin/reports` for reference)
768 - `actors`: users who had reported this status (see `/api/pleroma/admin/reports` for reference)
769 - `reports`: reports (see `/api/pleroma/admin/reports` for reference)
770
771 ```json
772 "reports": [
773 {
774 "date": "2019-10-07T12:31:39.615149Z",
775 "account": { ... },
776 "status": { ... },
777 "actors": [{ ... }, { ... }],
778 "reports": [{ ... }]
779 }
780 ]
781 ```
782
783 ## `GET /api/pleroma/admin/reports/:id`
784
785 ### Get an individual report
786
787 - Params:
788 - `id`
789 - Response:
790 - On failure:
791 - 403 Forbidden `{"error": "error_msg"}`
792 - 404 Not Found `"Not found"`
793 - On success: JSON, Report object (see above)
794
795 ## `PATCH /api/pleroma/admin/reports`
796
797 ### Change the state of one or multiple reports
798
799 - Params:
800
801 ```json
802 `reports`: [
803 {
804 `id`, // required, report id
805 `state` // required, the new state. Valid values are `open`, `closed` and `resolved`
806 },
807 ...
808 ]
809 ```
810
811 - Response:
812 - On failure:
813 - 400 Bad Request, JSON:
814
815 ```json
816 [
817 {
818 `id`, // report id
819 `error` // error message
820 }
821 ]
822 ```
823
824 - On success: `204`, empty response
825
826 ## `POST /api/pleroma/admin/reports/:id/notes`
827
828 ### Create report note
829
830 - Params:
831 - `id`: required, report id
832 - `content`: required, the message
833 - Response:
834 - On failure:
835 - 400 Bad Request `"Invalid parameters"` when `status` is missing
836 - On success: `204`, empty response
837
838 ## `DELETE /api/pleroma/admin/reports/:report_id/notes/:id`
839
840 ### Delete report note
841
842 - Params:
843 - `report_id`: required, report id
844 - `id`: required, note id
845 - Response:
846 - On failure:
847 - 400 Bad Request `"Invalid parameters"` when `status` is missing
848 - On success: `204`, empty response
849
850 ## `GET /api/pleroma/admin/statuses/:id`
851
852 ### Show status by id
853
854 - Params:
855 - `id`: required, status id
856 - Response:
857 - On failure:
858 - 404 Not Found `"Not Found"`
859 - On success: JSON, Mastodon Status entity
860
861 ## `PUT /api/pleroma/admin/statuses/:id`
862
863 ### Change the scope of an individual reported status
864
865 - Params:
866 - `id`
867 - `sensitive`: optional, valid values are `true` or `false`
868 - `visibility`: optional, valid values are `public`, `private` and `unlisted`
869 - Response:
870 - On failure:
871 - 400 Bad Request `"Unsupported visibility"`
872 - 403 Forbidden `{"error": "error_msg"}`
873 - 404 Not Found `"Not found"`
874 - On success: JSON, Mastodon Status entity
875
876 ## `DELETE /api/pleroma/admin/statuses/:id`
877
878 ### Delete an individual reported status
879
880 - Params:
881 - `id`
882 - Response:
883 - On failure:
884 - 403 Forbidden `{"error": "error_msg"}`
885 - 404 Not Found `"Not found"`
886 - On success: 200 OK `{}`
887
888 ## `GET /api/pleroma/admin/restart`
889
890 ### Restarts pleroma application
891
892 **Only works when configuration from database is enabled.**
893
894 - Params: none
895 - Response:
896 - On failure:
897 - 400 Bad Request `"To use this endpoint you need to enable configuration from database."`
898
899 ```json
900 {}
901 ```
902
903 ## `GET /api/pleroma/admin/need_reboot`
904
905 ### Returns the flag whether the pleroma should be restarted
906
907 - Params: none
908 - Response:
909 - `need_reboot` - boolean
910 ```json
911 {
912 "need_reboot": false
913 }
914 ```
915
916 ## `GET /api/pleroma/admin/config`
917
918 ### Get list of merged default settings with saved in database.
919
920 *If `need_reboot` is `true`, instance must be restarted, so reboot time settings can take effect.*
921
922 **Only works when configuration from database is enabled.**
923
924 - Params:
925 - `only_db`: true (*optional*, get only saved in database settings)
926 - Response:
927 - On failure:
928 - 400 Bad Request `"To use this endpoint you need to enable configuration from database."`
929
930 ```json
931 {
932 "configs": [
933 {
934 "group": ":pleroma",
935 "key": "Pleroma.Upload",
936 "value": []
937 }
938 ],
939 "need_reboot": true
940 }
941 ```
942
943 ## `POST /api/pleroma/admin/config`
944
945 ### Update config settings
946
947 *If `need_reboot` is `true`, instance must be restarted, so reboot time settings can take effect.*
948
949 **Only works when configuration from database is enabled.**
950
951 Some modifications are necessary to save the config settings correctly:
952
953 - strings which start with `Pleroma.`, `Phoenix.`, `Tesla.` or strings like `Oban`, `Ueberauth` will be converted to modules;
954 ```
955 "Pleroma.Upload" -> Pleroma.Upload
956 "Oban" -> Oban
957 ```
958 - strings starting with `:` will be converted to atoms;
959 ```
960 ":pleroma" -> :pleroma
961 ```
962 - objects with `tuple` key and array value will be converted to tuples;
963 ```
964 {"tuple": ["string", "Pleroma.Upload", []]} -> {"string", Pleroma.Upload, []}
965 ```
966 - arrays with *tuple objects* will be converted to keywords;
967 ```
968 [{"tuple": [":key1", "value"]}, {"tuple": [":key2", "value"]}] -> [key1: "value", key2: "value"]
969 ```
970
971 Most of the settings will be applied in `runtime`, this means that you don't need to restart the instance. But some settings are applied in `compile time` and require a reboot of the instance, such as:
972 - all settings inside these keys:
973 - `:hackney_pools`
974 - `:connections_pool`
975 - `:pools`
976 - `:chat`
977 - partially settings inside these keys:
978 - `:seconds_valid` in `Pleroma.Captcha`
979 - `:proxy_remote` in `Pleroma.Upload`
980 - `:upload_limit` in `:instance`
981
982 - Params:
983 - `configs` - array of config objects
984 - config object params:
985 - `group` - string (**required**)
986 - `key` - string (**required**)
987 - `value` - string, [], {} or {"tuple": []} (**required**)
988 - `delete` - true (*optional*, if setting must be deleted)
989 - `subkeys` - array of strings (*optional*, only works when `delete=true` parameter is passed, otherwise will be ignored)
990
991 *When a value have several nested settings, you can delete only some nested settings by passing a parameter `subkeys`, without deleting all settings by key.*
992 ```
993 [subkey: val1, subkey2: val2, subkey3: val3] \\ initial value
994 {"group": ":pleroma", "key": "some_key", "delete": true, "subkeys": [":subkey", ":subkey3"]} \\ passing json for deletion
995 [subkey2: val2] \\ value after deletion
996 ```
997
998 *Most of the settings can be partially updated through merge old values with new values, except settings value of which is list or is not keyword.*
999
1000 Example of setting without keyword in value:
1001 ```elixir
1002 config :tesla, :adapter, Tesla.Adapter.Hackney
1003 ```
1004
1005 List of settings which support only full update by key:
1006 ```elixir
1007 @full_key_update [
1008 {:pleroma, :ecto_repos},
1009 {:quack, :meta},
1010 {:mime, :types},
1011 {:cors_plug, [:max_age, :methods, :expose, :headers]},
1012 {:auto_linker, :opts},
1013 {:swarm, :node_blacklist},
1014 {:logger, :backends}
1015 ]
1016 ```
1017
1018 List of settings which support only full update by subkey:
1019 ```elixir
1020 @full_subkey_update [
1021 {:pleroma, :assets, :mascots},
1022 {:pleroma, :emoji, :groups},
1023 {:pleroma, :workers, :retries},
1024 {:pleroma, :mrf_subchain, :match_actor},
1025 {:pleroma, :mrf_keyword, :replace}
1026 ]
1027 ```
1028
1029 *Settings without explicit key must be sended in separate config object params.*
1030 ```elixir
1031 config :quack,
1032 level: :debug,
1033 meta: [:all],
1034 ...
1035 ```
1036 ```json
1037 {
1038 "configs": [
1039 {"group": ":quack", "key": ":level", "value": ":debug"},
1040 {"group": ":quack", "key": ":meta", "value": [":all"]},
1041 ...
1042 ]
1043 }
1044 ```
1045 - Request:
1046
1047 ```json
1048 {
1049 "configs": [
1050 {
1051 "group": ":pleroma",
1052 "key": "Pleroma.Upload",
1053 "value": [
1054 {"tuple": [":uploader", "Pleroma.Uploaders.Local"]},
1055 {"tuple": [":filters", ["Pleroma.Upload.Filter.Dedupe"]]},
1056 {"tuple": [":link_name", true]},
1057 {"tuple": [":proxy_remote", false]},
1058 {"tuple": [":proxy_opts", [
1059 {"tuple": [":redirect_on_failure", false]},
1060 {"tuple": [":max_body_length", 1048576]},
1061 {"tuple": [":http", [
1062 {"tuple": [":follow_redirect", true]},
1063 {"tuple": [":pool", ":upload"]},
1064 ]]}
1065 ]
1066 ]},
1067 {"tuple": [":dispatch", {
1068 "tuple": ["/api/v1/streaming", "Pleroma.Web.MastodonAPI.WebsocketHandler", []]
1069 }]}
1070 ]
1071 }
1072 ]
1073 }
1074 ```
1075
1076 - Response:
1077 - On failure:
1078 - 400 Bad Request `"To use this endpoint you need to enable configuration from database."`
1079 ```json
1080 {
1081 "configs": [
1082 {
1083 "group": ":pleroma",
1084 "key": "Pleroma.Upload",
1085 "value": [...]
1086 }
1087 ],
1088 "need_reboot": true
1089 }
1090 ```
1091
1092 ## ` GET /api/pleroma/admin/config/descriptions`
1093
1094 ### Get JSON with config descriptions.
1095 Loads json generated from `config/descriptions.exs`.
1096
1097 - Params: none
1098 - Response:
1099
1100 ```json
1101 [{
1102 "group": ":pleroma", // string
1103 "key": "ModuleName", // string
1104 "type": "group", // string or list with possible values,
1105 "description": "Upload general settings", // string
1106 "children": [
1107 {
1108 "key": ":uploader", // string or module name `Pleroma.Upload`
1109 "type": "module",
1110 "description": "Module which will be used for uploads",
1111 "suggestions": ["module1", "module2"]
1112 },
1113 {
1114 "key": ":filters",
1115 "type": ["list", "module"],
1116 "description": "List of filter modules for uploads",
1117 "suggestions": [
1118 "module1", "module2", "module3"
1119 ]
1120 }
1121 ]
1122 }]
1123 ```
1124
1125 ## `GET /api/pleroma/admin/moderation_log`
1126
1127 ### Get moderation log
1128
1129 - Params:
1130 - *optional* `page`: **integer** page number
1131 - *optional* `page_size`: **integer** number of log entries per page (default is `50`)
1132 - *optional* `start_date`: **datetime (ISO 8601)** filter logs by creation date, start from `start_date`. Accepts datetime in ISO 8601 format (YYYY-MM-DDThh:mm:ss), e.g. `2005-08-09T18:31:42`
1133 - *optional* `end_date`: **datetime (ISO 8601)** filter logs by creation date, end by from `end_date`. Accepts datetime in ISO 8601 format (YYYY-MM-DDThh:mm:ss), e.g. 2005-08-09T18:31:42
1134 - *optional* `user_id`: **integer** filter logs by actor's id
1135 - *optional* `search`: **string** search logs by the log message
1136 - Response:
1137
1138 ```json
1139 [
1140 {
1141 "id": 1234,
1142 "data": {
1143 "actor": {
1144 "id": 1,
1145 "nickname": "lain"
1146 },
1147 "action": "relay_follow"
1148 },
1149 "time": 1502812026, // timestamp
1150 "message": "[2017-08-15 15:47:06] @nick0 followed relay: https://example.org/relay" // log message
1151 }
1152 ]
1153 ```
1154
1155 ## `POST /api/pleroma/admin/reload_emoji`
1156
1157 ### Reload the instance's custom emoji
1158
1159 - Authentication: required
1160 - Params: None
1161 - Response: JSON, "ok" and 200 status
1162
1163 ## `PATCH /api/pleroma/admin/users/confirm_email`
1164
1165 ### Confirm users' emails
1166
1167 - Params:
1168 - `nicknames`
1169 - Response: Array of user nicknames
1170
1171 ## `PATCH /api/pleroma/admin/users/resend_confirmation_email`
1172
1173 ### Resend confirmation email
1174
1175 - Params:
1176 - `nicknames`
1177 - Response: Array of user nicknames
1178
1179 ## `GET /api/pleroma/admin/stats`
1180
1181 ### Stats
1182
1183 - Query Params:
1184 - *optional* `instance`: **string** instance hostname (without protocol) to get stats for
1185 - Example: `https://mypleroma.org/api/pleroma/admin/stats?instance=lain.com`
1186
1187 - Response:
1188
1189 ```json
1190 {
1191 "status_visibility": {
1192 "direct": 739,
1193 "private": 9,
1194 "public": 17,
1195 "unlisted": 14
1196 }
1197 }
1198 ```
1199
1200 ## `GET /api/pleroma/admin/oauth_app`
1201
1202 ### List OAuth app
1203
1204 - Params:
1205 - *optional* `name`
1206 - *optional* `client_id`
1207 - *optional* `page`
1208 - *optional* `page_size`
1209 - *optional* `trusted`
1210
1211 - Response:
1212
1213 ```json
1214 {
1215 "apps": [
1216 {
1217 "id": 1,
1218 "name": "App name",
1219 "client_id": "yHoDSiWYp5mPV6AfsaVOWjdOyt5PhWRiafi6MRd1lSk",
1220 "client_secret": "nLmis486Vqrv2o65eM9mLQx_m_4gH-Q6PcDpGIMl6FY",
1221 "redirect_uri": "https://example.com/oauth-callback",
1222 "website": "https://example.com",
1223 "trusted": true
1224 }
1225 ],
1226 "count": 17,
1227 "page_size": 50
1228 }
1229 ```
1230
1231
1232 ## `POST /api/pleroma/admin/oauth_app`
1233
1234 ### Create OAuth App
1235
1236 - Params:
1237 - `name`
1238 - `redirect_uris`
1239 - `scopes`
1240 - *optional* `website`
1241 - *optional* `trusted`
1242
1243 - Response:
1244
1245 ```json
1246 {
1247 "id": 1,
1248 "name": "App name",
1249 "client_id": "yHoDSiWYp5mPV6AfsaVOWjdOyt5PhWRiafi6MRd1lSk",
1250 "client_secret": "nLmis486Vqrv2o65eM9mLQx_m_4gH-Q6PcDpGIMl6FY",
1251 "redirect_uri": "https://example.com/oauth-callback",
1252 "website": "https://example.com",
1253 "trusted": true
1254 }
1255 ```
1256
1257 - On failure:
1258 ```json
1259 {
1260 "redirect_uris": "can't be blank",
1261 "name": "can't be blank"
1262 }
1263 ```
1264
1265 ## `PATCH /api/pleroma/admin/oauth_app/:id`
1266
1267 ### Update OAuth App
1268
1269 - Params:
1270 - *optional* `name`
1271 - *optional* `redirect_uris`
1272 - *optional* `scopes`
1273 - *optional* `website`
1274 - *optional* `trusted`
1275
1276 - Response:
1277
1278 ```json
1279 {
1280 "id": 1,
1281 "name": "App name",
1282 "client_id": "yHoDSiWYp5mPV6AfsaVOWjdOyt5PhWRiafi6MRd1lSk",
1283 "client_secret": "nLmis486Vqrv2o65eM9mLQx_m_4gH-Q6PcDpGIMl6FY",
1284 "redirect_uri": "https://example.com/oauth-callback",
1285 "website": "https://example.com",
1286 "trusted": true
1287 }
1288 ```
1289
1290 ## `DELETE /api/pleroma/admin/oauth_app/:id`
1291
1292 ### Delete OAuth App
1293
1294 - Params: None
1295
1296 - Response:
1297 - On success: `204`, empty response
1298 - On failure:
1299 - 400 Bad Request `"Invalid parameters"` when `status` is missing
1300
1301 ## `GET /api/pleroma/admin/media_proxy_caches`
1302
1303 ### Get a list of all banned MediaProxy URLs in Cachex
1304
1305 - Authentication: required
1306 - Params:
1307 - *optional* `page`: **integer** page number
1308 - *optional* `page_size`: **integer** number of log entries per page (default is `50`)
1309 - *optional* `query`: **string** search term
1310
1311 - Response:
1312
1313 ``` json
1314 {
1315 "page_size": integer,
1316 "count": integer,
1317 "urls": [
1318 "http://example.com/media/a688346.jpg",
1319 "http://example.com/media/fb1f4d.jpg"
1320 ]
1321 }
1322
1323 ```
1324
1325 ## `POST /api/pleroma/admin/media_proxy_caches/delete`
1326
1327 ### Remove a banned MediaProxy URL from Cachex
1328
1329 - Authentication: required
1330 - Params:
1331 - `urls` (array)
1332
1333 - Response:
1334
1335 ``` json
1336 { }
1337
1338 ```
1339
1340 ## `POST /api/pleroma/admin/media_proxy_caches/purge`
1341
1342 ### Purge a MediaProxy URL
1343
1344 - Authentication: required
1345 - Params:
1346 - `urls` (array)
1347 - `ban` (boolean)
1348
1349 - Response:
1350
1351 ``` json
1352 { }
1353
1354 ```
1355
1356 ## GET /api/pleroma/admin/users/:nickname/chats
1357
1358 ### List a user's chats
1359
1360 - Params: None
1361
1362 - Response:
1363
1364 ```json
1365 [
1366 {
1367 "sender": {
1368 "id": "someflakeid",
1369 "username": "somenick",
1370 ...
1371 },
1372 "receiver": {
1373 "id": "someflakeid",
1374 "username": "somenick",
1375 ...
1376 },
1377 "id" : "1",
1378 "unread" : 2,
1379 "last_message" : {...}, // The last message in that chat
1380 "updated_at": "2020-04-21T15:11:46.000Z"
1381 }
1382 ]
1383 ```
1384
1385 ## GET /api/pleroma/admin/chats/:chat_id
1386
1387 ### View a single chat
1388
1389 - Params: None
1390
1391 - Response:
1392
1393 ```json
1394 {
1395 "sender": {
1396 "id": "someflakeid",
1397 "username": "somenick",
1398 ...
1399 },
1400 "receiver": {
1401 "id": "someflakeid",
1402 "username": "somenick",
1403 ...
1404 },
1405 "id" : "1",
1406 "unread" : 2,
1407 "last_message" : {...}, // The last message in that chat
1408 "updated_at": "2020-04-21T15:11:46.000Z"
1409 }
1410 ```
1411
1412 ## GET /api/pleroma/admin/chats/:chat_id/messages
1413
1414 ### List the messages in a chat
1415
1416 - Params: `max_id`, `min_id`
1417
1418 - Response:
1419
1420 ```json
1421 [
1422 {
1423 "account_id": "someflakeid",
1424 "chat_id": "1",
1425 "content": "Check this out :firefox:",
1426 "created_at": "2020-04-21T15:11:46.000Z",
1427 "emojis": [
1428 {
1429 "shortcode": "firefox",
1430 "static_url": "https://dontbulling.me/emoji/Firefox.gif",
1431 "url": "https://dontbulling.me/emoji/Firefox.gif",
1432 "visible_in_picker": false
1433 }
1434 ],
1435 "id": "13",
1436 "unread": true
1437 },
1438 {
1439 "account_id": "someflakeid",
1440 "chat_id": "1",
1441 "content": "Whats' up?",
1442 "created_at": "2020-04-21T15:06:45.000Z",
1443 "emojis": [],
1444 "id": "12",
1445 "unread": false
1446 }
1447 ]
1448 ```
1449
1450 ## DELETE /api/pleroma/admin/chats/:chat_id/messages/:message_id
1451
1452 ### Delete a single message
1453
1454 - Params: None
1455
1456 - Response:
1457
1458 ```json
1459 {
1460 "account_id": "someflakeid",
1461 "chat_id": "1",
1462 "content": "Check this out :firefox:",
1463 "created_at": "2020-04-21T15:11:46.000Z",
1464 "emojis": [
1465 {
1466 "shortcode": "firefox",
1467 "static_url": "https://dontbulling.me/emoji/Firefox.gif",
1468 "url": "https://dontbulling.me/emoji/Firefox.gif",
1469 "visible_in_picker": false
1470 }
1471 ],
1472 "id": "13",
1473 "unread": false
1474 }
1475 ```
1476
1477 ## `GET /api/pleroma/admin/instance_document/:document_name`
1478
1479 ### Get an instance document
1480
1481 - Authentication: required
1482
1483 - Response:
1484
1485 Returns the content of the document
1486
1487 ```html
1488 <h1>Instance panel</h1>
1489 ```
1490
1491 ## `PATCH /api/pleroma/admin/instance_document/:document_name`
1492 - Params:
1493 - `file` (the file to be uploaded, using multipart form data.)
1494
1495 ### Update an instance document
1496
1497 - Authentication: required
1498
1499 - Response:
1500
1501 ``` json
1502 {
1503 "url": "https://example.com/instance/panel.html"
1504 }
1505 ```
1506
1507 ## `DELETE /api/pleroma/admin/instance_document/:document_name`
1508
1509 ### Delete an instance document
1510
1511 - Response:
1512
1513 ``` json
1514 {
1515 "url": "https://example.com/instance/panel.html"
1516 }
1517 ```
1518
1519 ## `GET /api/pleroma/admin/frontends
1520
1521 ### List available frontends
1522
1523 - Response:
1524
1525 ```json
1526 [
1527 {
1528 "build_url": "https://git.pleroma.social/pleroma/fedi-fe/-/jobs/artifacts/${ref}/download?job=build",
1529 "git": "https://git.pleroma.social/pleroma/fedi-fe",
1530 "installed": true,
1531 "name": "fedi-fe",
1532 "ref": "master"
1533 },
1534 {
1535 "build_url": "https://git.pleroma.social/lambadalambda/kenoma/-/jobs/artifacts/${ref}/download?job=build",
1536 "git": "https://git.pleroma.social/lambadalambda/kenoma",
1537 "installed": false,
1538 "name": "kenoma",
1539 "ref": "master"
1540 }
1541 ]
1542 ```
1543
1544 ## `POST /api/pleroma/admin/frontends/install`
1545
1546 ### Install a frontend
1547
1548 - Params:
1549 - `name`: frontend name, required
1550 - `ref`: frontend ref
1551 - `file`: path to a frontend zip file
1552 - `build_url`: build URL
1553 - `build_dir`: build directory
1554
1555 - Response:
1556
1557 ```json
1558 [
1559 {
1560 "build_url": "https://git.pleroma.social/pleroma/fedi-fe/-/jobs/artifacts/${ref}/download?job=build",
1561 "git": "https://git.pleroma.social/pleroma/fedi-fe",
1562 "installed": true,
1563 "name": "fedi-fe",
1564 "ref": "master"
1565 },
1566 {
1567 "build_url": "https://git.pleroma.social/lambadalambda/kenoma/-/jobs/artifacts/${ref}/download?job=build",
1568 "git": "https://git.pleroma.social/lambadalambda/kenoma",
1569 "installed": false,
1570 "name": "kenoma",
1571 "ref": "master"
1572 }
1573 ]
1574 ```
1575
1576 ```json
1577 {
1578 "error": "Could not install frontend"
1579 }
1580 ```