MikrotikApi (mikrotik_api v0.3.4)
View SourcePublic API for interacting with MikroTik RouterOS REST endpoints.
Usage pattern:
- Establish an %MikrotikApi.Auth{} once.
- Pass Auth and a target IP (IPv4/IPv6 literal) to each call.
Transport via OTP; JSON via Elixir's built-in JSON. Logging uses Logger only.
Summary
Functions
GET /ip/arp
PUT /interface/bridge - create a bridge interface. RouterOS REST API uses PUT for creating resources.
DELETE /interface/bridge/{id}
Ensure a bridge exists by name. Returns {:ok, name} if found or created.
GET /interface/bridge
PUT /interface/bridge/port - create a bridge port. RouterOS REST API uses PUT for creating resources.
DELETE /interface/bridge/port/{id}
Ensure a bridge port exists for the given bridge and interface. Returns {:ok, {bridge, interface}} when found or created.
GET /interface/bridge/port
PATCH /interface/bridge/port/{id}
PATCH /interface/bridge/{id}
PUT /interface/bridge/vlan - create a bridge VLAN entry. RouterOS REST API uses PUT for creating resources.
DELETE /interface/bridge/vlan/{id}
Ensure a bridge VLAN entry exists for the given bridge and vlan-ids. Returns {:ok, {bridge, vlan_ids}} when found or created.
GET /interface/bridge/vlan
PATCH /interface/bridge/vlan/{id}
Generic call. See get/3, post/4, put/4, patch/4, delete/3. opts: :body (map or list), :params (map), :headers (list), :scheme (:https | :http), :port (integer)
GET /caps-man/interface
PUT /caps-man/provisioning - create a CAPsMAN provisioning rule. RouterOS REST API uses PUT for creating resources.
Ensure a CAPsMAN provisioning rule exists. By default matches by ["action", "master-configuration"]. Returns {:ok, map()} of matched keys when found or created.
GET /caps-man/provisioning
GET /caps-man/registration-table
PUT /caps-man/security - create a CAPsMAN security profile. RouterOS REST API uses PUT for creating resources.
Ensure a CAPsMAN security profile with the given name exists.
GET /caps-man/security
GET /certificate
GET /container
DELETE a path under /rest on the target.
PUT /ip/dhcp-server/lease - create a DHCP lease. RouterOS REST API uses PUT for creating resources.
DELETE /ip/dhcp-server/lease/{id}
Ensure a DHCP lease exists. Matches by ["address", "mac-address"]. Returns {:ok, %{address: ..., mac: ...}} if found or created.
GET /ip/dhcp-server/lease
PATCH /ip/dhcp-server/lease/{id}
POST /ip/dns/cache/flush - flush the DNS cache.
GET /ip/dns/cache
GET /ip/dns (config/stats)
GET /ip/dns - alias for dns_config for consistency with REST pattern.
POST /ip/dns/set - update DNS server settings.
PUT /ip/dns/static - create a DNS static record. RouterOS REST API uses PUT for creating resources.
DELETE /ip/dns/static/{id}
Ensure a DNS static record exists by name. If present, patches only differing keys. Returns {:ok, %{id: id | name, name: name, changed: [keys]}}.
GET /ip/dns/static
PATCH /ip/dns/static/{id}
Create a WireGuard interface on router A, then replicate its private key to router B.
GET /interface/eoip
GET /interface/ethernet/poe
GET /interface/ethernet/switch/port
GET /ip/firewall/address-list
GET /ip/firewall/connection
PUT /ip/firewall/filter - create a firewall filter rule. RouterOS REST API uses PUT for creating resources.
DELETE /ip/firewall/filter/{id}
Ensure a firewall filter rule exists. By default, matches existing by ["chain", "action"]. You can pass unique_keys: [..] in opts to control matching. Returns {:ok, Map.t()} with the matched key-values when found or created.
GET /ip/firewall/filter
PUT /ip/firewall/nat - create a firewall NAT rule. RouterOS REST API uses PUT for creating resources.
DELETE /ip/firewall/nat/{id}
Ensure a firewall NAT rule exists. By default matches by ["chain", "action"]. You can pass unique_keys: [..] in opts. Returns {:ok, map()} of matched keys when found or created.
GET /ip/firewall/nat
GET a path under /rest on the target.
PUT /interface/gre - create a GRE interface. RouterOS REST API uses PUT for creating resources. Falls back to POST /interface/gre/add on older RouterOS versions.
DELETE /interface/gre/{id}
Ensure a GRE interface by name or .id. If present, patches only differing keys. Returns {:ok, %{id: id | name, name: name, changed: [keys]}}.
GET /interface/gre
PATCH /interface/gre/{id}
Convenience: set disabled=yes
Convenience: set disabled=no
Ensure interface settings. Ident can be an interface name or .id. Applies only differing keys from attrs. Returns {:ok, %{id: id, name: name, changed: [keys]}} when up-to-date or updated; {:error, not_found} if interface not present.
GET /interface/ethernet/monitor/{ident}
GET /interface
PATCH /interface/{id} with attrs
PUT /ip/address - create an IP address. RouterOS REST API uses PUT for creating resources.
DELETE /ip/address/{id}
Ensure an IP address exists on an interface. Requires attrs to include at least "address" and optionally "interface"; matches existing entries by these keys. Returns {:ok, address} when found or created.
GET /ip/address
PATCH /ip/address/{id}
GET /ip/cloud
GET /ip/pool
GET /interface/ipip
GET /ipv6/firewall/address-list
GET /ipv6/firewall/filter
GET /ipv6/neighbor
GET /ipv6/pool
GET /ipv6/route
Execute the same REST call concurrently across multiple IPs.
GET /ip/neighbor
PATCH JSON to a path under /rest on the target.
POST JSON to a path under /rest on the target.
Probe core device info and summarize.
Probe wireless (legacy) and wifi (wifiwave2) endpoint availability and summarize.
PUT JSON to a path under /rest on the target.
GET /queue/simple
GET /queue/tree
PUT /ip/route - create a route. RouterOS REST API uses PUT for creating resources.
DELETE /ip/route/{id}
Ensure a route exists. Matches by ["dst-address", "gateway"]. Returns {:ok, %{dst: ..., gw: ...}} if found or created.
GET /ip/route
GET /routing/bfd/session
GET /routing/bgp/session
GET /routing/stats
GET /system/health
GET /system/identity
POST /system/identity/set - update the system identity (router name).
GET /system/package
GET /system/resource
GET /tool/netwatch
GET /user/active
PUT /user - create a new user. RouterOS REST API uses PUT for creating resources.
DELETE /user/{id} - delete a user by .id.
Ensure a user exists by name. If present, patches only differing keys. Returns {:ok, %{id: id | name, name: name, changed: [keys]}}.
GET /user/group
GET /user
PATCH /user/{id} - update a user by .id.
GET /interface/wifi
PATCH /interface/wifi/{id}
PUT /interface/wifi/security - create a WiFi security profile. RouterOS REST API uses PUT for creating resources.
DELETE /interface/wifi/security/{id}
Ensure a WiFi security profile with the given name exists; returns the found or created entry name. If the endpoint is unavailable, returns the underlying error.
GET /interface/wifi/security
PATCH /interface/wifi/security/{id}
PUT /interface/wifi/ssid - create a WiFi SSID. RouterOS REST API uses PUT for creating resources.
DELETE /interface/wifi/ssid/{id}
Ensure a WiFi SSID with the given name exists; returns the found or created entry name. If the endpoint is unavailable (:wifi_ssid_unavailable), returns the underlying error.
GET /interface/wifi/ssid
PATCH /interface/wifi/ssid/{id}
Create a WireGuard interface across a cluster of routers.
Add or update WireGuard peers across a cluster on an existing interface.
PUT /interface/wireguard - create a WireGuard interface. RouterOS REST API uses PUT for creating resources. Falls back to POST /interface/wireguard/add on older RouterOS versions.
DELETE /interface/wireguard/{id}
Ensure a WireGuard interface by name. If present, patches only differing keys. Returns {:ok, %{id: id | name, name: name, changed: [keys]}} when up-to-date or updated; {:error, not_found} if list fails. Note: On create, the actual .id may not be known immediately; id will fallback to the provided name.
POST /interface/wireguard/getall with a .proplist to retrieve fields like private-key and public-key.
GET /interface/wireguard
PATCH /interface/wireguard/{id}
PUT /interface/wireguard/peers - create a WireGuard peer. RouterOS REST API uses PUT for creating resources. Falls back to POST /interface/wireguard/peers/add on older RouterOS versions.
DELETE /interface/wireguard/peers/{id}
Ensure a WireGuard peer identified by {interface, public-key} exists with desired attributes. Only differing keys are patched. Returns {:ok, %{id: id | public-key, interface: name, changed: [keys]}}.
GET /interface/wireguard/peers
PATCH /interface/wireguard/peers/{id}
PUT /interface/wireless - create a wireless interface. RouterOS REST API uses PUT for creating resources.
DELETE /interface/wireless/{id}
Ensure a legacy wireless interface exists by name.
GET /interface/wireless
PATCH /interface/wireless/{id}
GET /interface/wireless/registration-table
PUT /interface/wireless/security-profiles - create a wireless security profile. RouterOS REST API uses PUT for creating resources.
DELETE /interface/wireless/security-profiles/{id}
Ensure a legacy wireless security profile exists by name.
GET /interface/wireless/security-profiles
PATCH /interface/wireless/security-profiles/{id}
Types
Functions
@spec arp_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /ip/arp
@spec bridge_add(MikrotikApi.Auth.t(), String.t(), map() | list(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PUT /interface/bridge - create a bridge interface. RouterOS REST API uses PUT for creating resources.
@spec bridge_delete(MikrotikApi.Auth.t(), String.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
DELETE /interface/bridge/{id}
@spec bridge_ensure(MikrotikApi.Auth.t(), String.t(), String.t(), map(), Keyword.t()) :: {:ok, String.t()} | {:error, MikrotikApi.Error.t()}
Ensure a bridge exists by name. Returns {:ok, name} if found or created.
@spec bridge_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /interface/bridge
@spec bridge_port_add(MikrotikApi.Auth.t(), String.t(), map() | list(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PUT /interface/bridge/port - create a bridge port. RouterOS REST API uses PUT for creating resources.
@spec bridge_port_delete(MikrotikApi.Auth.t(), String.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
DELETE /interface/bridge/port/{id}
@spec bridge_port_ensure( MikrotikApi.Auth.t(), String.t(), String.t(), String.t(), map(), Keyword.t() ) :: {:ok, {String.t(), String.t()}} | {:error, MikrotikApi.Error.t()}
Ensure a bridge port exists for the given bridge and interface. Returns {:ok, {bridge, interface}} when found or created.
@spec bridge_port_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /interface/bridge/port
@spec bridge_port_update( MikrotikApi.Auth.t(), String.t(), String.t(), map() | list(), Keyword.t() ) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PATCH /interface/bridge/port/{id}
@spec bridge_update( MikrotikApi.Auth.t(), String.t(), String.t(), map() | list(), Keyword.t() ) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PATCH /interface/bridge/{id}
@spec bridge_vlan_add(MikrotikApi.Auth.t(), String.t(), map() | list(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PUT /interface/bridge/vlan - create a bridge VLAN entry. RouterOS REST API uses PUT for creating resources.
@spec bridge_vlan_delete(MikrotikApi.Auth.t(), String.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
DELETE /interface/bridge/vlan/{id}
@spec bridge_vlan_ensure( MikrotikApi.Auth.t(), String.t(), String.t(), String.t(), map(), Keyword.t() ) :: {:ok, {String.t(), String.t()}} | {:error, MikrotikApi.Error.t()}
Ensure a bridge VLAN entry exists for the given bridge and vlan-ids. Returns {:ok, {bridge, vlan_ids}} when found or created.
@spec bridge_vlan_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /interface/bridge/vlan
@spec bridge_vlan_update( MikrotikApi.Auth.t(), String.t(), String.t(), map() | list(), Keyword.t() ) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PATCH /interface/bridge/vlan/{id}
@spec call(MikrotikApi.Auth.t(), String.t(), method(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
Generic call. See get/3, post/4, put/4, patch/4, delete/3. opts: :body (map or list), :params (map), :headers (list), :scheme (:https | :http), :port (integer)
@spec capsman_interface_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /caps-man/interface
@spec capsman_provisioning_add( MikrotikApi.Auth.t(), String.t(), map() | list(), Keyword.t() ) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PUT /caps-man/provisioning - create a CAPsMAN provisioning rule. RouterOS REST API uses PUT for creating resources.
@spec capsman_provisioning_ensure( MikrotikApi.Auth.t(), String.t(), map(), Keyword.t() ) :: {:ok, map()} | {:error, MikrotikApi.Error.t()}
Ensure a CAPsMAN provisioning rule exists. By default matches by ["action", "master-configuration"]. Returns {:ok, map()} of matched keys when found or created.
@spec capsman_provisioning_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /caps-man/provisioning
@spec capsman_registration_table(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /caps-man/registration-table
@spec capsman_security_add( MikrotikApi.Auth.t(), String.t(), map() | list(), Keyword.t() ) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PUT /caps-man/security - create a CAPsMAN security profile. RouterOS REST API uses PUT for creating resources.
@spec capsman_security_ensure( MikrotikApi.Auth.t(), String.t(), String.t(), map(), Keyword.t() ) :: {:ok, String.t()} | {:error, MikrotikApi.Error.t()}
Ensure a CAPsMAN security profile with the given name exists.
@spec capsman_security_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /caps-man/security
@spec certificate_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /certificate
@spec container_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /container
@spec delete(MikrotikApi.Auth.t(), String.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
DELETE a path under /rest on the target.
@spec dhcp_lease_add(MikrotikApi.Auth.t(), String.t(), map() | list(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PUT /ip/dhcp-server/lease - create a DHCP lease. RouterOS REST API uses PUT for creating resources.
@spec dhcp_lease_delete(MikrotikApi.Auth.t(), String.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
DELETE /ip/dhcp-server/lease/{id}
@spec dhcp_lease_ensure(MikrotikApi.Auth.t(), String.t(), map(), Keyword.t()) :: {:ok, map()} | {:error, MikrotikApi.Error.t()}
Ensure a DHCP lease exists. Matches by ["address", "mac-address"]. Returns {:ok, %{address: ..., mac: ...}} if found or created.
@spec dhcp_lease_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /ip/dhcp-server/lease
@spec dhcp_lease_update( MikrotikApi.Auth.t(), String.t(), String.t(), map() | list(), Keyword.t() ) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PATCH /ip/dhcp-server/lease/{id}
@spec dns_cache_flush(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
POST /ip/dns/cache/flush - flush the DNS cache.
@spec dns_cache_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /ip/dns/cache
@spec dns_config(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /ip/dns (config/stats)
@spec dns_settings_get(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /ip/dns - alias for dns_config for consistency with REST pattern.
@spec dns_settings_set(MikrotikApi.Auth.t(), String.t(), map() | list(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
POST /ip/dns/set - update DNS server settings.
@spec dns_static_add(MikrotikApi.Auth.t(), String.t(), map() | list(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PUT /ip/dns/static - create a DNS static record. RouterOS REST API uses PUT for creating resources.
@spec dns_static_delete(MikrotikApi.Auth.t(), String.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
DELETE /ip/dns/static/{id}
@spec dns_static_ensure( MikrotikApi.Auth.t(), String.t(), String.t(), map(), Keyword.t() ) :: {:ok, %{id: String.t(), name: String.t(), changed: [String.t()]}} | {:error, term()}
Ensure a DNS static record exists by name. If present, patches only differing keys. Returns {:ok, %{id: id | name, name: name, changed: [keys]}}.
@spec dns_static_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /ip/dns/static
@spec dns_static_update( MikrotikApi.Auth.t(), String.t(), String.t(), map() | list(), Keyword.t() ) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PATCH /ip/dns/static/{id}
@spec ensure_wireguard_pair( MikrotikApi.Auth.t(), String.t(), String.t(), String.t(), String.t(), map(), Keyword.t() ) :: {:ok, %{a: map(), b: map()}} | {:error, MikrotikApi.Error.t() | term()}
Create a WireGuard interface on router A, then replicate its private key to router B.
Sequential steps (no concurrency):
- Ensure interface on A with provided attrs (RouterOS may generate private-key).
- Read back interface list on A; locate the entry by name and extract "private-key".
- If not present, returns {:error, %MikrotikApi.Error{reason: :wireguard_private_key_unreadable}}.
- Ensure interface on B with the same "private-key" plus provided attrs.
Security: Never logs the private key. The returned value does not include the key.
@spec eoip_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /interface/eoip
@spec ethernet_poe_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /interface/ethernet/poe
@spec ethernet_switch_port_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /interface/ethernet/switch/port
@spec firewall_address_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /ip/firewall/address-list
@spec firewall_connection_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /ip/firewall/connection
@spec firewall_filter_add( MikrotikApi.Auth.t(), String.t(), map() | list(), Keyword.t() ) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PUT /ip/firewall/filter - create a firewall filter rule. RouterOS REST API uses PUT for creating resources.
@spec firewall_filter_delete( MikrotikApi.Auth.t(), String.t(), String.t(), Keyword.t() ) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
DELETE /ip/firewall/filter/{id}
@spec firewall_filter_ensure(MikrotikApi.Auth.t(), String.t(), map(), Keyword.t()) :: {:ok, map()} | {:error, MikrotikApi.Error.t()}
Ensure a firewall filter rule exists. By default, matches existing by ["chain", "action"]. You can pass unique_keys: [..] in opts to control matching. Returns {:ok, Map.t()} with the matched key-values when found or created.
@spec firewall_filter_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /ip/firewall/filter
@spec firewall_nat_add(MikrotikApi.Auth.t(), String.t(), map() | list(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PUT /ip/firewall/nat - create a firewall NAT rule. RouterOS REST API uses PUT for creating resources.
@spec firewall_nat_delete(MikrotikApi.Auth.t(), String.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
DELETE /ip/firewall/nat/{id}
@spec firewall_nat_ensure(MikrotikApi.Auth.t(), String.t(), map(), Keyword.t()) :: {:ok, map()} | {:error, MikrotikApi.Error.t()}
Ensure a firewall NAT rule exists. By default matches by ["chain", "action"]. You can pass unique_keys: [..] in opts. Returns {:ok, map()} of matched keys when found or created.
@spec firewall_nat_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /ip/firewall/nat
@spec get(MikrotikApi.Auth.t(), String.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET a path under /rest on the target.
@spec gre_add(MikrotikApi.Auth.t(), String.t(), map() | list(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PUT /interface/gre - create a GRE interface. RouterOS REST API uses PUT for creating resources. Falls back to POST /interface/gre/add on older RouterOS versions.
@spec gre_delete(MikrotikApi.Auth.t(), String.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
DELETE /interface/gre/{id}
@spec gre_ensure(MikrotikApi.Auth.t(), String.t(), String.t(), map(), Keyword.t()) :: {:ok, %{id: String.t(), name: String.t(), changed: [String.t()]}} | {:error, term()}
Ensure a GRE interface by name or .id. If present, patches only differing keys. Returns {:ok, %{id: id | name, name: name, changed: [keys]}}.
@spec gre_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /interface/gre
@spec gre_update( MikrotikApi.Auth.t(), String.t(), String.t(), map() | list(), Keyword.t() ) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PATCH /interface/gre/{id}
@spec interface_disable(MikrotikApi.Auth.t(), String.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
Convenience: set disabled=yes
@spec interface_enable(MikrotikApi.Auth.t(), String.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
Convenience: set disabled=no
@spec interface_ensure( MikrotikApi.Auth.t(), String.t(), String.t(), map(), Keyword.t() ) :: {:ok, %{id: String.t(), name: String.t(), changed: [String.t()]}} | {:error, term()}
Ensure interface settings. Ident can be an interface name or .id. Applies only differing keys from attrs. Returns {:ok, %{id: id, name: name, changed: [keys]}} when up-to-date or updated; {:error, not_found} if interface not present.
@spec interface_ethernet_monitor( MikrotikApi.Auth.t(), String.t(), String.t(), Keyword.t() ) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /interface/ethernet/monitor/{ident}
@spec interface_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /interface
@spec interface_update( MikrotikApi.Auth.t(), String.t(), String.t(), map() | list(), Keyword.t() ) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PATCH /interface/{id} with attrs
@spec ip_address_add(MikrotikApi.Auth.t(), String.t(), map() | list(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PUT /ip/address - create an IP address. RouterOS REST API uses PUT for creating resources.
@spec ip_address_delete(MikrotikApi.Auth.t(), String.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
DELETE /ip/address/{id}
@spec ip_address_ensure(MikrotikApi.Auth.t(), String.t(), map(), Keyword.t()) :: {:ok, String.t()} | {:error, MikrotikApi.Error.t()}
Ensure an IP address exists on an interface. Requires attrs to include at least "address" and optionally "interface"; matches existing entries by these keys. Returns {:ok, address} when found or created.
@spec ip_address_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /ip/address
@spec ip_address_update( MikrotikApi.Auth.t(), String.t(), String.t(), map() | list(), Keyword.t() ) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PATCH /ip/address/{id}
@spec ip_cloud_info(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /ip/cloud
@spec ip_pool_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /ip/pool
@spec ipip_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /interface/ipip
@spec ipv6_firewall_address_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /ipv6/firewall/address-list
@spec ipv6_firewall_filter_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /ipv6/firewall/filter
@spec ipv6_neighbor_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /ipv6/neighbor
@spec ipv6_pool_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /ipv6/pool
@spec ipv6_route_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /ipv6/route
@spec multi( MikrotikApi.Auth.t(), [String.t()], method(), String.t(), Keyword.t(), Keyword.t() ) :: [ %{ ip: String.t(), result: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()} } ]
Execute the same REST call concurrently across multiple IPs.
- ips: list of target IPs (IPv4/IPv6 as strings)
method: :get | :post | :put | :patch | :delete
- path: string path under /rest (e.g., "/system/resource")
- opts: keyword options accepted by call/5 (e.g., scheme:, decode:, params:, headers:, body: for write methods)
- stream_opts:
- :max_concurrency (default System.schedulers_online())
- :timeout (default 15_000 ms)
Returns a list in input order: [%{ip: ip, result: {:ok, value} | {:error, %MikrotikApi.Error{}}}]
@spec neighbor_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /ip/neighbor
@spec patch(MikrotikApi.Auth.t(), String.t(), String.t(), map() | list(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PATCH JSON to a path under /rest on the target.
@spec post( MikrotikApi.Auth.t(), String.t(), String.t(), map() | list() | nil, Keyword.t() ) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
POST JSON to a path under /rest on the target.
@spec probe_device(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, map()} | {:error, MikrotikApi.Error.t()}
Probe core device info and summarize.
Returns a map with keys:
system: {:ok, map()} | {:error, error_summary}
counts: %{interfaces: n | nil, ip_addresses: n | nil, arp: n | nil, neighbors: n | nil}
Accepts same opts as other calls (e.g., scheme: :http | :https).
@spec probe_wireless(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, map()} | {:error, MikrotikApi.Error.t()}
Probe wireless (legacy) and wifi (wifiwave2) endpoint availability and summarize.
Returns a map with sections :wireless and :wifi, each containing endpoint keys and status maps like %{status: :ok | :unavailable | :error, count: non_neg_integer | nil, reason: term() | nil, status_code: integer | nil}.
Accepts the same opts as other calls (e.g., scheme: :http | :https).
@spec put(MikrotikApi.Auth.t(), String.t(), String.t(), map() | list(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PUT JSON to a path under /rest on the target.
@spec queue_simple_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /queue/simple
@spec queue_tree_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /queue/tree
@spec route_add(MikrotikApi.Auth.t(), String.t(), map() | list(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PUT /ip/route - create a route. RouterOS REST API uses PUT for creating resources.
@spec route_delete(MikrotikApi.Auth.t(), String.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
DELETE /ip/route/{id}
@spec route_ensure(MikrotikApi.Auth.t(), String.t(), map(), Keyword.t()) :: {:ok, map()} | {:error, MikrotikApi.Error.t()}
Ensure a route exists. Matches by ["dst-address", "gateway"]. Returns {:ok, %{dst: ..., gw: ...}} if found or created.
@spec route_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /ip/route
@spec routing_bfd_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /routing/bfd/session
@spec routing_bgp_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /routing/bgp/session
@spec routing_stats(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /routing/stats
@spec system_health(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /system/health
@spec system_identity(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /system/identity
@spec system_identity_set(MikrotikApi.Auth.t(), String.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
POST /system/identity/set - update the system identity (router name).
@spec system_packages(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /system/package
@spec system_resource(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /system/resource
@spec tool_netwatch_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /tool/netwatch
@spec user_active_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /user/active
@spec user_add(MikrotikApi.Auth.t(), String.t(), map() | list(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PUT /user - create a new user. RouterOS REST API uses PUT for creating resources.
@spec user_delete(MikrotikApi.Auth.t(), String.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
DELETE /user/{id} - delete a user by .id.
@spec user_ensure(MikrotikApi.Auth.t(), String.t(), String.t(), map(), Keyword.t()) :: {:ok, %{id: String.t(), name: String.t(), changed: [String.t()]}} | {:error, term()}
Ensure a user exists by name. If present, patches only differing keys. Returns {:ok, %{id: id | name, name: name, changed: [keys]}}.
@spec user_group_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /user/group
@spec user_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /user
@spec user_update( MikrotikApi.Auth.t(), String.t(), String.t(), map() | list(), Keyword.t() ) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PATCH /user/{id} - update a user by .id.
@spec wifi_interface_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /interface/wifi
@spec wifi_interface_update( MikrotikApi.Auth.t(), String.t(), String.t(), map() | list(), Keyword.t() ) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PATCH /interface/wifi/{id}
@spec wifi_security_add(MikrotikApi.Auth.t(), String.t(), map() | list(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PUT /interface/wifi/security - create a WiFi security profile. RouterOS REST API uses PUT for creating resources.
@spec wifi_security_delete(MikrotikApi.Auth.t(), String.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
DELETE /interface/wifi/security/{id}
@spec wifi_security_ensure( MikrotikApi.Auth.t(), String.t(), String.t(), map(), Keyword.t() ) :: {:ok, String.t()} | {:error, MikrotikApi.Error.t()}
Ensure a WiFi security profile with the given name exists; returns the found or created entry name. If the endpoint is unavailable, returns the underlying error.
@spec wifi_security_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /interface/wifi/security
@spec wifi_security_update( MikrotikApi.Auth.t(), String.t(), String.t(), map() | list(), Keyword.t() ) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PATCH /interface/wifi/security/{id}
@spec wifi_ssid_add(MikrotikApi.Auth.t(), String.t(), map() | list(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PUT /interface/wifi/ssid - create a WiFi SSID. RouterOS REST API uses PUT for creating resources.
@spec wifi_ssid_delete(MikrotikApi.Auth.t(), String.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
DELETE /interface/wifi/ssid/{id}
@spec wifi_ssid_ensure( MikrotikApi.Auth.t(), String.t(), String.t(), map(), Keyword.t() ) :: {:ok, String.t()} | {:error, MikrotikApi.Error.t()}
Ensure a WiFi SSID with the given name exists; returns the found or created entry name. If the endpoint is unavailable (:wifi_ssid_unavailable), returns the underlying error.
@spec wifi_ssid_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /interface/wifi/ssid
@spec wifi_ssid_update( MikrotikApi.Auth.t(), String.t(), String.t(), map() | list(), Keyword.t() ) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PATCH /interface/wifi/ssid/{id}
@spec wireguard_cluster_add( MikrotikApi.Auth.t(), [String.t()], String.t(), map(), Keyword.t() ) :: {:ok, %{ primary: %{ip: String.t(), result: map()}, members: [ %{ip: String.t(), result: {:ok, map()} | {:error, MikrotikApi.Error.t()}} ], public_key: String.t() }} | {:error, MikrotikApi.Error.t() | term()}
Create a WireGuard interface across a cluster of routers.
Workflow:
- Choose the first router in the list as the primary (key source).
- Ensure the interface on the primary WITHOUT sending a private-key (allow RouterOS to auto-generate).
- Retrieve the private-key (and public-key) from the primary; falls back to getall if list omits it.
- Ensure the interface with the same private-key on all other routers concurrently.
Returns {:ok, %{primary: %{ip: ip, result: map()}, members: [%{ip: ip, result: {:ok, map()} | {:error, %MikrotikApi.Error{}}}], public_key: String.t()}} on success.
@spec wireguard_cluster_add_peers( MikrotikApi.Auth.t(), [String.t()], String.t(), [map()], Keyword.t() ) :: {:ok, [ %{ ip: String.t(), results: [ok: map(), error: MikrotikApi.Error.t() | term()] } ]}
Add or update WireGuard peers across a cluster on an existing interface.
- ips: list of router IPs (all members to apply peers to)
- name: wireguard interface name (e.g., "wg0"); will be set on each peer attrs
- peers: list of peer maps, each requiring at least "public-key"; optional keys include "allowed-address", "endpoint-address", "endpoint-port", "persistent-keepalive", etc.
Returns {:ok, [%{ip: ip, results: [result_per_peer]}]}.
@spec wireguard_interface_add( MikrotikApi.Auth.t(), String.t(), map() | list(), Keyword.t() ) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PUT /interface/wireguard - create a WireGuard interface. RouterOS REST API uses PUT for creating resources. Falls back to POST /interface/wireguard/add on older RouterOS versions.
@spec wireguard_interface_delete( MikrotikApi.Auth.t(), String.t(), String.t(), Keyword.t() ) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
DELETE /interface/wireguard/{id}
@spec wireguard_interface_ensure( MikrotikApi.Auth.t(), String.t(), String.t(), map(), Keyword.t() ) :: {:ok, %{id: String.t(), name: String.t(), changed: [String.t()]}} | {:error, term()}
Ensure a WireGuard interface by name. If present, patches only differing keys. Returns {:ok, %{id: id | name, name: name, changed: [keys]}} when up-to-date or updated; {:error, not_found} if list fails. Note: On create, the actual .id may not be known immediately; id will fallback to the provided name.
@spec wireguard_interface_getall( MikrotikApi.Auth.t(), String.t(), String.t(), Keyword.t() ) :: {:ok, [map()]} | {:error, MikrotikApi.Error.t()}
POST /interface/wireguard/getall with a .proplist to retrieve fields like private-key and public-key.
@spec wireguard_interface_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /interface/wireguard
@spec wireguard_interface_update( MikrotikApi.Auth.t(), String.t(), String.t(), map() | list(), Keyword.t() ) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PATCH /interface/wireguard/{id}
@spec wireguard_peer_add( MikrotikApi.Auth.t(), String.t(), map() | list(), Keyword.t() ) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PUT /interface/wireguard/peers - create a WireGuard peer. RouterOS REST API uses PUT for creating resources. Falls back to POST /interface/wireguard/peers/add on older RouterOS versions.
@spec wireguard_peer_delete(MikrotikApi.Auth.t(), String.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
DELETE /interface/wireguard/peers/{id}
@spec wireguard_peer_ensure( MikrotikApi.Auth.t(), String.t(), String.t(), String.t(), map(), Keyword.t() ) :: {:ok, %{id: String.t() | nil, interface: String.t(), changed: [String.t()]}} | {:error, term()}
Ensure a WireGuard peer identified by {interface, public-key} exists with desired attributes. Only differing keys are patched. Returns {:ok, %{id: id | public-key, interface: name, changed: [keys]}}.
@spec wireguard_peer_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /interface/wireguard/peers
@spec wireguard_peer_update( MikrotikApi.Auth.t(), String.t(), String.t(), map() | list(), Keyword.t() ) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PATCH /interface/wireguard/peers/{id}
@spec wireless_interface_add( MikrotikApi.Auth.t(), String.t(), map() | list(), Keyword.t() ) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PUT /interface/wireless - create a wireless interface. RouterOS REST API uses PUT for creating resources.
@spec wireless_interface_delete( MikrotikApi.Auth.t(), String.t(), String.t(), Keyword.t() ) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
DELETE /interface/wireless/{id}
@spec wireless_interface_ensure( MikrotikApi.Auth.t(), String.t(), String.t(), map(), Keyword.t() ) :: {:ok, String.t()} | {:error, MikrotikApi.Error.t()}
Ensure a legacy wireless interface exists by name.
@spec wireless_interface_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /interface/wireless
@spec wireless_interface_update( MikrotikApi.Auth.t(), String.t(), String.t(), map() | list(), Keyword.t() ) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PATCH /interface/wireless/{id}
@spec wireless_registration_table(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /interface/wireless/registration-table
@spec wireless_security_profile_add( MikrotikApi.Auth.t(), String.t(), map() | list(), Keyword.t() ) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PUT /interface/wireless/security-profiles - create a wireless security profile. RouterOS REST API uses PUT for creating resources.
@spec wireless_security_profile_delete( MikrotikApi.Auth.t(), String.t(), String.t(), Keyword.t() ) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
DELETE /interface/wireless/security-profiles/{id}
@spec wireless_security_profile_ensure( MikrotikApi.Auth.t(), String.t(), String.t(), map(), Keyword.t() ) :: {:ok, String.t()} | {:error, MikrotikApi.Error.t()}
Ensure a legacy wireless security profile exists by name.
@spec wireless_security_profile_list(MikrotikApi.Auth.t(), String.t(), Keyword.t()) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
GET /interface/wireless/security-profiles
@spec wireless_security_profile_update( MikrotikApi.Auth.t(), String.t(), String.t(), map() | list(), Keyword.t() ) :: {:ok, any() | nil} | {:error, MikrotikApi.Error.t()}
PATCH /interface/wireless/security-profiles/{id}