Skip to main contentSkip to Content
Push Notifications

Push Notifications

CampaignOS supports web push notifications via the VAPID protocol.

List Push Subscriptions

GET /api/workspaces/{workspaceId}/push

Lists active push subscriptions.

Auth: Session required

Query Parameters:

ParamTypeDescription
contactIdstringFilter by contact

Response:

[ { "id": "ps_abc123", "contactId": "ct_1", "endpoint": "https://fcm.googleapis.com/fcm/send/...", "topic": "marketing", "active": true, "createdAt": "2026-01-15T10:00:00.000Z", "contact": { "id": "ct_1", "email": "jane@example.com", "firstName": "Jane" } } ]

Register Push Subscription

POST /api/workspaces/{workspaceId}/push

Registers or updates a web push subscription for a contact.

Auth: Session required

Request Body:

{ "contactId": "ct_abc123", "endpoint": "https://fcm.googleapis.com/fcm/send/abc123...", "p256dh": "BNcRdreALRFXTkOOUH...", "auth": "tBHItJI5svbpC7sc...", "topic": "marketing" }
FieldTypeRequiredDescription
contactIdstringYesContact to associate
endpointstringYesPush service endpoint URL
p256dhstringYesClient public key
authstringYesAuthentication secret
topicstringNoTopic for topic-based subscriptions

Push via CampaignOS.js

The embedded script handles push subscription automatically:

  1. Script checks if push is enabled for the workspace
  2. Prompts the user for notification permission
  3. Registers the subscription with the CampaignOS API
  4. Subscription is linked to the contact via identity

See Website Script for embedding details.

VAPID Configuration

Set these environment variables for web push:

NEXT_PUBLIC_VAPID_PUBLIC_KEY="your-public-key" VAPID_PRIVATE_KEY="your-private-key"

Generate VAPID keys:

npx web-push generate-vapid-keys
Last updated on