You can provide configuration data for specific Microvisor-empowered IoT devices using the Config subresource. Configs are intended as a way to upload data such as API keys, PKI certificates, and other items to the Twilio cloud so they need not be baked into application code. Instead, the application code running on the device retrieves the Config when it needs the information.
Each Config is a key:value pair which your application code can access using Microvisor System Calls.
Keys are text identifiers of up to 100 characters in length. They must be unique for a given device. For example, devices A and B can both have Configs with the key cloud_service_api_key
, but each device can have only one Config with that key.
Values must also be supplied as text, of up to 4096 characters in length. If you wish to make binary data available to your devices, you will need to encode it as text before creating the Config. For example, you might used base64 encoding. Your application must decode the value back to binary after acquiring it from the Twilio cloud.
Config subresources are accessed at these endpoints:
1https://microvisor.twilio.com/v1/Devices/{sid}/Configs2https://microvisor.twilio.com/v1/Devices/{UniqueName}/Configs
Device Configs are accessible only by the specified device. For Configs that are made available to all devices associated with a given account, please see Account-level Configs.
It is possible for anyone with account access to read back the value of any Config. If you have information which, once created, you would not like to be accessible to other account holders, use Device Secrets, which are, from the API perspective, write- and delete-only.
Configs can't yet be updated. If you need to change a Config's value, delete it first, and then create a new Config with the same key.
A 34-character string that uniquely identifies the parent Device.
^UV[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The absolute URL of the Config.
POST https://microvisor.twilio.com/v1/Devices/{DeviceSid}/Configs
A 34-character string that uniquely identifies the Device.
application/x-www-form-urlencoded
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createDeviceConfig() {11const deviceConfig = await client.microvisor.v112.devices("UVxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")13.deviceConfigs.create({14key: "Key",15value: "Value",16});1718console.log(deviceConfig.deviceSid);19}2021createDeviceConfig();
1{2"device_sid": "UVxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",3"key": "Key",4"value": "Value",5"date_updated": "2021-01-01T12:34:56Z",6"url": "https://microvisor.twilio.com/v1/Devices/UVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Configs/first"7}
GET https://microvisor.twilio.com/v1/Devices/{DeviceSid}/Configs/{Key}
The config key; up to 100 characters.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function fetchDeviceConfig() {11const deviceConfig = await client.microvisor.v112.devices("UVxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")13.deviceConfigs("key_name")14.fetch();1516console.log(deviceConfig.deviceSid);17}1819fetchDeviceConfig();
1{2"device_sid": "UVxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",3"key": "key_name",4"value": "some value",5"date_updated": "2021-01-01T12:34:57Z",6"url": "https://microvisor.twilio.com/v1/Devices/UVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Configs/first"7}
GET https://microvisor.twilio.com/v1/Devices/{DeviceSid}/Configs
A 34-character string that uniquely identifies the Device.
How many resources to return in each list page. The default is 50, and the maximum is 1000.
1
Maximum: 1000
The page token. This is provided by the API.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function listDeviceConfig() {11const deviceConfigs = await client.microvisor.v112.devices("UVxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")13.deviceConfigs.list({ limit: 20 });1415deviceConfigs.forEach((d) => console.log(d.deviceSid));16}1718listDeviceConfig();
1{2"configs": [],3"meta": {4"page": 0,5"page_size": 50,6"first_page_url": "https://microvisor.twilio.com/v1/Devices/UVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Configs?PageSize=50&Page=0",7"previous_page_url": null,8"url": "https://microvisor.twilio.com/v1/Devices/UVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Configs?PageSize=50&Page=0",9"next_page_url": null,10"key": "configs"11}12}
DELETE https://microvisor.twilio.com/v1/Devices/{DeviceSid}/Configs/{Key}
The config key; up to 100 characters.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function deleteDeviceConfig() {11await client.microvisor.v112.devices("UVxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")13.deviceConfigs("key_name")14.remove();15}1617deleteDeviceConfig();