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