Overview
One client-mode connector, Mender, for the Mender Management APIs on hosted Mender (https://hosted.mender.io). Mender is an open-source over-the-air (OTA) update manager for Linux edge devices. The connector covers four of its services, all behind the same token:
- Device inventory: list, read and search devices, tag them and put them in groups;
- Device authentication: list pending devices and accept or reject them;
- Deployments: list releases, start a deployment to devices or to a group, read its statistics and abort it;
- Mender Connect: ask an online device to check for an update or re-send its inventory right now.
All paths start with
/api/management. Topics use cloud-iot/mender/<object>/<verb>; replies land on <topic>/response. For hosted Mender in the EU, change BASE_ADDRESS to https://eu.hosted.mender.io. For a self-hosted Mender Server, use your own server address.
Authentication
Every event exceptLogin sends Authorization: Bearer <token>. Use a Personal Access Token: create it on the My profile page of the Mender UI, or call POST /api/management/v1/useradm/settings/tokens as described in Using the APIs. Tokens last up to one year, and Mender revokes them when your plan or add-ons change.
Pass the token as token on every payload. A missing, expired or invalid token returns 401.
Login exchanges email:password for a user JWT that expires after about a week. Pass basic_auth as the Base64 of email:password; the response is the JWT as plain text. Prefer a Personal Access Token on a broker: no password is stored, and accounts with two-factor authentication cannot use Basic login.
Basic Syntax
MQTT examples
Request bodies go underbody, so control fields like token, device_id and group are not sent to Mender.
Accept a new gateway: list pending devices by publishing to cloud-iot/mender/auth-device/list:
id and an auth_sets list. Accept it on cloud-iot/mender/auth-device/set-status:
cloud-iot/mender/device-tags/add:
{"token": "<token>", "device_id": "<device id>", "body": {"group": "line-1"}} on cloud-iot/mender/device-group/assign. A device belongs to one group at a time.
Find devices by inventory attribute: publish to cloud-iot/mender/device/search:
cloud-iot/mender/deployment/create-group:
201 and puts the new deployment id in the Location header; ListDeployments with "query": "status=inprogress" also returns it. To deploy to specific devices instead, use cloud-iot/mender/deployment/create with "devices": ["<device id>", ...] in the body. Get artifact names from cloud-iot/mender/release/list.
Track and abort a rollout: publish {"token": "<token>", "deployment_id": "<id>"} to cloud-iot/mender/deployment/statistics for per-status device counts (pending, downloading, installing, success, failure and more). To stop it, publish {"token": "<token>", "deployment_id": "<id>", "body": {"status": "aborted"}} to cloud-iot/mender/deployment/abort.
Ask a device to check now: publish {"token": "<token>", "device_id": "<device id>"} to cloud-iot/mender/device/check-update or cloud-iot/mender/device/send-inventory. These need Mender Connect running on the device and return 202; the device has to be online.
Helper actions
Keep the token in a broker secret, watch for new gateways on a timer, and let operators or line logic trigger rollouts and tags with small payloads:MenderPollPendingDevices publishes the pending device list to cloud-iot/mender/auth-device/list/response every ten minutes. MenderDeployToGroupOnRequest uses the artifact name as the deployment name. Restrict who can publish to ops/mender/# and read cloud-iot/mender/# with a rule: these topics can push software to devices and their payloads carry the token.
Notes
- Errors come back on the response topic:
401for a missing or invalid token,403when your plan or role does not allow the call,404for an unknown device, group or deployment,400or422for a bad body or an artifact that does not exist,409when a deployment has no target devices or a device is not connected, and429when rate limited. CountDevicesalways sendsstatus=, so pass one ofaccepted,pending,rejected,preauthorizedornoauth. Thequeryfield on list events must be URL-encoded.- Device ids are Mender’s own ids, not your device serial numbers. Find them with
SearchDevicesorListDevices. - Artifact upload, device decommissioning, configuration (
deviceconfig), remote terminal and file transfer, and user management are not part of this template. Upload artifacts withmender-clior the UI.

