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