How to manage device shares

Once user have his device set, he will probably want to share it with other users (e.g. family or friends). To do this he need to create a share. In this tutorial we will walk through the process of creating, updating, deleting and listing share for user device.

Get current share list

If you want to get current shares for device, you will need deviceId and use Get all shares. This endpoint will return all shares for device.

Sample request

curl -X GET "https://api.tedee.com/api/v1.22/my/deviceShare?deviceId=1" -H "accept: application/json" -H "Authorization: Bearer <<access token>>"

Permanent access type

If you want user to have permanent access to the device you need send empty repeatEvent object.

Sample repeat event object

"repeatEvent": {
    "weekDays": null,
    "dayStartTime": null,
    "dayEndTime": null,
    "startDate": null,
    "endDate": null
},

Time restricted access type

If you want to restrict user access to the device you can send fields “startDate” or “endDate”, it will mark the period when share for user will be active. You can also restrict access to specific hours of the day by sending “dayStartTime” and “dayEndTime”. User can further customize this by selecting days. To send it proper way you need to use Week days enum.

Sample repeat event objects

In this case the share will be created from 14 december to 31 december.

"repeatEvent": {
    "weekDays": null,
    "dayStartTime": null,
    "dayEndTime": null,
    "startDate": "2020-12-14T08:09:57.781Z",
    "endDate": "2020-12-31T08:10:57.781Z"
},

In this case the share will be created from 1 december to 31 december, and user will have access only on friday and saturday between 15:00 and 18:00

"repeatEvent": {
    "weekDays": 48,
    "dayStartTime": "2020-12-01T15:00:00.000Z",
    "dayEndTime": "2020-12-31T18:00:00.000Z",
    "startDate": "2020-12-01T08:00:00.000Z",
    "endDate": "2020-12-31T20:00:00.000Z"
},

In this case user will have access only from monday to friday between 8:00 and 16:00

"repeatEvent": {
    "weekDays": 31,
    "dayStartTime": "2020-12-01T08:00:00.000Z",
    "dayEndTime": "2020-12-31T16:00:00.000Z",
    "startDate": null,
    "endDate": null
},

Add access to the device

Let’s consider that situation. You are responsible for managing access for users in your organization. If new employee is recruited you don’t want to give him keys to the office (or you don’t use keys in your organization). Instead you want to share door lock to him/her. To do that you need to use Create share. Simply call this endpoint with new organization email address to create new device share.

If user that you want to share device with already have Tedee account he will be notified that device was shared with him. If not the email with invitaion will be sent.

Sample request

curl -X POST "https://api.tedee.com/api/v1.22/my/deviceshare" -H "accept: application/json" -H "Content-Type: application/json-patch+json" -H "Authorization: Bearer <<access token>>" -d "<<body>>"

Body:

{
    "deviceId": 1,
    "accessLevel": 1,
    "userEmail": "john.doe@email.com"
    "repeatEvent": {
        "weekDays": 10,
        "dayStartTime": "2020-12-14T08:09:57.781Z",
        "dayEndTime": "2020-12-31T08:10:57.781Z",
        "startDate": null,
        "endDate": null
    },
    "remoteAccessDisabled" : false
}

Update access to the device

If you want to change access to the door lock for your employees for example you want give some of them admin permissions, you can update user access to the device. For that you need to have shareId, which you get when creating share with success or you can simply use endpoint to get all share for the device Get all shares. When you have complete information you can send request Update share to update share.

Sample request

curl -X PATCH "https://api.tedee.com/api/v1.22/my/deviceshare" -H "accept: application/json" -H "Content-Type: application/json-patch+json" -H "Authorization: Bearer <<access token>>" -d "<<body>>"

Body:

{
    "id": 1,
    "accessLevel": 1,
    "repeatEvent": {
        "id": 1,
        "weekDays": 10,
        "dayStartTime": "2020-12-14T08:09:57.781Z",
        "dayEndTime": "2020-12-31T08:10:57.781Z",
        "startDate": null,
        "endDate": null
    },
    "remoteAccessDisabled" : false
}

Delete share

Let’s consider different situation. Unfortunately, you need to fire one of your employee. After deleting access to organization resources you can also remove employee’s access to the devices within organization with the call to the Delete share endpoint. For that you need to have share id you want to delete. You can get shares for each device from Get all shares endpoint.

Sample request

curl -X DELETE "https://api.tedee.com/api/v1.22/my/deviceshare/15" -H "accept: application/json" -H "Content-Type: application/json-patch+json" -H "Authorization: Bearer <<access token>>"