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