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