HiveMQ Cloud REST API

The HiveMQ Cloud REST API provides an interface for applications to interact programmatically with HiveMQ Cloud.
Our REST API allows applications to send and receive data as JSON (JavaScript Object Notation) objects over standard HTTPS.

HiveMQ Cloud users can leverage the REST API to automate credentials management and numerous actions that they would otherwise perform manually. For example, delete specific MQTT user credentials, attach permissions to a role, and more.

HiveMQ Cloud REST API Endpoints

The endpoints the HiveMQ Cloud REST API offer fulfill many common use cases:

The HiveMQ Cloud Streaming events API is available for HiveMQ Cloud Enterprise clusters only. For more information about all the plans HiveMQ Cloud offers, contact HiveMQ sales.

HiveMQ uses the versatile and widely supported OpenAPI Specification to create standard, machine-readable, programming-language agnostic interface descriptions for REST API.

The style of the HiveMQ Cloud REST API focuses on providing scalability and extensibility. The OpenAPI 3.0 schema definition of the REST API can be easily imported into popular API tools such as Postman or used to generate client-code in a wide array of programming languages. For more information, see API Style.

Data Hub Endpoints - HiveMQ Cloud Enterprise

HiveMQ Cloud Enterprise clusters offer endpoints to manage HiveMQ Data Hub schemas, data policies, behavior policies, scripts, and module instances. A separate endpoint returns the Data Hub state of a client. For all endpoints that are available on HiveMQ Cloud Enterprise clusters, see the HiveMQ Cloud Enterprise REST API Specification.

Requirements

Access to the Data Hub endpoints is available on request. To request access for your organization, contact your HiveMQ account team or open a support case in the Get Help section of the HiveMQ Platform.

The Data Hub endpoints have two requirements:

  • Data Hub API access for your organization: Until HiveMQ enables access, every Data Hub endpoint returns HTTP status 403 with the following response body:

    {"error":"The Data Hub API is not enabled for this organization. To request access, open a support case at https://app.hivemq.com/get-help"}
  • Data Hub enabled on your cluster: If Data Hub is not enabled, every Data Hub endpoint returns HTTP status 404 with the following response body:

    {"errors":[{"title":"Resource not found"}]}

    To enable Data Hub on your HiveMQ Cloud Enterprise cluster, contact HiveMQ.

Request and Response Format

The Cloud REST API forwards each Data Hub request unchanged to the Data Hub REST API of the HiveMQ broker on your cluster. The request and response bodies use the format of the HiveMQ broker Data Hub REST API. For the format of each object, see Data Hub Schemas, Data Hub Policies, Data Hub Transformations, and Data Hub Modules.

Currently, HiveMQ backup and restore does not include Data Hub schemas, scripts, policies, or module instances. To prevent data loss, use the GET endpoints to keep a copy of your Data Hub configuration outside the cluster. After a restore, create the configuration again.

HiveMQ monitors the availability of each HiveMQ Cloud cluster with messages on topics that start with probes-hivemq-internal-monitoring/. If a Data Hub policy blocks or changes these messages, HiveMQ monitoring reports the cluster as unreachable.

Do not apply data policies to topics that start with probes-hivemq-internal-monitoring/. Check policies with a broad topic filter, such as #, because a broad filter also matches the monitoring topics.

The module instance endpoints require HiveMQ 4.36 or higher on the cluster. The lists of data policies and behavior policies do not include policies that a module instance creates.

Errors

The HiveMQ Cloud REST API returns validation errors from the HiveMQ broker unchanged. For example, if you delete a schema that a policy still references, the API returns HTTP status 400. Errors from the HiveMQ broker use the format {"errors":[…​]}, and errors from the Cloud REST API itself, such as 401 and 403, use the format {"error":"…​"}.

HiveMQ Cloud REST API Authorization Tokens

The HiveMQ Cloud REST API requires an API token. The token is a JSON Web Token (JWT) that grants programmatic access to manage MQTT credentials, MQTT roles, and MQTT permissions.

The HiveMQ Platform lists API tokens on the API Keys tab. In this documentation, "API token" and "API key" refer to the same credential.

On HiveMQ Cloud Enterprise clusters, the API token also grants access to the Data Hub endpoints after HiveMQ enables Data Hub API access for your organization. The permissions of the Cluster category control which Data Hub requests the token allows:

Permission Allowed requests

Read

GET

Write

POST, PUT, and PATCH

Delete

DELETE

If the API token lacks the required permission, the API returns HTTP status 401.

API Token Properties

Property Description

Token name

A unique name for the token on the cluster. The name must start with a letter and contain 2 to 16 alphanumeric characters (a-z, A-Z, and 0-9).

Lifetime

The length of time that the token is valid. The default setting is 7 days.

Access type

The permissions that the token grants. All grants all available permissions for the cluster, including MQTT roles and permissions. Custom grants only the permissions that you select.

Create an API Token

  1. Log in to the HiveMQ Platform at app.hivemq.com.

  2. Go to Connect > Connect & Manage Network, and select your HiveMQ Cloud broker.

  3. On the broker details page, switch to the API Keys tab, and click Generate Key.

  4. On the New API Key page, enter a unique name for the token in the Token name field.

  5. In the Lifetime field, select how long the token is valid.

  6. In the Access Type field, select All or Custom. If you select Custom, select the permissions that the token needs under Custom permissions.

  7. To generate the token, click Create API token.

  8. On the API Keys tab, click the copy icon next to the new token, and save the value in a secure location.

You can view the token value only once. After you leave the page, you cannot copy the token again.

Delete an API Token

When you delete an API token, HiveMQ revokes access to the API for that token immediately. You cannot undo the deletion. To regain access, create a new API token.

For more information about the available API endpoints and the request and response objects, see HiveMQ Cloud REST API Specification.

HiveMQ Cloud Enterprise clusters offer additional endpoints, including the Data Hub endpoints, which are available on request. For all endpoints that are available on HiveMQ Cloud Enterprise clusters, see the HiveMQ Cloud Enterprise REST API Specification.