Commands
Reusable commands defined on a tracker, sent to the device or to a URL on demand.
A command is a reusable action defined on one tracker and run when someone asks for it. Two kinds exist. A hardware command sends a protocol string straight to the device, to reboot its firmware or toggle a relay. An HTTP command sends a POST request with a JSON body to any URL, optionally carrying live device values in the payload.
Commands are stored per tracker and executed from the Commands block in the interface or through command/execute.
Hardware command strings are device-specific. Always check the device manufacturer's documentation for valid values, because an incorrect string can have unintended effects on the device.
Command object
The config object takes one of two shapes, chosen by type:
In an HTTP command's body, {{attribute_name}} placeholders are replaced with the device's current values at the moment the command runs.
Dynamic command values
A hardware command's command string, or an HTTP command's body, can carry a single <> placeholder in place of a fixed value. The caller supplies the substitution in param when running the command, and the Navixy platform replaces <> before sending. This lets one stored command cover a family of calls, such as a relay command whose channel number changes per use.
It is a different mechanism from the {{attribute_name}} placeholders above: those read live device values, while <> takes a value from the caller.
A configuration may contain at most one
<>placeholder. Create and update reject one with more.paramis required when the configuration contains a placeholder, and rejected when it does not. Either mismatch returns error 7. A blank value counts as absent.paramaccepts up to 500 printable characters.
API actions
API base path: /tracker/command. One call, batch_get_commands, sits at the tracker root instead.
Operations that list no errors of their own return only the general error codes.
Required sub-user rights: tracker_update.
Define a reusable command on a tracker. Commands are stored per tracker and executed on demand.
A tracker holds at most 10 commands, and an eleventh is rejected. Commands cannot be created on a clone device.
A configuration may contain at most one <> placeholder, and one with more than one is rejected. See the dynamic values note on execute.
For automated, rule-based command sending across many devices, use IoT Logic's device action or webhook nodes instead; this family is for manual, single-tracker actions.
Requires the tracker_update right.
Either a user session hash or an API key, with the "NVX " prefix, for example "NVX 22eac1c27af4be7b9d04da2ce1af111b". Obtain a session hash from the userAuth operation, or create an API key from the API keys operations. A small number of operations accept a session hash only and reject an API key with error code 4; each says so in its description.
ID of the tracker, also known as the object ID. Must belong to the current account and not be blocked.
123456The created command
true if request finished successfully.
trueID of the new command.
19Bad request. The response body carries the API-level error code in status.code. Validation failures also include an errors array naming each offending parameter.
Error 201: the command or the tracker does not exist.
Error response object
POST /v2/tracker/command/create HTTP/1.1
Host: api.eu.navixy.com
Authorization: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 123
{
"tracker_id": 123456,
"command": {
"id": 19,
"name": "Reboot",
"type": "hardware",
"config": {
"command": "cpureset",
"reliable": true
}
}
}{
"success": true,
"id": 19
}Errors
These errors come in addition to the general error codes:
201 - The command or the tracker does not exist.
Required sub-user rights: tracker_update.
Replace an existing command. The whole object must be sent, including its id; there is no partial update.
As with create, the configuration may contain at most one <> placeholder, and one with more than one is rejected.
Requires the tracker_update right.
Either a user session hash or an API key, with the "NVX " prefix, for example "NVX 22eac1c27af4be7b9d04da2ce1af111b". Obtain a session hash from the userAuth operation, or create an API key from the API keys operations. A small number of operations accept a session hash only and reject an API key with error code 4; each says so in its description.
ID of the tracker, also known as the object ID. Must belong to the current account and not be blocked.
123456The command was updated
true if request finished successfully.
trueBad request. The response body carries the API-level error code in status.code. Validation failures also include an errors array naming each offending parameter.
Error 201: the command or the tracker does not exist.
Error response object
POST /v2/tracker/command/update HTTP/1.1
Host: api.eu.navixy.com
Authorization: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 123
{
"tracker_id": 123456,
"command": {
"id": 19,
"name": "Reboot",
"type": "hardware",
"config": {
"command": "cpureset",
"reliable": true
}
}
}{
"success": true
}Errors
These errors come in addition to the general error codes:
201 - The command or the tracker does not exist.
Required sub-user rights: tracker_configure, tracker_set_output.
If the command's configuration contains a <> placeholder, pass its value in param. See Dynamic command values.
Run a stored command immediately. A hardware command sends its string to the device; an http command dispatches the POST request with live attribute values substituted into the body.
Dynamic values. Where the command's configuration contains a <> placeholder, the value that replaces it is supplied here as param, and the substitution happens before the command is sent. param is required when the configuration contains a placeholder, and rejected when it does not: either mismatch returns error 7. A blank param counts as absent.
Requires the tracker_configure and tracker_set_output rights.
Either a user session hash or an API key, with the "NVX " prefix, for example "NVX 22eac1c27af4be7b9d04da2ce1af111b". Obtain a session hash from the userAuth operation, or create an API key from the API keys operations. A small number of operations accept a session hash only and reject an API key with error code 4; each says so in its description.
ID of the tracker, also known as the object ID. Must belong to the current account and not be blocked.
123456ID of the command to run.
3Value that replaces the <> placeholder in the command configuration. Required if the configuration contains one, rejected if it does not. Up to 500 printable characters.
1The command was executed
true if request finished successfully.
trueBad request. The response body carries the API-level error code in status.code. Validation failures also include an errors array naming each offending parameter.
Error 201: the command or the tracker does not exist.
Error response object
POST /v2/tracker/command/execute HTTP/1.1
Host: api.eu.navixy.com
Authorization: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 48
{
"tracker_id": 123456,
"command_id": 3,
"param": "1"
}{
"success": true
}Errors
These errors come in addition to the general error codes:
201 - The command or the tracker does not exist.
Required sub-user rights: tracker_update.
Remove a stored command from a tracker.
Requires the tracker_update right.
Either a user session hash or an API key, with the "NVX " prefix, for example "NVX 22eac1c27af4be7b9d04da2ce1af111b". Obtain a session hash from the userAuth operation, or create an API key from the API keys operations. A small number of operations accept a session hash only and reject an API key with error code 4; each says so in its description.
ID of the tracker, also known as the object ID. Must belong to the current account and not be blocked.
123456ID of the command to delete.
5The command was deleted
true if request finished successfully.
trueBad request. The response body carries the API-level error code in status.code. Validation failures also include an errors array naming each offending parameter.
Error 201: the command or the tracker does not exist.
Error response object
POST /v2/tracker/command/delete HTTP/1.1
Host: api.eu.navixy.com
Authorization: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 36
{
"tracker_id": 123456,
"command_id": 5
}{
"success": true
}Errors
These errors come in addition to the general error codes:
201 - The command or the tracker does not exist.
Get the stored commands for the given trackers, grouped by tracker ID. Available to demo accounts.
Omitting trackers returns commands for every tracker the account can reach. Trackers with no commands come back as empty arrays.
Either a user session hash or an API key, with the "NVX " prefix, for example "NVX 22eac1c27af4be7b9d04da2ce1af111b". Obtain a session hash from the userAuth operation, or create an API key from the API keys operations. A small number of operations accept a session hash only and reject an API key with error code 4; each says so in its description.
Optional. Tracker IDs. Omit for every accessible tracker.
[70074765,70074766]Commands per tracker
true if request finished successfully.
trueBad request. The response body carries the API-level error code in status.code. Validation failures also include an errors array naming each offending parameter.
Error response object
POST /v2/tracker/batch_get_commands HTTP/1.1
Host: api.eu.navixy.com
Authorization: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 32
{
"trackers": [
70074765,
70074766
]
}{
"success": true,
"result": {
"ANY_ADDITIONAL_PROPERTY": [
{
"id": 19,
"name": "Reboot",
"type": "hardware",
"config": {
"command": "cpureset",
"reliable": true
}
}
]
}
}Last updated
Was this helpful?