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