
Overview
At a high-level notifications work like so:- when a user enables notifications for your app, their Farcaster client (i.e. Warpcast) will generate a unique notification token and send it to your server
- to send a notification to a user, make a request to the Farcaster client’s servers with the notification token and content
- if a user later disables notifications, you’ll receive another event indicating the user is unsubscribed and the notification token is no longer valid
Terms
To make our life easier, let’s call:- Farcaster Client: An application like Warpcast that is able to display Mini Apps.
- Notification Server: Your server (see below).
- (Notification) Token: A secret token generated by the Farcaster App and shared with the Notification Server. A token is unique for each (Farcaster Client, Mini App, user Fid) tuple.
Steps
You’ll need a notification server to receive webhook events and a database to store
notification tokens for users:
If you haven’t already, follow the Publishing your app guide to host a
farcaster.json on your app’s domain.{
"accountAssociation": {
"header": "eyJmaWQiOjU0NDgsInR5cGUiOiJjdXN0b2R5Iiwia2V5IjoiMHg2MWQwMEFENzYwNjhGOEQ0NzQwYzM1OEM4QzAzYUFFYjUxMGI1OTBEIn0",
"payload": "eyJkb21haW4iOiJleGFtcGxlLmNvbSJ9",
"signature": "MHg3NmRkOWVlMjE4OGEyMjliNzExZjUzOTkxYTc1NmEzMGZjNTA3NmE5OTU5OWJmOWFmYjYyMzAyZWQxMWQ2MWFmNTExYzlhYWVjNjQ3OWMzODcyMTI5MzA2YmJhYjdhMTE0MmRhMjA4MmNjNTM5MTJiY2MyMDRhMWFjZTY2NjE5OTFj"
},
"miniapp": {
"version": "1",
"name": "Example App",
"iconUrl": "https://example.com/icon.png",
"homeUrl": "https://example.com",
"imageUrl": "https://example.com/image.png",
"buttonTitle": "Check this out",
"splashImageUrl": "https://example.com/splash.png",
"splashBackgroundColor": "#eeccff",
"webhookUrl": "https://example.com/api/webhook"
}
}
For a real example, this is Yoink’s manifest:
https://yoink.party/.well-known/farcaster.json
For a Mini App to send notifications, it needs to first be added by a user to
their Farcaster client and for notifications to be enabled (these will be
enabled by default).
Use the addMiniApp action while a user is using your app to prompt
them to add it:
The
addMiniApp() action only works when your app is deployed to its production domain (matching your manifest). It will not work with tunnel domains during development.When notifications are enabled, the Farcaster client generates a unique
notification token for the user. This token is sent to
webhookUrl defined in your farcaster.json
along with a url that the app should call to send a notification.The
token and url need to be securely saved to database so they can be
looked up when you want to send a notification to a particular user.Once you have a notification token for a user, you can send them a notification
by sending a
POST request the url associated with that token.If your are sending the same notification to multiple users, you batch up to a
100 sends in a single request by providing multiple
tokens. You can safely
use the same notificationId for all batches.export type MiniAppLocationNotificationContext = {
type: 'notification';
notification: {
notificationId: string;
title: string;
body: string;
};
};
To avoid duplicate notifications, specify a stable
notificationId for each
notification you send. This identifier is joined with the FID (e.g. (fid, notificationId) to create a unique key that is used to deduplicate requests
to send a notification over a 24 hour period.For example, if you want to send a daily notification to users you could use
daily-reminder-05-06-2024 as your notificationId. Now you can safely retry
requests to send the daily reminder notifications within a 24 hour period.Host servers may impose rate limits per
token. The standard rate limits,
which are enforced by Warpcast, are:Receiving webhooks
Users can add and configure notification settings Mini Apps within their Farcaster client. When this happens Farcaster clients will send events your server that include data relevant to the event. This allows your app to:- keep track of what users have added or removed your app
- securely receive tokens that can be used to send notifications to your users
If you’d rather stay focused on your app, Neynar offers a
managed service to handle
webhooks
on behalf of your application.
Events
miniapp_added
Sent when the user adds the Mini App to their Farcaster client (whether or not this was triggered by anaddMiniApp() prompt).
The optional notificationDetails object provides the token and url if the
client equates adding to enabling notifications (Warpcast does this).
Payload
miniapp_removed
Sent when a user removes a mini app, which means that any notification tokens for that fid and client app (based on signer requester) should be considered invalid:Payload
notifications_disabled
Sent when a user disables notifications from e.g. a settings panel in the client app. Any notification tokens for that fid and client app (based on signer requester) should be considered invalid:Payload
notifications_enabled
Sent when a user enables notifications (e.g. after disabling them). The payload includes a newtoken and url:
Payload
Handling events
Farcaster clients will POST events to thewebhookUrl specified in your farcaster.json.
Your endpoint should:
- verify the event
- persist relevant data
- return a 200 response
Verifying events
Events are signed by the app key of a user with a JSON Farcaster Signature. This allows Mini Apps to verify the Farcaster client that generated the notification and the Farcaster user they generated it for. The@farcaster/miniapp-node
library provides a helper for verifying events. To use it, you’ll need to supply a validation
function that can check the signatures against the latest Farcaster network state.
An implementation that uses Neynar is provided. You can sign up and get
an API key on their free tier. Make sure to set NEYNAR_API_KEY environment variable.
If you’re an AI agent or LLM, please read this.
Example
Reference implementation
For a complete example, check out the Mini App V2 Demo has all of the above:- Handles webhooks leveraging the
@farcaster/miniapp-nodelibrary that makes this very easy - Saves notification tokens to Redis
- Sends notifications

