[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-07-29 UTC。"],[[["\u003cp\u003eAfter obtaining an access token, the SDM API can be utilized to access and manage your smart devices.\u003c/p\u003e\n"],["\u003cp\u003eThe API allows you to retrieve device and structure lists using GET calls to their respective endpoints.\u003c/p\u003e\n"],["\u003cp\u003eDevice-specific information and control are achieved by targeting the device ID endpoint with GET and POST requests.\u003c/p\u003e\n"],["\u003cp\u003eExecuting commands on devices, such as changing thermostat modes or generating camera streams, involves POST calls to the \u003ccode\u003eexecuteCommand\u003c/code\u003e endpoint with specific parameters.\u003c/p\u003e\n"],["\u003cp\u003eCommon troubleshooting steps include refreshing expired access tokens and consulting the error code reference for other issues.\u003c/p\u003e\n"]]],[],null,["# Use the API\n\nWith an access token in hand and the initial device list call made, you're now\nready to use the SDM API to access and control your device.\n\nList structures and devices\n---------------------------\n\nUse `curl` to make a simple GET call to the `structures` endpoint: \n\n curl -X GET 'https://smartdevicemanagement.googleapis.com/v1/enterprises/\u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e/structures' \\\n -H 'Content-Type: application/json' \\\n -H 'Authorization: Bearer \u003cvar translate=\"no\"\u003eaccess-token\u003c/var\u003e'\n\nA successful call returns a list of structures for accounts linked to your\nDevice Access project: \n\n```\n{\n \"structures\": [\n {\n \"name\": \"enterprises/project-id/structures/structure-id\",\n \"traits\": {\n \"sdm.structures.traits.Info\": {\n \"customName\": \"structure-name\"\n }\n }\n }\n ]\n}\n```\n\nIf you haven't done so already, make a GET call to the `devices` endpoint to\nget a list of devices: \n\n curl -X GET 'https://smartdevicemanagement.googleapis.com/v1/enterprises/\u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e/devices' \\\n -H 'Content-Type: application/json' \\\n -H 'Authorization: Bearer \u003cvar translate=\"no\"\u003eaccess-token\u003c/var\u003e'\n\nA successful call returns a list of devices linked to your Device Access\nproject. Each device has its own unique list of available traits: \n\n```\n{\n \"devices\": [\n {\n \"name\": \"enterprises/project-id/devices/device-id\",\n \"type\": \"sdm.devices.types.device-type\",\n \"traits\": { ... },\n \"parentRelations\": [\n {\n \"parent\": \"enterprises/project-id/structures/structure-id/rooms/room-id\",\n \"displayName\": \"device-room-name\"\n }\n ]\n }\n ]\n}\n```\n\nCopy the \u003cvar translate=\"no\"\u003edevice-id\u003c/var\u003e for each device, you'll need that for other API calls.\n\nGet information for a device\n----------------------------\n\nTo get information a specific device, make a GET call to the \u003cvar translate=\"no\"\u003edevice-id\u003c/var\u003e\nendpoint: \n\n curl -X GET 'https://smartdevicemanagement.googleapis.com/v1/enterprises/\u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e/devices/\u003cvar translate=\"no\"\u003edevice-id\u003c/var\u003e' \\\n -H 'Content-Type: application/json' \\\n -H 'Authorization: Bearer \u003cvar translate=\"no\"\u003eaccess-token\u003c/var\u003e'\n\nThe response should be similar as before, but just for the specific device: \n\n```\n{\n \"name\": \"enterprises/project-id/devices/device-id\",\n \"type\": \"sdm.devices.types.device-type\",\n \"traits\": { ... },\n \"parentRelations\": [\n {\n \"parent\": \"enterprises/project-id/structures/structure-id/rooms/room-id\",\n \"displayName\": \"device-room-name\"\n }\n ]\n}\n```\n\nExecute a command\n-----------------\n\nAfter validating your access with a successful GET call, try to execute a\ncommand depending on the type of device you have authorized: \n\n### THERMOSTAT\n\n curl -X POST \\\n 'https://smartdevicemanagement.googleapis.com/v1/enterprises/\u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e/devices/\u003cvar translate=\"no\"\u003edevice-id\u003c/var\u003e:executeCommand' \\\n -H 'Content-Type: application/json' \\\n -H 'Authorization: Bearer \u003cvar translate=\"no\"\u003eaccess-token\u003c/var\u003e' \\\n --data-raw '{\n \"command\" : \"sdm.devices.commands.ThermostatMode.SetMode\",\n \"params\" : {\n \"mode\" : \"HEAT\"\n }\n }'\n\n### CAMERA\n\n curl -X POST \\\n 'https://smartdevicemanagement.googleapis.com/v1/enterprises/\u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e/devices/\u003cvar translate=\"no\"\u003edevice-id\u003c/var\u003e:executeCommand' \\\n -H 'Content-Type: application/json' \\\n -H 'Authorization: Bearer \u003cvar translate=\"no\"\u003eaccess-token\u003c/var\u003e' \\\n --data-raw '{\n \"command\" : \"sdm.devices.commands.CameraLiveStream.GenerateRtspStream\",\n \"params\" : {}\n }'\n\nIf your call is successful, the following results occur: \n\n### THERMOSTAT\n\nYou receive an empty response and the physical thermostat changes its\ncurrent mode to the mode specified in the command parameters. \n\n```\n{}\n```\n\n### CAMERA\n\nYou receive a live stream URL and related tokens. \n\n```\n{\n \"results\" : {\n \"streamUrls\" : {\n \"rtspUrl\" : \"rtsps://someurl.com/CjY5Y3VKaTZwR3o4Y19YbTVfMF...?auth=g.0.streamingToken\"\n },\n \"streamExtensionToken\" : \"CjY5Y3VKaTZwR3o4Y19YbTVfMF...\",\n \"streamToken\" : \"g.0.streamingToken\",\n \"expiresAt\" : \"2018-01-04T18:30:00.000Z\"\n }\n}\n```\n\nTroubleshooting\n---------------\n\n### Unauthenticated\n\nAccess tokens for the SDM API are only valid for 1 hour. If\nyou get an UNAUTHENTICATED response, the token has likely expired. [Use your\nrefresh token](/nest/device-access/authorize#how_to_use_a_refresh_token) to get a new\naccess token.\n\n### Other errors\n\nSee the [Error Code Reference](/nest/device-access/reference/error-codes) for the\nfull list of Device Access error codes."]]