Skip to content
On this page


EMQX exposes an HTTP management API designed following OpenAPI (Swagger) 3.0 specification.

After EMQX is started, you can visit http://localhost:18083/api-docs/index.html to view the API document, and also execute the management APIs from this UI.

The section will introduce how to work with EMQX REST API.

Basic Path

EMQX has version control on the REST API, all API paths from EMQX 5.0.0 start with /api/v5.


EMQX's REST API uses HTTP Basic Authentication.

You can create an API key by clicking System -> API Key from the left navigation menu on the Dashboard. For instructions on creating the API key, see System - API Keys.


For security reasons, starting with EMQX 5.0.0, Dashboard user cannot be used for REST API authentication.

You can use the generated API Key and Secret Key as the username and password for Basic authentication:

HTTP Headers

Unless otherwise specified, most API requests require the Accept header to be set to application/json, and then the response will be returned in JSON format.

HTTP Response Status Code

EMQX follows the HTTP Response Status Code standard, and the possible status codes are as follows:

200Request successfully, and the returned JSON data will provide more details
201Created successfully, and the new object will be returned in the Body
204Request successfully. Usually used for delete and update operations, and the returned Body will be empty
400Bad Request. Usually request body or parameter error
401Unauthorized. API key expires or does not exist.
403Forbidden. Check if the object is in use or has dependency constraints.
404Not Found. You can refer to the message field in the Body to check the reason
409Conflict. The object already exists or the number limit is exceeded
500Internal Server Error. Check the reason in the Body and logs

Error Codes

Besides the HTTP response status codes, EMQX also defines a list of error codes to identify specific errors.

When an error happens, the error code is returned in JSON format by the Body:

# GET /clients/foo

  "reason": "Client id not found"
Error CodesDescription
WRONG_USERNAME_OR_PWDWrong username or password
WRONG_USERNAME_OR_PWD_OR_API_KEY_OR_API_SECRETWrong username & password or key & secret
BAD_REQUESTRequest parameters not legal
NOT_MATCHConditions not matched
ALREADY_EXISTSResources already exist
BAD_CONFIG_SCHEMAConfiguration data not legal
BAD_RPCRPC Failed. Check the cluster status and the requested node status
BAD_TOPICTopic syntax error, topic needs to comply with the MQTT protocol standard
EXCEED_LIMITResources to be created exceed the maximum limit or minimum limit
INVALID_PARAMETERRequest parameters not legal and exceed the boundary value
CONFLICTConflicting request resources
NO_DEFAULT_VALUERequest parameters do not use default values
DEPENDENCY_EXISTSResource depends on other resources
MESSAGE_ID_SCHEMA_ERRORMessage ID parsing error
MESSAGE_ID_NOT_FOUNDMessage ID does not exist
NOT_FOUNDResource not found or does not exist
CLIENTID_NOT_FOUNDClient ID not found or does not exist
CLIENT_NOT_FOUNDClient not found or does not exist(usually not an MQTT client)
RESOURCE_NOT_FOUNDResource not found
TOPIC_NOT_FOUNDTopic not found
USER_NOT_FOUNDUser not found
INTERNAL_ERRORServer inter error
SERVICE_UNAVAILABLEService unavailable
SOURCE_ERRORSource error
REST_FAILEDReset source or configuration fails
CLIENT_NOT_RESPONSEClient not responding