move to 2.5.5
[anni] / 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     {:mime, :types},
1068     {:cors_plug, [:max_age, :methods, :expose, :headers]},
1069     {:auto_linker, :opts},
1070     {:swarm, :node_blacklist},
1071     {:logger, :backends}
1072   ]
1073 ```
1074
1075 List of settings which support only full update by subkey:
1076 ```elixir
1077 @full_subkey_update [
1078     {:pleroma, :assets, :mascots},
1079     {:pleroma, :emoji, :groups},
1080     {:pleroma, :workers, :retries},
1081     {:pleroma, :mrf_subchain, :match_actor},
1082     {:pleroma, :mrf_keyword, :replace}
1083   ]
1084 ```
1085
1086 *Settings without explicit key must be sent in separate config object params.*
1087 ```elixir
1088 config :foo,
1089   bar: :baz,
1090   meta: [:data],
1091   ...
1092 ```
1093 ```json
1094 {
1095   "configs": [
1096     {"group": ":foo", "key": ":bar", "value": ":baz"},
1097     {"group": ":foo", "key": ":meta", "value": [":data"]},
1098     ...
1099   ]
1100 }
1101 ```
1102 - Request:
1103
1104 ```json
1105 {
1106   "configs": [
1107     {
1108       "group": ":pleroma",
1109       "key": "Pleroma.Upload",
1110       "value": [
1111         {"tuple": [":uploader", "Pleroma.Uploaders.Local"]},
1112         {"tuple": [":filters", ["Pleroma.Upload.Filter.Dedupe"]]},
1113         {"tuple": [":link_name", true]},
1114         {"tuple": [":proxy_remote", false]},
1115         {"tuple": [":proxy_opts", [
1116           {"tuple": [":redirect_on_failure", false]},
1117           {"tuple": [":max_body_length", 1048576]},
1118           {"tuple": [":http", [
1119             {"tuple": [":follow_redirect", true]},
1120             {"tuple": [":pool", ":upload"]},
1121           ]]}
1122         ]
1123         ]},
1124         {"tuple": [":dispatch", {
1125           "tuple": ["/api/v1/streaming", "Pleroma.Web.MastodonAPI.WebsocketHandler", []]
1126         }]}
1127       ]
1128     }
1129   ]
1130 }
1131 ```
1132
1133 - Response:
1134   - On failure:
1135     - 400 Bad Request `"To use this endpoint you need to enable configuration from database."`
1136 ```json
1137 {
1138   "configs": [
1139     {
1140       "group": ":pleroma",
1141       "key": "Pleroma.Upload",
1142       "value": [...]
1143      }
1144   ],
1145   "need_reboot": true
1146 }
1147 ```
1148
1149 ## ` GET /api/v1/pleroma/admin/config/descriptions`
1150
1151 ### Get JSON with config descriptions.
1152 Loads json generated from `config/descriptions.exs`.
1153
1154 - Params: none
1155 - Response:
1156
1157 ```json
1158 [{
1159     "group": ":pleroma", // string
1160     "key": "ModuleName", // string
1161     "type": "group", // string or list with possible values,
1162     "description": "Upload general settings", // string
1163     "children": [
1164       {
1165         "key": ":uploader", // string or module name `Pleroma.Upload`
1166         "type": "module",
1167         "description": "Module which will be used for uploads",
1168         "suggestions": ["module1", "module2"]
1169       },
1170       {
1171         "key": ":filters",
1172         "type": ["list", "module"],
1173         "description": "List of filter modules for uploads",
1174         "suggestions": [
1175           "module1", "module2", "module3"
1176         ]
1177       }
1178     ]
1179 }]
1180 ```
1181
1182 ## `GET /api/v1/pleroma/admin/moderation_log`
1183
1184 ### Get moderation log
1185
1186 - Params:
1187   - *optional* `page`: **integer** page number
1188   - *optional* `page_size`: **integer** number of log entries per page (default is `50`)
1189   - *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`
1190   - *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
1191   - *optional* `user_id`: **integer** filter logs by actor's id
1192   - *optional* `search`: **string** search logs by the log message
1193 - Response:
1194
1195 ```json
1196 [
1197   {
1198     "id": 1234,
1199     "data": {
1200       "actor": {
1201         "id": 1,
1202         "nickname": "lain"
1203       },
1204       "action": "relay_follow"
1205     },
1206     "time": 1502812026, // timestamp
1207     "message": "[2017-08-15 15:47:06] @nick0 followed relay: https://example.org/relay" // log message
1208   }
1209 ]
1210 ```
1211
1212 ## `POST /api/v1/pleroma/admin/reload_emoji`
1213
1214 ### Reload the instance's custom emoji
1215
1216 - Authentication: required
1217 - Params: None
1218 - Response: JSON, "ok" and 200 status
1219
1220 ## `PATCH /api/v1/pleroma/admin/users/confirm_email`
1221
1222 ### Confirm users' emails
1223
1224 - Params:
1225   - `nicknames`
1226 - Response: Array of user nicknames
1227
1228 ## `PATCH /api/v1/pleroma/admin/users/resend_confirmation_email`
1229
1230 ### Resend confirmation email
1231
1232 - Params:
1233   - `nicknames`
1234 - Response: Array of user nicknames
1235
1236 ## `GET /api/v1/pleroma/admin/stats`
1237
1238 ### Stats
1239
1240 - Query Params:
1241   - *optional* `instance`: **string** instance hostname (without protocol) to get stats for
1242 - Example: `https://mypleroma.org/api/v1/pleroma/admin/stats?instance=lain.com`
1243
1244 - Response:
1245
1246 ```json
1247 {
1248   "status_visibility": {
1249     "direct": 739,
1250     "private": 9,
1251     "public": 17,
1252     "unlisted": 14
1253   }
1254 }
1255 ```
1256
1257 ## `GET /api/v1/pleroma/admin/oauth_app`
1258
1259 ### List OAuth app
1260
1261 - Params:
1262   - *optional* `name`
1263   - *optional* `client_id`
1264   - *optional* `page`
1265   - *optional* `page_size`
1266   - *optional* `trusted`
1267
1268 - Response:
1269
1270 ```json
1271 {
1272   "apps": [
1273     {
1274       "id": 1,
1275       "name": "App name",
1276       "client_id": "yHoDSiWYp5mPV6AfsaVOWjdOyt5PhWRiafi6MRd1lSk",
1277       "client_secret": "nLmis486Vqrv2o65eM9mLQx_m_4gH-Q6PcDpGIMl6FY",
1278       "redirect_uri": "https://example.com/oauth-callback",
1279       "website": "https://example.com",
1280       "trusted": true
1281     }
1282   ],
1283   "count": 17,
1284   "page_size": 50
1285 }
1286 ```
1287
1288
1289 ## `POST /api/v1/pleroma/admin/oauth_app`
1290
1291 ### Create OAuth App
1292
1293 - Params:
1294   - `name`
1295   - `redirect_uris`
1296   - `scopes`
1297   - *optional* `website`
1298   - *optional* `trusted`
1299
1300 - Response:
1301
1302 ```json
1303 {
1304   "id": 1,
1305   "name": "App name",
1306   "client_id": "yHoDSiWYp5mPV6AfsaVOWjdOyt5PhWRiafi6MRd1lSk",
1307   "client_secret": "nLmis486Vqrv2o65eM9mLQx_m_4gH-Q6PcDpGIMl6FY",
1308   "redirect_uri": "https://example.com/oauth-callback",
1309   "website": "https://example.com",
1310   "trusted": true
1311 }
1312 ```
1313
1314 - On failure:
1315 ```json
1316 {
1317   "redirect_uris": "can't be blank",
1318   "name": "can't be blank"
1319 }
1320 ```
1321
1322 ## `PATCH /api/v1/pleroma/admin/oauth_app/:id`
1323
1324 ### Update OAuth App
1325
1326 - Params:
1327   -  *optional* `name`
1328   -  *optional* `redirect_uris`
1329   -  *optional* `scopes`
1330   -  *optional* `website`
1331   -  *optional* `trusted`
1332
1333 - Response:
1334
1335 ```json
1336 {
1337   "id": 1,
1338   "name": "App name",
1339   "client_id": "yHoDSiWYp5mPV6AfsaVOWjdOyt5PhWRiafi6MRd1lSk",
1340   "client_secret": "nLmis486Vqrv2o65eM9mLQx_m_4gH-Q6PcDpGIMl6FY",
1341   "redirect_uri": "https://example.com/oauth-callback",
1342   "website": "https://example.com",
1343   "trusted": true
1344 }
1345 ```
1346
1347 ## `DELETE /api/v1/pleroma/admin/oauth_app/:id`
1348
1349 ### Delete OAuth App
1350
1351 - Params: None
1352
1353 - Response:
1354   - On success: `204`, empty response
1355   - On failure:
1356     - 400 Bad Request `"Invalid parameters"` when `status` is missing
1357
1358 ## `GET /api/v1/pleroma/admin/media_proxy_caches`
1359
1360 ### Get a list of all banned MediaProxy URLs in Cachex
1361
1362 - Authentication: required
1363 - Params:
1364 - *optional* `page`: **integer** page number
1365 - *optional* `page_size`: **integer** number of log entries per page (default is `50`)
1366 - *optional* `query`: **string** search term
1367
1368 - Response:
1369
1370 ``` json
1371 {
1372   "page_size": integer,
1373   "count": integer,
1374   "urls": [
1375     "http://example.com/media/a688346.jpg",
1376     "http://example.com/media/fb1f4d.jpg"
1377   ]
1378 }
1379
1380 ```
1381
1382 ## `POST /api/v1/pleroma/admin/media_proxy_caches/delete`
1383
1384 ### Remove a banned MediaProxy URL from Cachex
1385
1386 - Authentication: required
1387 - Params:
1388   - `urls` (array)
1389
1390 - Response:
1391
1392 ``` json
1393 { }
1394
1395 ```
1396
1397 ## `POST /api/v1/pleroma/admin/media_proxy_caches/purge`
1398
1399 ### Purge a MediaProxy URL
1400
1401 - Authentication: required
1402 - Params:
1403   - `urls` (array)
1404   - `ban` (boolean)
1405
1406 - Response:
1407
1408 ``` json
1409 { }
1410
1411 ```
1412
1413 ## GET /api/v1/pleroma/admin/users/:nickname/chats
1414
1415 ### List a user's chats
1416
1417 - Params: None
1418
1419 - Response:
1420
1421 ```json
1422 [
1423    {
1424       "sender": {
1425         "id": "someflakeid",
1426         "username": "somenick",
1427         ...
1428       },
1429       "receiver": {
1430         "id": "someflakeid",
1431         "username": "somenick",
1432         ...
1433       },
1434       "id" : "1",
1435       "unread" : 2,
1436       "last_message" : {...}, // The last message in that chat
1437       "updated_at": "2020-04-21T15:11:46.000Z"
1438    }
1439 ]
1440 ```
1441
1442 ## GET /api/v1/pleroma/admin/chats/:chat_id
1443
1444 ### View a single chat
1445
1446 - Params: None
1447
1448 - Response:
1449
1450 ```json
1451 {
1452   "sender": {
1453     "id": "someflakeid",
1454     "username": "somenick",
1455     ...
1456   },
1457   "receiver": {
1458     "id": "someflakeid",
1459     "username": "somenick",
1460     ...
1461   },
1462   "id" : "1",
1463   "unread" : 2,
1464   "last_message" : {...}, // The last message in that chat
1465   "updated_at": "2020-04-21T15:11:46.000Z"
1466 }
1467 ```
1468
1469 ## GET /api/v1/pleroma/admin/chats/:chat_id/messages
1470
1471 ### List the messages in a chat
1472
1473 - Params: `max_id`, `min_id`
1474
1475 - Response:
1476
1477 ```json
1478 [
1479   {
1480     "account_id": "someflakeid",
1481     "chat_id": "1",
1482     "content": "Check this out :firefox:",
1483     "created_at": "2020-04-21T15:11:46.000Z",
1484     "emojis": [
1485       {
1486         "shortcode": "firefox",
1487         "static_url": "https://dontbulling.me/emoji/Firefox.gif",
1488         "url": "https://dontbulling.me/emoji/Firefox.gif",
1489         "visible_in_picker": false
1490       }
1491     ],
1492     "id": "13",
1493     "unread": true
1494   },
1495   {
1496     "account_id": "someflakeid",
1497     "chat_id": "1",
1498     "content": "Whats' up?",
1499     "created_at": "2020-04-21T15:06:45.000Z",
1500     "emojis": [],
1501     "id": "12",
1502     "unread": false
1503   }
1504 ]
1505 ```
1506
1507 ## DELETE /api/v1/pleroma/admin/chats/:chat_id/messages/:message_id
1508
1509 ### Delete a single message
1510
1511 - Params: None
1512
1513 - Response:
1514
1515 ```json
1516 {
1517   "account_id": "someflakeid",
1518   "chat_id": "1",
1519   "content": "Check this out :firefox:",
1520   "created_at": "2020-04-21T15:11:46.000Z",
1521   "emojis": [
1522     {
1523       "shortcode": "firefox",
1524       "static_url": "https://dontbulling.me/emoji/Firefox.gif",
1525       "url": "https://dontbulling.me/emoji/Firefox.gif",
1526       "visible_in_picker": false
1527     }
1528   ],
1529   "id": "13",
1530   "unread": false
1531 }
1532 ```
1533
1534 ## `GET /api/v1/pleroma/admin/instance_document/:document_name`
1535
1536 ### Get an instance document
1537
1538 - Authentication: required
1539
1540 - Response:
1541
1542 Returns the content of the document
1543
1544 ```html
1545 <h1>Instance panel</h1>
1546 ```
1547
1548 ## `PATCH /api/v1/pleroma/admin/instance_document/:document_name`
1549 - Params:
1550   - `file` (the file to be uploaded, using multipart form data.)
1551
1552 ### Update an instance document
1553
1554 - Authentication: required
1555
1556 - Response:
1557
1558 ``` json
1559 {
1560   "url": "https://example.com/instance/panel.html"
1561 }
1562 ```
1563
1564 ## `DELETE /api/v1/pleroma/admin/instance_document/:document_name`
1565
1566 ### Delete an instance document
1567
1568 - Response:
1569
1570 ``` json
1571 {
1572   "url": "https://example.com/instance/panel.html"
1573 }
1574 ```
1575
1576 ## `GET /api/v1/pleroma/admin/frontends
1577
1578 ### List available frontends
1579
1580 - Response:
1581
1582 ```json
1583 [
1584    {
1585     "build_url": "https://git.pleroma.social/pleroma/fedi-fe/-/jobs/artifacts/${ref}/download?job=build",
1586     "git": "https://git.pleroma.social/pleroma/fedi-fe",
1587     "installed": true,
1588     "name": "fedi-fe",
1589     "ref": "master"
1590   },
1591   {
1592     "build_url": "https://git.pleroma.social/lambadalambda/kenoma/-/jobs/artifacts/${ref}/download?job=build",
1593     "git": "https://git.pleroma.social/lambadalambda/kenoma",
1594     "installed": false,
1595     "name": "kenoma",
1596     "ref": "master"
1597   }
1598 ]
1599 ```
1600
1601 ## `POST /api/v1/pleroma/admin/frontends/install`
1602
1603 ### Install a frontend
1604
1605 - Params:
1606   - `name`: frontend name, required
1607   - `ref`: frontend ref
1608   - `file`: path to a frontend zip file
1609   - `build_url`: build URL
1610   - `build_dir`: build directory
1611
1612 - Response:
1613
1614 ```json
1615 [
1616    {
1617     "build_url": "https://git.pleroma.social/pleroma/fedi-fe/-/jobs/artifacts/${ref}/download?job=build",
1618     "git": "https://git.pleroma.social/pleroma/fedi-fe",
1619     "installed": true,
1620     "name": "fedi-fe",
1621     "ref": "master"
1622   },
1623   {
1624     "build_url": "https://git.pleroma.social/lambadalambda/kenoma/-/jobs/artifacts/${ref}/download?job=build",
1625     "git": "https://git.pleroma.social/lambadalambda/kenoma",
1626     "installed": false,
1627     "name": "kenoma",
1628     "ref": "master"
1629   }
1630 ]
1631 ```
1632
1633 ```json
1634 {
1635   "error": "Could not install frontend"
1636 }
1637 ```
1638
1639 ## `GET /api/v1/pleroma/admin/announcements`
1640
1641 ### List announcements
1642
1643 - Params: `offset`, `limit`
1644
1645 - Response: JSON, list of announcements
1646
1647 ```json
1648 [
1649   {
1650     "id": "AHDp0GBdRn1EPN5HN2",
1651     "content": "some content",
1652     "starts_at": null,
1653     "ends_at": null,
1654     "all_day": false,
1655     "published_at": "2022-03-09T02:13:05",
1656     "reactions": [],
1657     "statuses": [],
1658     "tags": [],
1659     "emojis": [],
1660     "updated_at": "2022-03-09T02:13:05"
1661   }
1662 ]
1663 ```
1664
1665 Note that this differs from the Mastodon API variant: Mastodon API only returns *active* announcements, while this returns all.
1666
1667 ## `GET /api/v1/pleroma/admin/announcements/:id`
1668
1669 ### Display one announcement
1670
1671 - Response: JSON, one announcement
1672
1673 ```json
1674 {
1675   "id": "AHDp0GBdRn1EPN5HN2",
1676   "content": "some content",
1677   "starts_at": null,
1678   "ends_at": null,
1679   "all_day": false,
1680   "published_at": "2022-03-09T02:13:05",
1681   "reactions": [],
1682   "statuses": [],
1683   "tags": [],
1684   "emojis": [],
1685   "updated_at": "2022-03-09T02:13:05"
1686 }
1687 ```
1688
1689 ## `POST /api/v1/pleroma/admin/announcements`
1690
1691 ### Create an announcement
1692
1693 - Params:
1694   - `content`: string, required, announcement content
1695   - `starts_at`: datetime, optional, default to null, the time when the announcement will become active (displayed to users); if it is null, the announcement will be active immediately
1696   - `ends_at`: datetime, optional, default to null, the time when the announcement will become inactive (no longer displayed to users); if it is null, the announcement will be active until an admin deletes it
1697   - `all_day`: boolean, optional, default to false, tells the client whether to only display dates for `starts_at` and `ends_at`
1698
1699 - Response: JSON, created announcement
1700
1701 ```json
1702 {
1703   "id": "AHDp0GBdRn1EPN5HN2",
1704   "content": "some content",
1705   "starts_at": null,
1706   "ends_at": null,
1707   "all_day": false,
1708   "published_at": "2022-03-09T02:13:05",
1709   "reactions": [],
1710   "statuses": [],
1711   "tags": [],
1712   "emojis": [],
1713   "updated_at": "2022-03-09T02:13:05"
1714 }
1715 ```
1716
1717 ## `PATCH /api/v1/pleroma/admin/announcements/:id`
1718
1719 ### Change an announcement
1720
1721 - Params: same as `POST /api/v1/pleroma/admin/announcements`, except no param is required.
1722
1723 - Updates the announcement according to params. Missing params are kept as-is.
1724
1725 - Response: JSON, updated announcement
1726
1727 ```json
1728 {
1729   "id": "AHDp0GBdRn1EPN5HN2",
1730   "content": "some content",
1731   "starts_at": null,
1732   "ends_at": null,
1733   "all_day": false,
1734   "published_at": "2022-03-09T02:13:05",
1735   "reactions": [],
1736   "statuses": [],
1737   "tags": [],
1738   "emojis": [],
1739   "updated_at": "2022-03-09T02:13:05"
1740 }
1741 ```
1742
1743 ## `DELETE /api/v1/pleroma/admin/announcements/:id`
1744
1745 ### Delete an announcement
1746
1747 - Response: JSON, empty object
1748
1749 ```json
1750 {}
1751 ```