NAV
shell

Introduction🔗

Documentation for CloudMQTT API.

Authentication🔗

Authentication is done by sending your API key in the password field in Basic Auth, the username should be kept empty.

curl -u :apikey \
  https://api.cloudmqtt.com/api/user

Instance🔗

curl -XPOST -u :apikey \
  https://api.cloudmqtt.com/api/instance/restart

POST https://api.cloudmqtt.com/api/instance/restart

curl -XPOST -u :apikey \
  https://api.cloudmqtt.com/api/instance/reset

POST https://api.cloudmqtt.com/api/instance/reset

Instance info🔗

curl -u :apikey \
  https://api.cloudmqtt.com/api/info/connections

GET https://api.cloudmqtt.com/api/info/connections

Users🔗

curl -u :apikey \
  https://api.cloudmqtt.com/api/user

The above command returns JSON structured like this:

[
  {
    "username":"test"
  }
]

GET https://api.cloudmqtt.com/api/user

Parameter Description
limit Limit number of records in result (max 1000)
page Page to fetch. 1-indexed.
query Filter result by matching start of usernames with query
curl -u :apikey \
  https://api.cloudmqtt.com/api/user/test

The above command returns JSON structured like this:

{
  "username":"test",
  "acls": [{
    "topic":"sensor/%u",
    "read":false,
    "write":true
  }]
}

GET https://api.cloudmqtt.com/api/user/<USERNAME>

Parameter Description
USERNAME Username of the user to get info about
curl -u :apikey \
-d '{"username":"test", "password":"super_secret_password"}' \
-H "content-type:application/json" https://api.cloudmqtt.com/api/user

POST https://api.cloudmqtt.com/api/user

Parameter Description
username Username for the new user
password Password for the new user
curl -XPUT -u :apikey \
-d '{"password":"super_secret_password"}' \
-H "content-type:application/json" https://api.cloudmqtt.com/api/user/test

# You can also pass the username in the body
curl -XPUT -u :apikey \
-d '{"username":"test","password":"super_secret_password"}' \
-H "content-type:application/json" https://api.cloudmqtt.com/api/user

PUT https://api.cloudmqtt.com/api/user/<USERNAME>

Parameter Description
USERNAME The user to update
Parameter Description
password New password for the user
curl -XDELETE -u :apikey \
https://api.cloudmqtt.com/api/user/test

# You can also pass the username in the body
curl -XDELETE -u :apikey \
-d username=foo \
https://api.cloudmqtt.com/api/user

DELETE https://api.cloudmqtt.com/api/user/<USERNAME>

Parameter Description
USERNAME The user to delete

ACL🔗

curl -u :apikey \
  https://api.cloudmqtt.com/api/acl

The above command returns JSON structured like this:

[
  {
    "type":"topic",
    "pattern":"test/users/topic",
    "read":true,
    "write":true,
    "username":"custom-user"
  },
  {
    "type":"pattern",
    "pattern":"sensor/%u/data",
    "read":true,
    "write":true,
    "username":null
  }
]

There are two types of ACL rules, topic and pattern. Topic ACLs is applied to a given user. Pattern ACLs is applied to all users.

Creating and deleting users and ACLs are asyncronous tasks and may take up to a minute. Poll list API to see when ready.

GET https://api.cloudmqtt.com/api/acl

curl -u :apikey \
-d '{"type": "topic", "username":"test", "pattern": "readonly", "read": true, "write": false}' \
-H "content-type:application/json" \
https://api.cloudmqtt.com/api/acl

POST https://api.cloudmqtt.com/api/acl

Parameter Description
type Which type of ACL rule to create
username Which user the rule applies to
pattern Pattern for which topics to match
read Allow reads
write Allow writes
curl -XDELETE -u :apikey \
-d '{"username":"test", "topic":"readonly"}'
-H "content-type:application/json" \
https://api.cloudmqtt.com/api/acl

DELETE https://api.cloudmqtt.com/api/acl

Parameter Description
username Delete rules for this user
topic Delete rules for this topic

Account🔗

Initiate rotation of the user password on your instance.

curl -XPOST -u :xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx \
  https://api.cloudmqtt.com/api/account/rotate-password

POST https://api.cloudmqtt.com/api/account/rotate-password

curl -XPOST -u :xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx \
  https://api.cloudmqtt.com/api/account/rotate-apikey

POST https://api.cloudmqtt.com/api/account/rotate-apikey

Maintenance🔗

List, run and reschedule maintenance

curl -XGET -u :xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx https://api.cloudmqtt.com/api/maintenance

The above command returns JSON structured like this:

[
  {
    "id": 1234,
    "scheduled_by": "2022-02-05 00:36:00 +0000",
    "status": "scheduled",
    "required_by": "2022-03-05 00:00:00 +0000",
    "duration": "1 hour",
    "description": "..."
  }
]

GET https://api.cloudmqtt.com/api/maintenance

curl -XPUT -u :xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx \
  -d '{"scheduled_by":"2022-02-05 00:36:00 +0000"}' \
  -H "Content-type: application/json" \
  https://api.cloudmqtt.com/api/maintenance/1234

PUT https://api.cloudmqtt.com/api/maintenance/<ID>

Parameter Description
scheduled_by Date string
Parameter Description
ID Maintenance id
curl -XPOST -u :xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx https://api.cloudmqtt.com/api/maintenance/<ID>
Parameter Description
ID Maintenance id

Formats🔗

All API end points support form FormData and JSON in the request. You need to format the request accordingly and if you send the request as JSON be sure to add the content type header content-type: application/json otherwise the server won't be able to parse your request.

Status Codes🔗

Status Code Meaning
200 The request completed successfully.
204 The request completed successfully.
400 Bad Request -- Your request might be invalid.
401 Unauthorized -- Your API key is wrong.
403 Forbidden -- The kitten requested is hidden for administrators only.
404 Not Found -- The specified kitten could not be found.
405 Method Not Allowed -- You tried to access a kitten with an invalid method.
429 Too Many Requests -- Rate limiting, you have requested too many kittens in a given amount of time.
500 Internal Server Error -- We had a problem with our server. Try again later.