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