You can update the runtime parameters with the Update the State of an nRF9x Device endpoint of the nRF Cloud API. The request body is merged into the existing device shadow, and a key set to null is deleted.
The requests need the following values:
- An organization auth token (OAT) with the
device:writepermission. Organization admins create tokens under Admin > Organization Auth Tokens > Create Token. - The organization slug and project slug, which you find under Project Settings > General.
Set them as environment variables, together with the device ID:
export NRFCLOUD_OAT=<your-organization-auth-token>
export NRFCLOUD_ORG=<your-organization-slug>
export NRFCLOUD_PROJECT=<your-project-slug>
export DEVICE_ID=<your-device-id>
export BASE="https://api.nrfcloud.com/v1/organizations/$NRFCLOUD_ORG/projects/$NRFCLOUD_PROJECT"
Example 1 sets a 5-minute sampling interval and sends data immediately after each sample:
curl -X PATCH "$BASE/long-range/devices/$DEVICE_ID/state" \
-H "Authorization: Bearer $NRFCLOUD_OAT" \
-H "Content-Type: application/json" \
-d '{ "desired": { "config": { "sample_interval": 300, "storage_threshold": 1 } } }'
Example 2 sets a 10-minute sampling interval and sends data after six samples, which is once per hour:
curl -X PATCH "$BASE/long-range/devices/$DEVICE_ID/state" \
-H "Authorization: Bearer $NRFCLOUD_OAT" \
-H "Content-Type: application/json" \
-d '{ "desired": { "config": { "sample_interval": 600, "storage_threshold": 6 } } }'
To read the current shadow, including the reported, desired, and delta sections, use the Retrieve the State of an nRF9x Device endpoint:
curl "$BASE/long-range/devices/$DEVICE_ID/state" \
-H "Authorization: Bearer $NRFCLOUD_OAT"
For more information, see Device Shadow and Transitioning the REST API in the nRF Cloud documentation.