Distributor Api v5 Documentation
Distributor Api v5 Documentation
Documentation
updated: 2020.03.09
version 1.0.0
Table of Contents
References........................................................................................................................................3
Distributor API overview......................................................................................................................4
Endpoint overview...........................................................................................................................4
API details............................................................................................................................................5
Authentication..................................................................................................................................5
Security............................................................................................................................................5
Response structure...........................................................................................................................5
Error response..................................................................................................................................5
API endpoints.......................................................................................................................................6
/wallet/balance.................................................................................................................................6
/vouchers/status................................................................................................................................6
/vouchers/purchase...........................................................................................................................7
/vouchers/generate...........................................................................................................................7
/vouchers/transfer.............................................................................................................................8
/licenses/purchase............................................................................................................................8
/licenses/cf.......................................................................................................................................9
Code values and error messages.........................................................................................................10
Integration from APIv4.......................................................................................................................11
Version history....................................................................................................................................12
2
References
3
Distributor API overview
Distributor API uses REST protocol to Gateway API, url communicates in JSON format.
This resource is aimed to help distributors to automate their business activities with MikroTik,
changing activities previously available only in user interface to be enabled in client side
operations.
Endpoint overview
/wallet/balance Retrieves actual ROS Wallet asset balance (previously known as deposit
money)
/vouchers/status Retrieves amount of vouchers (previously: prepaid keys) available for usage
/vouchers/purchase Purchase vouchers using ROS Wallet assets
/vouchers/generate Converts voucher into ROS license
/vouchers/transfer Send vouchers to other MikroTik client account
/licenses/purchase Purchase ROS license using ROS Wallet assets
/licenses/cf Upgrade ROS license with Custom Frequency option
4
API details
All available endpoints are accessible using Gateway API url. Operations are performed using
standart HTTP method POST.
Authentication
Each operation request contains value „apikey”, that can be acquired in distributor MikroTik
account under account details in „Account API key” section. This API key is valid for 1 year after
generation or until it is regenerated and .
Please note, that non-distributors can generate „Account authorization key”, this key is similar by
structure to „Account API key”, but cannot be used as API service authenticator – only to
authenticate receiving client.
Security
All connections are carried out over TLS connection, to prevent Man-in-the-middle attacks.
Response structure
Each operation returns integer value named „code”. If such value is not present, there is
communication error. If „code” is 1, then request was successfull and response structure contains all
response values. If „code” is other than 1, response contains string value named „message”, where
problem is explained in human readable format.
Error response
If „code” value in response is other than 1, response contains string value named „message”, where
problem is explained in human readable format. You can read common errors in „Code errors”
section.
Additionaly there can be additional value named „error_reference”. If this value exists, keep this
reference to communicate to support about this particular error.
5
API endpoints
/wallet/balance
Request parameters
/vouchers/status
Request parameters
There exists difference between total vouchers and transferable vouchers, please take that in mind
when transferring vouchers.
There are also specific vouchers for generating only CHR licenses, also noted in status.
6
/vouchers/purchase
Request parameters
/vouchers/generate
Used for generating new ROS license buy using available vouchers in account.
Request parameters
7
/vouchers/transfer
Used for transfering your vouchers to other account. Other account is identified by access key, that
client should generate and provide for transaction. Please consult „transferable” value from
/vouchers/status endpoint.
Request parameters
Parameter Optional Description
apikey Mandatory Authentication key
level Mandatory Voucher level (4,5,6)
amount Mandatory Amout of vouchers to transfer
client Mandatory API key where to transfer vouchers
/licenses/purchase
Used for acquiring new ROS licence by using ROS Wallet assets
Request parameters
Parameter Optional Description
apikey Mandatory Authentication key
software_id Mandatory Future license Software ID (AAAA-BBBB)
level Mandatory Future license level (4,5,6)
is_cf Optional Optional true/false value. Generates licence with added Custom-
Frequency option. Considered obsolete. See integration from v4.
note Optional Base64 encoded note
8
/licenses/cf
Used for adding Custom Frequency option for license. This option is becoming obsolete and only
usable for older routers.
Request parameters
9
Code values and error messages
10
Integration from APIv4
In distributor documents you should be able to download distributor API library for PHP, replace
previous v4 library and all function calls should work as there exists support for all the old
functions.
However, please note there are notable changes from previous API version, please read the
following.
In APIv5 distributor access is authentificated by „Account API key” - this key has write privileges
and is available only for distributors. In APIv4 authentification was done by MikroTik account login
and password. Buy using API key, distributor is free to change his account password frequently,
increasing account security. And distributor can also provide store api key on his integration, not
worrying if his web account can be compromised.
There are no more „Credit keys”. Old v4 function „checkCreditkeys” now returns permanent error
„not supported” and there is no endpoint in APIv5 for that.
APIv5 has implemented endpoint call to purchase vouchers (prepaid keys) using ROS Wallet
(Deposit money). This option was not available in APIv4.
APIv5 has implemented endpoint call to transfer vouchers (prepaid keys) to other account,
identified by their „Authorization key”. This option was not available in APIv4.
In APIv4 library call „keypurchase” and invoking function purchaseKey had parameters „board”
and „pay_type”. Both of those are removed. In APIv5 board type is determined automatically, so
there is no need to provide it. In APIv4 „pay_type” had specific codes for each payment: 0 –
prepaid key, 1 – deposit money, 2 – credit key, 255 – test mode. Now there are specific endpoint
calls for each available action: paying by prepaid key is done by call to /vouchers/generate and
paying by deposit money is done by calling /licences/purchase.
11
Version history
12