Control who can send messages to your users

If you work with a larger team or complex project, more people and services likely need access to your Firebase project and the capabilities associated with Firebase Cloud Messaging (FCM). For example, a marketer might need to send notification campaigns, or one of your project's backend services might need to send messages with the FCM API. Other team members might only need to view results.

This page helps you give each person and service the access that they need, and no more. It shows what each role can do, recommends roles for common jobs, and lists what to check when someone leaves your team.

What each role can do

Access to FCM is controlled by Identity and Access Management (IAM) roles. A good practice is to grant each person and service account only the access that they need. This practice is called least privilege. If you're new to IAM, start with Manage project access with Firebase IAM.

The following table summarizes the main predefined roles for FCM. Most columns are actions that affect the messages that your users receive. The last column shows which roles can create service account keys, which are long-lived credentials that can be used to send messages. Yes means that the role includes the permissions for that action. Use the table to choose the narrowest role for each person and service account.

Role Send with the FCM API Create, start, and stop campaigns Manage topic subscriptions from a server Delete Firebase installations Manage APNs and Web Push credentials Create service account keys
Owner, Editor
roles/owner, roles/editor
Yes Yes Yes Yes Yes Yes. See Avoid downloaded service account keys when possible.
Firebase Admin
roles/firebase.admin
Yes Yes Yes Yes Yes No
Firebase messaging campaigns Admin
roles/firebasemessagingcampaigns.admin
No Yes, with Firebase Viewer No No No No
Firebase Cloud Messaging API Admin
roles/firebasecloudmessaging.admin
Yes No Yes No No No
Viewer, Firebase Viewer, Firebase Cloud Messaging API Viewer, Firebase messaging campaigns Viewer
roles/viewer, roles/firebase.viewer, roles/firebasecloudmessaging.viewer, roles/firebasemessagingcampaigns.viewer
No. These roles can only view campaigns, subscriptions, or delivery data.

The table doesn't list every role or permission. For the complete permission list of each role, see Firebase predefined roles and the Google Cloud IAM roles reference. For the IAM permissions that each API method requires, see the REST reference for sending messages and managing topic subscriptions.

Recommendations

This section shows which roles to grant for common jobs. It also lists best practices for managing access to your project.

Roles for common jobs

Grant the narrowest role for each job. Reserve Owner, Editor, and Firebase Admin for people who administer the whole project.

Who needs access Roles to grant What the roles let them do
Campaign authors Firebase messaging campaigns Admin and Firebase Viewer View and change existing campaigns, and create, publish, and stop campaigns in the Firebase console. They can also send test messages, view campaign metrics, and see targeting estimates.
Campaign viewers Firebase Viewer View campaigns and campaign metrics in the Firebase console. They can't create, change, or send campaigns.
Backend services that send messages Firebase Cloud Messaging API Admin, granted to a dedicated service account Send messages and manage topic subscriptions with the FCM API. Avoid using Owner, Editor, or the default Firebase Admin SDK service account for this job, because they have broad access across your project.

Best practices for managing access

  • Use a separate project for testing. Keep development and production in separate Firebase projects. Roles apply to a whole project, so you can grant broader access in your test project than in your production project. For example, a team member who builds your app can have Firebase messaging campaigns Admin and Firebase Viewer in the test project only. They can test notifications freely, and their test messages can't reach the users of your production app. See General best practices for setting up Firebase projects.
  • Test before you send to all of your users. Before you publish a campaign, use Send test message in the Notifications composer to send it to your own device. A test message goes only to the devices that you enter. We recommend that you send test messages only to individual devices, not to a topic. A message to a topic goes to every device that's subscribed to it, so a test can reach the users of your production app by accident. When you select a topic as the target of a campaign, the composer shows an estimated audience size next to each topic, for example <1000 or 1K-10K. This estimate helps you avoid that mistake.
  • Avoid downloaded service account keys when possible. A downloaded key keeps working even after you remove the person who created it from your project. People with the Owner or Editor role can create keys, which is another reason to reserve those roles. Instead of downloading a key, use these alternatives:

    • To test your app: Send a test message from the Firebase console. You don't need a key.
    • To test your server code: Use your test project and a service account in that project. Its credentials can't send messages to the users of your production app.
    • To run your server on Google Cloud: Use Application Default Credentials (ADC), so that your server gets credentials without a key file. See Provide credentials using ADC.

    If you must use a key file, keep it secret and follow the best practices for managing service account keys.

  • Review access regularly. On the IAM page of the Google Cloud console, check which principals hold Owner, Editor, Firebase Admin, Firebase messaging campaigns Admin, Firebase Cloud Messaging API Admin, or Firebase Cloud Messaging Service Editor. Cloud Audit Logs record IAM role changes and service account key creation by default.

  • Make sure that your organization owns your project. If a contractor or service provider set up your Firebase project, check that people in your own organization have the Owner role. Owners are often the only project members who can do administrative tasks, such as assigning roles. To check who has access, go to the Settings > Users and permissions tab in the Firebase console. To learn more, see Why or when should I assign a project member the Owner role?.

  • Keep your project's contacts up to date. Google sends important notifications about your project, such as legal, security, and billing notices. By default, these notifications often go only to project Owners. To make sure that the right people receive them and can act on them, set up Essential Contacts for your project.

  • Review the Firebase security checklist. For more ways to protect your project and your users, see the Firebase security checklist.

When someone leaves your team

Follow the guidance on revoking access, and complete these FCM checks:

  1. Remove their roles on the IAM page of the Google Cloud console. Check service accounts there too, because the Firebase console doesn't list service accounts.
  2. Delete or rotate any service account keys they could access. Removing a person's IAM roles doesn't revoke keys they already downloaded.
  3. Make sure at least two current team members are Owners, ideally in a Google Cloud organization. If a former team member is the sole Owner, see How do I find the Owner of a Firebase project?.
  4. Review your campaigns and push credentials in the Firebase console. Go to DevOps & Engagement > Messaging to check for active or scheduled campaigns you didn't create. Go to the Settings > Cloud Messaging tab to verify your APNs and Web Push credentials. If an app or project was deleted, you can restore a removed app from the Settings > General tab or restore a deleted project in the Google Cloud console.