Skip to content

Sending Notifications

  • An API key with notify or full scope
  • The App ID of the app to send notifications to

Send a notification to all active subscribers of the app.

Terminal window
curl -X POST https://api.todoke.dev/api/v1/notify \
-H "Authorization: Bearer pk_notify_key" \
-H "Content-Type: application/json" \
-d '{
"title": "New Update",
"body": "There is an update available",
"url": "https://yourapp.com/news",
"icon": "https://yourapp.com/icon.png"
}'

Specify the endpoint field to send to only that subscriber.

Terminal window
curl -X POST https://api.todoke.dev/api/v1/notify \
-H "Authorization: Bearer pk_notify_key" \
-H "Content-Type: application/json" \
-d '{
"title": "Message for you",
"body": "This is a targeted notification",
"endpoint": "https://fcm.googleapis.com/fcm/send/..."
}'

Send to multiple endpoints in a single request using the batch API.

Terminal window
curl -X POST https://api.todoke.dev/api/v1/notify/batch \
-H "Authorization: Bearer pk_notify_key" \
-H "Content-Type: application/json" \
-d '{
"endpoints": [
"https://fcm.googleapis.com/fcm/send/endpoint1",
"https://fcm.googleapis.com/fcm/send/endpoint2"
],
"payload": {
"title": "Batch notification",
"body": "Sent to multiple users"
}
}'

Response: { "queued": 2 }

FieldTypeRequiredDescription
titlestringNotification title
bodystringNotification body
urlstringURL to navigate to on click
iconstringNotification icon URL
badgestringBadge icon URL
endpointstringIf specified, sends only to this subscriber
FieldTypeRequiredDescription
endpointsstring[]List of endpoints (max 100 items; returns 400 TOO_MANY_ENDPOINTS if exceeded)
payload.titlestringNotification title
payload.bodystringNotification body
payload.urlstringURL to navigate to on click (https:// only)

title and body are required. url / icon / badge only allow https:// URLs; specifying an http:// URL returns 400 INVALID_URL.

  • Payload size: the combined size of title / body / url / icon / badge is limited to 3,072 bytes (returns 413 PAYLOAD_TOO_LARGE if exceeded)
  • Monthly sends: the Free plan is limited to 30,000 notifications (returns 429 MONTHLY_LIMIT_EXCEEDED with upgrade_url if exceeded)
  • URL format: url / icon / badge must be https:// only (400 INVALID_URL)

See Error Codes and Limits for the full list of error codes.

REST API → Cloudflare Queues → Queue Consumer Worker → Browser Push

Notifications are enqueued immediately upon receiving the request. The Consumer Worker automatically starts and sends them asynchronously, so there are no timeouts even with a large number of subscribers.