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