DELETE /api/pleroma/admin/users now accepts nicknames array
[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.info`
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.info`
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.info`
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.info`
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 ## `/api/pleroma/admin/users/invite_token`
293
294 ### Create an account registration invite token
295
296 - Methods: `POST`
297 - Params:
298 - *optional* `max_use` (integer)
299 - *optional* `expires_at` (date string e.g. "2019-04-07")
300 - Response:
301
302 ```json
303 {
304 "id": integer,
305 "token": string,
306 "used": boolean,
307 "expires_at": date,
308 "uses": integer,
309 "max_use": integer,
310 "invite_type": string (possible values: `one_time`, `reusable`, `date_limited`, `reusable_date_limited`)
311 }
312 ```
313
314 ## `/api/pleroma/admin/users/invites`
315
316 ### Get a list of generated invites
317
318 - Methods: `GET`
319 - Params: none
320 - Response:
321
322 ```json
323 {
324
325 "invites": [
326 {
327 "id": integer,
328 "token": string,
329 "used": boolean,
330 "expires_at": date,
331 "uses": integer,
332 "max_use": integer,
333 "invite_type": string (possible values: `one_time`, `reusable`, `date_limited`, `reusable_date_limited`)
334 },
335 ...
336 ]
337 }
338 ```
339
340 ## `/api/pleroma/admin/users/revoke_invite`
341
342 ### Revoke invite by token
343
344 - Methods: `POST`
345 - Params:
346 - `token`
347 - Response:
348
349 ```json
350 {
351 "id": integer,
352 "token": string,
353 "used": boolean,
354 "expires_at": date,
355 "uses": integer,
356 "max_use": integer,
357 "invite_type": string (possible values: `one_time`, `reusable`, `date_limited`, `reusable_date_limited`)
358
359 }
360 ```
361
362
363 ## `/api/pleroma/admin/users/email_invite`
364
365 ### Sends registration invite via email
366
367 - Methods: `POST`
368 - Params:
369 - `email`
370 - `name`, optional
371
372 ## `/api/pleroma/admin/users/:nickname/password_reset`
373
374 ### Get a password reset token for a given nickname
375
376 - Methods: `GET`
377 - Params: none
378 - Response:
379
380 ```json
381 {
382 "token": "base64 reset token",
383 "link": "https://pleroma.social/api/pleroma/password_reset/url-encoded-base64-token"
384 }
385 ```
386
387
388 ## `/api/pleroma/admin/users/:nickname/force_password_reset`
389
390 ### Force passord reset for a user with a given nickname
391
392 - Methods: `PATCH`
393 - Params: none
394 - Response: none (code `204`)
395
396 ## `/api/pleroma/admin/reports`
397 ### Get a list of reports
398 - Method `GET`
399 - Params:
400 - *optional* `state`: **string** the state of reports. Valid values are `open`, `closed` and `resolved`
401 - *optional* `limit`: **integer** the number of records to retrieve
402 - *optional* `page`: **integer** page number
403 - *optional* `page_size`: **integer** number of log entries per page (default is `50`)
404 - Response:
405 - On failure: 403 Forbidden error `{"error": "error_msg"}` when requested by anonymous or non-admin
406 - On success: JSON, returns a list of reports, where:
407 - `account`: the user who has been reported
408 - `actor`: the user who has sent the report
409 - `statuses`: list of statuses that have been included to the report
410
411 ```json
412 {
413 "total" : 1,
414 "reports": [
415 {
416 "account": {
417 "acct": "user",
418 "avatar": "https://pleroma.example.org/images/avi.png",
419 "avatar_static": "https://pleroma.example.org/images/avi.png",
420 "bot": false,
421 "created_at": "2019-04-23T17:32:04.000Z",
422 "display_name": "User",
423 "emojis": [],
424 "fields": [],
425 "followers_count": 1,
426 "following_count": 1,
427 "header": "https://pleroma.example.org/images/banner.png",
428 "header_static": "https://pleroma.example.org/images/banner.png",
429 "id": "9i6dAJqSGSKMzLG2Lo",
430 "locked": false,
431 "note": "",
432 "pleroma": {
433 "confirmation_pending": false,
434 "hide_favorites": true,
435 "hide_followers": false,
436 "hide_follows": false,
437 "is_admin": false,
438 "is_moderator": false,
439 "relationship": {},
440 "tags": []
441 },
442 "source": {
443 "note": "",
444 "pleroma": {},
445 "sensitive": false
446 },
447 "tags": ["force_unlisted"],
448 "statuses_count": 3,
449 "url": "https://pleroma.example.org/users/user",
450 "username": "user"
451 },
452 "actor": {
453 "acct": "lain",
454 "avatar": "https://pleroma.example.org/images/avi.png",
455 "avatar_static": "https://pleroma.example.org/images/avi.png",
456 "bot": false,
457 "created_at": "2019-03-28T17:36:03.000Z",
458 "display_name": "Roger Braun",
459 "emojis": [],
460 "fields": [],
461 "followers_count": 1,
462 "following_count": 1,
463 "header": "https://pleroma.example.org/images/banner.png",
464 "header_static": "https://pleroma.example.org/images/banner.png",
465 "id": "9hEkA5JsvAdlSrocam",
466 "locked": false,
467 "note": "",
468 "pleroma": {
469 "confirmation_pending": false,
470 "hide_favorites": false,
471 "hide_followers": false,
472 "hide_follows": false,
473 "is_admin": false,
474 "is_moderator": false,
475 "relationship": {},
476 "tags": []
477 },
478 "source": {
479 "note": "",
480 "pleroma": {},
481 "sensitive": false
482 },
483 "tags": ["force_unlisted"],
484 "statuses_count": 1,
485 "url": "https://pleroma.example.org/users/lain",
486 "username": "lain"
487 },
488 "content": "Please delete it",
489 "created_at": "2019-04-29T19:48:15.000Z",
490 "id": "9iJGOv1j8hxuw19bcm",
491 "state": "open",
492 "statuses": [
493 {
494 "account": { ... },
495 "application": {
496 "name": "Web",
497 "website": null
498 },
499 "bookmarked": false,
500 "card": null,
501 "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>",
502 "created_at": "2019-04-23T19:15:47.000Z",
503 "emojis": [],
504 "favourited": false,
505 "favourites_count": 0,
506 "id": "9i6mQ9uVrrOmOime8m",
507 "in_reply_to_account_id": null,
508 "in_reply_to_id": null,
509 "language": null,
510 "media_attachments": [],
511 "mentions": [
512 {
513 "acct": "lain",
514 "id": "9hEkA5JsvAdlSrocam",
515 "url": "https://pleroma.example.org/users/lain",
516 "username": "lain"
517 },
518 {
519 "acct": "user",
520 "id": "9i6dAJqSGSKMzLG2Lo",
521 "url": "https://pleroma.example.org/users/user",
522 "username": "user"
523 }
524 ],
525 "muted": false,
526 "pinned": false,
527 "pleroma": {
528 "content": {
529 "text/plain": "@lain click on my link https://www.google.com/"
530 },
531 "conversation_id": 28,
532 "in_reply_to_account_acct": null,
533 "local": true,
534 "spoiler_text": {
535 "text/plain": ""
536 }
537 },
538 "reblog": null,
539 "reblogged": false,
540 "reblogs_count": 0,
541 "replies_count": 0,
542 "sensitive": false,
543 "spoiler_text": "",
544 "tags": [],
545 "uri": "https://pleroma.example.org/objects/8717b90f-8e09-4b58-97b0-e3305472b396",
546 "url": "https://pleroma.example.org/notice/9i6mQ9uVrrOmOime8m",
547 "visibility": "direct"
548 }
549 ]
550 }
551 ]
552 }
553 ```
554
555 ## `/api/pleroma/admin/reports/:id`
556 ### Get an individual report
557 - Method `GET`
558 - Params:
559 - `id`
560 - Response:
561 - On failure:
562 - 403 Forbidden `{"error": "error_msg"}`
563 - 404 Not Found `"Not found"`
564 - On success: JSON, Report object (see above)
565
566 ## `/api/pleroma/admin/reports/:id`
567 ### Change the state of the report
568 - Method `PUT`
569 - Params:
570 - `id`
571 - `state`: required, the new state. Valid values are `open`, `closed` and `resolved`
572 - Response:
573 - On failure:
574 - 400 Bad Request `"Unsupported state"`
575 - 403 Forbidden `{"error": "error_msg"}`
576 - 404 Not Found `"Not found"`
577 - On success: JSON, Report object (see above)
578
579 ## `/api/pleroma/admin/reports/:id/respond`
580 ### Respond to a report
581 - Method `POST`
582 - Params:
583 - `id`
584 - `status`: required, the message
585 - Response:
586 - On failure:
587 - 400 Bad Request `"Invalid parameters"` when `status` is missing
588 - 403 Forbidden `{"error": "error_msg"}`
589 - 404 Not Found `"Not found"`
590 - On success: JSON, created Mastodon Status entity
591
592 ```json
593 {
594 "account": { ... },
595 "application": {
596 "name": "Web",
597 "website": null
598 },
599 "bookmarked": false,
600 "card": null,
601 "content": "Your claim is going to be closed",
602 "created_at": "2019-05-11T17:13:03.000Z",
603 "emojis": [],
604 "favourited": false,
605 "favourites_count": 0,
606 "id": "9ihuiSL1405I65TmEq",
607 "in_reply_to_account_id": null,
608 "in_reply_to_id": null,
609 "language": null,
610 "media_attachments": [],
611 "mentions": [
612 {
613 "acct": "user",
614 "id": "9i6dAJqSGSKMzLG2Lo",
615 "url": "https://pleroma.example.org/users/user",
616 "username": "user"
617 },
618 {
619 "acct": "admin",
620 "id": "9hEkA5JsvAdlSrocam",
621 "url": "https://pleroma.example.org/users/admin",
622 "username": "admin"
623 }
624 ],
625 "muted": false,
626 "pinned": false,
627 "pleroma": {
628 "content": {
629 "text/plain": "Your claim is going to be closed"
630 },
631 "conversation_id": 35,
632 "in_reply_to_account_acct": null,
633 "local": true,
634 "spoiler_text": {
635 "text/plain": ""
636 }
637 },
638 "reblog": null,
639 "reblogged": false,
640 "reblogs_count": 0,
641 "replies_count": 0,
642 "sensitive": false,
643 "spoiler_text": "",
644 "tags": [],
645 "uri": "https://pleroma.example.org/objects/cab0836d-9814-46cd-a0ea-529da9db5fcb",
646 "url": "https://pleroma.example.org/notice/9ihuiSL1405I65TmEq",
647 "visibility": "direct"
648 }
649 ```
650
651 ## `/api/pleroma/admin/statuses/:id`
652 ### Change the scope of an individual reported status
653 - Method `PUT`
654 - Params:
655 - `id`
656 - `sensitive`: optional, valid values are `true` or `false`
657 - `visibility`: optional, valid values are `public`, `private` and `unlisted`
658 - Response:
659 - On failure:
660 - 400 Bad Request `"Unsupported visibility"`
661 - 403 Forbidden `{"error": "error_msg"}`
662 - 404 Not Found `"Not found"`
663 - On success: JSON, Mastodon Status entity
664
665 ## `/api/pleroma/admin/statuses/:id`
666 ### Delete an individual reported status
667 - Method `DELETE`
668 - Params:
669 - `id`
670 - Response:
671 - On failure:
672 - 403 Forbidden `{"error": "error_msg"}`
673 - 404 Not Found `"Not found"`
674 - On success: 200 OK `{}`
675
676
677 ## `/api/pleroma/admin/config/migrate_to_db`
678 ### Run mix task pleroma.config migrate_to_db
679 Copy settings on key `:pleroma` to DB.
680 - Method `GET`
681 - Params: none
682 - Response:
683
684 ```json
685 {}
686 ```
687
688 ## `/api/pleroma/admin/config/migrate_from_db`
689 ### Run mix task pleroma.config migrate_from_db
690 Copy all settings from DB to `config/prod.exported_from_db.secret.exs` with deletion from DB.
691 - Method `GET`
692 - Params: none
693 - Response:
694
695 ```json
696 {}
697 ```
698
699 ## `/api/pleroma/admin/config`
700 ### List config settings
701 List config settings only works with `:pleroma => :instance => :dynamic_configuration` setting to `true`.
702 - Method `GET`
703 - Params: none
704 - Response:
705
706 ```json
707 {
708 configs: [
709 {
710 "group": string,
711 "key": string or string with leading `:` for atoms,
712 "value": string or {} or [] or {"tuple": []}
713 }
714 ]
715 }
716 ```
717
718 ## `/api/pleroma/admin/config`
719 ### Update config settings
720 Updating config settings only works with `:pleroma => :instance => :dynamic_configuration` setting to `true`.
721 Module name can be passed as string, which starts with `Pleroma`, e.g. `"Pleroma.Upload"`.
722 Atom keys and values can be passed with `:` in the beginning, e.g. `":upload"`.
723 Tuples can be passed as `{"tuple": ["first_val", Pleroma.Module, []]}`.
724 `{"tuple": ["some_string", "Pleroma.Some.Module", []]}` will be converted to `{"some_string", Pleroma.Some.Module, []}`.
725 Keywords can be passed as lists with 2 child tuples, e.g.
726 `[{"tuple": ["first_val", Pleroma.Module]}, {"tuple": ["second_val", true]}]`.
727
728 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.:
729 {"group": "pleroma", "key": "some_key", "delete": "true", "subkeys": [":subkey", ":subkey3"]}.
730
731 Compile time settings (need instance reboot):
732 - all settings by this keys:
733 - `:hackney_pools`
734 - `:chat`
735 - `Pleroma.Web.Endpoint`
736 - `Pleroma.Repo`
737 - part settings:
738 - `Pleroma.Captcha` -> `:seconds_valid`
739 - `Pleroma.Upload` -> `:proxy_remote`
740 - `:instance` -> `:upload_limit`
741
742 - Method `POST`
743 - Params:
744 - `configs` => [
745 - `group` (string)
746 - `key` (string or string with leading `:` for atoms)
747 - `value` (string, [], {} or {"tuple": []})
748 - `delete` = true (optional, if parameter must be deleted)
749 - `subkeys` [(string with leading `:` for atoms)] (optional, works only if `delete=true` parameter is passed, otherwise will be ignored)
750 ]
751
752 - Request (example):
753
754 ```json
755 {
756 configs: [
757 {
758 "group": "pleroma",
759 "key": "Pleroma.Upload",
760 "value": [
761 {"tuple": [":uploader", "Pleroma.Uploaders.Local"]},
762 {"tuple": [":filters", ["Pleroma.Upload.Filter.Dedupe"]]},
763 {"tuple": [":link_name", true]},
764 {"tuple": [":proxy_remote", false]},
765 {"tuple": [":proxy_opts", [
766 {"tuple": [":redirect_on_failure", false]},
767 {"tuple": [":max_body_length", 1048576]},
768 {"tuple": [":http": [
769 {"tuple": [":follow_redirect", true]},
770 {"tuple": [":pool", ":upload"]},
771 ]]}
772 ]
773 ]},
774 {"tuple": [":dispatch", {
775 "tuple": ["/api/v1/streaming", "Pleroma.Web.MastodonAPI.WebsocketHandler", []]
776 }]}
777 ]
778 }
779 ]
780 }
781 ```
782
783 - Response:
784
785 ```json
786 {
787 configs: [
788 {
789 "group": string,
790 "key": string or string with leading `:` for atoms,
791 "value": string or {} or [] or {"tuple": []}
792 }
793 ]
794 }
795 ```
796
797 ## `/api/pleroma/admin/moderation_log`
798 ### Get moderation log
799 - Method `GET`
800 - Params:
801 - *optional* `page`: **integer** page number
802 - *optional* `page_size`: **integer** number of log entries per page (default is `50`)
803 - *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`
804 - *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
805 - *optional* `user_id`: **integer** filter logs by actor's id
806 - *optional* `search`: **string** search logs by the log message
807 - Response:
808
809 ```json
810 [
811 {
812 "data": {
813 "actor": {
814 "id": 1,
815 "nickname": "lain"
816 },
817 "action": "relay_follow"
818 },
819 "time": 1502812026, // timestamp
820 "message": "[2017-08-15 15:47:06] @nick0 followed relay: https://example.org/relay" // log message
821 }
822 ]
823 ```
824
825 ## `POST /api/pleroma/admin/reload_emoji`
826 ### Reload the instance's custom emoji
827 * Method `POST`
828 * Authentication: required
829 * Params: None
830 * Response: JSON, "ok" and 200 status