Merge branch 'failing-search-fixes' into 'develop'
[akkoma] / docs / API / admin_api.md
1 # Admin API
2
3 Authentication is required and the user must be an admin.
4
5 ## `/api/pleroma/admin/users`
6
7 ### List users
8
9 - Method `GET`
10 - Query Params:
11 - *optional* `query`: **string** search term (e.g. nickname, domain, nickname@domain)
12 - *optional* `filters`: **string** comma-separated string of filters:
13 - `local`: only local users
14 - `external`: only external users
15 - `active`: only active users
16 - `deactivated`: only deactivated users
17 - `is_admin`: users with admin role
18 - `is_moderator`: users with moderator role
19 - *optional* `page`: **integer** page number
20 - *optional* `page_size`: **integer** number of users per page (default is `50`)
21 - *optional* `tags`: **[string]** tags list
22 - *optional* `name`: **string** user display name
23 - *optional* `email`: **string** user email
24 - 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`
25 - Response:
26
27 ```json
28 {
29 "page_size": integer,
30 "count": integer,
31 "users": [
32 {
33 "deactivated": bool,
34 "id": integer,
35 "nickname": string,
36 "roles": {
37 "admin": bool,
38 "moderator": bool
39 },
40 "local": bool,
41 "tags": array,
42 "avatar": string,
43 "display_name": string
44 },
45 ...
46 ]
47 }
48 ```
49
50 ## DEPRECATED `DELETE /api/pleroma/admin/users`
51
52 ### Remove a user
53
54 - Method `DELETE`
55 - Params:
56 - `nickname`
57 - Response: User’s nickname
58
59 ## `DELETE /api/pleroma/admin/users`
60
61 ### Remove a user
62
63 - Method `DELETE`
64 - Params:
65 - `nicknames`
66 - Response: Array of user nicknames
67
68 ### Create a user
69
70 - Method: `POST`
71 - Params:
72 `users`: [
73 {
74 `nickname`,
75 `email`,
76 `password`
77 }
78 ]
79 - Response: User’s nickname
80
81 ## `/api/pleroma/admin/users/follow`
82 ### Make a user follow another user
83
84 - Methods: `POST`
85 - Params:
86 - `follower`: The nickname of the follower
87 - `followed`: The nickname of the followed
88 - Response:
89 - "ok"
90
91 ## `/api/pleroma/admin/users/unfollow`
92 ### Make a user unfollow another user
93
94 - Methods: `POST`
95 - Params:
96 - `follower`: The nickname of the follower
97 - `followed`: The nickname of the followed
98 - Response:
99 - "ok"
100
101 ## `/api/pleroma/admin/users/:nickname/toggle_activation`
102
103 ### Toggle user activation
104
105 - Method: `PATCH`
106 - Params:
107 - `nickname`
108 - Response: User’s object
109
110 ```json
111 {
112 "deactivated": bool,
113 "id": integer,
114 "nickname": string
115 }
116 ```
117
118 ## `/api/pleroma/admin/users/tag`
119
120 ### Tag a list of users
121
122 - Method: `PUT`
123 - Params:
124 - `nicknames` (array)
125 - `tags` (array)
126
127 ### Untag a list of users
128
129 - Method: `DELETE`
130 - Params:
131 - `nicknames` (array)
132 - `tags` (array)
133
134 ## `/api/pleroma/admin/users/:nickname/permission_group`
135
136 ### Get user user permission groups membership
137
138 - Method: `GET`
139 - Params: none
140 - Response:
141
142 ```json
143 {
144 "is_moderator": bool,
145 "is_admin": bool
146 }
147 ```
148
149 ## `/api/pleroma/admin/users/:nickname/permission_group/:permission_group`
150
151 Note: Available `:permission_group` is currently moderator and admin. 404 is returned when the permission group doesn’t exist.
152
153 ### Get user user permission groups membership per permission group
154
155 - Method: `GET`
156 - Params: none
157 - Response:
158
159 ```json
160 {
161 "is_moderator": bool,
162 "is_admin": bool
163 }
164 ```
165
166 ## DEPRECATED `POST /api/pleroma/admin/users/:nickname/permission_group/:permission_group`
167
168 ### Add user to permission group
169
170 - Params: none
171 - Response:
172 - On failure: `{"error": "…"}`
173 - On success: JSON of the user
174
175 ## `POST /api/pleroma/admin/users/permission_group/:permission_group`
176
177 ### Add users to permission group
178
179 - Params:
180 - `nicknames`: nicknames array
181 - Response:
182 - On failure: `{"error": "…"}`
183 - On success: JSON of the user
184
185 ## DEPRECATED `DELETE /api/pleroma/admin/users/:nickname/permission_group/:permission_group`
186
187 ### Remove user from permission group
188
189 - Params: none
190 - Response:
191 - On failure: `{"error": "…"}`
192 - On success: JSON of the user
193 - Note: An admin cannot revoke their own admin status.
194
195 ## `DELETE /api/pleroma/admin/users/permission_group/:permission_group`
196
197 ### Remove users from permission group
198
199 - Params:
200 - `nicknames`: nicknames array
201 - Response:
202 - On failure: `{"error": "…"}`
203 - On success: JSON of the user
204 - Note: An admin cannot revoke their own admin status.
205
206 ## `PATCH /api/pleroma/admin/users/activate`
207
208 ### Activate user
209
210 - Params:
211 - `nicknames`: nicknames array
212 - Response:
213
214 ```json
215 {
216 users: [
217 {
218 // user object
219 }
220 ]
221 }
222 ```
223
224 ## `PATCH /api/pleroma/admin/users/deactivate`
225
226 ### Deactivate user
227
228 - Params:
229 - `nicknames`: nicknames array
230 - Response:
231
232 ```json
233 {
234 users: [
235 {
236 // user object
237 }
238 ]
239 }
240 ```
241
242 ## DEPRECATED `PATCH /api/pleroma/admin/users/:nickname/activation_status`
243
244 ### Active or deactivate a user
245
246 - Params:
247 - `nickname`
248 - `status` BOOLEAN field, false value means deactivation.
249
250 ## `/api/pleroma/admin/users/:nickname_or_id`
251
252 ### Retrive the details of a user
253
254 - Method: `GET`
255 - Params:
256 - `nickname` or `id`
257 - Response:
258 - On failure: `Not found`
259 - On success: JSON of the user
260
261 ## `/api/pleroma/admin/users/:nickname_or_id/statuses`
262
263 ### Retrive user's latest statuses
264
265 - Method: `GET`
266 - Params:
267 - `nickname` or `id`
268 - *optional* `page_size`: number of statuses to return (default is `20`)
269 - *optional* `godmode`: `true`/`false` – allows to see private statuses
270 - Response:
271 - On failure: `Not found`
272 - On success: JSON array of user's latest statuses
273
274 ## `/api/pleroma/admin/relay`
275
276 ### Follow a Relay
277
278 - Methods: `POST`
279 - Params:
280 - `relay_url`
281 - Response:
282 - On success: URL of the followed relay
283
284 ### Unfollow a Relay
285
286 - Methods: `DELETE`
287 - Params:
288 - `relay_url`
289 - Response:
290 - On success: URL of the unfollowed relay
291
292 ## `GET /api/pleroma/admin/relay`
293
294 ### List Relays
295
296 - Params: none
297 - Response:
298 - On success: JSON array of relays
299
300 ## `/api/pleroma/admin/users/invite_token`
301
302 ### Create an account registration invite token
303
304 - Methods: `POST`
305 - Params:
306 - *optional* `max_use` (integer)
307 - *optional* `expires_at` (date string e.g. "2019-04-07")
308 - Response:
309
310 ```json
311 {
312 "id": integer,
313 "token": string,
314 "used": boolean,
315 "expires_at": date,
316 "uses": integer,
317 "max_use": integer,
318 "invite_type": string (possible values: `one_time`, `reusable`, `date_limited`, `reusable_date_limited`)
319 }
320 ```
321
322 ## `/api/pleroma/admin/users/invites`
323
324 ### Get a list of generated invites
325
326 - Methods: `GET`
327 - Params: none
328 - Response:
329
330 ```json
331 {
332
333 "invites": [
334 {
335 "id": integer,
336 "token": string,
337 "used": boolean,
338 "expires_at": date,
339 "uses": integer,
340 "max_use": integer,
341 "invite_type": string (possible values: `one_time`, `reusable`, `date_limited`, `reusable_date_limited`)
342 },
343 ...
344 ]
345 }
346 ```
347
348 ## `/api/pleroma/admin/users/revoke_invite`
349
350 ### Revoke invite by token
351
352 - Methods: `POST`
353 - Params:
354 - `token`
355 - Response:
356
357 ```json
358 {
359 "id": integer,
360 "token": string,
361 "used": boolean,
362 "expires_at": date,
363 "uses": integer,
364 "max_use": integer,
365 "invite_type": string (possible values: `one_time`, `reusable`, `date_limited`, `reusable_date_limited`)
366
367 }
368 ```
369
370
371 ## `/api/pleroma/admin/users/email_invite`
372
373 ### Sends registration invite via email
374
375 - Methods: `POST`
376 - Params:
377 - `email`
378 - `name`, optional
379
380 ## `/api/pleroma/admin/users/:nickname/password_reset`
381
382 ### Get a password reset token for a given nickname
383
384 - Methods: `GET`
385 - Params: none
386 - Response:
387
388 ```json
389 {
390 "token": "base64 reset token",
391 "link": "https://pleroma.social/api/pleroma/password_reset/url-encoded-base64-token"
392 }
393 ```
394
395
396 ## `/api/pleroma/admin/users/:nickname/force_password_reset`
397
398 ### Force passord reset for a user with a given nickname
399
400 - Methods: `PATCH`
401 - Params: none
402 - Response: none (code `204`)
403
404 ## `/api/pleroma/admin/reports`
405 ### Get a list of reports
406 - Method `GET`
407 - Params:
408 - *optional* `state`: **string** the state of reports. Valid values are `open`, `closed` and `resolved`
409 - *optional* `limit`: **integer** the number of records to retrieve
410 - *optional* `page`: **integer** page number
411 - *optional* `page_size`: **integer** number of log entries per page (default is `50`)
412 - Response:
413 - On failure: 403 Forbidden error `{"error": "error_msg"}` when requested by anonymous or non-admin
414 - On success: JSON, returns a list of reports, where:
415 - `account`: the user who has been reported
416 - `actor`: the user who has sent the report
417 - `statuses`: list of statuses that have been included to the report
418
419 ```json
420 {
421 "total" : 1,
422 "reports": [
423 {
424 "account": {
425 "acct": "user",
426 "avatar": "https://pleroma.example.org/images/avi.png",
427 "avatar_static": "https://pleroma.example.org/images/avi.png",
428 "bot": false,
429 "created_at": "2019-04-23T17:32:04.000Z",
430 "display_name": "User",
431 "emojis": [],
432 "fields": [],
433 "followers_count": 1,
434 "following_count": 1,
435 "header": "https://pleroma.example.org/images/banner.png",
436 "header_static": "https://pleroma.example.org/images/banner.png",
437 "id": "9i6dAJqSGSKMzLG2Lo",
438 "locked": false,
439 "note": "",
440 "pleroma": {
441 "confirmation_pending": false,
442 "hide_favorites": true,
443 "hide_followers": false,
444 "hide_follows": false,
445 "is_admin": false,
446 "is_moderator": false,
447 "relationship": {},
448 "tags": []
449 },
450 "source": {
451 "note": "",
452 "pleroma": {},
453 "sensitive": false
454 },
455 "tags": ["force_unlisted"],
456 "statuses_count": 3,
457 "url": "https://pleroma.example.org/users/user",
458 "username": "user"
459 },
460 "actor": {
461 "acct": "lain",
462 "avatar": "https://pleroma.example.org/images/avi.png",
463 "avatar_static": "https://pleroma.example.org/images/avi.png",
464 "bot": false,
465 "created_at": "2019-03-28T17:36:03.000Z",
466 "display_name": "Roger Braun",
467 "emojis": [],
468 "fields": [],
469 "followers_count": 1,
470 "following_count": 1,
471 "header": "https://pleroma.example.org/images/banner.png",
472 "header_static": "https://pleroma.example.org/images/banner.png",
473 "id": "9hEkA5JsvAdlSrocam",
474 "locked": false,
475 "note": "",
476 "pleroma": {
477 "confirmation_pending": false,
478 "hide_favorites": false,
479 "hide_followers": false,
480 "hide_follows": false,
481 "is_admin": false,
482 "is_moderator": false,
483 "relationship": {},
484 "tags": []
485 },
486 "source": {
487 "note": "",
488 "pleroma": {},
489 "sensitive": false
490 },
491 "tags": ["force_unlisted"],
492 "statuses_count": 1,
493 "url": "https://pleroma.example.org/users/lain",
494 "username": "lain"
495 },
496 "content": "Please delete it",
497 "created_at": "2019-04-29T19:48:15.000Z",
498 "id": "9iJGOv1j8hxuw19bcm",
499 "state": "open",
500 "statuses": [
501 {
502 "account": { ... },
503 "application": {
504 "name": "Web",
505 "website": null
506 },
507 "bookmarked": false,
508 "card": null,
509 "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>",
510 "created_at": "2019-04-23T19:15:47.000Z",
511 "emojis": [],
512 "favourited": false,
513 "favourites_count": 0,
514 "id": "9i6mQ9uVrrOmOime8m",
515 "in_reply_to_account_id": null,
516 "in_reply_to_id": null,
517 "language": null,
518 "media_attachments": [],
519 "mentions": [
520 {
521 "acct": "lain",
522 "id": "9hEkA5JsvAdlSrocam",
523 "url": "https://pleroma.example.org/users/lain",
524 "username": "lain"
525 },
526 {
527 "acct": "user",
528 "id": "9i6dAJqSGSKMzLG2Lo",
529 "url": "https://pleroma.example.org/users/user",
530 "username": "user"
531 }
532 ],
533 "muted": false,
534 "pinned": false,
535 "pleroma": {
536 "content": {
537 "text/plain": "@lain click on my link https://www.google.com/"
538 },
539 "conversation_id": 28,
540 "in_reply_to_account_acct": null,
541 "local": true,
542 "spoiler_text": {
543 "text/plain": ""
544 }
545 },
546 "reblog": null,
547 "reblogged": false,
548 "reblogs_count": 0,
549 "replies_count": 0,
550 "sensitive": false,
551 "spoiler_text": "",
552 "tags": [],
553 "uri": "https://pleroma.example.org/objects/8717b90f-8e09-4b58-97b0-e3305472b396",
554 "url": "https://pleroma.example.org/notice/9i6mQ9uVrrOmOime8m",
555 "visibility": "direct"
556 }
557 ]
558 }
559 ]
560 }
561 ```
562
563 ## `/api/pleroma/admin/reports/:id`
564 ### Get an individual report
565 - Method `GET`
566 - Params:
567 - `id`
568 - Response:
569 - On failure:
570 - 403 Forbidden `{"error": "error_msg"}`
571 - 404 Not Found `"Not found"`
572 - On success: JSON, Report object (see above)
573
574 ## `/api/pleroma/admin/reports/:id`
575 ### Change the state of the report
576 - Method `PUT`
577 - Params:
578 - `id`
579 - `state`: required, the new state. Valid values are `open`, `closed` and `resolved`
580 - Response:
581 - On failure:
582 - 400 Bad Request `"Unsupported state"`
583 - 403 Forbidden `{"error": "error_msg"}`
584 - 404 Not Found `"Not found"`
585 - On success: JSON, Report object (see above)
586
587 ## `/api/pleroma/admin/reports/:id/respond`
588 ### Respond to a report
589 - Method `POST`
590 - Params:
591 - `id`
592 - `status`: required, the message
593 - Response:
594 - On failure:
595 - 400 Bad Request `"Invalid parameters"` when `status` is missing
596 - 403 Forbidden `{"error": "error_msg"}`
597 - 404 Not Found `"Not found"`
598 - On success: JSON, created Mastodon Status entity
599
600 ```json
601 {
602 "account": { ... },
603 "application": {
604 "name": "Web",
605 "website": null
606 },
607 "bookmarked": false,
608 "card": null,
609 "content": "Your claim is going to be closed",
610 "created_at": "2019-05-11T17:13:03.000Z",
611 "emojis": [],
612 "favourited": false,
613 "favourites_count": 0,
614 "id": "9ihuiSL1405I65TmEq",
615 "in_reply_to_account_id": null,
616 "in_reply_to_id": null,
617 "language": null,
618 "media_attachments": [],
619 "mentions": [
620 {
621 "acct": "user",
622 "id": "9i6dAJqSGSKMzLG2Lo",
623 "url": "https://pleroma.example.org/users/user",
624 "username": "user"
625 },
626 {
627 "acct": "admin",
628 "id": "9hEkA5JsvAdlSrocam",
629 "url": "https://pleroma.example.org/users/admin",
630 "username": "admin"
631 }
632 ],
633 "muted": false,
634 "pinned": false,
635 "pleroma": {
636 "content": {
637 "text/plain": "Your claim is going to be closed"
638 },
639 "conversation_id": 35,
640 "in_reply_to_account_acct": null,
641 "local": true,
642 "spoiler_text": {
643 "text/plain": ""
644 }
645 },
646 "reblog": null,
647 "reblogged": false,
648 "reblogs_count": 0,
649 "replies_count": 0,
650 "sensitive": false,
651 "spoiler_text": "",
652 "tags": [],
653 "uri": "https://pleroma.example.org/objects/cab0836d-9814-46cd-a0ea-529da9db5fcb",
654 "url": "https://pleroma.example.org/notice/9ihuiSL1405I65TmEq",
655 "visibility": "direct"
656 }
657 ```
658
659 ## `/api/pleroma/admin/statuses/:id`
660 ### Change the scope of an individual reported status
661 - Method `PUT`
662 - Params:
663 - `id`
664 - `sensitive`: optional, valid values are `true` or `false`
665 - `visibility`: optional, valid values are `public`, `private` and `unlisted`
666 - Response:
667 - On failure:
668 - 400 Bad Request `"Unsupported visibility"`
669 - 403 Forbidden `{"error": "error_msg"}`
670 - 404 Not Found `"Not found"`
671 - On success: JSON, Mastodon Status entity
672
673 ## `/api/pleroma/admin/statuses/:id`
674 ### Delete an individual reported status
675 - Method `DELETE`
676 - Params:
677 - `id`
678 - Response:
679 - On failure:
680 - 403 Forbidden `{"error": "error_msg"}`
681 - 404 Not Found `"Not found"`
682 - On success: 200 OK `{}`
683
684
685 ## `/api/pleroma/admin/config/migrate_to_db`
686 ### Run mix task pleroma.config migrate_to_db
687 Copy settings on key `:pleroma` to DB.
688 - Method `GET`
689 - Params: none
690 - Response:
691
692 ```json
693 {}
694 ```
695
696 ## `/api/pleroma/admin/config/migrate_from_db`
697 ### Run mix task pleroma.config migrate_from_db
698 Copy all settings from DB to `config/prod.exported_from_db.secret.exs` with deletion from DB.
699 - Method `GET`
700 - Params: none
701 - Response:
702
703 ```json
704 {}
705 ```
706
707 ## `/api/pleroma/admin/config`
708 ### List config settings
709 List config settings only works with `:pleroma => :instance => :dynamic_configuration` setting to `true`.
710 - Method `GET`
711 - Params: none
712 - Response:
713
714 ```json
715 {
716 configs: [
717 {
718 "group": string,
719 "key": string or string with leading `:` for atoms,
720 "value": string or {} or [] or {"tuple": []}
721 }
722 ]
723 }
724 ```
725
726 ## `/api/pleroma/admin/config`
727 ### Update config settings
728 Updating config settings only works with `:pleroma => :instance => :dynamic_configuration` setting to `true`.
729 Module name can be passed as string, which starts with `Pleroma`, e.g. `"Pleroma.Upload"`.
730 Atom keys and values can be passed with `:` in the beginning, e.g. `":upload"`.
731 Tuples can be passed as `{"tuple": ["first_val", Pleroma.Module, []]}`.
732 `{"tuple": ["some_string", "Pleroma.Some.Module", []]}` will be converted to `{"some_string", Pleroma.Some.Module, []}`.
733 Keywords can be passed as lists with 2 child tuples, e.g.
734 `[{"tuple": ["first_val", Pleroma.Module]}, {"tuple": ["second_val", true]}]`.
735
736 If value contains list of settings `[subkey: val1, subkey2: val2, subkey3: val3]`, it's possible to remove only subkeys instead of all settings passing `subkeys` parameter. E.g.:
737 {"group": "pleroma", "key": "some_key", "delete": "true", "subkeys": [":subkey", ":subkey3"]}.
738
739 Compile time settings (need instance reboot):
740 - all settings by this keys:
741 - `:hackney_pools`
742 - `:chat`
743 - `Pleroma.Web.Endpoint`
744 - `Pleroma.Repo`
745 - part settings:
746 - `Pleroma.Captcha` -> `:seconds_valid`
747 - `Pleroma.Upload` -> `:proxy_remote`
748 - `:instance` -> `:upload_limit`
749
750 - Method `POST`
751 - Params:
752 - `configs` => [
753 - `group` (string)
754 - `key` (string or string with leading `:` for atoms)
755 - `value` (string, [], {} or {"tuple": []})
756 - `delete` = true (optional, if parameter must be deleted)
757 - `subkeys` [(string with leading `:` for atoms)] (optional, works only if `delete=true` parameter is passed, otherwise will be ignored)
758 ]
759
760 - Request (example):
761
762 ```json
763 {
764 configs: [
765 {
766 "group": "pleroma",
767 "key": "Pleroma.Upload",
768 "value": [
769 {"tuple": [":uploader", "Pleroma.Uploaders.Local"]},
770 {"tuple": [":filters", ["Pleroma.Upload.Filter.Dedupe"]]},
771 {"tuple": [":link_name", true]},
772 {"tuple": [":proxy_remote", false]},
773 {"tuple": [":proxy_opts", [
774 {"tuple": [":redirect_on_failure", false]},
775 {"tuple": [":max_body_length", 1048576]},
776 {"tuple": [":http": [
777 {"tuple": [":follow_redirect", true]},
778 {"tuple": [":pool", ":upload"]},
779 ]]}
780 ]
781 ]},
782 {"tuple": [":dispatch", {
783 "tuple": ["/api/v1/streaming", "Pleroma.Web.MastodonAPI.WebsocketHandler", []]
784 }]}
785 ]
786 }
787 ]
788 }
789 ```
790
791 - Response:
792
793 ```json
794 {
795 configs: [
796 {
797 "group": string,
798 "key": string or string with leading `:` for atoms,
799 "value": string or {} or [] or {"tuple": []}
800 }
801 ]
802 }
803 ```
804
805 ## `/api/pleroma/admin/moderation_log`
806 ### Get moderation log
807 - Method `GET`
808 - Params:
809 - *optional* `page`: **integer** page number
810 - *optional* `page_size`: **integer** number of log entries per page (default is `50`)
811 - *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`
812 - *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
813 - *optional* `user_id`: **integer** filter logs by actor's id
814 - *optional* `search`: **string** search logs by the log message
815 - Response:
816
817 ```json
818 [
819 {
820 "data": {
821 "actor": {
822 "id": 1,
823 "nickname": "lain"
824 },
825 "action": "relay_follow"
826 },
827 "time": 1502812026, // timestamp
828 "message": "[2017-08-15 15:47:06] @nick0 followed relay: https://example.org/relay" // log message
829 }
830 ]
831 ```
832
833 ## `POST /api/pleroma/admin/reload_emoji`
834 ### Reload the instance's custom emoji
835 * Method `POST`
836 * Authentication: required
837 * Params: None
838 * Response: JSON, "ok" and 200 status