Register Device via Notify Aim API

Register Device via API – Notify Aim

Base URL


            https://api.notifyaim.com/api/v1/
                    

All endpoints require HTTPS.


Endpoints


1. Register Device

Registers a device/browser to receive push notifications.

Endpoint


            POST    /register-subscription
                    

Request Body

                
            {
                "vapidKey": "YOUR_VAPID_KEY", // Your API Key
                "endpoint": "https://fcm.googleapis.com/fcm/send/abcd1234", // Device endpoint
                "public_key": "sub.toJSON().keys.p256dh", // VAPID public key
                "auth_token": "sub.toJSON().keys.auth", // VAPID auth token
                "topics": ["news", "offers"], // Array of topics to subscribe to
                "user_id": "optional_user_identifier", // Optional user ID for personalization
                "group_id": "vip_customers", // Optional group ID for segmentation
                "locale": "en-US", // Optional locale for language preferences
                "preferences": {
                    promotions: true, // User preferences for notifications
                    alerts: true, // Enable/disable alerts
                    system: true, // System notifications
                    marketing: false // Marketing notifications
                },
            }
                    

Response


            {
                "status": "success", // Registration status
                "user_id": "notify_aim_1234" // Unique user ID for the device
            }
                    

3. Subscribe to Topic

Subscribes a registered device to a topic for targeted notifications.

Endpoint


            POST    /update-subscription-topics
                    

Request Body


            {
                "api_key": "YOUR_API_KEY", // Your API Key
                "endpoint": "https://fcm.googleapis.com/fcm/send/abcd1234", // Device endpoint
                "topics": "[offers, news]", // Comma-separated list of topics to subscribe to
            }
                    

Response


            {
                "status": "success",
                "topic": "offers",
                "message": "Subscribed to topic successfully",
            }
                    

Error Handling

All errors follow the structure:


            {
                "status": "error",
                "message": "Description of the error"
            }
                    

Common HTTP Status Codes

  • 200 – Success
  • 400 – Bad request
  • 401 – Invalid API key
  • 403 – Origin mismatch
  • 404 – Not found
  • 422 – No subscribers
  • 429 – Daily notification limit reached
  • 500 – Server error

Rate Limits

  • Free Plan – 1000 requests/day
  • Pro Plan – 50,000 requests/day
  • Enterprise – Custom limits

Example – Send a Notification (cURL)


            curl --location 'https://api.notifyaim.com/api/v1/notification/send' \
            --header 'Content-Type: application/json' \
            --data '{
                "vapid_private": "YOUR_vapid_private_KEY",
                "title": "Sale Alert",
                "body": "50% OFF Today!",
                "url": "https://example.com",
                "icon": "https://example.com/icon.png",
                "webhook": "https://example.com/webhook",
                "topic": "offers"
            }'