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