Watch our video about this feature.

The term "REST API" generally refers to an API accessed via HTTP protocol at a predefined set of resource-oriented URLs.
Starting from RouterOS v7.1beta4, it is implemented as a JSON wrapper interface of the console API. It allows to create, read, update and delete resources and call arbitrary console commands.

To start using REST API, the www-ssl or www (starting with RouterOS v7.9) service must be configured and running. When the www-ssl service (HTTPS access) is enabled, the REST service can be accessed by connecting to https://<routers_IP>/rest. When www service (HTTP access) is enabled the REST service can be accessed by connecting to http://<routers_IP>/rest.

We do not advise enabling HTTP access (www service). The main risk is that authentication credentials can be read with passive eavesdropping. You can use it only when performing tests (not in a production environment) and when you are certain that nobody can listen in (inspect your traffic)!

The easiest way to start is to use cURL, wget, or any other HTTP client even RouterOS fetch tool.

$ curl -k -u admin:
"build-time":"Dec/04/2020 14:19:51","cpu":"tilegx","cpu-count":"16",
"uptime":"2d20h12m20s","version":"7.1beta4 (development)"}]


Authentication to the REST API is performed via HTTP Basic Auth. Provide your Username and password are the same as for the console user (by default "admin" with no password).

You have to set up certificates to use secure HTTPS, if self-signed certs are used, then CA must be imported to the trusted root. However, for testing purposes, it is possible to connect insecurely (for cUrl use -k flag, for wget use --no-check-certificate).

JSON format

Server broadly follows ECMA-404 standard, with following notes:

  • In JSON replies all object values are encoded as strings, even if the underlying data is a number or a boolean.
  • The server also accepts numbers in octal format (begins with 0) and hexadecimal format (begins with 0x). If the numbers are sent in a string format, they are assumed to be in decimal format.
  • Numbers with exponents are not supported.

HTTP Methods

Below is a table summarising supported HTTP methods

HTTP VervCRUDROSDescription
GETReadprintTo get the records.
PATCHUpdate/ModifysetTo update a single record.
PUTCreateaddTo create a new record.
DELETEDeleteremoveTo delete a single record.

Universal method to get access to all console commands.


This method allows getting the list of all records or a single record from the specified menu encoded in the URL.
For example, get all IP addresses (equivalent to the 'ip/address/print' command from the CLI):

$ curl -k -u admin:

To return a single record, append the ID at the end of the URL:

$ curl -k -u admin:*1

If table contains named parameters, then name instread of ID can be used, for example, get ether1:

$ curl -k -u admin:

It is also possible to filter the output, for example, return only valid addresses that belong to the network:

$ curl -k -u admin: ""

Another example returns only addresses on the "dummy" interface and with the comment "test":

$ curl -k -u admin: ''

If you want to return only specific properties, you can use the '.proplist', followed by the '=' and a list of comma-separated properties. For example, to show only the address and if it's disabled:

$ curl -k -u admin:,disabled


This method is used to update a single record. Set PATCH call body as a JSON object which contains fields and values of the properties to be updated. For example, add a comment:

$ curl -k -u admin: -X PATCH*3 \
  --data '{"comment": "test"}' -H "content-type: application/json"

In case of a successful update, the server returns the updated object with all its parameters.


A method is used to create new records in the menu encoded in the URL. The body should be set as a JSON object containing parameters applied to the newly created record.

In case of success, the server returns the created object with all its parameters.

Only one resource can be created in a single request.

For example, add an IP address to a dummy interface:

$ curl -k -u admin: -X PUT \
  --data '{"address": "", "interface": "dummy"}' -H "content-type: application/json"


This method is used to delete the record with a specified ID from the menu encoded in the URL. If the deletion has been succeeded, the server responds with an empty response. For example, call to delete the record twice, on second call router will return 404 error:

$ curl -k -u admin: -X DELETE*9
$ curl -k -u admin: -X DELETE*9
{"error":404,"message":"Not Found"}


All the API features are available through the POST method. The command word is encoded in the header and optional parameters are passed in the JSON object with the corresponding fields and values. For example, to change the password of the active user, send

POST https://router/rest/password
{"old-password":"old","new-password":"N3w", "confirm-new-password":"N3w"}

REST response is structured similar to API response: 

  • If the response contains '!re' sentences (records), the JSON reply will contain a list of objects.
  • If the '!done' sentence contains data, the JSON reply will contain an object with the data.
  • If there are no records or data in the '!done' sentence, the response will hold an empty list.

There are two special keys: .proplist and .query, which are used with the print command word. Read more about APIs responses, prop lists, and queries in the API documentation.


The '.proplist' key is used to create .proplist attribute word. The values can be a single string with comma-separated values:

POST https://router/rest/interface/print

or a list of strings:

POST https://router/rest/interface/print

For example, return address and interface properties from the ip/address list:

$ curl -k -u admin: -X POST\
  --data '{"_proplist": ["address","interface"]}' -H "content-type: application/json"


The '.query' key is used to create a query stack. The value is a list of query words. For example this POST request :

POST https://router/rest/interface/print

is equivalent to this API sentence


For example, let's combine 'query' and 'proplist', to return '.id', 'address', and 'interface' properties for all dynamic records and records with the network

$ curl -k -u admin: -X POST \
  --data '{".proplist": [".id","address","interface"], ".query": ["network=","dynamic=true","#|"]}'\
  -H "content-type: application/json"


If the command runs indefinitely, it will timeout and the connection will be closed with an error. The current timeout interval is 60 seconds. To avoid timeout errors, add a parameter that would sufficiently limit the command execution time.

Timeout is not affected by the parameters passed to the commands. If the command is set to run for an hour, it will terminate early and return an error message.

For example, let's see what we get when the ping command exceeds the timeout and how to prevent this by adding a count parameter:

$ curl -k -u admin: -X POST \
  --data '{"address":""}' \
  -H "content-type: application/json"
{"detail":"Session closed","error":400,"message":"Bad Request"}

$ curl -k -u admin: -X POST \
  --data '{"address":"","count":"4"}' \
  -H "content-type: application/json"

Another example is a bandwidth test tool, which can be limited by providing run duration:

$ curl -k -u admin: -X POST '' \
  --data '{"address":"","duration":"2s"}' \
  -H "content-type: application/json"
"status":"done testing"}]


The success or failure of the API calls is indicated in the HTTP status code. In case of failure (status code 400 or larger), the body of the response contains a JSON object with the error code, a description of the error, and optional error details. For example, trying to delete an interface will return

{"error":406,"message":"Not Acceptable","detail":"no such command or directory (remove)"}

  • No labels