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