In this guide you will stream health data from Sahha to Firebase Firestore using Sahha Webhooks and Firebase Cloud Functions (TypeScript) — choosing which data types to send, verifying webhooks securely, and persisting structured events in Firestore.
Prerequisites
Before you begin, make sure you have:
- Node.js 18+ installed
- A Firebase project created
- Firestore enabled in your Firebase project
- Firebase CLI installed:
npm i -g firebase-tools - Access to Data Delivery → Webhooks in the Sahha dashboard
Get data flowing into Sahha Required
Webhooks only fire when Sahha is actually receiving data. Choose how to connect:
Use the Sahha Demo App (fastest way to test)
- In the Sahha dashboard, go to Configure → Demo App
- Copy the Configuration URL (or scan the QR code)
- Install the Sahha Demo App from the App Store / Google Play
- In the demo app, paste the Configuration URL (or scan the QR) to connect it to your project
- Keep the demo app running so it can collect and submit device data
Once connected, you should see a new profile appear in your Sahha project and data beginning to flow.
If you’ve already integrated the Sahha SDK into your application, ensure that:
- Your app is successfully streaming data to Sahha
- You are setting a stable
externalIdwhen creating Sahha profiles (for example, your Firebase Auth UID)
This externalId will later be sent back in webhooks as X-External-Id, which allows you to map Sahha events to the correct user in Firestore.
Set up your Firebase Functions project
Install the Firebase CLI (once per machine)
npm install -g firebase-tools
Authenticate with Firebase
firebase login
This links your local machine to your Google account.
Download the starter project — it includes a Cloud Function with signature verification, Firestore writes, and all project configuration already set up.
Download starter projectAfter downloading:
- Unzip and open the project
- Open
.firebasercand replace the placeholder project ID with your real Firebase project ID - Link it to your Firebase project — when prompted, select your project and give it an alias (e.g.
default):
firebase use --add- Install dependencies:
cd functions
npm install From your project root, initialize Firebase:
firebase initWhen prompted, select:
- Functions
- Firestore
- Your existing Firebase project
- TypeScript when prompted
- Node 18 as your runtime
This creates the configuration needed for firebase deploy to work.
Deploy and connect to Sahha
Store your webhook secret
Sahha signs every webhook request. Your Cloud Function must verify this signature.
- In Sahha, go to Data Delivery → Webhooks → Create webhook
- Copy the Secret value
Then in your terminal run:
firebase functions:secrets:set SAHHA_WEBHOOK_SECRET
You will be prompted to enter the secret — paste it and press Enter.
Deploy the Cloud Function
firebase deploy --only functions
After deployment, get your Cloud Function URL it should look something like this:
https://us-central1-yourproject.cloudfunctions.net/sahhaWebhook
This is your Destination Webhook URL. You can also find it in Firebase Console → Build → Functions → click sahhaWebhook → Trigger URL.

Configure Sahha
Go to Sahha Dashboard → Data Delivery → Webhooks → Create webhook and fill in:

- Webhook name:
Firebase Webhook - Destination URL: your Cloud Function URL from above
- Event subscriptions: choose the data you want to stream (Health Scores, Biomarkers, Archetypes, Raw Data Logs)
Click Create webhook.
Test the webhook
In the Sahha dashboard, find your webhook and click Actions → Test. This sends a real signed test payload to your endpoint.

How data works in Firestore
Events are stored under sahha_events/{eventType}/events/{eventHash} — organized by event type with deduplication built in.
Here’s an example of a biomarker event payload that Sahha sends via webhook:
{
"id": "1cb680dd-7e67-553c-9a29-c1bc066f6eb7",
"type": "activity_low_intensity_duration",
"unit": "minute",
"value": "345",
"version": 1,
"category": "activity",
"accountId": "4e9357a7-6275-4b22-b0f8-524962e4c7f7",
"profileId": "b27fac52-0ae6-49d5-97c4-d720b7d6be16",
"valueType": "long",
"externalId": "SahhaInternalTestingProfile",
"aggregation": "total",
"endDateTime": "2026-02-11T23:59:59Z",
"periodicity": "daily",
"createdAtUtc": "2026-02-11T04:00:22.724731Z",
"startDateTime": "2026-02-11T00:00:00Z"
} X-External-Id header with every webhook. Set this to your Firebase Auth UID when creating Sahha profiles so you can map events back to the correct user in Firestore. Troubleshooting
Webhook requests aren't reaching Firebase
Check:
- You deployed the function to the correct Firebase project
- You copied the correct Trigger URL from Firebase
- Your Sahha webhook Destination URL matches that exact URL
401 Invalid signature
This means your secret in Firebase does not match Sahha.
Fix:
firebase functions:secrets:set SAHHA_WEBHOOK_SECRET
firebase deploy --only functions No data in Firestore
- Confirm Sahha is actually receiving data (Demo App or SDK active)
- Check Cloud Functions logs in Firebase Console → Functions → Logs
Next steps
You now have a secure, production-ready Sahha webhook endpoint in Firebase with automatic streaming into Firestore