Fetch is one of the console tools in Mikrotik RouterOS. It is used to copy files to/from a network device via HTTP, FTP or SFTP (Support for SFTP added on v6.45), it can also be used to send POST/GET requests and send any kind of data to a remote server. The HTTPS protocol is supported; by default, no certificate checks are made, but setting check-certificate to yes enables trust chain validation from the local certificate store.


address (string; Default: )IP address of the device to copy file from.
as-value (set | not-set; Default: not-set)Store the output in a variable, should be used with the output property.
ascii (yes | no; Default: no)Can be used with FTP and TFTP
check-certificate (yes | yes-without-crl | no; Default: no)

Enables trust chain validation from local certificate store. yes-without-crl, validates the certificate, not performing CRL check (certificate revocation list)

dst-path (string; Default: )Destination filename and path
host (string; Default: )

A domain name or virtual domain name (if used on a website, from which you want to copy information). For example,

In this example the resolved ip address is the same (, but hosts are different.
http-method (|delete|get|post|put; Default: get)the HTTP method to use
http-data (string; Default: )the data, that is going to be sent, when using PUT or POST methods
http-header-field (string; Default: *empty*)list of all header fields and their values, in the form of http-header-field=h1:fff,h2:yyy
http-content-encoding (deflate|gzip; Default: *empty*)Encodes the payload using gzip or deflate compression and adds a corresponding Content-Encoding header. Usable for HTTP POST and PUT only.
keep-result (yes | no; Default: yes)If yes, creates an input file.
mode (ftp|http|tftp {!} https; Default: http)Choose the protocol of connection - http, https , ftp or tftp.
output (none|file|user; Default: file)Sets where to store the downloaded data.
  • none - do not store downloaded data
  • file - store downloaded data in a file
  • user - store downloaded data in the data variable (variable limit is 64Kb)
password (string; Default: anonymous)Password, which is needed for authentication to the remote device.
port (integer; Default: )Connection port.
src-path (string; Default: )Title of the remote file you need to copy.
upload (yes | no; Default: no)Only (S)FTP modes support uploads. If enabled then fetch will be used to upload files to a remote server. Requires src-path and dst-path parameters to be set.
url (string; Default: )URL pointing to file. Can be used instead of address and src-path parameters.
user (string; Default: anonymous)User name, which is needed for authentication to the remote device.

Configuration Examples

The following example shows how to copy the file with filename "conf.rsc" from a device with ip address by FTP protocol and save it as file with filename "123.rsc". User and password are needed to login into the device.

[admin@MikroTik] /tool> fetch address= src-path=conf.rsc \
user=admin mode=ftp password=123 dst-path=123.rsc port=21 \
host="" keep-result=yes

Example to upload file to another router:

[admin@MikroTik] /tool> fetch address= src-path=conf.rsc \
user=admin mode=ftp password=123 dst-path=123.rsc upload=yes

Another file download example that demonstrates the usage of url property.

[admin@MikroTik] /> /tool fetch url="" mode=http 
  status: finished

[admin@test_host] /> /file print 
 # NAME                     TYPE                  SIZE                 CREATION-TIME       
 5 netaddresses2.pdf        .pdf file             11547                jun/01/2010 11:59:51

Sending information to a remote host

It is possible to use an HTTP POST request to send information to a remote server, that is prepared to accept it. In the following example, we send geographic coordinates to a PHP page:

/tool/fetch http-method=post http-header-field="Content-Type:application/json" http-data="{\"lat\":\"56.12\",\"lon\":\"25.12\"}" url=""    

In this example, the data is uploaded as a file. Important note, since variable data comes from a file, a file can only be in size up to 4KB. This is a limitation of RouterOS variables.

/export file=export.rsc

:global data [/file get [/file find name=export.rsc] contents];
:global $url "";

/tool fetch mode=https http-method=put http-data=$data url=$url

Return value to a variable

It is possible to save the result of the fetch command to a variable. For example, it is possible to trigger a certain action based on the result that an HTTP page returns. You can find a very simple example below that disables ether2 whenever a PHP page returns "0":

    :local result [/tool fetch url= as-value output=user];
    :if ($result->"status" = "finished") do={
        :if ($result->"data" = "0") do={
            /interface ethernet set ether2 disabled=yes;
        } else={
            /interface ethernet set ether2 disabled=no;


Since 6.45beta50 /tool fetch support SFTP (SSH File Transfer Protocol) protocol:

[admin@MikroTik] > /tool fetch url="sftp://" user=x86 password=root dst-path=disk1
      status: downloading
  downloaded: 1048KiB
       total: 51200KiB
    duration: 6s
-- [Q quit|D dump|C-z pause]

  • No labels