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