unPLUGDevelopers

Devices and messages API

Register a device

PUT/v1/members/me/devices/{device_id}

Creates or updates the device for the signed-in member. Call it on every app start, and whenever the push token, the notification permission or the signed-in member changes. Sending the same body again changes nothing. A member can have many devices. If another member registered this device_id before, the device moves to the member in the token.

Permissions: Member token.

Path parameters#

  • device_idstringRequired
    Your stable id for this install.

Request body#

  • platformstringRequired
    ios or android.
    One of ios, android
  • push_tokenstringNullable
    Current push token. Send null if the app hasn't got one yet.
  • token_typestring
    fcm or apns. Required with push_token.
    One of fcm, apns
  • app_idstringRequired
    Bundle id or package name.
  • push_enabledbooleanRequired
    The OS notification permission right now.
  • app_versionstring
    Your app's version.
  • os_versionstring
    OS version.
  • localestring
    Device language.
  • time_zonestring
    Device time zone.

Response fields#

Returns 200 with Device

  • device_idstring
    Your id for this install, up to 128 characters. Use a UUID you generate once and keep in app storage.
  • member_idstring (uuid)
    The member signed in on the device.
  • platformstring
    ios or android.
    One of ios, android
  • push_tokenstringNullable
    The push token from Firebase or APNs. null if the app has none yet.
  • token_typestring
    fcm (from the Firebase SDK) or apns (a raw APNs token, iOS only).
    One of fcm, apns
  • app_idstring
    iOS bundle id or Android package name. Must be an app support set up for your brand.
  • push_enabledboolean
    The OS notification permission. Marketing consent is separate: communication_preferences.push_marketing on the member.
  • app_versionstring
    Your app's version, for example 4.2.0.
  • os_versionstring
    For example 18.1.
  • localestring
    BCP 47 tag, for example en-US.
  • time_zonestring
    IANA name, for example America/Chicago. unPLUG uses it for quiet hours.
  • created_atstring (date-time)
    First registration.
  • updated_atstring (date-time)
    Last change.

Error descriptions#

400Bad request
missing_param

: platform, app_id or push_enabled is missing, or token_type is missing with a push_token.

400Bad request
invalid_param

: token_type isn't fcm or apns, apns was sent for Android, or app_id isn't an app set up for your brand.

401Unauthorized
token_expired

Get a new member token and retry.

Any endpoint can also return the common errors.