Create a new subscription for the user identified by the alias_label
and alias_id
in the path parameters. A subscription refers to the ways a user can receive messages sent from OneSignal like push notifications, SMS, and email. Learn more about subscriptions here.
onesignal_id
can be used as a special alias_label
, with the UUID as the alias_id
.
At minimum, a device type
must be provided in the request when creating a new subscription. For example, for an iOS push subscription, it would look like the following:
{
"subscription": {
"type": "iOSPush"
}
}
A subscription is uniquely identified by its device type
and token
pair. If the given (type, token)
pair exists on an existing subscription, that subscription will be transferred to this User.
Note: You can also create and modify existing subscriptions associated with a user. Refer to the create user documentation here.
Response codes:
201
: a new Subscription was created202
: an existing Subscription was transferred to this User200
: the subscription already exists on this user (cannot be used to update an existing subscription. Please use Update Subscription)
Response object fields:
Field | Type | Description |
---|---|---|
id | string | The OneSignal Subscription ID (UUID) |
app_id | string | The OneSignal Application ID (UUID) |
type | string | The subscription types. Will be one of the following:iOSPush AndroidPush FireOSPush ChromeExtensionPush ChromePush WindowsPush SafariLegacyPush FirefoxPush macOSPush HuaweiPush SafariPush Email SMS |
token | string | This field is depending on the subscription type. For push subscriptions the token is the push token, for email subscriptions the token is the email address, for SMS subscriptions the token is the phone number |
enabled | boolean | Whether this subscription enabled or not |
notification_types | number | For internal use only |
session_time | number | Total session duration in seconds |
session_count | number | The number of times a subscription has visited the app or site |
sdk | string | The OneSignal SDK version installed on the subscription device |
device_model | string | The subscription device make and model |
device_os | string | The subscription device operating system version |
rooted | boolean | Whether the device is rooted or not |
test_type | number | This is used in deciding whether to use your iOS Sandbox or Production push certificate when sending a push when both have been uploaded. Set to the iOS provisioning profile that was used to build your app. 1 = Development 2 = Ad-Hoc Omit this field for App Store & Test Flight builds. |
app_version | string | The client application version |
net_type | number | The device network type.net_type: 0 = wifinet_type: 1 = cellular |
carrier | string | The cellular carrier |
web_auth | string | Web only authorization key |
web_p256 | string | Web only p256 key |