Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Secret resource


You can provide configuration data for multiple Microvisor-empowered IoT devices using the Secret resource. Secrets are intended as a way to upload confidential data to the Twilio cloud so it need not be baked into application code. Instead, the application code running on the device retrieves the Secret when it needs the information.

Unlike Configs, Secrets' values cannot be accessed via the API once they have been created. The retrieval actions listed below will return Secrets' metadata, not their values.

Each Secret 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 account.

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 Secret. For example, you might used base64 encoding. Your application must decode the value back to binary after acquiring it from the Twilio cloud.

Secret resources are accessed at this endpoint:


_10
https://microvisor.twilio.com/v1/Secrets

Secret resources are accessible from all devices associated with an account. For Secrets that are made available to specific devices, please see Device Secrets.


AccountSecret Properties

accountsecret-properties page anchor
Property nameTypePIIDescription
keystring
Not PII

The secret key; up to 100 characters.


date_rotatedstring<date-time>

urlstring<uri>

The absolute URL of the Secret.


Create an account-level Secret

create-an-account-level-secret page anchor
POST https://microvisor.twilio.com/v1/Secrets

Request body parameters

request-body-parameters page anchor
Property nameTypeRequiredPIIDescription
Keystringrequired

The secret key; up to 100 characters.


Valuestringrequired

The secret value; up to 4096 characters.

Create an account-level Secret

create-an-account-level-secret-1 page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_19
// Download the helper library from https://www.twilio.com/docs/node/install
_19
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_19
_19
// Find your Account SID and Auth Token at twilio.com/console
_19
// and set the environment variables. See http://twil.io/secure
_19
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_19
const authToken = process.env.TWILIO_AUTH_TOKEN;
_19
const client = twilio(accountSid, authToken);
_19
_19
async function createAccountSecret() {
_19
const accountSecret = await client.microvisor.v1.accountSecrets.create({
_19
key: "key_name",
_19
value: "value",
_19
});
_19
_19
console.log(accountSecret.key);
_19
}
_19
_19
createAccountSecret();

Output

_10
{
_10
"key": "key_name",
_10
"date_rotated": "2021-01-01T12:34:56Z",
_10
"url": "https://microvisor.twilio.com/v1/Secrets/first"
_10
}


Retrieve an account-level Secret's metadata

retrieve-an-account-level-secrets-metadata page anchor
GET https://microvisor.twilio.com/v1/Secrets/{Key}

Property nameTypeRequiredPIIDescription
Keystringrequired

The secret key; up to 100 characters.

Fetch an account-level Secret's metadata

fetch-an-account-level-secrets-metadata page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_18
// Download the helper library from https://www.twilio.com/docs/node/install
_18
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_18
_18
// Find your Account SID and Auth Token at twilio.com/console
_18
// and set the environment variables. See http://twil.io/secure
_18
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18
const authToken = process.env.TWILIO_AUTH_TOKEN;
_18
const client = twilio(accountSid, authToken);
_18
_18
async function fetchAccountSecret() {
_18
const accountSecret = await client.microvisor.v1
_18
.accountSecrets("Key_name")
_18
.fetch();
_18
_18
console.log(accountSecret.key);
_18
}
_18
_18
fetchAccountSecret();

Output

_10
{
_10
"key": "Key_name",
_10
"date_rotated": "2021-01-01T12:34:57Z",
_10
"url": "https://microvisor.twilio.com/v1/Secrets/first"
_10
}


Delete an account-level Secret

delete-an-account-level-secret page anchor
DELETE https://microvisor.twilio.com/v1/Secrets/{Key}

Property nameTypeRequiredPIIDescription
Keystringrequired

The secret key; up to 100 characters.

Delete an account-level Secret

delete-an-account-level-secret-1 page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_14
// Download the helper library from https://www.twilio.com/docs/node/install
_14
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_14
_14
// Find your Account SID and Auth Token at twilio.com/console
_14
// and set the environment variables. See http://twil.io/secure
_14
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_14
const authToken = process.env.TWILIO_AUTH_TOKEN;
_14
const client = twilio(accountSid, authToken);
_14
_14
async function deleteAccountSecret() {
_14
await client.microvisor.v1.accountSecrets("key_name").remove();
_14
}
_14
_14
deleteAccountSecret();


Rate this page: