Enabling devices
The API endpoint will allow you to enable or disable a device.
To access the API you must provide the `bearer token`.
Send a PUT
request to the API endpoint /api/orgs/{org-slug}/device/{device-id}/enable
with the body:
{
"enable": <requested state>
}
Where the requested state is enable
or disable
.
Replace {org-slug}
with your organisations slug.
Replace {device-id}
with the device id.
You can find your slug:
- in the organisations settings page
- from the organisations API
The device ID is available from the listing devices API
This will return a device with the enabled filed set to that requested in the PUT
, for example:
{
"address": 0,
"channel": 0,
"description": "Description-738",
"enabled": true,
"id": "
0197302f-faa4-7b73-8a82-0a0359b6c518",
"name": "Sensor-706"
}
Example:
curl -X 'PUT' \
'https://iotsimhub.net/api/orgs/<org-slug>/device/<device-id>/enable' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer <token>" \
-d '{ "enable": "enable" }'
API error codes
The endpoint will return errors in the format:
{
"errors": {
"details": <error response>
}
}
Error response | Description |
---|---|
Unauthorized | The request was not successful because: 1.You are not authenticated. 2. You are not part of the organisation |
Not found | The device ID was not found in this organisation |