Install a Device

I am trying to install the device through API commands. I have tried following these instructions.

I have tried to test the installation with the Postman.

Authentication seems to work, but rejects the request (403 Forbidden).
I assume the header is correct. The problem is probably in the body.

  • locationId
    • I use the location ID returned by the SmartApp.
  • profileId
    • Device Profile ID from the SmartApp Connector
  • installedAppId
    • I use the installedAppId returned by the SmartApp.
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://api.smartthings.com/v1/devices',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer 91a5dcc3-31ae-40b3-ba41-xxxxxxxx'
  },
  body: JSON.stringify({
    "locationId": "d5920722-0959-4fae-8083-xxxxxxxx",
    "app": {
      "profileId": "0e1f8b77-12a6-443b-9525-xxxxxxxxx",
      "installedAppId": "f84509fa-ad63-4bb9-be96-xxxxxxxxx"
    }
  })

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

I think 403 means what it says. You have a permissions issue. I believe you need to use a SmartApp token with i:deviceprofiles permission.

Where are you getting the token from? It seems a little odd to see SmartApp tokens typed manually.

1 Like

We use cloud to cloud and Webhooks. I have created a cloud connector on the Developers Workspace. After the SmartApp configuration, I get an access token. I use the Postman because it is faster to test the connection. I tried to add i:deviceprofiles permission, but now the SmartApp crashes (An unexpected error occured).

  data = {
    configurationData: {
      initialize: {
        name: "Sense",
        description: "Test init.",
        id: "d4050528-bb0d-4ef1-a02b-xxxxxxxxx",
        permissions: ["r:locations:*", "r:devices:*", "i:deviceprofiles"],
        firstPageId: "1",
      },
    },
  };

Sounds like you have far more experience in this area than I do. I guess you whitelisted the permissions in the developer workspace, though if you didn’t a crash would seem rather unnecessary.

Let’s tag @nayelyz and @andresg as I reckon it falls nicely in their remit.

That permission was what I had wrong. I just wrote that wrong at first. It should be like this: “i:deviceprofiles:*”

I got it working now, thanks.

1 Like

Whether or not you need “:*” on a permission seems awfully inconsistent and the documentation and reality sometimes seems to differ.

Hi, @Heikki_Pirttinen!

When you whitelist scopes in the Developer Workspace, you can only include those in the SmartApp definition. For example, if we select only these:


We cannot include r:rules:* in the SmartApp definition, otherwise, we’ll get the error you mentioned above. In the Dev WS you can see the format you need to use.

I’ll check why the reference in the docs doesn’t include :*, if you see another case like this, please, let me know.

Thanks for the tag, @orangebucket.