
* fix relrefs around trends and related entities * revert moving caption-links to middle of page * hide empty menu in table of contents * clarify edit notifs are only for boosted statuses * following/followers no longer need auth * fix typo * specify cooldown period for account Move * use the correct cooldown * add missing parameters to accounts/id/statuses * link to account_statuses_filter.rb * fix typo (#1072) * fix typo (#1073) * fix link to http sig spec (#1067) * simply HTTP request examples in api methods docs * add missing client_secret to oauth/token (#1062) * Add any, all, none to hashtag timeline * minor formatting changes * Update signature requirements and advice * fix public key -> private key * clarify use of RSA with SHA256 * Add note about saving your profile after adding rel-me link * v2 filters api * comment out params that shouldn't be used in v2 filter api * admin trends * remove old todo * canonical email blocks + scheduled statuses * remove under-construction warnings from finished pages * verify api method params with source code * fix typo (#1088) * fix broken caption-links (#1100) * fix formatting of entities (#1094) * Remove keybase section from user guide (#1093) * fix typos (#1092) * Verify limits are accurate (#1086) * add mention of iframe limitation (#1084) * Add CORS header to WEB_DOMAIN example (#1083) * Fix typo (#1081) * pin http sigs spec at draft 8 * Revert "pin http sigs spec at draft 8" This reverts commit 9fd5f7032b69b29e77599dd62adfe8d2f5cd4f20. * add case sensitivity warning to 4.0 roles * Add url length note to bio (#1087) * remove follow scope from examples (#1103) * clarify usage of update_credentials to update profile fields * add noindex to Account entitity * remove required hint from technically not required property
8.2 KiB
title | description | menu | aliases | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
notifications API methods | Receive notifications for activity on your account or statuses. |
|
|
Get all notifications
GET /api/v1/notifications HTTP/1.1
Notifications concerning the user. This API returns Link headers containing links to the next/previous page. However, the links can also be constructed dynamically using query params and id
values.
Types to filter include:
mention
= Someone mentioned you in their statusstatus
= Someone you enabled notifications for has posted a statusreblog
= Someone boosted one of your statusesfollow
= Someone followed youfollow_request
= Someone requested to follow youfavourite
= Someone favourited one of your statusespoll
= A poll you have voted in or created has endedupdate
= A status you boosted with has been editedadmin.sign_up
= Someone signed up (optionally sent to admins)admin.report
= A new report has been filed
Returns: Array of [Notification]({{< relref "entities/Notification" >}})
OAuth: User token + read:notifications
Version history:
0.0.0 - added
2.6.0 - added min_id
2.9.0 - added account_id
3.1.0 - added follow_request
type
3.3.0 - added status
type; both min_id
and max_id
can be used at the same time now
3.5.0 - added types
; add update
and admin.sign_up
types
4.0.0 - added admin.report
type
Request
Headers
- Authorization
- {{}} Provide this header with
Bearer <user token>
to gain authorized access to this API method.
Query parameters
- max_id
- String. Return results older than this ID
- since_id
- String. Return results newer than this ID
- min_id
- String. Return results immediately newer than this ID
- limit
- Integer. Maximum number of results to return. Defaults to 15 notifications. Max 30 notifications.
- types[]
- Array of String. Types to include in the result.
- exclude_types[]
- Array of String. Types to exclude from the results.
- account_id
- String. Return only notifications received from the specified account.
Response
Sample call with limit=2.
GET https://mastodon.social/api/v1/notifications?limit=2 HTTP/1.1
Authorization: Bearer xxx
200: OK
The response body contains one page of notifications. You can use the HTTP Link header for further pagination.
Link: <https://mastodon.example/api/v1/notifications?max_id=34975535>; rel="next", <https://mastodon.example/api/v1/notifications?min_id=34975861>;
[
{
"id": "34975861",
"type": "mention",
"created_at": "2019-11-23T07:49:02.064Z",
"account": {
"id": "971724",
"username": "zsc",
"acct": "zsc",
// ...
},
"status": {
"id": "103186126728896492",
"created_at": "2019-11-23T07:49:01.940Z",
"in_reply_to_id": "103186038209478945",
"in_reply_to_account_id": "14715",
// ...
"content": "<p><span class=\"h-card\"><a href=\"https://mastodon.social/@trwnh\" class=\"u-url mention\">@<span>trwnh</span></a></span> sup!</p>",
// ...
"account": {
"id": "971724",
"username": "zsc",
"acct": "zsc",
// ...
},
// ...
"mentions": [
{
"id": "14715",
"username": "trwnh",
"url": "https://mastodon.social/@trwnh",
"acct": "trwnh"
}
],
// ...
}
},
{
"id": "34975535",
"type": "favourite",
"created_at": "2019-11-23T07:29:18.903Z",
"account": {
"id": "297420",
"username": "haskal",
"acct": "haskal@cybre.space",
// ...
},
"status": {
"id": "103186046267791694",
"created_at": "2019-11-23T07:28:34.210Z",
"in_reply_to_id": "103186044372624124",
"in_reply_to_account_id": "297420",
// ...
"account": {
"id": "14715",
"username": "trwnh",
"acct": "trwnh",
// ...
}
}
}
]
401: Unauthorized
Invalid or missing Authorization header.
{
"error": "The access token is invalid"
}
Get a single notification
GET /api/v1/notification/:id HTTP/1.1
View information about a notification with a given ID.
Returns: [Notification]({{< relref "entities/Notification" >}})
OAuth: User token + read:notifications
Version history:
0.0.0 - added
Request
Path parameters
- :id
- {{}} String. The ID of the Notification in the database.
Headers
- Authorization
- {{}} Provide this header with
Bearer <user token>
to gain authorized access to this API method.
Response
200: OK
A single Notification
{
"id": "34975861",
"type": "mention",
"created_at": "2019-11-23T07:49:02.064Z",
"account": {
"id": "971724",
"username": "zsc",
"acct": "zsc",
// ...
},
"status": {
"id": "103186126728896492",
"created_at": "2019-11-23T07:49:01.940Z",
"in_reply_to_id": "103186038209478945",
"in_reply_to_account_id": "14715",
// ...
"content": "<p><span class=\"h-card\"><a href=\"https://mastodon.social/@trwnh\" class=\"u-url mention\">@<span>trwnh</span></a></span> sup!</p>",
// ...
"account": {
"id": "971724",
"username": "zsc",
"acct": "zsc",
// ...
},
// ...
"mentions": [
{
"id": "14715",
"username": "trwnh",
"url": "https://mastodon.social/@trwnh",
"acct": "trwnh"
}
],
// ...
}
}
401: Unauthorized
Invalid or missing Authorization header.
{
"error": "The access token is invalid"
}
Dismiss all notifications
POST /api/v1/notifications/clear HTTP/1.1
Clear all notifications from the server.
Returns: empty object
OAuth: User token + write:notifications
Version history:
0.0.0 - added
Request
Headers
- Authorization
- {{}} Provide this header with
Bearer <user token>
to gain authorized access to this API method.
Response
200: OK
Notifications successfully cleared.
{}
401: Unauthorized
Invalid or missing Authorization header.
{
"error": "The access token is invalid"
}
Dismiss a single notification
POST /api/v1/notifications/:id/dismiss HTTP/1.1
Dismiss a single notification from the server.
Returns: empty object
OAuth: User token + write:notifications
Version history:
1.3.0 - added
Request
Path parameters
- :id
- {{}} String. The ID of the Notification in the database.
Headers
- Authorization
- {{}} Provide this header with
Bearer <user token>
to gain authorized access to this API method.
Response
200: OK
Notification with given ID successfully dismissed
{}
401: Unauthorized
Invalid or missing Authorization header.
{
"error": "The access token is invalid"
}
(REMOVED) Dismiss a single notification
POST /api/v1/notifications/dismiss HTTP/1.1
Dismiss a single notification from the server.
Returns: empty object
OAuth: User token + write:notifications
Version history:
0.0.0 - available
1.3.0 - deprecated in favor of notifications/:id/dismiss
3.0.0 - removed
Request
Headers
- Authorization
- {{}} Provide this header with
Bearer <user token>
to gain authorized access to this API method.
Form data parameters
- id
- {{}} String. The ID of the notification in the database.
Response
200: OK
Notification with given ID successfully dismissed
{}
401: Unauthorized
Invalid or missing Authorization header.
{
"error": "The access token is invalid"
}
See also
{{< page-relref ref="methods/push" caption="push API methods" >}}
{{< caption-link url="https://github.com/mastodon/mastodon/blob/main/app/controllers/api/v1/notifications_controller.rb" caption="app/controllers/api/v1/notifications_controller.rb" >}}