Add 'notifying' to relationship for compatibility with Mastodon
[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 "notifying": true,
163 "requested": false,
164 "domain_blocking": false,
165 "showing_reblogs": true,
166 "endorsed": false
167 }
168 ```
169
170 ## `/api/v1/pleroma/accounts/:id/unsubscribe`
171 ### Unsubscribe to stop receiving notifications from user statuses
172 * Method `POST`
173 * Authentication: required
174 * Params:
175 * `id`: account id to unsubscribe from
176 * Response: JSON, returns a mastodon relationship object on success, otherwise returns `{"error": "error_msg"}`
177 * Example response:
178 ```json
179 {
180 "id": "abcdefg",
181 "following": true,
182 "followed_by": false,
183 "blocking": false,
184 "muting": false,
185 "muting_notifications": false,
186 "subscribing": false,
187 "notifying": false,
188 "requested": false,
189 "domain_blocking": false,
190 "showing_reblogs": true,
191 "endorsed": false
192 }
193 ```
194
195 ## `/api/v1/pleroma/accounts/:id/favourites`
196 ### Returns favorites timeline of any user
197 * Method `GET`
198 * Authentication: not required
199 * Params:
200 * `id`: the id of the account for whom to return results
201 * `limit`: optional, the number of records to retrieve
202 * `since_id`: optional, returns results that are more recent than the specified id
203 * `max_id`: optional, returns results that are older than the specified id
204 * Response: JSON, returns a list of Mastodon Status entities on success, otherwise returns `{"error": "error_msg"}`
205 * Example response:
206 ```json
207 [
208 {
209 "account": {
210 "id": "9hptFmUF3ztxYh3Svg",
211 "url": "https://pleroma.example.org/users/nick2",
212 "username": "nick2",
213 ...
214 },
215 "application": {"name": "Web", "website": null},
216 "bookmarked": false,
217 "card": null,
218 "content": "This is :moominmamma: note 0",
219 "created_at": "2019-04-15T15:42:15.000Z",
220 "emojis": [],
221 "favourited": false,
222 "favourites_count": 1,
223 "id": "9hptFmVJ02khbzYJaS",
224 "in_reply_to_account_id": null,
225 "in_reply_to_id": null,
226 "language": null,
227 "media_attachments": [],
228 "mentions": [],
229 "muted": false,
230 "pinned": false,
231 "pleroma": {
232 "content": {"text/plain": "This is :moominmamma: note 0"},
233 "conversation_id": 13679,
234 "local": true,
235 "spoiler_text": {"text/plain": "2hu"}
236 },
237 "reblog": null,
238 "reblogged": false,
239 "reblogs_count": 0,
240 "replies_count": 0,
241 "sensitive": false,
242 "spoiler_text": "2hu",
243 "tags": [{"name": "2hu", "url": "/tag/2hu"}],
244 "uri": "https://pleroma.example.org/objects/198ed2a1-7912-4482-b559-244a0369e984",
245 "url": "https://pleroma.example.org/notice/9hptFmVJ02khbzYJaS",
246 "visibility": "public"
247 }
248 ]
249 ```
250
251 ## `/api/v1/pleroma/accounts/update_*`
252 ### Set and clear account avatar, banner, and background
253
254 - PATCH `/api/v1/pleroma/accounts/update_avatar`: Set/clear user avatar image
255 - PATCH `/api/v1/pleroma/accounts/update_banner`: Set/clear user banner image
256 - PATCH `/api/v1/pleroma/accounts/update_background`: Set/clear user background image
257
258 ## `/api/v1/pleroma/accounts/confirmation_resend`
259 ### Resend confirmation email
260 * Method `POST`
261 * Params:
262 * `email`: email of that needs to be verified
263 * Authentication: not required
264 * Response: 204 No Content
265
266 ## `/api/v1/pleroma/mascot`
267 ### Gets user mascot image
268 * Method `GET`
269 * Authentication: required
270
271 * Response: JSON. Returns a mastodon media attachment entity.
272 * Example response:
273 ```json
274 {
275 "id": "abcdefg",
276 "url": "https://pleroma.example.org/media/abcdefg.png",
277 "type": "image",
278 "pleroma": {
279 "mime_type": "image/png"
280 }
281 }
282 ```
283
284 ### Updates user mascot image
285 * Method `PUT`
286 * Authentication: required
287 * Params:
288 * `file`: Multipart image
289 * Response: JSON. Returns a mastodon media attachment entity
290 when successful, otherwise returns HTTP 415 `{"error": "error_msg"}`
291 * Example response:
292 ```json
293 {
294 "id": "abcdefg",
295 "url": "https://pleroma.example.org/media/abcdefg.png",
296 "type": "image",
297 "pleroma": {
298 "mime_type": "image/png"
299 }
300 }
301 ```
302 * Note: Behaves exactly the same as `POST /api/v1/upload`.
303 Can only accept images - any attempt to upload non-image files will be met with `HTTP 415 Unsupported Media Type`.
304
305 ## `/api/pleroma/notification_settings`
306 ### Updates user notification settings
307 * Method `PUT`
308 * Authentication: required
309 * Params:
310 * `block_from_strangers`: BOOLEAN field, blocks notifications from accounts you do not follow
311 * `hide_notification_contents`: BOOLEAN field. When set to true, it removes the contents of a message from the push notification.
312 * Response: JSON. Returns `{"status": "success"}` if the update was successful, otherwise returns `{"error": "error_msg"}`
313
314 ## `/api/v1/pleroma/healthcheck`
315 ### Healthcheck endpoint with additional system data.
316 * Method `GET`
317 * Authentication: not required
318 * Params: none
319 * Response: JSON, statuses (200 - healthy, 503 unhealthy).
320 * Example response:
321 ```json
322 {
323 "pool_size": 0, # database connection pool
324 "active": 0, # active processes
325 "idle": 0, # idle processes
326 "memory_used": 0.00, # Memory used
327 "healthy": true, # Instance state
328 "job_queue_stats": {} # Job queue stats
329 }
330 ```
331
332 ## `/api/v1/pleroma/change_email`
333 ### Change account email
334 * Method `POST`
335 * Authentication: required
336 * Params:
337 * `password`: user's password
338 * `email`: new email
339 * Response: JSON. Returns `{"status": "success"}` if the change was successful, `{"error": "[error message]"}` otherwise
340 * Note: Currently, Mastodon has no API for changing email. If they add it in future it might be incompatible with Pleroma.
341
342 # Pleroma Conversations
343
344 Pleroma Conversations have the same general structure that Mastodon Conversations have. The behavior differs in the following ways when using these endpoints:
345
346 1. Pleroma Conversations never add or remove recipients, unless explicitly changed by the user.
347 2. Pleroma Conversations statuses can be requested by Conversation id.
348 3. Pleroma Conversations can be replied to.
349
350 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.
351
352 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.
353
354 âš  Conversation IDs can be found in direct messages with the `pleroma.direct_conversation_id` key, do not confuse it with `pleroma.conversation_id`.
355
356 ## `GET /api/v1/pleroma/conversations/:id/statuses`
357 ### Timeline for a given conversation
358 * Method `GET`
359 * Authentication: required
360 * Params: Like other timelines
361 * Response: JSON, statuses (200 - healthy, 503 unhealthy).
362
363 ## `GET /api/v1/pleroma/conversations/:id`
364 ### The conversation with the given ID.
365 * Method `GET`
366 * Authentication: required
367 * Params: None
368 * Response: JSON, statuses (200 - healthy, 503 unhealthy).
369
370 ## `PATCH /api/v1/pleroma/conversations/:id`
371 ### Update a conversation. Used to change the set of recipients.
372 * Method `PATCH`
373 * Authentication: required
374 * Params:
375 * `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.
376 * Response: JSON, statuses (200 - healthy, 503 unhealthy)
377
378 ## `POST /api/v1/pleroma/conversations/read`
379 ### Marks all user's conversations as read.
380 * Method `POST`
381 * Authentication: required
382 * Params: None
383 * Response: JSON, returns a list of Mastodon Conversation entities that were marked as read (200 - healthy, 503 unhealthy).
384
385 ## `GET /api/v1/pleroma/emoji/pack?name=:name`
386
387 ### Get pack.json for the pack
388
389 * Method `GET`
390 * Authentication: not required
391 * Params:
392 * `page`: page number for files (default 1)
393 * `page_size`: page size for files (default 30)
394 * Response: JSON, pack json with `files`, `files_count` and `pack` keys with 200 status or 404 if the pack does not exist.
395
396 ```json
397 {
398 "files": {...},
399 "files_count": 0, // emoji count in pack
400 "pack": {...}
401 }
402 ```
403
404 ## `POST /api/v1/pleroma/emoji/pack?name=:name`
405
406 ### Creates an empty pack
407
408 * Method `POST`
409 * Authentication: required (admin)
410 * Params:
411 * `name`: pack name
412 * Response: JSON, "ok" and 200 status or 409 if the pack with that name already exists
413
414 ## `PATCH /api/v1/pleroma/emoji/pack?name=:name`
415
416 ### Updates (replaces) pack metadata
417
418 * Method `PATCH`
419 * Authentication: required (admin)
420 * Params:
421 * `name`: pack name
422 * `metadata`: metadata to replace the old one
423 * `license`: Pack license
424 * `homepage`: Pack home page url
425 * `description`: Pack description
426 * `fallback-src`: Fallback url to download pack from
427 * `fallback-src-sha256`: SHA256 encoded for fallback pack archive
428 * `share-files`: is pack allowed for sharing (boolean)
429 * Response: JSON, updated "metadata" section of the pack and 200 status or 400 if there was a
430 problem with the new metadata (the error is specified in the "error" part of the response JSON)
431
432 ## `DELETE /api/v1/pleroma/emoji/pack?name=:name`
433
434 ### Delete a custom emoji pack
435
436 * Method `DELETE`
437 * Authentication: required (admin)
438 * Params:
439 * `name`: pack name
440 * Response: JSON, "ok" and 200 status or 500 if there was an error deleting the pack
441
442 ## `GET /api/v1/pleroma/emoji/packs/import`
443
444 ### Imports packs from filesystem
445
446 * Method `GET`
447 * Authentication: required (admin)
448 * Params: None
449 * Response: JSON, returns a list of imported packs.
450
451 ## `GET /api/v1/pleroma/emoji/packs/remote`
452
453 ### Make request to another instance for packs list
454
455 * Method `GET`
456 * Authentication: required (admin)
457 * Params:
458 * `url`: url of the instance to get packs from
459 * `page`: page number for packs (default 1)
460 * `page_size`: page size for packs (default 50)
461 * Response: JSON with the pack list, hashmap with pack name and pack contents
462
463 ## `POST /api/v1/pleroma/emoji/packs/download`
464
465 ### Download pack from another instance
466
467 * Method `POST`
468 * Authentication: required (admin)
469 * Params:
470 * `url`: url of the instance to download from
471 * `name`: pack to download from that instance
472 * `as`: (*optional*) name how to save pack
473 * Response: JSON, "ok" with 200 status if the pack was downloaded, or 500 if there were
474 errors downloading the pack
475
476 ## `POST /api/v1/pleroma/emoji/packs/files?name=:name`
477
478 ### Add new file to the pack
479
480 * Method `POST`
481 * Authentication: required (admin)
482 * Params:
483 * `name`: pack name
484 * `file`: file needs to be uploaded with the multipart request or link to remote file.
485 * `shortcode`: (*optional*) shortcode for new emoji, must be unique for all emoji. If not sended, shortcode will be taken from original filename.
486 * `filename`: (*optional*) new emoji file name. If not specified will be taken from original filename.
487 * Response: JSON, list of files for updated pack (hashmap -> shortcode => filename) with status 200, either error status with error message.
488
489 ## `PATCH /api/v1/pleroma/emoji/packs/files?name=:name`
490
491 ### Update emoji file from pack
492
493 * Method `PATCH`
494 * Authentication: required (admin)
495 * Params:
496 * `name`: pack name
497 * `shortcode`: emoji file shortcode
498 * `new_shortcode`: new emoji file shortcode
499 * `new_filename`: new filename for emoji file
500 * `force`: (*optional*) with true value to overwrite existing emoji with new shortcode
501 * Response: JSON, list with updated files for updated pack (hashmap -> shortcode => filename) with status 200, either error status with error message.
502
503 ## `DELETE /api/v1/pleroma/emoji/packs/files?name=:name`
504
505 ### Delete emoji file from pack
506
507 * Method `DELETE`
508 * Authentication: required (admin)
509 * Params:
510 * `name`: pack name
511 * `shortcode`: emoji file shortcode
512 * Response: JSON, list with updated files for updated pack (hashmap -> shortcode => filename) with status 200, either error status with error message.
513
514 ## `GET /api/v1/pleroma/emoji/packs`
515
516 ### Lists local custom emoji packs
517
518 * Method `GET`
519 * Authentication: not required
520 * Params:
521 * `page`: page number for packs (default 1)
522 * `page_size`: page size for packs (default 50)
523 * Response: `packs` key with JSON hashmap of pack name to pack contents and `count` key for count of packs.
524
525 ```json
526 {
527 "packs": {
528 "pack_name": {...}, // pack contents
529 ...
530 },
531 "count": 0 // packs count
532 }
533 ```
534
535 ## `GET /api/v1/pleroma/emoji/packs/archive?name=:name`
536
537 ### Requests a local pack archive from the instance
538
539 * Method `GET`
540 * Authentication: not required
541 * Params:
542 * `name`: pack name
543 * Response: the archive of the pack with a 200 status code, 403 if the pack is not set as shared,
544 404 if the pack does not exist
545
546 ## `GET /api/v1/pleroma/accounts/:id/scrobbles`
547 ### Requests a list of current and recent Listen activities for an account
548 * Method `GET`
549 * Authentication: not required
550 * Params: None
551 * Response: An array of media metadata entities.
552 * Example response:
553 ```json
554 [
555 {
556 "account": {...},
557 "id": "1234",
558 "title": "Some Title",
559 "artist": "Some Artist",
560 "album": "Some Album",
561 "length": 180000,
562 "created_at": "2019-09-28T12:40:45.000Z"
563 }
564 ]
565 ```
566
567 ## `POST /api/v1/pleroma/scrobble`
568 ### Creates a new Listen activity for an account
569 * Method `POST`
570 * Authentication: required
571 * Params:
572 * `title`: the title of the media playing
573 * `album`: the album of the media playing [optional]
574 * `artist`: the artist of the media playing [optional]
575 * `length`: the length of the media playing [optional]
576 * Response: the newly created media metadata entity representing the Listen activity
577
578 # Emoji Reactions
579
580 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.
581
582 ## `PUT /api/v1/pleroma/statuses/:id/reactions/:emoji`
583 ### React to a post with a unicode emoji
584 * Method: `PUT`
585 * Authentication: required
586 * Params: `emoji`: A unicode RGI emoji or a regional indicator
587 * Response: JSON, the status.
588
589 ## `DELETE /api/v1/pleroma/statuses/:id/reactions/:emoji`
590 ### Remove a reaction to a post with a unicode emoji
591 * Method: `DELETE`
592 * Authentication: required
593 * Params: `emoji`: A unicode RGI emoji or a regional indicator
594 * Response: JSON, the status.
595
596 ## `GET /api/v1/pleroma/statuses/:id/reactions`
597 ### Get an object of emoji to account mappings with accounts that reacted to the post
598 * Method: `GET`
599 * Authentication: optional
600 * Params: None
601 * 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.
602 * Example Response:
603 ```json
604 [
605 {"name": "😀", "count": 2, "me": true, "accounts": [{"id" => "xyz.."...}, {"id" => "zyx..."}]},
606 {"name": "☕", "count": 1, "me": false, "accounts": [{"id" => "abc..."}]}
607 ]
608 ```
609
610 ## `GET /api/v1/pleroma/statuses/:id/reactions/:emoji`
611 ### Get an object of emoji to account mappings with accounts that reacted to the post for a specific emoji
612 * Method: `GET`
613 * Authentication: optional
614 * Params: None
615 * Response: JSON, a list of emoji/account list tuples
616 * Example Response:
617 ```json
618 [
619 {"name": "😀", "count": 2, "me": true, "accounts": [{"id" => "xyz.."...}, {"id" => "zyx..."}]}
620 ]
621 ```
622
623 ## `POST /api/v1/pleroma/backups`
624 ### Create a user backup archive
625
626 * Method: `POST`
627 * Authentication: required
628 * Params: none
629 * Response: JSON
630 * Example response:
631
632 ```json
633 [{
634 "content_type": "application/zip",
635 "file_size": 0,
636 "inserted_at": "2020-09-10T16:18:03.000Z",
637 "processed": false,
638 "url": "https://example.com/media/backups/archive-foobar-20200910T161803-QUhx6VYDRQ2wfV0SdA2Pfj_2CLM_ATUlw-D5l5TJf4Q.zip"
639 }]
640 ```
641
642 ## `GET /api/v1/pleroma/backups`
643 ### Lists user backups
644
645 * Method: `GET`
646 * Authentication: not required
647 * Params: none
648 * Response: JSON
649 * Example response:
650
651 ```json
652 [{
653 "content_type": "application/zip",
654 "file_size": 55457,
655 "inserted_at": "2020-09-10T16:18:03.000Z",
656 "processed": true,
657 "url": "https://example.com/media/backups/archive-foobar-20200910T161803-QUhx6VYDRQ2wfV0SdA2Pfj_2CLM_ATUlw-D5l5TJf4Q.zip"
658 }]
659 ```