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