Is still possible to create SmartApps through API

Hi,

i have seen that the “old” smartthings mobile app is not working anymore. With it, i was able to create a smartapp through the api: SmartThings API and add permission to it from the mobile app.

Classification value is “AUTOMATION”

But now, I create a app with the api, i go to mobile app (in developer mode) and my smartapp created with the API is not listed in custom apps.
If i go (manually) to the developer workspace and i create a smartapp there, this manually-created smartapp is listed in custom, i can choose it and everything works fine.

Here is an example

async function createAPP(accessToken){

return new Promise((resolve,reject)=>{

var config={

  method: 'POST',

  url: `${urlBase}/apps`,

  headers: {'Authorization': 'Bearer '+accessToken,'Content-Type': 'application/json',},

  data: {

    "appName": "myname",

    "displayName": "My name",

    "description": "App",

    "singleInstance": false,

    "iconImage": {

    },

    "appType": "WEBHOOK_SMART_APP",

    "principalType": "LOCATION",

    "classifications": [

      "DEVICE"

    ],

    "lambdaSmartApp": {

      "functions": [

        "arn:aws:lambda:eu-central-1:account-id:function:function-name:alias-name",

        "arn:aws:lambda:ap-southeast-1:account-id:function:function-name:alias-name"

      ]

    },

    "webhookSmartApp": {

      "targetUrl": "MYURL"

    },

    "oauth": {

      "clientName": "My SmartThings Integration",

      "scope": [

        "r:devices:*",

        "x:devices:*",

        "i:deviceprofiles:*",

        "r:locations:*"

      ]

    },

    "ui": {

      "pluginUri": "MYURL",

      "dashboardCardsEnabled": true,

      "preInstallDashboardCardsEnabled": true

    }

  }

  };

  

  axios(config)

    .then(r=>resolve(r))

    .catch(e=>reject(e))

})

}

It won’t appear because it can only be “deployed to test” from the Developer Workspace. Can you explain what you’re trying to achieve, please? I mean:

  • Do you want to create the SmartApp through the API and then install it through the ST mobile app?
    The user needs to configure the inputs of the SmartApp pages.
  • Or, you want to create a SmartApp this way to be able to use its context in your project (eg. event’s subscriptions.)

The objective is to create a SmartApp to use event’s subscriptions (eg. subscribing to a door sensor to see when it’s open), and i want to do everything in a automated way, I dont want users need to create the subscription by their own.

You can register the SmartApp at the Developer Workspace and leave empty the configuration page. The user would only have to accept the permissions and the Subscriptions can be created within the SmartApp.

See this example to create a device component Subscription without having a configurationData input:

app.enableEventLogging(2)  // Log and pretty-print all lifecycle events and responses
    .configureI18n()      // Use files from locales directory for configuration page localization
    .appId("manual-subscriptions")
    .permissions([
        "r:devices:*",
        "r:locations:*"
    ])
    .page('mainPage', (context, page, configData) => {
        
    })
    .updated(async (context, updateData) => {
        let deviceInfo=[{
            "valueType":"DEVICE",
            "deviceConfig":{
                "deviceId":"device-id",
                "componentId":"main"
            }
        }]

        return Promise.all([
            context.api.subscriptions.subscribeToDevices(deviceInfo, '*', '*', 'deviceSubscription')
        ]).then(resp => { 
            console.log(resp);  
        });
    })
    .subscribedEventHandler('deviceSubscription', (context, deviceEvent) => {
        console.log(deviceEvent);
        
    });

So, the only option is that the user creates the subscription into the debeloper workspace?

Unfortunately, I think it is not suitable for me :frowning:

Thanks for your quick reply

Yes, considering the use case you mention.
The OAuth Integration (for third-party clouds), would be useful in this case, but this one is available only if your request is approved.