# Set up push notifications

**Summary:** Create a Firebase service account key and send it to Subrite, create M2M tokens for the app (Push Subscription) and the server (Push Content), and decide whether to discard topics.

- Space: [Developers](https://www.subrite.no/developers)
- Source: https://www.subrite.no/developers/push-notifications-setup
- Updated: 2026-09-23
- Markdown index: https://www.subrite.no/developers/llms.txt

Subrite uses Firebase Cloud Messaging to send push notifications, and needs credentials from your Firebase project to enable this.

<a id="step-1-create-a-firebase-project"></a>
## Step 1: Create a Firebase project

If there isn't already a Firebase project for your app, set one up. Follow the guides in the [Firebase docs](https://firebase.google.com/docs).

<a id="step-2-create-a-service-account-key"></a>
## Step 2: Create a service account key

Go to the **Project settings** of your Firebase project. Under **Cloud Messaging**, click the **Manage Service Account** link.

![Firebase project settings, Cloud Messaging tab, with the Manage Service Account link](https://cdn.sanity.io/images/1x2xswq6/production/6e8af106d39ff3d8f7b0b98b30b507e6551c5b73-1074x752.png?w=1600&fit=max&auto=format)

Click **Manage keys** under **Actions**.

![Google Cloud service accounts list with Manage keys under Actions](https://cdn.sanity.io/images/1x2xswq6/production/83dfb94bfcd3042bff03204722b8c80402172253-1622x992.png?w=1600&fit=max&auto=format)

Add a new key by clicking **ADD KEY** \> **Create new key**.

![ADD KEY menu with the Create new key option](https://cdn.sanity.io/images/1x2xswq6/production/edc2b0348434c8e8eb71123dc6832f4a779cfbc2-1644x296.png?w=1600&fit=max&auto=format)

Select the default **JSON** key type.

![Create private key dialog with the JSON key type selected](https://cdn.sanity.io/images/1x2xswq6/production/3a850e65c7aeb9be8cdd6d8b898c0913022ec164-1686x724.png?w=1600&fit=max&auto=format)

You should now have a JSON file from Google with the credentials needed to send push notifications.

<a id="step-3-send-the-credentials-to-subrite"></a>
## Step 3: Send the credentials to Subrite

POST the JSON contents of the credentials to the Subrite API.

- **Method:** `POST`
- **Route:** `{baseUrl}/api/v1/app-push/setup`
- **Authorization:** Bearer token (use the JWT of a logged-in user with tenant administration access)
- **Body:** see the example below

<a id="example-body"></a>
### Example body

```json
{
  "providerCredentials": "{\"type\":\"service_account\",\"project_id\":\"test\",\"private_key_id\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"private_key\":\"-----BEGIN PRIVATE KEY-----\\n<<private key here>>\\n-----END PRIVATE KEY-----\\n\",\"client_email\":\"firebase-adminsdk-zynzs@test.iam.gserviceaccount.com\",\"client_id\":\"100000000000000000000\",\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"token_uri\":\"https://oauth2.googleapis.com/token\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\",\"client_x509_cert_url\":\"https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-zynzs%40test.iam.gserviceaccount.com\",\"universe_domain\":\"googleapis.com\"}"
}
```

<a id="step-4-create-an-m2m-token-for-the-app"></a>
## Step 4: Create an M2M token for the app

For the app to authenticate itself to the Subrite API when adding or removing subscribers, you need an M2M authentication token.

Go to the admin dashboard in Subrite, typically a URL like `https://minside.YOUR_TENANT.no/admin/dashboard`.

Click into **Account settings**, **Settings**, **M2M Client**. Click **New Settings**.

![Subrite admin dashboard, M2M Client settings with the New Settings button](https://cdn.sanity.io/images/1x2xswq6/production/9da29a2119db7d41f9571ba3136098452d1369bb-2022x1284.png?w=1600&fit=max&auto=format)

Fill in the form as shown below. Make sure the section **Push Subscription** has **Read** and **Update** selected. Click **Save**.

> [!WARNING]
> **Important**
>
> **Do not** select any other sections, as this token will be embedded in your app, readable to any user. Leaked tokens with extended privileges can cause serious security issues.

![M2M client form with the Push Subscription section set to Read and Update](https://cdn.sanity.io/images/1x2xswq6/production/b6524769da396788fa246ce13fa704ee4e4cde64-2530x1556.png?w=1600&fit=max&auto=format)

Copy the provided JWT string and keep it for embedding in the app.

<a id="step-5-create-an-m2m-token-for-the-server"></a>
## Step 5: Create an M2M token for the server

You need one more M2M token, this one for triggering the dispatch of new push notifications to all subscribers.

Repeat step 4, but this time select the section **Push Content** with **Read** and **Update** selected. Click **Save**.

![M2M client form with the Push Content section set to Read and Update](https://cdn.sanity.io/images/1x2xswq6/production/3865634274a562c42599fdebda1a154844f41dd5-2536x1550.png?w=1600&fit=max&auto=format)

The two selections map to the scopes the server integration needs:

- `push-content:update`: dispatching a new push notification
- `push-content:read`: reading campaigns back and looking up their delivery stats

Copy the provided JWT string and keep it for embedding in your server environment.

<a id="step-6-decide-how-topics-are-handled"></a>
## Step 6: Decide how topics are handled

By default, a push notification is only filtered by topic when you send topics with it. If you send none, every subscribed device is notified. If you do send topics, only devices that subscribed to at least one of them are notified, and if no device matches, no one is notified at all. The API call still returns success, and the campaign ends up with `status: "skipped"` when you read it back (see [content server integration](https://www.subrite.no/developers/push-notifications-server?md=true)).

That is a common trap when your CMS puts article tags or categories into the topics it sends with the notification, while your app subscribes devices without any topics.

If that is your case, go to the admin dashboard and click into **Account settings**, **Settings**, **Communications**. Open the **Push notifications** tab and turn on **Discard topics**.

The setting is off by default. When it is on, the topics on the notification are ignored, and every subscribed device on your tenant is notified. This applies to all sends, both the ones triggered from your server and campaigns composed in the admin dashboard. The topics are still stored on the campaign, so you can see what was sent.

Leave it off if you rely on per-topic opt-in.

The **Push notifications** tab is only available for tenants with push notifications enabled.

The basic setup is now ready, and you can continue with [integrating the app](https://www.subrite.no/developers/push-notifications-app?md=true).
