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