How can I receive installedAppId?

Hello

I created my own Automation for the SmartThings App project here https://smartthings.developer.samsung.com/workspace/projects

and successfully deployed my project (Deployed to test)

But, I have a problem

I want to add subscription about my personal device(Smart Things app)

So I tried to add subscription in my project using this API: https://api.smartthings.com/v1/installedapps/{installedAppId}/subscriptions

but I received 403 response.

I used below data to {installedAppId}

Is it right?

and I used this Bearer token from here https://account.smartthings.com/tokens

Is it right too?

I hope your response.

Have a good day

Thank you!

They are two different values:

  • The AppID identifies the app in general, with that, you make the requests to the /apps endpoint to change the configuration (eg. OAuth configuration)
  • When you install it, a new instance of the SmartApp is created. This is identified with the installedAppID and you can only use it with the /installedapps endpoint

Also, the token you must use to authorize the request is the one granted to the SmartApp. Personal Access Tokens cannot be used for the requests
to the /installedapps endpoint.
Those values are included in the “Install Request”, see the sample below:

INSTALL REQUEST: {      
  "lifecycle": "INSTALL",
  "executionId": "36c3952e-17cb-...",
  "appId": "c424c087-a45b-4a00-...",      
  "locale": "en",
  "version": "0.1.0",
  "client": {
    "os": "android",
    "version": "1.7.63.22",
    "language": "en-MX",
    "displayMode": "LIGHT",
    "timeZoneOffset": "",
    "supportedTemplates": [],
    "samsungAccountId": ""
  },
  "installData": {
    "authToken": "4ac53853-9c8d-...", /*This is used to authorize the requests (eg. create a subscription)*/
    "refreshToken": "7785ea2c-904f-...", /*This is used in case the Access Token is expired to get  a new one*/
    "installedApp": {
      "installedAppId": "33b72459-5599-...", /*This ID identifies the SmartApp instance*/
      "locationId": "7770e091-79cf-...",
      "config": {
        "sensor": [
          {
            "valueType": "DEVICE",
            "deviceConfig": {
              "deviceId": "7dd1ae0e-fe07-...",
              "componentId": "main"
            }
          }
        ]
      },
      "permissions": [
        "r:devices:7dd1ae0e-fe07-..."
      ]
    }
  },
  "settings": {}
}

For more info, take a look at the Lifecycles doc.

Thank you so much for your response!

You say “When you install it, a new instance of the SmartApp is created. This is identified with the installedAppID and you can only use it with the /installedapps endpoint”

What is that means ‘install’? Is it Samsung SmartThings app?(Android or iOS)

I meant when finishing the installation process of the SmartApp. The “Install” request is sent when you click on “Allow” in the permissions page:

Thank you very very very much!

Have a good day!