# Send device health info through webhook endpoint

**URL:** <https://community.smartthings.com/t/send-device-health-info-through-webhook-endpoint/254129>\
**Category:** Support\
**Created:** [December 15, 2022, 9:09pm UTC](https://community.smartthings.com/t/send-device-health-info-through-webhook-endpoint/254129 "2022-12-15T21:09:38Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![sandra-nestor](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@sandra-nestor](https://community.smartthings.com/u/sandra-nestor)\
**Post date:** [December 15, 2022, 9:09pm UTC](https://community.smartthings.com/t/send-device-health-info-through-webhook-endpoint/254129/1 "2022-12-15T21:09:38Z")

</div>

Hi there!  
I faced the problem. I can select the device capability healthCheck only using European accounts. When I use my UA account, I cannot select this capability in order to use it in SmartApp.

Also, when I send GET request to the `/devices/<deviceId>/health` endpoint, I receive information about online/offline status of the device, which is a bit weird:)

The questions are:

1. Why can I not subscribe to healthCheck capability?
2. Can I send this information to my webhook endpoint in the SmartApp?

What I’m trying to do is to add a new feature to our app to tell devices are offline. I need to subscribe to HealthCheck capability and use CheckInterval property(I guess…) to ping devices with some frequency. And I want to have these events sent via Webhook endpoint in our SmartApp.

Can someone help me? Tagging @nayelyz  
Thanks

---

<div class="post-metadata">

**Author:** ![orangebucket](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/orangebucket/32/81590_2.png) [@orangebucket](https://community.smartthings.com/u/orangebucket)\
**Post date:** [December 15, 2022, 9:34pm UTC](https://community.smartthings.com/t/send-device-health-info-through-webhook-endpoint/254129/2 "2022-12-15T21:34:24Z")

</div>

Rather than subscribing to the Health Check capability, subscribe to DEVICE\_HEALTH.

> **[API | SmartThings Developers](https://developer.smartthings.com/docs/api/public/#operation/saveSubscription)**
>
> SmartThings Public API

---

<div class="post-metadata">

**Author:** ![nayelyz](https://avatars.discourse-cdn.com/v4/letter/n/59ef9b/32.png) [@nayelyz](https://community.smartthings.com/u/nayelyz)\
**Post date:** [December 15, 2022, 10:20pm UTC](https://community.smartthings.com/t/send-device-health-info-through-webhook-endpoint/254129/3 "2022-12-15T22:20:51Z")

</div>

> [@sandra-nestor](#):
>
> I need to subscribe to HealthCheck capability and use CheckInterval property(I guess…) to ping devices with some frequency. And I want to have these events sent via Webhook endpoint in our SmartApp

Hi, @sandra-nestor!

The correct place to get the health status is this endpoint `/devices/<deviceId>/health`. The healthCheck capability is no longer used to provide this status. It was only used by DTHs which will be deprecated soon.  
For Hub-Connected devices that work with Edge drivers, the health check (ping) is handled internally. So, if you subscribe to the event mentioned by @orangebucket, you should get an event in your Webhook indicating if the device changed its state to offline/online.

---

<div class="post-metadata">

**Author:** ![sandra-nestor](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@sandra-nestor](https://community.smartthings.com/u/sandra-nestor)\
**Post date:** [December 16, 2022, 11:47am UTC](https://community.smartthings.com/t/send-device-health-info-through-webhook-endpoint/254129/4 "2022-12-16T11:47:13Z")

</div>

Thank you, @nayelyz @orangebucket! I’ll try that)

---

<div class="post-metadata">

**Author:** ![sandra-nestor](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@sandra-nestor](https://community.smartthings.com/u/sandra-nestor)\
**Post date:** [December 20, 2022, 12:31pm UTC](https://community.smartthings.com/t/send-device-health-info-through-webhook-endpoint/254129/5 "2022-12-20T12:31:47Z")

</div>

Hi @nayelyz @orangebucket, I have successfully subscribed to DEVICE\_HEALTH, but I can’t understand how it works((

As you can see, I have a 200 response code, so my device\_health subscription has definitely been created.

 ![87545fd0f13ef593673e668363bbad5efecfb3c3](https://global.discourse-cdn.com/smartthings/original/3X/1/7/17fc028672870003af4779c5e0332da445f8703b.jpeg)

But when my device goes offline, I don’t receive any info about the changed device status on my webhook endpoint(but I can see it in the SmartThings app).  
I haven’t found any docs concerning DEVICE\_HEALTH. So should I receive info that the device goes offline immediately? Or are there some settings on how often online/offline status is updated?

And also, I suspect that online/offline status will be provided in the ‘EVENT’ lifecycle, am I right?

---

<div class="post-metadata">

**Author:** ![sandra-nestor](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@sandra-nestor](https://community.smartthings.com/u/sandra-nestor)\
**Post date:** [December 20, 2022, 1:28pm UTC](https://community.smartthings.com/t/send-device-health-info-through-webhook-endpoint/254129/6 "2022-12-20T13:28:22Z")

</div>

It seems that I found a bug here. When we take out the battery from our motion sensor while it has active motion event, the offline status isn’t updated. It remains with ‘motion detected’ status, currently for more than an hour:((

These two motion sensors are without batteries, so they are offline. But as you can see, the first one displays incorrect status.

 ![image](https://global.discourse-cdn.com/smartthings/original/3X/c/6/c6f891fa6b1df32931be013f6a566eb1e2ca07fc.png)

---

<div class="post-metadata">

**Author:** ![nayelyz](https://avatars.discourse-cdn.com/v4/letter/n/59ef9b/32.png) [@nayelyz](https://community.smartthings.com/u/nayelyz)\
**Post date:** [December 20, 2022, 2:07pm UTC](https://community.smartthings.com/t/send-device-health-info-through-webhook-endpoint/254129/7 "2022-12-20T14:07:25Z")

</div>

> [@sandra-nestor](#):
>
> So should I receive info that the device goes offline immediately?

You should receive it once the device is marked offline, did you define the correct event handler? It is different from a capability subscription, its name is [subscribedDeviceHealthEventHandler](https://github.com/SmartThingsCommunity/smartapp-sdk-nodejs/blob/main/lib/smart-app.js#L279).

> [@sandra-nestor](#):
>
> I suspect that online/offline status will be provided in the ‘EVENT’ lifecycle, am I right?

Correct, it will tell you the type of event and provide the `deviceId` involved.

> [@sandra-nestor](#):
>
> It seems that I found a bug here. When we take out the battery from our motion sensor while it has active motion event, the offline status isn’t updated.

Is it the same in the API’s health endpoint or only in the app?

---

<div class="post-metadata">

**Author:** ![sandra-nestor](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@sandra-nestor](https://community.smartthings.com/u/sandra-nestor)\
**Post date:** [December 21, 2022, 2:19pm UTC](https://community.smartthings.com/t/send-device-health-info-through-webhook-endpoint/254129/8 "2022-12-21T14:19:26Z")

</div>

Thanks for the reply, @nayelyz.

> [@nayelyz](#):
>
> Is it the same in the API’s health endpoint or only in the app?

Yes, this was the same in the API’s health endpoint. But today it seems to work fine. The status is updated within 15-20 mins.

> [@nayelyz](#):
>
> did you define the correct event handler?

We are using only your API, I used [this endpoint](https://developer.smartthings.com/docs/api/public/#operation/saveSubscription). Payload:

```auto
{
      sourceType: 'DEVICE_HEALTH',
      deviceHealth: {
        subscriptionName: 'device_health_subscription',
        deviceIds: [device_ids]
      }
    }

```

All event handling we do on our side. And also, we log all events that are coming to our webhook endpoint (before processing it). So I’m 100% sure I don’t miss anything.

---

<div class="post-metadata">

**Author:** ![nayelyz](https://avatars.discourse-cdn.com/v4/letter/n/59ef9b/32.png) [@nayelyz](https://community.smartthings.com/u/nayelyz)\
**Post date:** [December 21, 2022, 2:31pm UTC](https://community.smartthings.com/t/send-device-health-info-through-webhook-endpoint/254129/9 "2022-12-21T14:31:51Z")

</div>

> [@sandra-nestor](#):
>
> All event handling we do on our side. And also, we log all events that are coming to our webhook endpoint (before processing it). So I’m 100% sure I don’t miss anything

Ah, ok. Then, it might have been a glitch, you said it is working fine now, right? If the problem persists it would be good to know if the device is handled by a DTH or Edge driver.

---

<div class="post-metadata">

**Author:** ![sandra-nestor](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@sandra-nestor](https://community.smartthings.com/u/sandra-nestor)\
**Post date:** [December 22, 2022, 10:32am UTC](https://community.smartthings.com/t/send-device-health-info-through-webhook-endpoint/254129/10 "2022-12-22T10:32:50Z")

</div>

No, I haven’t received any events from my device\_health\_subscription yet…  
I meant that the offline status is behaving ok in the SmartThings app now. Maybe it was a glitch.

Our devices are handled by Edge drivers. When I make a request to list all subscriptions, I see DEVICE\_HEALTH in the list:

```auto
{
    "items": [
        {
            "id": "dfca-4237",
            "installedAppId": "eca3d3d5",
            "sourceType": "DEVICE",
            "device": {
                "deviceId": "7843396a",
                "componentId": "main",
                "capability": "*",
                "attribute": "*",
                "value": "*",
                "stateChangeOnly": true,
                "subscriptionName": "button_0_subscription",
                "modes": []
            }
        },
        {
            "id": "d9a75c27",
            "installedAppId": "eca3d3d5-26cd",
            "sourceType": "DEVICE",
            "device": {
                "deviceId": "23c90510",
                "componentId": "main",
                "capability": "*",
                "attribute": "*",
                "value": "*",
                "stateChangeOnly": true,
                "subscriptionName": "contactSensor_0_subscription",
                "modes": []
            }
        },
        {
            "id": "c14198ff",
            "installedAppId": "eca3d3d5",
            "sourceType": "DEVICE",
            "device": {
                "deviceId": "2c5b376",
                "componentId": "main",
                "capability": "*",
                "attribute": "*",
                "value": "*",
                "stateChangeOnly": true,
                "subscriptionName": "motionSensor_0_subscription",
                "modes": []
            }
        },
        {
            "id": "c02a276d",
            "installedAppId": "eca3d3d5",
            "sourceType": "DEVICE",
            "device": {
                "deviceId": "1bc5fcd0",
                "componentId": "main",
                "capability": "*",
                "attribute": "*",
                "value": "*",
                "stateChangeOnly": true,
                "subscriptionName": "motionSensor_1_subscription",
                "modes": []
            }
        },
        {
            "id": "618584d4",
            "installedAppId": "eca3d3d5",
            "sourceType": "DEVICE_HEALTH",
            "deviceHealth": {
                "deviceIds": [
                    "1bc5fcd0",
                    "23c90510",
                    "2c5b376a",
                    "7843396a"
                ],
                "subscriptionName": "device_health_subscription",
                "locationId": "*"
            }
        }
    ],
    "_links": {}
}

```

So I cannot get it. I have a subscription to devices health. Why events are not coming?((

---

<div class="post-metadata">

**Author:** ![orangebucket](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/orangebucket/32/81590_2.png) [@orangebucket](https://community.smartthings.com/u/orangebucket)\
**Post date:** [December 22, 2022, 12:19pm UTC](https://community.smartthings.com/t/send-device-health-info-through-webhook-endpoint/254129/11 "2022-12-22T12:19:36Z")

</div>

Have you tried the subscription using the `locationId` rather than the individual `deviceIds`?

---

<div class="post-metadata">

**Author:** ![sandra-nestor](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@sandra-nestor](https://community.smartthings.com/u/sandra-nestor)\
**Post date:** [December 22, 2022, 1:54pm UTC](https://community.smartthings.com/t/send-device-health-info-through-webhook-endpoint/254129/12 "2022-12-22T13:54:35Z")

</div>

Hmm, I tried, its not working. I receive 403 response code

 ![image](https://global.discourse-cdn.com/smartthings/original/3X/a/8/a82b12b24a278b36856bdf0f7701c8758dd07b3d.jpeg)  
The payload is:

```auto
{
      sourceType: 'DEVICE_HEALTH',
      deviceHealth: {
        subscriptionName: 'device_health_subscription',
        locationId: location_id
      }
    }

```

I take the locationId from [INSTALL lifecycle](https://developer.smartthings.com/docs/connected-services/lifecycles/#install-request-body) data.

---

<div class="post-metadata">

**Author:** ![nayelyz](https://avatars.discourse-cdn.com/v4/letter/n/59ef9b/32.png) [@nayelyz](https://community.smartthings.com/u/nayelyz)\
**Post date:** [December 22, 2022, 9:57pm UTC](https://community.smartthings.com/t/send-device-health-info-through-webhook-endpoint/254129/13 "2022-12-22T21:57:58Z")

</div>

Hi, @sandra-nestor.  
Indeed using the locationId is better as @orangebucket said. There’s a limit of 20 DeviceIDs to use in the array of the subscription.  
I created the subscription using the SDK and this is what I found getting it’s details from the API:

```auto
{
    "id": "d9738d37-48a8-4605-...",
    "installedAppId": "b5ccfb08-d26d-4e03-...",
    "sourceType": "DEVICE_HEALTH",
    "deviceHealth": {
        "deviceIds": [],
        "subscriptionName": "healthEventHandler",
        "locationId": "0b018721-6bc0-483c-..."
    }
}

```

I got health update events of the devices in my location. Are you using the scopes of `r:devices:*` and `r:locations:*`?

---

<div class="post-metadata">

**Author:** ![sandra-nestor](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@sandra-nestor](https://community.smartthings.com/u/sandra-nestor)\
**Post date:** [December 23, 2022, 3:32pm UTC](https://community.smartthings.com/t/send-device-health-info-through-webhook-endpoint/254129/14 "2022-12-23T15:32:34Z")

</div>

I think that the problem is in locationId. Devices’ location and the location of installed app could be different, that’s why I receive 403 response when trying to subscribe to device health using locationId. And that’s why I don’t receive events from my health subscription when subscribing using deviceIds.

I’ll try to debug this and create a health subscription using locationId. Hope, this will help me) I’ll share my success with you.

---

<div class="post-metadata">

**Author:** ![sandra-nestor](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@sandra-nestor](https://community.smartthings.com/u/sandra-nestor)\
**Post date:** [February 3, 2023, 8:45am UTC](https://community.smartthings.com/t/send-device-health-info-through-webhook-endpoint/254129/15 "2023-02-03T08:45:19Z")

</div>

Hi @nayelyz! Could you please share the script you used to subscribe to the device health events? And could you specify the version of SDK you are using? Is it [smartapp-sdk-nodejs](https://github.com/SmartThingsCommunity/smartapp-sdk-nodejs) version 4.0.0?

Also, I’ve managed to create a subscription to device health using `deviceIds`, but not `locationId`. I think that the reason why I receive 403 error for `locationId` is the problem with auth\_token provided by INSTALL lifecycle. It just seems to me that it does not have “r:locations:\*” scope. But when creating an app I select all possible scopes:

 ![image](https://global.discourse-cdn.com/smartthings/original/3X/6/1/611219e08cb151fbf24215dcc385187f62a983bb.jpeg)

---

<div class="post-metadata">

**Author:** ![nayelyz](https://avatars.discourse-cdn.com/v4/letter/n/59ef9b/32.png) [@nayelyz](https://community.smartthings.com/u/nayelyz)\
**Post date:** [February 3, 2023, 11:40pm UTC](https://community.smartthings.com/t/send-device-health-info-through-webhook-endpoint/254129/16 "2023-02-03T23:40:55Z")

</div>

Hi, @sandra-nestor!  
Did you include the scope in the SmartApp’s definition? That might be the difference.  
When we select them in the Dev Workspace, we’re only whitelisting them but not using them directly. The SmartApp definition I used to create a location health subscription is:

```auto
app.enableEventLogging().appId("location-room-request")
.permissions([
    "r:locations:*","r:devices:*"
])
.page('mainPage', (context, page, configData) => {
    page.section('sensors', section => {
        //This section doesn't affect the location subscription
    });
})
.updated(async (context, updateData) => {
    await context.api.subscriptions.unsubscribeAll();
    return Promise.all([
        context.api.subscriptions.subscribeToDeviceHealth('healthEventHandler')
    ])
})
.subscribedDeviceHealthEventHandler('healthEventHandler', (context, deviceEvent) => {
    console.log('health event',deviceEvent)
})

```

---

<div class="post-metadata">

**Author:** ![sandra-nestor](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@sandra-nestor](https://community.smartthings.com/u/sandra-nestor)\
**Post date:** [February 15, 2023, 2:41pm UTC](https://community.smartthings.com/t/send-device-health-info-through-webhook-endpoint/254129/17 "2023-02-15T14:41:30Z")

</div>

Hi, @nayelyz! Thank you so much for your support! One more question. I wasn’t able to find a way how to set up additional permissions for a certain installed app using [this doc](https://developer.smartthings.com/docs/api/public/#tag/Installedapps). Is there a way to define these permissions like you did it here:

```auto
.permissions([
    "r:locations:*","r:devices:*"
])

```

via SmartThings API?

---

<div class="post-metadata">

**Author:** ![nayelyz](https://avatars.discourse-cdn.com/v4/letter/n/59ef9b/32.png) [@nayelyz](https://community.smartthings.com/u/nayelyz)\
**Post date:** [February 15, 2023, 10:05pm UTC](https://community.smartthings.com/t/send-device-health-info-through-webhook-endpoint/254129/18 "2023-02-15T22:05:11Z")

</div>

> [@sandra-nestor](#):
>
> I wasn’t able to find a way how to set up additional permissions for a certain installed app using [this doc](https://developer.smartthings.com/docs/api/public/#tag/Installedapps).

For the SmartApp, if you registered it using the Developer Workspace, you only need to select them there to whitelist them.  
However, you can change them through the API as well. I suggest you do this carefully as any change you make through the API won’t be shown in the Dev WS.

To do that, you need to follow these steps:

1. First need to get the Oauth config from the app and copy the result from that query:  
[Apps endoint \> GET OAuth config](https://developer.smartthings.com/docs/api/public/#operation/getAppOauth)
2. Paste that config into the body of a PUT request to the[same endpoint](https://developer.smartthings.com/docs/api/public/#operation/updateAppOauth), remember you need to add the `redirectURL`. For example:

```auto
{
    "clientName": "TestSmartApp2023",
    "scope": [
        "r:devices:*",
        "r:locations:*",
        "w:devices:*",
        "x:devices:*"
    ],
    "redirectUris": [
        "https://domain.com"
    ]
}

```

---

<div class="post-metadata">

**Author:** ![mcnaveen](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/mcnaveen/32/252994_2.png) [@mcnaveen](https://community.smartthings.com/u/mcnaveen)\
**Post date:** [August 29, 2026, 3:47am UTC](https://community.smartthings.com/t/send-device-health-info-through-webhook-endpoint/254129/19 "2026-08-29T03:47:37Z")

</div>

I ended up using this app. Even though it’s a paid app. Gets the job done 100%

> <https://play.google.com/store/apps/details?id=com.hcwebhook.app>
>
> Export your health data to any webhook. No servers. Total control...
