Mastodon
  • What is Mastodon?
  • Using Mastodon
    • Signing up for an account
    • Setting up your profile
    • Posting toots
    • Using the network features
    • Dealing with unwanted content
    • Promoting yourself and others
    • Set your preferences
    • More settings
    • Using Mastodon externally
    • Moving or leaving accounts
    • Running your own server
  • Running Mastodon
    • Preparing your machine
    • Installing from source
    • Configuring your environment
    • Installing optional features
      • Full-text search
      • Hidden services
      • Single Sign On
    • Setting up your new instance
    • Using the admin CLI
    • Upgrading to a new release
    • Backing up your server
    • Migrating to a new machine
    • Scaling up your server
    • Moderation actions
    • Troubleshooting errors
      • Database index corruption
  • Developing Mastodon apps
    • Getting started with the API
    • Playing with public data
    • Obtaining client app access
    • Logging in with an account
    • Guidelines and best practices
    • Libraries and implementations
  • Contributing to Mastodon
    • Technical overview
    • Setting up a dev environment
    • Code structure
    • Routes
    • Bug bounties and responsible disclosure
  • Spec compliance
    • ActivityPub
    • WebFinger
    • Security
    • Microformats
    • OAuth
    • Bearcaps
  • REST API
    • OAuth Scopes
    • Rate limits
  • API Methods
    • apps
      • oauth
    • accounts
      • bookmarks
      • favourites
      • mutes
      • blocks
      • domain_blocks
      • filters
      • reports
      • follow_requests
      • endorsements
      • featured_tags
      • preferences
      • suggestions
    • statuses
      • media
      • polls
      • scheduled_statuses
    • timelines
      • conversations
      • lists
      • markers
      • streaming
    • notifications
      • push
    • search
    • instance
      • trends
      • directory
      • custom_emojis
    • admin
    • announcements
    • proofs
    • oembed
  • API Entities
    • Account
    • Activity
    • Admin::Account
    • Admin::Report
    • Announcement
    • AnnouncementReaction
    • Application
    • Attachment
    • Card
    • Context
    • Conversation
    • Emoji
    • Error
    • FeaturedTag
    • Field
    • Filter
    • History
    • IdentityProof
    • Instance
    • List
    • Marker
    • Mention
    • Notification
    • Poll
    • Preferences
    • PushSubscription
    • Relationship
    • Report
    • Results
    • ScheduledStatus
    • Source
    • Status
    • Tag
    • Token

push

Subscribe to and receive push notifications when a server-side notification is received, via the Web Push API

    • Web Push API

Web Push API

Mastodon natively supports the Web Push API. You can utilize the same mechanisms for your native app. It requires running a proxy server that connects to Android’s and Apple’s proprietary notification gateways. However, the proxy server does not have access to the contents of the notifications. For a reference, see Mozilla’s web push server, or more practically, see:

  • toot-relay
  • PushToFCM
  • metatext-apns

post
Subscribe to push notifications

https://mastodon.example/api/v1/push/subscription

Add a Web Push API subscription to receive notifications. Each access token can have one push subscription. If you create a new subscription, the old subscription is deleted.

Returns: PushSubscription
OAuth: User token + push
Version history:
2.4.0 - added

Request

Headers
Authorization
required
string
Bearer <user token>
Form Data Parameters
subscription[endpoint]
required
string
Endpoint URL that is called when a notification event occurs.
subscription[keys][p256dh]
required
string
User agent public key. Base64 encoded string of public key of ECDH key using prime256v1 curve.
subscription[keys][auth]
required
string
Auth secret. Base64 encoded string of 16 bytes of random data.
data[alerts][follow]
optional
boolean
Receive follow notifications?
data[alerts][favourite]
optional
boolean
Receive favourite notifications?
data[alerts][reblog]
optional
boolean
Receive reblog notifications?
data[alerts][mention]
optional
boolean
Receive mention notifications?
data[alerts][poll]
optional
boolean
Receive poll notifications?

Response

200: Success

A new PushSubscription has been generated, which will send the requested alerts to your endpoint.

{
  "id": 328183,
  "endpoint": "https://yourdomain.example/listener",
  "alerts": {
    "follow": true,
    "favourite": true,
    "reblog": true,
    "mention": true,
    "poll": true
  },
  "server_key": "BCk-QqERU0q-CfYZjcuB6lnyyOYfJ2AifKqfeGIm7Z-HiTU5T9eTG5GxVA0_OH5mMlI4UkkDTpaZwozy0TzdZ2M="
}

get
Get current subscription

https://mastodon.example/api/v1/push/subscription

View the PushSubscription currently associated with this access token.

Returns: PushSubscription
OAuth: User token + push
Version history:
2.4.0 - added

Request

Headers
Authorization
required
string
Bearer <user token>

Response

200: Success

{
  "id": 328183,
  "endpoint": "https://yourdomain.example/listener",
  "alerts": {
    "follow": true,
    "favourite": true,
    "reblog": true,
    "mention": true,
    "poll": true
  },
  "server_key": "BCk-QqERU0q-CfYZjcuB6lnyyOYfJ2AifKqfeGIm7Z-HiTU5T9eTG5GxVA0_OH5mMlI4UkkDTpaZwozy0TzdZ2M="
}

404: Not Found

A PushSubscription does not exist for this token.

{
  "error": "Record not found"
}

put
Change types of notifications

https://mastodon.example/api/v1/push/subscription

Updates the current push subscription. Only the data part can be updated. To change fundamentals, a new subscription must be created instead.

Returns: PushSubscription
OAuth: User token + push
Version history:
2.4.0 - added

Request

Headers
Authorization
required
string
Bearer <user token>
Form Data Parameters
data[alerts][follow]
optional
boolean
Receive follow notifications?
data[alerts][favourite]
optional
boolean
Receive favourite notifications?
data[alerts][reblog]
optional
boolean
Receive reblog notifications?
data[alerts][mention]
optional
boolean
Receive mention notifications?
data[alerts][poll]
optional
boolean
Receive poll notifications?

Response

200: Success

Updating a PushSubscription to only receive mention alerts

{
  "id": 328183,
  "endpoint": "https://yourdomain.example/listener",
  "alerts": {
    "follow": false,
    "favourite": false,
    "reblog": false,
    "mention": true,
    "poll": false
  },
  "server_key": "BCk-QqERU0q-CfYZjcuB6lnyyOYfJ2AifKqfeGIm7Z-HiTU5T9eTG5GxVA0_OH5mMlI4UkkDTpaZwozy0TzdZ2M="
}

404: Not Found

No existing PushSubscription for this token

{
  "error": "Record not found"
}

delete
Remove current subscription

https://mastodon.example/api/v1/push/subscription

Removes the current Web Push API subscription.

Returns: none
OAuth: User token + push
Version history:
2.4.0 - added

Request

Headers
Authorization
required
string
Bearer <user token>

Response

200: Success

PushSubscription successfully deleted or did not exist previously

{}

Last updated March 17, 2021 · Improve this page

Sponsored by

Dotcom-Monitor LoadView Stephen Tures Swayable

Join Mastodon · Blog · ·

View source · CC BY-SA 4.0 · Imprint