env Requests
Environment variables are key-value pairs that can be set on the Notecard, or on a device, project and fleet in Notehub.
The Hierarchy of Environment Variables
Environment variables can be defined in a number of locations, from the Notecard, to Notehub device settings, the device's Fleet, and the Notehub project. Variables set at different levels of this hierarchy can override one another. When obtaining an environment variable, the Notecard uses the following priority order, where the first matched result is returned:
- The local value.
- The value set in Notehub directly on Notehub's record for the Device.
- The value set in Notehub on a Fleet to which the Device belongs.
- The value set in Notehub on the Project to which the Device belongs.
- The default value defined with the
env.default
request.
env.default
Used by the Notecard host to specify a default value for an environment variable until that variable is overridden by a device, project or fleet-wide setting at Notehub.
name
string
The name of the environment variable (case-insensitive).
text
string (optional)
The value of the variable. Pass ""
or omit from the request to delete it.
Response Members
{}
means success.env.get
Returns a single environment variable, or all variables according to precedence rules.
name
string (optional)
The name of the environment variable (case-insensitive). Omit to return all environment variables known to the Notecard.
names
(Added in v3.4.1)
Array (optional)
An list of one or more variables to retrieve, by name (case-insensitive).
time
(Added in v3.4.1)
UNIX Epoch time (optional)
Request a modified environment variable or variables from the Notecard, but only if modified after the time provided.
Response Members
text
string
If a name
was specified, the value of the environment variable.
body
JSON object
If a name
was not specified, an object with name
and value
pairs for
all environment variables.
time
(Added v3.4.1.)
UNIX Epoch time
The time of the Notecard variable or variables change.
env.modified
Get the time of the update to any environment variable managed by the Notecard.
time
(Added in v3.4.1)
UNIX Epoch time (optional)
Request whether the Notecard has detected an environment variable change since a known epoch time.
Response Members
time
UNIX Epoch time
Timestamp indicating the last time any environment variable was changed on the device.
{ "time": 1605814493 }
env.set
Sets a local environment variable on the Notecard. Local environment variables cannot be overridden by a Notehub variable of any scope.
name
string
The name of the environment variable (case-insensitive).
text
string (optional)
The value of the variable. Pass ""
or omit from the request to delete it.
Response Members
time
(Added v3.4.1.)
UNIX Epoch time
The logged time of the variable change.