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