> ## Documentation Index
> Fetch the complete documentation index at: https://docs.masivo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Integrate push notifications

> Learn how to register device tokens for push notifications using Masivo's REST API

<Note>
  Check the complete list of parameters and responses of the [`PATCH Device
      Token`](/api-reference/customers/\[id]/devices/patch) endpoint for registering push
  notification tokens.
</Note>

### What are push notifications in Masivo?

Push notifications allow you to send timely, relevant messages directly to your customers' mobile devices. By registering device tokens, you can target specific users or segments with personalized notifications, promotions, or alerts.

### Register a device token

To enable push notifications for a customer, you need to register their device token with Masivo. This links their device to their customer profile, allowing for targeted messaging.

```typescript theme={null}
const customerId = "unique-customer-id";
const payload = {
  device_token: "duPXivAiS_uR1o2WGFb5fb:APA91bHYGH0sQcTWtJwSPTRB-CR47-lfo7mh_ygPVHDxBnyW45CjrV_PwVFARL8HLQ1AQOhaJfUxoPfBLtRmCZrTUYPPq9o67aXVQ-khIpiKcf4YvaFnba0",
  device_info: {
    platform: "android", // "android" | "ios" | "web"
    model: "SM-S918B", // Device model identifier
    osVersion: "34" // Operating system version
  }
};

const response = await fetch(
  `https://app.masivo.ai/api/storefront/v1/customers/${customerId}/devices`,
  {
    method: "PATCH",
    headers: {
      Authorization: `Bearer ${accessToken}`,
      "Content-Type": "application/json"
    },
    body: JSON.stringify(payload)
  }
);
```

### Understanding device tokens

* **device\_token**: A unique identifier provided by Firebase Cloud Messaging (FCM) that allows Masivo to send notifications to a specific device. This token is generated by the Firebase SDK in your mobile application.
* **device\_info**: Additional information about the device that helps with segmentation:
  * **platform**: The operating system of the device ("android", "ios", or "web")
  * **model**: The device model name or identifier
  * **osVersion**: The version of the operating system running on the device

<Note>
  Device tokens can change over time. Your app should update the token in Masivo
  whenever the FCM SDK provides a new token to ensure uninterrupted delivery of
  notifications.
</Note>

### User segmentation with push notifications

Registering device tokens enables powerful audience segmentation capabilities:

1. **Target by demographics**: Send notifications to specific user segments based on demographics, location, or behavior
2. **Campaign-specific messaging**: Tailor notifications to specific marketing campaigns or loyalty programs
3. **Engagement tracking**: Monitor which notifications drive user engagement and conversions

### Best practices

* Always request push notification permissions at appropriate times in the user journey
* Refresh and update device tokens regularly to maintain delivery reliability
* Provide clear opt-out options to respect user preferences
* Test notifications across different device types before sending to your entire audience
* Keep messages concise and actionable to improve engagement
