Before you start, you need:
- An app in Channels > Push that isn’t disabled. See Connect Firebase.
- A platform API key with the
contacts:writescope, kept on your server. Listing apps also needssenders:read. See API keys. - The contact who uses the device, already in Brudcast.
Find your app’s ID
Every registration names the app the token was issued for. List your apps to get itsid. The
identifier field is the Firebase project ID.
Register a device
POST /contacts/{contactId}/push-notifications
string
required
The contact who uses the device.
string
required
The app the token was issued for. It must belong to your organization and must not be disabled.
string
required
The Firebase registration token. Up to 4,096 characters.
string
required
android, ios or web.string
Your app’s version, for your own records.
object
Any JSON object that describes the device, such as its model or operating system version.
boolean
Marks this as the contact’s primary device. Other devices keep their flag, so more than one can
be primary.
201, whether the device is new or already known.
id. You need it to update or remove the device, and the
push.token_invalidated webhook names devices by it.
Registering again is safe
Brudcast keeps one record per token per app. Registering a token that the app already knows updates that record instead of adding a second one.- If the token belonged to another contact, it moves to this one. This covers a shared device, or one user signing out and another signing in.
- The device becomes
activeagain, and any earlier opt-out or expiry is cleared. appVersion,deviceInfoandisPrimarykeep their earlier values unless you send new ones.
Register devices when you create a contact
POST /contacts also accepts devices, in a pushNotifications array alongside the contact’s other
fields. Each entry takes the same fields as a single registration, including the required
pushApplicationId. The same one-record-per-token rule and the same subscribers quota apply.
The subscribers quota
A subscriber is a contact with at least one active device. Push plans cap how many subscribers your organization can have, and the free plan allows 1,000.- A contact counts once, however many devices it has.
- Registering a device for a contact that already has an active device never counts against the cap.
- Inactive and expired devices don’t count, so a contact whose devices have all expired or opted out frees its place.
- Without a push plan, registration still works up to the free plan’s 1,000 subscribers, so your app can start collecting tokens before you buy push.
400 and code
QUOTA_EXCEEDED, and the device isn’t saved. Upgrade your push plan in Billing & Plans, or
remove devices you no longer need.
When a user turns notifications off
When a user switches notifications off in your app, mark the deviceinactive. Brudcast records
when in optedOutAt and stops sending to that device.
status back to active when they turn notifications on again. That clears optedOutAt.
Brudcast can’t see a permission the user revokes in the device’s own settings. Check the permission
when your app opens, and mark the device inactive if it’s gone.
To remove a device completely, for example when the user signs out, send
DELETE /contacts/{contactId}/push-notifications/{id}.
Expired tokens
Tokens stop working when the app is uninstalled, when its data is cleared, or when Firebase replaces the token. When Firebase rejects a token as unregistered, invalid, or issued by a different Firebase project, Brudcast expires the device automatically.statusbecomesexpired.invalidatedAtrecords when, andlastFailureReasonholds Firebase’s reason. The contact’s page shows the device as invalidated, with the reason.- Later campaigns skip the device, and it stops counting as a subscriber.
The push.token_invalidated webhook
To hear about each expiry, for example to delete the token from your own database, subscribe a webhook endpoint topush.token_invalidated under Developers > Webhooks. The event fires once
per device, when Brudcast expires it.
The event doesn’t carry the token itself. Match on
tokenId. See
Webhook event types.
Errors
Related
Connect Firebase
Create the Firebase service account key and add your app.
Write the notification
Send to the devices you’ve registered.
Sync contacts from your app
Create and update contacts from your backend.
Push troubleshooting
Invalid tokens and campaigns that reach no one.