The REST API for Mosquitto Management Center provides endpoints to return status data and allows active management of the Mosquitto Dynamic Security Plugin and the User Management. Mosquitto administrators can use the REST API to perform automated actions, which would normally be administered via the Management Center.
Authenticate / Login
In order to use the REST API you first need to authenticate. Note that after a successful login a cookie is created that contains the session id. This cookie needs to be passed to any further request to the API. For example when using the
curl command you can use the
--cookie-jar option for storing that cookie automatically and the
--cookie option for further requests to automatically read that cookie and pass it with the request.
The following command shows how to authenticate using
curl. Please replace the
<PASSWORD> placeholders accordingly:
<BASE_URL>: The base URL where the installation of the Management Center is hosted (including the protocol and base path, e.g., https://mosquitto.cedalo.com).
<USERNAME>: The name of the user which has access to the REST API.
<PASSWORD>: The password of the user which has access to the REST API.
curl --cookie-jar .cookies \
--request POST <BASE_URL>/auth \
-H 'Content-Type: application/x-www-form-urlencoded' \