Contact devices

Updating devices

You can update a device by using a PUT request to the /contacts/{:cid}/devices/{:did} endpoint. To do this you need to know the exact ‘link’ associated with the contact device.

The application must provide all the fields during the update request, even if they’re not being updated.

The Content-Type can be:

  • application/vnd.whispir.contactdevice-v1+xml
    or
  • application/vnd.whispir.contactdevice-v1+json

Note: You can't selectively update the device fields needed as this is a PUT request.

So the standard process for updating a contact device record is:

  1. GET /contact/{id of contact}/devices/{id of device}.
  2. Update the device field in the object to the required value.
  3. PUT /contact/{id of contact}/devices/{id of device} the new object.

Reasons to update

  • Device tokens (push tokens) might change when the contact re-installs or upgrades the OS on their device.
  • Device information might change as a result of the contact upgrading their OS.
  • Change of device status to ‘Disabled’, if the push fails consistently. Whispir doesn't update the device to ‘Disabled’ on first failure; it only does that on second failure, given the device was not updated after the first failure. So, you will only be charged for the push as long as the status is ‘Active’.
  • Update doesn't automatically reset the ‘Disabled’ status. You, as the app owner, have to specifically turn the status back to ‘ACTIVE’ so that new push notifications can be triggered again.
  • Disabled devices will not receive any push notifications.

The response to the PUT request on success is usually a 204 response with no content being provided.

  • JSON
  • XML

Updating contact devices

The following endpoints allow users to update a contact’s devices using the Whispir API:

{{codeStart}}

HTTP 1.1 PUT https://api.<region>.whispir.com/workspaces/{:wid}/contacts/{:cid}/devices/{:did}?apikey=<your_api_key>

Authorization: Basic am9obi5zbWl0aDpteXBhc3N3b3Jk

x-api-key: your_api_key

Content-Type: application/vnd.whispir.contactdevice-v1+json

{

"deviceName": "BCDF6B61-CA55-F287FF272101-4496-9DA9",

"appId": "B1A24A8BF2DBB10E",

"platform": "APNS",

"deviceOS": "IOS 9",

"deviceModel": "Iphone 8",

"status": "active",

"pushToken": "15a01046 16f6f4f9 2f2055b5 f12d2c93 a70de908 487762f9 7b6c7115 e30083b1"

}

{{codeEnd}}

The response to the PUT request upon success is a 204 No Content response with no content being provided.