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

# Register FCM Token

> Registers a Firebase Cloud Messaging (FCM) token for push notifications on mobile devices

## Overview

Registers a Firebase Cloud Messaging (FCM) token for push notifications on mobile devices. This endpoint should be called when:

* User logs in on a mobile device
* App starts and user is already logged in
* FCM token is refreshed

## Use Cases

* **Mobile App Login**: Register device for push notifications after successful login
* **App Startup**: Re-register token when app starts with authenticated user
* **Token Refresh**: Update token if FCM token changes (rare but possible)

## Important Notes

<Warning>
  Each device needs a unique `deviceId`. Use a persistent identifier like
  `Device.deviceId` in React Native/Expo.
</Warning>

<Info>
  Users can have multiple registered devices (iPhone, iPad, Android tablet). All
  devices will receive push notifications.
</Info>

## Example Usage

### React Native/Expo

```typescript theme={null}
import * as Notifications from "expo-notifications";
import * as Device from "expo-device";
import { Platform } from "react-native";

// Request permissions and get token
const { status } = await Notifications.requestPermissionsAsync();
if (status !== "granted") {
  console.log("Permission not granted");
  return;
}

const token = (await Notifications.getExpoPushTokenAsync()).data;

// Register with backend
await fetch("/api/notifications/register-fcm-token", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    token,
    deviceId: Device.deviceId,
    platform: Platform.OS,
  }),
});
```

## Related Endpoints

* [Remove FCM Token](/engineering/apis/notifications/remove-fcm-token) - Remove token on logout
* [Update FCM Token Usage](/engineering/apis/notifications/update-fcm-token-usage) - Track active devices

## See Also

* [FCM Push Notifications Guide](/engineering/notifications/fcm-push-notifications) - Complete implementation guide
* [FCM Quick Start](/engineering/notifications/fcm-quick-start) - Quick setup guide


## OpenAPI

````yaml POST /notifications/register-fcm-token
openapi: 3.1.0
info:
  title: Tatu API
  description: API documentation for Tatu's booking and artist management system
  version: 1.0.0
servers:
  - url: http://localhost:3000/api
    description: Development server
security: []
paths:
  /notifications/register-fcm-token:
    post:
      summary: Register FCM Token
      description: >-
        Registers a Firebase Cloud Messaging (FCM) token for push notifications
        on mobile devices
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RegisterFCMTokenRequest'
      responses:
        '200':
          description: FCM token registered successfully
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - message
                properties:
                  success:
                    type: boolean
                    description: Whether the operation was successful
                    example: true
                  message:
                    type: string
                    description: Success message
                    example: FCM token registered successfully
        '400':
          description: Bad request - Invalid parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '405':
          description: Method not allowed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    RegisterFCMTokenRequest:
      type: object
      required:
        - token
        - deviceId
        - platform
      properties:
        token:
          type: string
          description: Firebase Cloud Messaging token from the device
          example: ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]
        deviceId:
          type: string
          description: Unique identifier for the device
          example: device_abc123
        platform:
          type: string
          enum:
            - ios
            - android
            - web
          description: Platform of the device
          example: ios
    Error:
      type: object
      required:
        - message
      properties:
        message:
          type: string

````