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