# Obtain FCM credentials

> \[!IMPORTANT]
>
> The Push Notifications API is part of the Twilio Communications API, currently available as a
> Private Beta product. The information contained in this document is subject to change. You acknowledge
> and agree that your use of the Twilio Communications API is subject to the terms of the [Services in
> Private Beta](https://www.twilio.com/en-us/legal/service-country-specific-terms/private-beta). This means that some features are not yet implemented and
> others may be changed before the product is declared as Generally Available. Private Beta products are not covered by the Twilio Support Terms or
> Twilio Service Level Agreement.
>
> Request access to the private beta through the [private beta access request form](https://airtable.com/appqQFoQmQ9WDS1YW/pagDQFkMvNi7O28dN/form).

## Overview

To send push notifications to Android devices and web browsers, you need Firebase Cloud Messaging (FCM) credentials. In this guide, you create a Firebase project and obtain the service account credentials required by the Twilio Communications API.

## Prerequisites

* A Google account
* Access to the [Firebase Console](https://console.firebase.google.com/)

## Create a Firebase project

1. Navigate to the [Firebase Console](https://console.firebase.google.com/).
2. Create a new Google Cloud project or select an existing one. See the [Firebase setup guide](https://firebase.google.com/docs/web/setup#create-project) for detailed instructions.
   ![Welcome message for Firebase with option to create a new project and integrate Firebase products into an app.](https://docs-resources.prod.twilio.com/581222731a54330481ce84237bad9a412fbb39c0e3954fc9e1b836015ce7e328.png)
3. Register a new Firebase application. For detailed instructions, see the [Firebase app registration guide](https://firebase.google.com/docs/web/setup#register-app).
   ![Add app button alongside push-demo-app under Explore section.](https://docs-resources.prod.twilio.com/0c7a7754ea9344e81f66fb9f440476c6a00134aad35793ff9aa5040c7bfee07d.png)

## Generate service account credentials

1. In the Firebase Console, select your app from the project overview, then click the gear icon to open **Settings**.
   ![Firebase project overview with the gear icon for accessing app settings.](https://docs-resources.prod.twilio.com/f438107497716dab0fe6bee32775e76baa86eff08ae0c0153022fc8b7b696815.png)
2. Navigate to the **Service accounts** tab and ensure **Firebase Admin SDK** is selected.
   ![Project settings menu with tabs for General, Cloud Messaging, Integrations, and Service accounts highlighted.](https://docs-resources.prod.twilio.com/3b10bc0a68d988e671fc5e6ee2cfc65ba592e09a542f869fd26b97aa20c4628e.png)
3. Click **Generate new private key**. This downloads a JSON file containing your credentials.
   ![Admin SDK configuration snippet with Node.js code example and a button labeled Generate new private key.](https://docs-resources.prod.twilio.com/a34361aba352f7583ea7582909a106173b2f7ea567804ece85db12e7095b132c.png)

## Encode the credentials

The credentials must be base64-encoded before you upload them to Twilio. Open a terminal in the directory where you saved the JSON file and run the following command.

```bash
cat YOUR_CREDENTIALS_FILE.json | base64 -b 0
```

## Upload credentials to Twilio

Use the base64-encoded string as the `privateKey` value when creating your FCM credential.

```bash {title="Upload FCM credentials using cURL"}
curl -X POST 'https://comms.twilio.com/preview/PushNotifications/Credentials' \
     -H 'Content-Type: application/json' \
     -d '{
          "credentialType": "FCM",
          "content": {
            "privateKey": "YOUR_BASE64_ENCODED_KEY"
          },
          "appName": "YOUR_APP_NAME"
        }' \
     -u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

## Next steps

* Send a push notification to a device. See [Send a notification](/docs/comms/send-a-push#send-a-notification).
* Set up APN credentials to send notifications to Apple devices. See [Obtain APN credentials](/docs/comms/apn-credentials).
