make bulk user creation from admin works as a transaction
[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 },
43 ...
44 ]
45 }
46 ```
47
48 ## `/api/pleroma/admin/users`
49
50 ### Remove a user
51
52 - Method `DELETE`
53 - Params:
54 - `nickname`
55 - Response: User’s nickname
56
57 ### Create a user
58
59 - Method: `POST`
60 - Params:
61 - `nickname`
62 - `email`
63 - `password`
64 - Response: User’s nickname
65
66 ## `/api/pleroma/admin/users/follow`
67 ### Make a user follow another user
68
69 - Methods: `POST`
70 - Params:
71 - `follower`: The nickname of the follower
72 - `followed`: The nickname of the followed
73 - Response:
74 - "ok"
75
76 ## `/api/pleroma/admin/users/unfollow`
77 ### Make a user unfollow another user
78
79 - Methods: `POST`
80 - Params:
81 - `follower`: The nickname of the follower
82 - `followed`: The nickname of the followed
83 - Response:
84 - "ok"
85
86 ## `/api/pleroma/admin/users/:nickname/toggle_activation`
87
88 ### Toggle user activation
89
90 - Method: `PATCH`
91 - Params:
92 - `nickname`
93 - Response: User’s object
94
95 ```JSON
96 {
97 "deactivated": bool,
98 "id": integer,
99 "nickname": string
100 }
101 ```
102
103 ## `/api/pleroma/admin/users/tag`
104
105 ### Tag a list of users
106
107 - Method: `PUT`
108 - Params:
109 - `nickname`
110 - `tags`
111
112 ### Untag a list of users
113
114 - Method: `DELETE`
115 - Params:
116 - `nickname`
117 - `tags`
118
119 ## `/api/pleroma/admin/users/:nickname/permission_group`
120
121 ### Get user user permission groups membership
122
123 - Method: `GET`
124 - Params: none
125 - Response:
126
127 ```JSON
128 {
129 "is_moderator": bool,
130 "is_admin": bool
131 }
132 ```
133
134 ## `/api/pleroma/admin/users/:nickname/permission_group/:permission_group`
135
136 Note: Available `:permission_group` is currently moderator and admin. 404 is returned when the permission group doesn’t exist.
137
138 ### Get user user permission groups membership per permission group
139
140 - Method: `GET`
141 - Params: none
142 - Response:
143
144 ```JSON
145 {
146 "is_moderator": bool,
147 "is_admin": bool
148 }
149 ```
150
151 ### Add user in permission group
152
153 - Method: `POST`
154 - Params: none
155 - Response:
156 - On failure: `{"error": "…"}`
157 - On success: JSON of the `user.info`
158
159 ### Remove user from permission group
160
161 - Method: `DELETE`
162 - Params: none
163 - Response:
164 - On failure: `{"error": "…"}`
165 - On success: JSON of the `user.info`
166 - Note: An admin cannot revoke their own admin status.
167
168 ## `/api/pleroma/admin/users/:nickname/activation_status`
169
170 ### Active or deactivate a user
171
172 - Method: `PUT`
173 - Params:
174 - `nickname`
175 - `status` BOOLEAN field, false value means deactivation.
176
177 ## `/api/pleroma/admin/users/:nickname`
178
179 ### Retrive the details of a user
180
181 - Method: `GET`
182 - Params:
183 - `nickname`
184 - Response:
185 - On failure: `Not found`
186 - On success: JSON of the user
187
188 ## `/api/pleroma/admin/relay`
189
190 ### Follow a Relay
191
192 - Methods: `POST`
193 - Params:
194 - `relay_url`
195 - Response:
196 - On success: URL of the followed relay
197
198 ### Unfollow a Relay
199
200 - Methods: `DELETE`
201 - Params:
202 - `relay_url`
203 - Response:
204 - On success: URL of the unfollowed relay
205
206 ## `/api/pleroma/admin/users/invite_token`
207
208 ### Get an account registration invite token
209
210 - Methods: `GET`
211 - Params:
212 - *optional* `invite` => [
213 - *optional* `max_use` (integer)
214 - *optional* `expires_at` (date string e.g. "2019-04-07")
215 ]
216 - Response: invite token (base64 string)
217
218 ## `/api/pleroma/admin/users/invites`
219
220 ### Get a list of generated invites
221
222 - Methods: `GET`
223 - Params: none
224 - Response:
225
226 ```JSON
227 {
228
229 "invites": [
230 {
231 "id": integer,
232 "token": string,
233 "used": boolean,
234 "expires_at": date,
235 "uses": integer,
236 "max_use": integer,
237 "invite_type": string (possible values: `one_time`, `reusable`, `date_limited`, `reusable_date_limited`)
238 },
239 ...
240 ]
241 }
242 ```
243
244 ## `/api/pleroma/admin/users/revoke_invite`
245
246 ### Revoke invite by token
247
248 - Methods: `POST`
249 - Params:
250 - `token`
251 - Response:
252
253 ```JSON
254 {
255 "id": integer,
256 "token": string,
257 "used": boolean,
258 "expires_at": date,
259 "uses": integer,
260 "max_use": integer,
261 "invite_type": string (possible values: `one_time`, `reusable`, `date_limited`, `reusable_date_limited`)
262
263 }
264 ```
265
266
267 ## `/api/pleroma/admin/users/email_invite`
268
269 ### Sends registration invite via email
270
271 - Methods: `POST`
272 - Params:
273 - `email`
274 - `name`, optional
275
276 ## `/api/pleroma/admin/users/:nickname/password_reset`
277
278 ### Get a password reset token for a given nickname
279
280 - Methods: `GET`
281 - Params: none
282 - Response: password reset token (base64 string)