Section 3 Official Documentation

Sending & Targeting Notifications via API

Send and manage push notifications using Firebase FCM v1 for Flutter and other platforms.

Device Management & Sending Notifications

In this guide, you will learn how to register and manage user device tokens through your HosteDay App API, and how to send push notifications from the dashboard or automatically via Job Hooks.


Part 1: Device Tokens API

All device management endpoints are protected by API Protection (X-Api-Token) and rate-limited to 60 requests per minute (throttle:60,1):

Action Method & Endpoint Purpose
List Devices GET /api/notifications/devices Fetch registered devices for the authenticated user or by device_id.
Register / Update Device POST /api/notifications/devices/register (or POST /api/notifications/devices) Register or update an FCM device token (supports both authenticated users and guests).
Unregister / Unlink Device POST /api/notifications/devices/unregister (or DELETE /api/notifications/devices) Unregister a device or unlink it from the user upon logout.

Required Headers

  • X-Api-Token: YOUR_API_TOKEN (when API Protection is enabled).
  • Authorization: Bearer YOUR_USER_TOKEN (optional on registration to link the device to a logged-in user, or omit for guest devices).

Example: Registering a Device (POST /api/notifications/devices/register)

curl -X POST "https://my-app.hosteday.com/api/notifications/devices/register" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -H "X-Api-Token: YOUR_API_TOKEN" \
  -H "Authorization: Bearer YOUR_USER_TOKEN" \
  -d '{
    "device_token": "fcm_device_token_here",
    "device_id": "unique-device-uuid-001",
    "device_type": "android",
    "device_name": "Pixel 8"
  }'

Supported Registration Fields:

  • device_token (required, string, max 500 chars)
  • device_id (required, string, max 255 chars)
  • device_type (optional, one of: android, ios, web, macos, windows, linux)
  • device_name (optional, string, max 255 chars)

Expected Response (200 OK):

{
    "success": true,
    "status": "success",
    "message": "تم تسجيل الجهاز بنجاح.",
    "data": {
        "id": 1,
        "device_id": "unique-device-uuid-001",
        "device_type": "android",
        "is_active": true
    }
}

Part 2: Sending Push Notifications

HosteDay supports two practical ways to send push notifications:

1. Direct Sending from the App Dashboard

From the Push Notifications tool in dash.hosteday.com, you can send notifications directly to:

  • A specific Device Token (token): Target an individual user or device.
  • A Topic (topic): Broadcast to all devices subscribed to a topic (such as offers or news).

Specify the Title (title, max 255 chars), Body (body, max 2000 chars), and optional custom data payload such as Deep Links:

{
    "screen": "/orders/details",
    "order_id": "8942"
}

2. Automated Sending via Table Hooks (Job Hooks) & Background Jobs

Automate push notifications whenever records are created, updated, or deleted in your App's tables using Job Hooks in Data Manager, or by dispatching background jobs (/api/jobs/dispatch).


Next Step

If you are integrating platforms other than Flutter (such as Web JavaScript, native Android/iOS, or React Native), continue to the next guide: