Unlink smartthings from my app

I wonder if I could unlink smartthings account from my app according to the course below. If it is able to unlink, which url is suitable? thanks all.
SmartThings Developers | Documentation

Tagging @nayelyz

Hi, there!
The “Integration Deleted” interaction is called from the SmartThings side when:

  • We select the device created by our ST Schema Connector and delete it.
  • In the ST app, we go to Menu > Settings > Linked Services and delete the integration.

The third-party cloud can also call it by sending a stateCallback to the Schema connector (see the configuration sample for the stateCallback here):

  • The URL will depend on the endpoint you configured in your Connector’s server to receive the request from the Third-Party, in the example, the endpoint to receive the “stateCallback” and update the device state is /command
  • The difference with a common stateCallback is that to trigger the “integrationDeleted” interaction, you need to send a globalError so, the payload from the stateCallback would look like this:
{
  "headers": {
    "schema": "st-schema",
    "version": "1.0",
    "interactionType": "stateCallback",
    "requestId": "xxx-xxxx-xxx"
  },
  "authentication": {
    "tokenType": "Bearer",
    "token": "token-received from SmartThings for callbacks" 
  },
  "deviceState":null,  //or "deviceState":[],
  "globalError": {
     "errorEnum": "INTEGRATION-DELETED",
     "detail": "The integration was deleted from the cloud"
  }
}

Thanks to this interaction type, we can remove any saved configuration, tokens, etc. from the server.

Here’s an example using the ST Schema SDK:

I will have a try.
You help a lot! Thanks nayelyz!

1 Like

@nayelyz
I have tried this method to delete integration and it works.
But response is globalError:bad request, Is that correct?

Yes, you receive an error in the updateRequest because we included the globalError in the stateCallback.
You will only receive a success message if there is no error in the stateCallback’s payload and it updates the device state correctly.

i try this way to delete the integration today again, but receive response {“globalError”:{“errorEnum”:“BAD-REQUEST”,“detail”:“deviceState missing or malformed”}} and fail. My serivce is still at linked status, observe from smartthings app.
Is that any changes i should know?
thanks!

Sorry, the JSON payload above wasn’t complete. The error is thrown because the deviceState is missing. It must always be included in the StateCallback, it can have a null or empty array([]) value.
In my sample, you can see how the this field is included in the request:

So, the payload should look like this: