Subscriptions
Create a Subscription for an Installed App
Changed onCreate a subscription to a type of event from the specified source. Both the source and the installed app must be in the location specified and the installed app must have read access to the event being subscribed to. An installed app is only permitted to created 20 subscriptions.
Authorization scopes
For installed app principal:
- installed app id matches the incoming request installed app id location must match the installed app location
| Subscription Type | Scope required |
|---|---|
| DEVICE | r:devices:$deviceId |
| CAPABILITY | r:devices:*:*:$capability or r:devices:*, |
| MODE | r:locations:$locationId or r:locations:* |
| DEVICE_LIFECYCLE | r:devices:$deviceId or r:devices:* |
| DEVICE_HEALTH | r:devices:$deviceId or r:devices:* |
| SECURITY_ARM_STATE | r:security:locations:$locationId:armstate or r:security:locations:*:armstate |
| HUB_HEALTH | r:hubs |
| SCENE_LIFECYCLE | r:scenes:* |
post/installedapps/{installedAppId}/subscriptions
Request
- Base URLhttps://api.smartthings.com/v1
- Auth
- OAuth 2Implicithttps://auth-global.api.smartthings.comScopesr:devices:*
- or OAuth 2Implicithttps://auth-global.api.smartthings.comScopesr:locations:*
- or OAuth 2Implicithttps://auth-global.api.smartthings.comScopesr:security:locations:*:armstate
- or OAuth 2Implicithttps://auth-global.api.smartthings.comScopesr:hubs
- or OAuth 2Implicithttps://auth-global.api.smartthings.comScopesr:scenes:*
- TypeScriptA function with typed inputs. Its response is checked against the schema.
Request body
Example request
{
"sourceType": "DEVICE",
"device": {
"deviceId": "736e3903-001c-4d40-b408-ff40d162a06b",
"componentId": "freezer",
"capability": "temperatureMeasurement",
"attribute": "temperature",
"stateChangeOnly": true,
"modes": [
"e34b57fb-e73a-4228-8819-e99502d17890",
"cfa3a42e-5f52-452e-9515-c32bcbea48ce"
]
}
}Response
The subscription
Example response
{
"id": "5e1b134b-bd85-4125-9c25-4a8291e754aa",
"installedAppId": "fb05c874-cf1d-406a-930c-69a081e0eaee",
"sourceType": "DEVICE",
"device": {
"componentId": "main",
"deviceId": "e457978e-5e37-43e6-979d-18112e12c961,",
"capability": "contactSensor,",
"attribute": "contact,",
"stateChangeOnly": "true,",
"subscriptionName": "contact_subscription',",
"value": "*"
}
}Changes
- info
the security scope
r:devices:*was added to the endpoint's security schemeBearer - info
the security scope
r:scenes:*was removed from the endpoint's security schemeBearer
- info
- info
the security scope
r:devices:*was added to the endpoint's security schemeBearer - info
the security scope
r:scenes:*was removed from the endpoint's security schemeBearer
- info