Skip to content

API

The EMQX Platform API follows RESTful definitions, providing you with programmatic access to manage deployments in EMQX Platform. Through the API, you can manage authentication, clients, topics, and access more metric information.

The API has the following features:

  • JSON Format: All response content is presented in JSON format.
  • HTTPS Only: You can only access the API via HTTPS, ensuring that all data sent over the network is encrypted using TLS.
  • Key-based Access and Digest Authentication: Before accessing the EMQX Platform API, you must generate an API key. All requests are authenticated through HTTP digest authentication, ensuring that the API key is never sent over the network.

How to Use API

You can get the API access address in the API access section under the deployment details page.

Authentication

HTTP API uses Basic authentication method, ID and password must be filled in AppID and AppSecret respectively. You can add and remove AppID/AppSecret by creating new application in the API access under the deployment details page.

api

Construct Request

The request address consists of the following parts:

{API}/{resource-path}?{query-string}

Response code

HTTP status codes

The EMQX Broker interface always returns 200 OK when the call is successful, and the response content is returned in JSON format.

The possible status codes are as follows:

Status CodeDescription
200Success, and the returned JSON data will provide more information.
400Invalid client request, such as wrong request body or parameters.
401Client authentication failed , maybe because of invalid authentication credentials.
404The requested path cannot be found or the requested object does not exist.
500An internal error occurred while the server was processing the request.

Result codes

The response message body of the EMQX Broker interface is in JSON format, which always contains the returned code.

The possible result codes are as follows:

Return CodeDescription
0Success.
101RPC error.
102Unknown mistake.
103Wrong user name or password.
104Empty username or password.
105User does not exist.
106Administrator account cannot be deleted.
107Missing key request parameters.
108Request parameter error.
109Request parameters are not in legal JSON format.
110Plug-in is enabled.
111Plugin is closed.
112Client is offline.
113User already exists.
114Old password is wrong.
115Illegal subject.

API Versions

Depending on the different EMQX versions used in EMQX Platform, the API is also divided into versions based on EMQX 4.x and EMQX 5.x. Please choose the API version that corresponds to the type of deployment you have activated.