REST API v4: POST profile mobile push subscription

This method associates a mobile push subscription with a specific profile.

A mobile push subscription represents a registered device that can receive mobile push notifications.

To add a mobile push subscription to a profile, send an HTTP POST request to the following URL:

https://api.copernica.com/v4/profile/$id/push/mobilesubscriptions

Replace $id with the ID of the profile.

Required fields

The following fields must be provided:

Name Description
project ID of the Google Firebase project used to send push notifications.
token The device token issued by Google Firebase Cloud Messaging (FCM).
os The operating system of the device, for example ios or android.

Optional fields

Name Description
model The device model, for example iPhone 17 or Pixel 9.

Example request

{
    "project": 1,
    "token": "fcm-device-token",
    "os": "ios",
    "model": "iPhone 17"
}

PHP example

The following script demonstrates how to use this API method.

// required scripts
require_once("CopernicaRestAPI.php");

// change this to your access token
$api = new CopernicaRestAPI("your-access-token", 4);

// replace {$id} with the ID of the profile
$api->post("profile/{$id}/push/mobilesubscriptions", [
    'project' => 1,
    'token'   => 'fcm-device-token',
    'os'      => 'ios',
    'model'   => 'iPhone 17'
]);

This example requires the REST API class.