8f6422da04bef9d546b3e5f15bb1064b9f62368b
[akkoma] / docs / development / API / pleroma_api.md
1 # Pleroma API
2
3 Requests that require it can be authenticated with [an OAuth token](https://tools.ietf.org/html/rfc6749), the `_pleroma_key` cookie, or [HTTP Basic Authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization).
4
5 Request parameters can be passed via [query strings](https://en.wikipedia.org/wiki/Query_string) or as [form data](https://www.w3.org/TR/html401/interact/forms.html). Files must be uploaded as `multipart/form-data`.
6
7 The `/api/v1/pleroma/*` path is backwards compatible with `/api/pleroma/*` (`/api/pleroma/*` will be deprecated in the future).
8
9 ## `/api/v1/pleroma/emoji`
10 ### Lists the custom emoji on that server.
11 * Method: `GET`
12 * Authentication: not required
13 * Params: none
14 * Response: JSON
15 * Example response:
16 ```json
17 {
18 "girlpower": {
19 "tags": [
20 "Finmoji"
21 ],
22 "image_url": "/finmoji/128px/girlpower-128.png"
23 },
24 "education": {
25 "tags": [
26 "Finmoji"
27 ],
28 "image_url": "/finmoji/128px/education-128.png"
29 },
30 "finnishlove": {
31 "tags": [
32 "Finmoji"
33 ],
34 "image_url": "/finmoji/128px/finnishlove-128.png"
35 }
36 }
37 ```
38 * Note: Same data as Mastodon API’s `/api/v1/custom_emojis` but in a different format
39
40 ## `/api/v1/pleroma/follow_import`
41 ### Imports your follows, for example from a Mastodon CSV file.
42 * Method: `POST`
43 * Authentication: required
44 * Params:
45 * `list`: STRING or FILE containing a whitespace-separated list of accounts to follow
46 * Response: HTTP 200 on success, 500 on error
47 * Note: Users that can't be followed are silently skipped.
48
49 ## `/api/v1/pleroma/blocks_import`
50 ### Imports your blocks.
51 * Method: `POST`
52 * Authentication: required
53 * Params:
54 * `list`: STRING or FILE containing a whitespace-separated list of accounts to block
55 * Response: HTTP 200 on success, 500 on error
56
57 ## `/api/v1/pleroma/mutes_import`
58 ### Imports your mutes.
59 * Method: `POST`
60 * Authentication: required
61 * Params:
62 * `list`: STRING or FILE containing a whitespace-separated list of accounts to mute
63 * Response: HTTP 200 on success, 500 on error
64
65 ## `/api/v1/pleroma/captcha`
66 ### Get a new captcha
67 * Method: `GET`
68 * Authentication: not required
69 * Params: none
70 * Response: Provider specific JSON, the only guaranteed parameter is `type`
71 * Example response: `{"type": "kocaptcha", "token": "whatever", "url": "https://captcha.kotobank.ch/endpoint", "seconds_valid": 300}`
72
73 ## `/api/v1/pleroma/delete_account`
74 ### Delete an account
75 * Method `POST`
76 * Authentication: required
77 * Params:
78 * `password`: user's password
79 * Response: JSON. Returns `{"status": "success"}` if the deletion was successful, `{"error": "[error message]"}` otherwise
80 * Example response: `{"error": "Invalid password."}`
81
82 ## `/api/v1/pleroma/disable_account`
83 ### Disable an account
84 * Method `POST`
85 * Authentication: required
86 * Params:
87 * `password`: user's password
88 * Response: JSON. Returns `{"status": "success"}` if the account was successfully disabled, `{"error": "[error message]"}` otherwise
89 * Example response: `{"error": "Invalid password."}`
90
91 ## `/api/v1/pleroma/accounts/mfa`
92 #### Gets current MFA settings
93 * method: `GET`
94 * Authentication: required
95 * OAuth scope: `read:security`
96 * Response: JSON. Returns `{"enabled": "false", "totp": false }`
97
98 ## `/api/v1/pleroma/accounts/mfa/setup/totp`
99 #### Pre-setup the MFA/TOTP method
100 * method: `GET`
101 * Authentication: required
102 * OAuth scope: `write:security`
103 * Response: JSON. Returns `{"key": [secret_key], "provisioning_uri": "[qr code uri]" }` when successful, otherwise returns HTTP 422 `{"error": "error_msg"}`
104
105 ## `/api/v1/pleroma/accounts/mfa/confirm/totp`
106 #### Confirms & enables MFA/TOTP support for user account.
107 * method: `POST`
108 * Authentication: required
109 * OAuth scope: `write:security`
110 * Params:
111 * `password`: user's password
112 * `code`: token from TOTP App
113 * Response: JSON. Returns `{}` if the enable was successful, HTTP 422 `{"error": "[error message]"}` otherwise
114
115
116 ## `/api/v1/pleroma/accounts/mfa/totp`
117 #### Disables MFA/TOTP method for user account.
118 * method: `DELETE`
119 * Authentication: required
120 * OAuth scope: `write:security`
121 * Params:
122 * `password`: user's password
123 * Response: JSON. Returns `{}` if the disable was successful, HTTP 422 `{"error": "[error message]"}` otherwise
124 * Example response: `{"error": "Invalid password."}`
125
126 ## `/api/v1/pleroma/accounts/mfa/backup_codes`
127 #### Generstes backup codes MFA for user account.
128 * method: `GET`
129 * Authentication: required
130 * OAuth scope: `write:security`
131 * Response: JSON. Returns `{"codes": codes}`when successful, otherwise HTTP 422 `{"error": "[error message]"}`
132
133 ## `/api/v1/pleroma/admin/`
134 See [Admin-API](admin_api.md)
135
136 ## `/api/v1/pleroma/notifications/read`
137 ### Mark notifications as read
138 * Method `POST`
139 * Authentication: required
140 * Params (mutually exclusive):
141 * `id`: a single notification id to read
142 * `max_id`: read all notifications up to this id
143 * Response: Notification entity/Array of Notification entities that were read. In case of `max_id`, only the first 80 read notifications will be returned.
144
145 ## `/api/v1/pleroma/accounts/:id/subscribe`
146 ### Subscribe to receive notifications for all statuses posted by a user
147 * Method `POST`
148 * Authentication: required
149 * Params:
150 * `id`: account id to subscribe to
151 * Response: JSON, returns a mastodon relationship object on success, otherwise returns `{"error": "error_msg"}`
152 * Example response:
153 ```json
154 {
155 "id": "abcdefg",
156 "following": true,
157 "followed_by": false,
158 "blocking": false,
159 "muting": false,
160 "muting_notifications": false,
161 "subscribing": true,
162 "requested": false,
163 "domain_blocking": false,
164 "showing_reblogs": true,
165 "endorsed": false
166 }
167 ```
168
169 ## `/api/v1/pleroma/accounts/:id/unsubscribe`
170 ### Unsubscribe to stop receiving notifications from user statuses
171 * Method `POST`
172 * Authentication: required
173 * Params:
174 * `id`: account id to unsubscribe from
175 * Response: JSON, returns a mastodon relationship object on success, otherwise returns `{"error": "error_msg"}`
176 * Example response:
177 ```json
178 {
179 "id": "abcdefg",
180 "following": true,
181 "followed_by": false,
182 "blocking": false,
183 "muting": false,
184 "muting_notifications": false,
185 "subscribing": false,
186 "requested": false,
187 "domain_blocking": false,
188 "showing_reblogs": true,
189 "endorsed": false
190 }
191 ```
192
193 ## `/api/v1/pleroma/accounts/:id/favourites`
194 ### Returns favorites timeline of any user
195 * Method `GET`
196 * Authentication: not required
197 * Params:
198 * `id`: the id of the account for whom to return results
199 * `limit`: optional, the number of records to retrieve
200 * `since_id`: optional, returns results that are more recent than the specified id
201 * `max_id`: optional, returns results that are older than the specified id
202 * Response: JSON, returns a list of Mastodon Status entities on success, otherwise returns `{"error": "error_msg"}`
203 * Example response:
204 ```json
205 [
206 {
207 "account": {
208 "id": "9hptFmUF3ztxYh3Svg",
209 "url": "https://pleroma.example.org/users/nick2",
210 "username": "nick2",
211 ...
212 },
213 "application": {"name": "Web", "website": null},
214 "bookmarked": false,
215 "card": null,
216 "content": "This is :moominmamma: note 0",
217 "created_at": "2019-04-15T15:42:15.000Z",
218 "emojis": [],
219 "favourited": false,
220 "favourites_count": 1,
221 "id": "9hptFmVJ02khbzYJaS",
222 "in_reply_to_account_id": null,
223 "in_reply_to_id": null,
224 "language": null,
225 "media_attachments": [],
226 "mentions": [],
227 "muted": false,
228 "pinned": false,
229 "pleroma": {
230 "content": {"text/plain": "This is :moominmamma: note 0"},
231 "conversation_id": 13679,
232 "local": true,
233 "spoiler_text": {"text/plain": "2hu"}
234 },
235 "reblog": null,
236 "reblogged": false,
237 "reblogs_count": 0,
238 "replies_count": 0,
239 "sensitive": false,
240 "spoiler_text": "2hu",
241 "tags": [{"name": "2hu", "url": "/tag/2hu"}],
242 "uri": "https://pleroma.example.org/objects/198ed2a1-7912-4482-b559-244a0369e984",
243 "url": "https://pleroma.example.org/notice/9hptFmVJ02khbzYJaS",
244 "visibility": "public"
245 }
246 ]
247 ```
248
249 ## `/api/v1/pleroma/accounts/update_*`
250 ### Set and clear account avatar, banner, and background
251
252 - PATCH `/api/v1/pleroma/accounts/update_avatar`: Set/clear user avatar image
253 - PATCH `/api/v1/pleroma/accounts/update_banner`: Set/clear user banner image
254 - PATCH `/api/v1/pleroma/accounts/update_background`: Set/clear user background image
255
256 ## `/api/v1/pleroma/accounts/confirmation_resend`
257 ### Resend confirmation email
258 * Method `POST`
259 * Params:
260 * `email`: email of that needs to be verified
261 * Authentication: not required
262 * Response: 204 No Content
263
264 ## `/api/v1/pleroma/mascot`
265 ### Gets user mascot image
266 * Method `GET`
267 * Authentication: required
268
269 * Response: JSON. Returns a mastodon media attachment entity.
270 * Example response:
271 ```json
272 {
273 "id": "abcdefg",
274 "url": "https://pleroma.example.org/media/abcdefg.png",
275 "type": "image",
276 "pleroma": {
277 "mime_type": "image/png"
278 }
279 }
280 ```
281
282 ### Updates user mascot image
283 * Method `PUT`
284 * Authentication: required
285 * Params:
286 * `file`: Multipart image
287 * Response: JSON. Returns a mastodon media attachment entity
288 when successful, otherwise returns HTTP 415 `{"error": "error_msg"}`
289 * Example response:
290 ```json
291 {
292 "id": "abcdefg",
293 "url": "https://pleroma.example.org/media/abcdefg.png",
294 "type": "image",
295 "pleroma": {
296 "mime_type": "image/png"
297 }
298 }
299 ```
300 * Note: Behaves exactly the same as `POST /api/v1/upload`.
301 Can only accept images - any attempt to upload non-image files will be met with `HTTP 415 Unsupported Media Type`.
302
303 ## `/api/pleroma/notification_settings`
304 ### Updates user notification settings
305 * Method `PUT`
306 * Authentication: required
307 * Params:
308 * `block_from_strangers`: BOOLEAN field, blocks notifications from accounts you do not follow
309 * `hide_notification_contents`: BOOLEAN field. When set to true, it removes the contents of a message from the push notification.
310 * Response: JSON. Returns `{"status": "success"}` if the update was successful, otherwise returns `{"error": "error_msg"}`
311
312 ## `/api/v1/pleroma/healthcheck`
313 ### Healthcheck endpoint with additional system data.
314 * Method `GET`
315 * Authentication: not required
316 * Params: none
317 * Response: JSON, statuses (200 - healthy, 503 unhealthy).
318 * Example response:
319 ```json
320 {
321 "pool_size": 0, # database connection pool
322 "active": 0, # active processes
323 "idle": 0, # idle processes
324 "memory_used": 0.00, # Memory used
325 "healthy": true, # Instance state
326 "job_queue_stats": {} # Job queue stats
327 }
328 ```
329
330 ## `/api/v1/pleroma/change_email`
331 ### Change account email
332 * Method `POST`
333 * Authentication: required
334 * Params:
335 * `password`: user's password
336 * `email`: new email
337 * Response: JSON. Returns `{"status": "success"}` if the change was successful, `{"error": "[error message]"}` otherwise
338 * Note: Currently, Mastodon has no API for changing email. If they add it in future it might be incompatible with Pleroma.
339
340 # Pleroma Conversations
341
342 Pleroma Conversations have the same general structure that Mastodon Conversations have. The behavior differs in the following ways when using these endpoints:
343
344 1. Pleroma Conversations never add or remove recipients, unless explicitly changed by the user.
345 2. Pleroma Conversations statuses can be requested by Conversation id.
346 3. Pleroma Conversations can be replied to.
347
348 Conversations have the additional field `recipients` under the `pleroma` key. This holds a list of all the accounts that will receive a message in this conversation.
349
350 The status posting endpoint takes an additional parameter, `in_reply_to_conversation_id`, which, when set, will set the visiblity to direct and address only the people who are the recipients of that Conversation.
351
352 âš  Conversation IDs can be found in direct messages with the `pleroma.direct_conversation_id` key, do not confuse it with `pleroma.conversation_id`.
353
354 ## `GET /api/v1/pleroma/conversations/:id/statuses`
355 ### Timeline for a given conversation
356 * Method `GET`
357 * Authentication: required
358 * Params: Like other timelines
359 * Response: JSON, statuses (200 - healthy, 503 unhealthy).
360
361 ## `GET /api/v1/pleroma/conversations/:id`
362 ### The conversation with the given ID.
363 * Method `GET`
364 * Authentication: required
365 * Params: None
366 * Response: JSON, statuses (200 - healthy, 503 unhealthy).
367
368 ## `PATCH /api/v1/pleroma/conversations/:id`
369 ### Update a conversation. Used to change the set of recipients.
370 * Method `PATCH`
371 * Authentication: required
372 * Params:
373 * `recipients`: A list of ids of users that should receive posts to this conversation. This will replace the current list of recipients, so submit the full list. The owner of owner of the conversation will always be part of the set of recipients, though.
374 * Response: JSON, statuses (200 - healthy, 503 unhealthy)
375
376 ## `POST /api/v1/pleroma/conversations/read`
377 ### Marks all user's conversations as read.
378 * Method `POST`
379 * Authentication: required
380 * Params: None
381 * Response: JSON, returns a list of Mastodon Conversation entities that were marked as read (200 - healthy, 503 unhealthy).
382
383 ## `GET /api/v1/pleroma/emoji/pack?name=:name`
384
385 ### Get pack.json for the pack
386
387 * Method `GET`
388 * Authentication: not required
389 * Params:
390 * `page`: page number for files (default 1)
391 * `page_size`: page size for files (default 30)
392 * Response: JSON, pack json with `files`, `files_count` and `pack` keys with 200 status or 404 if the pack does not exist.
393
394 ```json
395 {
396 "files": {...},
397 "files_count": 0, // emoji count in pack
398 "pack": {...}
399 }
400 ```
401
402 ## `POST /api/v1/pleroma/emoji/pack?name=:name`
403
404 ### Creates an empty pack
405
406 * Method `POST`
407 * Authentication: required (admin)
408 * Params:
409 * `name`: pack name
410 * Response: JSON, "ok" and 200 status or 409 if the pack with that name already exists
411
412 ## `PATCH /api/v1/pleroma/emoji/pack?name=:name`
413
414 ### Updates (replaces) pack metadata
415
416 * Method `PATCH`
417 * Authentication: required (admin)
418 * Params:
419 * `name`: pack name
420 * `metadata`: metadata to replace the old one
421 * `license`: Pack license
422 * `homepage`: Pack home page url
423 * `description`: Pack description
424 * `fallback-src`: Fallback url to download pack from
425 * `fallback-src-sha256`: SHA256 encoded for fallback pack archive
426 * `share-files`: is pack allowed for sharing (boolean)
427 * Response: JSON, updated "metadata" section of the pack and 200 status or 400 if there was a
428 problem with the new metadata (the error is specified in the "error" part of the response JSON)
429
430 ## `DELETE /api/v1/pleroma/emoji/pack?name=:name`
431
432 ### Delete a custom emoji pack
433
434 * Method `DELETE`
435 * Authentication: required (admin)
436 * Params:
437 * `name`: pack name
438 * Response: JSON, "ok" and 200 status or 500 if there was an error deleting the pack
439
440 ## `GET /api/v1/pleroma/emoji/packs/import`
441
442 ### Imports packs from filesystem
443
444 * Method `GET`
445 * Authentication: required (admin)
446 * Params: None
447 * Response: JSON, returns a list of imported packs.
448
449 ## `GET /api/v1/pleroma/emoji/packs/remote`
450
451 ### Make request to another instance for packs list
452
453 * Method `GET`
454 * Authentication: required (admin)
455 * Params:
456 * `url`: url of the instance to get packs from
457 * `page`: page number for packs (default 1)
458 * `page_size`: page size for packs (default 50)
459 * Response: JSON with the pack list, hashmap with pack name and pack contents
460
461 ## `POST /api/v1/pleroma/emoji/packs/download`
462
463 ### Download pack from another instance
464
465 * Method `POST`
466 * Authentication: required (admin)
467 * Params:
468 * `url`: url of the instance to download from
469 * `name`: pack to download from that instance
470 * `as`: (*optional*) name how to save pack
471 * Response: JSON, "ok" with 200 status if the pack was downloaded, or 500 if there were
472 errors downloading the pack
473
474 ## `POST /api/v1/pleroma/emoji/packs/files?name=:name`
475
476 ### Add new file to the pack
477
478 * Method `POST`
479 * Authentication: required (admin)
480 * Params:
481 * `name`: pack name
482 * `file`: file needs to be uploaded with the multipart request or link to remote file.
483 * `shortcode`: (*optional*) shortcode for new emoji, must be unique for all emoji. If not sended, shortcode will be taken from original filename.
484 * `filename`: (*optional*) new emoji file name. If not specified will be taken from original filename.
485 * Response: JSON, list of files for updated pack (hashmap -> shortcode => filename) with status 200, either error status with error message.
486
487 ## `PATCH /api/v1/pleroma/emoji/packs/files?name=:name`
488
489 ### Update emoji file from pack
490
491 * Method `PATCH`
492 * Authentication: required (admin)
493 * Params:
494 * `name`: pack name
495 * `shortcode`: emoji file shortcode
496 * `new_shortcode`: new emoji file shortcode
497 * `new_filename`: new filename for emoji file
498 * `force`: (*optional*) with true value to overwrite existing emoji with new shortcode
499 * Response: JSON, list with updated files for updated pack (hashmap -> shortcode => filename) with status 200, either error status with error message.
500
501 ## `DELETE /api/v1/pleroma/emoji/packs/files?name=:name`
502
503 ### Delete emoji file from pack
504
505 * Method `DELETE`
506 * Authentication: required (admin)
507 * Params:
508 * `name`: pack name
509 * `shortcode`: emoji file shortcode
510 * Response: JSON, list with updated files for updated pack (hashmap -> shortcode => filename) with status 200, either error status with error message.
511
512 ## `GET /api/v1/pleroma/emoji/packs`
513
514 ### Lists local custom emoji packs
515
516 * Method `GET`
517 * Authentication: not required
518 * Params:
519 * `page`: page number for packs (default 1)
520 * `page_size`: page size for packs (default 50)
521 * Response: `packs` key with JSON hashmap of pack name to pack contents and `count` key for count of packs.
522
523 ```json
524 {
525 "packs": {
526 "pack_name": {...}, // pack contents
527 ...
528 },
529 "count": 0 // packs count
530 }
531 ```
532
533 ## `GET /api/v1/pleroma/emoji/packs/archive?name=:name`
534
535 ### Requests a local pack archive from the instance
536
537 * Method `GET`
538 * Authentication: not required
539 * Params:
540 * `name`: pack name
541 * Response: the archive of the pack with a 200 status code, 403 if the pack is not set as shared,
542 404 if the pack does not exist
543
544 ## `GET /api/v1/pleroma/accounts/:id/scrobbles`
545 ### Requests a list of current and recent Listen activities for an account
546 * Method `GET`
547 * Authentication: not required
548 * Params: None
549 * Response: An array of media metadata entities.
550 * Example response:
551 ```json
552 [
553 {
554 "account": {...},
555 "id": "1234",
556 "title": "Some Title",
557 "artist": "Some Artist",
558 "album": "Some Album",
559 "length": 180000,
560 "created_at": "2019-09-28T12:40:45.000Z"
561 }
562 ]
563 ```
564
565 ## `POST /api/v1/pleroma/scrobble`
566 ### Creates a new Listen activity for an account
567 * Method `POST`
568 * Authentication: required
569 * Params:
570 * `title`: the title of the media playing
571 * `album`: the album of the media playing [optional]
572 * `artist`: the artist of the media playing [optional]
573 * `length`: the length of the media playing [optional]
574 * Response: the newly created media metadata entity representing the Listen activity
575
576 # Emoji Reactions
577
578 Emoji reactions work a lot like favourites do. They make it possible to react to a post with a single emoji character. To detect the presence of this feature, you can check `pleroma_emoji_reactions` entry in the features list of nodeinfo.
579
580 ## `PUT /api/v1/pleroma/statuses/:id/reactions/:emoji`
581 ### React to a post with a unicode emoji
582 * Method: `PUT`
583 * Authentication: required
584 * Params: `emoji`: A unicode RGI emoji or a regional indicator
585 * Response: JSON, the status.
586
587 ## `DELETE /api/v1/pleroma/statuses/:id/reactions/:emoji`
588 ### Remove a reaction to a post with a unicode emoji
589 * Method: `DELETE`
590 * Authentication: required
591 * Params: `emoji`: A unicode RGI emoji or a regional indicator
592 * Response: JSON, the status.
593
594 ## `GET /api/v1/pleroma/statuses/:id/reactions`
595 ### Get an object of emoji to account mappings with accounts that reacted to the post
596 * Method: `GET`
597 * Authentication: optional
598 * Params: None
599 * Response: JSON, a list of emoji/account list tuples, sorted by emoji insertion date, in ascending order, e.g, the first emoji in the list is the oldest.
600 * Example Response:
601 ```json
602 [
603 {"name": "😀", "count": 2, "me": true, "accounts": [{"id" => "xyz.."...}, {"id" => "zyx..."}]},
604 {"name": "☕", "count": 1, "me": false, "accounts": [{"id" => "abc..."}]}
605 ]
606 ```
607
608 ## `GET /api/v1/pleroma/statuses/:id/reactions/:emoji`
609 ### Get an object of emoji to account mappings with accounts that reacted to the post for a specific emoji
610 * Method: `GET`
611 * Authentication: optional
612 * Params: None
613 * Response: JSON, a list of emoji/account list tuples
614 * Example Response:
615 ```json
616 [
617 {"name": "😀", "count": 2, "me": true, "accounts": [{"id" => "xyz.."...}, {"id" => "zyx..."}]}
618 ]
619 ```
620
621 ## `POST /api/v1/pleroma/backups`
622 ### Create a user backup archive
623
624 * Method: `POST`
625 * Authentication: required
626 * Params: none
627 * Response: JSON
628 * Example response:
629
630 ```json
631 [{
632 "content_type": "application/zip",
633 "file_size": 0,
634 "inserted_at": "2020-09-10T16:18:03.000Z",
635 "processed": false,
636 "url": "https://example.com/media/backups/archive-foobar-20200910T161803-QUhx6VYDRQ2wfV0SdA2Pfj_2CLM_ATUlw-D5l5TJf4Q.zip"
637 }]
638 ```
639
640 ## `GET /api/v1/pleroma/backups`
641 ### Lists user backups
642
643 * Method: `GET`
644 * Authentication: not required
645 * Params: none
646 * Response: JSON
647 * Example response:
648
649 ```json
650 [{
651 "content_type": "application/zip",
652 "file_size": 55457,
653 "inserted_at": "2020-09-10T16:18:03.000Z",
654 "processed": true,
655 "url": "https://example.com/media/backups/archive-foobar-20200910T161803-QUhx6VYDRQ2wfV0SdA2Pfj_2CLM_ATUlw-D5l5TJf4Q.zip"
656 }]
657 ```