Registration

Module Link

Creating and managing short links. With the functions of this module, you can shorten long URLs for use in your SMS campaigns.

API methods

Creating a Short Link
https://api.mobizon.com.br/service/Link/Create

Deleting Short Links
https://api.mobizon.com.br/service/Link/Delete

Retrieving Basic Data of a Short Link
https://api.mobizon.com.br/service/Link/Get

Getting Campaign Short Links
https://api.mobizon.com.br/service/Link/GetLinks

Retrieving Click Statistics for Links
https://api.mobizon.com.br/service/Link/GetStats

Getting List of Links
https://api.mobizon.com.br/service/Link/List

Editing Short Link Data
https://api.mobizon.com.br/service/Link/Update

Creating a Short Link

https://api.mobizon.com.br/service/Link/Create

This method is designed for creating short links.

Request Parameters

data array – Link parameters

ParameterTypeDescription
data[fullLink]stringFull link.
The link that needs to be shortened in the correct URL format.
For example: https://help.mobizon.com/api-docs/sms-api?utm_campaign=docs&utm_source=help&utm_medium=test#server-response-format or www.mobizon.com
data[status]integerStatus of the short link:
0 – link inactive;
1 – link active (default).
data[expirationDate]dateExpiration date of the link.
The link will be valid until the end of the specified day in the user's time zone.
By default, the link does not expire.
Format: YYYY-MM-DD.
data[comment]stringComment on the link.
This field helps to easily find the short link among others.
For example: "Black Friday Discounts" or "Negative Balance Reminder".
Maximum comment length is 255 characters.

Server Response

array: Data of the created short link

FieldTypeDescription
idintegerLink identifier.
codestringShort link code.
shortLinkstringShort link.

API Response Codes

CodeDescription
0Short link successfully created.
1If any parameters contain invalid values.

Examples

curl -X POST \
  'https://api.mobizon.com.br/service/link/create?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/x-www-form-urlencoded' \
  -d 'data%5BfullLink%5D=http%3A%2F%2Fmobizon.com&data%5Bstatus%5D=1&data%5BexpirationDate%5D=2020-10-05&data%5Bcomment%5D=Comment+on+the+link'
var data = "data%5BfullLink%5D=http%3A%2F%2Fmobizon.com&data%5Bstatus%5D=1&data%5BexpirationDate%5D=2020-10-05&data%5Bcomment%5D=Comment+on+the+link";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});

xhr.open("POST", "https://api.mobizon.com.br/service/link/create?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK");
xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("cache-control", "no-cache");

xhr.send(data);
<?php
use Mobizon\MobizonApi;

$api = new MobizonApi('KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK', 'api.mobizon.com.br');

// API method call
if ($api->call(
    'link',
    'create',
    array(
        'data' => array(
            //full link
            'fullLink' => 'http://mobizon.com',
            //link status
            'status' => '1',
            //link expiration date
            'expirationDate' => '2020-10-05',
            //comment on the link
            'comment' => 'Comment on the link'
        )
    )
)
) {
    // Getting the result of an API request
    $result = $api->getData();
} else {
    // An error occurred during execution. Error code and message text output
    echo '[' . $api->getCode() . '] ' . $api->getMessage() . PHP_EOL;
}

Deleting Short Links

https://api.mobizon.com.br/service/Link/Delete

This method is intended for deleting short links.

Request Parameters

ParameterTypeDescription
idsarrayLink identifiers.

Server Response

Array of data

FieldTypeDescription
processedarrayIdentifiers of deleted links.
notProcessedarrayIdentifiers of links that were not deleted.

Examples

curl -X POST \
  'https://api.mobizon.com.br/service/link/delete?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/x-www-form-urlencoded' \
  -d 'ids%5B0%5D=123&ids%5B1%5D=455&ids%5B2%5D=567'
var data = "ids%5B0%5D=123&ids%5B1%5D=455&ids%5B2%5D=567";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});

xhr.open("POST", "https://api.mobizon.com.br/service/link/delete?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK");
xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("cache-control", "no-cache");

xhr.send(data);
<?php
use Mobizon\MobizonApi;

$api = new MobizonApi('KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK', 'api.mobizon.com.br');

// API method call
if ($api->call(
    'link',
    'delete',
    array(
        //link identifiers
        'ids' => array(
            '123',
            '455',
            '567'
        )
    )
)
) {
    // Getting the result of an API request
    $result = $api->getData();
} else {
    // An error occurred during execution. Error code and message text output
    echo '[' . $api->getCode() . '] ' . $api->getMessage() . PHP_EOL;
}

Retrieving Basic Data of a Short Link

https://api.mobizon.com.br/service/Link/Get

This method allows you to retrieve the basic data of a short link by one of its three parameters: id, code, shortLink.

Only one short link's data can be retrieved in a single request.

Request Parameters

To retrieve the data, one of the parameters must be passed:

ParameterTypeDescription
idintegerLink identifier.
codestringShort link code.
A combination of characters unique to each short link.
Located at the very end of the short link.
Example: http://mbz.im/mgjf, where mgjf is the short link code.
shortLinkstringShort link.
URL created by our service, which redirects your visitors to the link you initially specified.
Example: http://mbz.im/mgjf.

Server Response

Array of data

FieldTypeDescription
idintegerLink identifier.
statusintegerStatus set by the user:
0 – link inactive;
1 – link active.
moderatorStatusintegerStatus set by the administrator:
0 – blocked by the administrator;
1 – approved by the administrator.
clickCntintegerNumber of clicks on the short link.
createTsstringCreation time of the short link.
Format: YYYY-MM-DD HH:MM:SS.
expirationDatestringExpiration date of the short link.
Format: YYYY-MM-DD.
If the date is not set, the field value is NULL.
codestringShort link code.
fullLinkstringFull link.
shortLinkstringShort link.
commentstringUser's comment on the short link.
If the comment is absent, the field value is NULL.
moderatorCommentstringModerator's comment.
If the comment is absent, the field value is NULL.

API Response Codes

CodeDescription
0Basic data of the short link successfully retrieved.
2If the link with the specified identifier is not found.
12If none of the parameters are passed.

Examples

curl -X POST \
  'https://api.mobizon.com.br/service/link/get?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/x-www-form-urlencoded' \
  -d 'code=zxc'
var data = "code=zxc";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});

xhr.open("POST", "https://api.mobizon.com.br/service/link/get?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK");
xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("cache-control", "no-cache");

xhr.send(data);
<?php
use Mobizon\MobizonApi;

$api = new MobizonApi('KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK', 'api.mobizon.com.br');

// API method call
if ($api->call(
    'link',
    'get',
    array(
        //short link code
        'code' => 'zxc'
    )
)
) {
    // Getting the result of an API request
    $result = $api->getData();
} else {
    // An error occurred during execution. Error code and message text output
    echo '[' . $api->getCode() . '] ' . $api->getMessage() . PHP_EOL;
}

Getting Campaign Short Links

https://api.mobizon.com.br/service/Link/GetLinks

This method allows you to get information and statistics of the campaign's short links.

Request Parameters

ParameterTypeDescription
campaignIdintegerCampaign identifier.

Server Response

Link object structure: an array of short links, where each element contains the following fields:

FieldTypeDescription
idintegerShort link identifier.
codestringShort link code.
fullLinkstringFull link.
shortLinkstringShort link.
clickCntintegerNumber of clicks on the short link.
redirectCntintegerNumber of redirects via the short link.
commentstringUser comment on the short link.

API Response Codes

CodeDescription
0Campaign short links successfully retrieved.
2If the campaign is not found.

Retrieving Click Statistics for Links

https://api.mobizon.com.br/service/Link/GetStats

This method is designed to retrieve click statistics for one or more short links by their ID.

Data can be grouped by months, days, hours, minutes.

Request Parameters

ParameterTypeDescription
idsarrayLink identifiers.
Maximum number of IDs in a request – 5.
Parameter syntax: ids[] for each identifier.
typestringType of requested statistics.
Allows you to get data in various time intervals:
monthly – number of clicks per month. Maximum interval for retrieving statistics – 3 years;
daily – number of clicks per day. Maximum interval for retrieving statistics – 90 days;
hourly – number of clicks per hour. Maximum interval for retrieving statistics – 1 week;
minute – number of clicks per minute. Maximum interval for retrieving statistics – 3 hours.
criteriaarraySearch criteria (See table Search Criteria).

Search Criteria

Statistical data retrieval is based on the specified date and time.

ParameterTypeDescription
criteria[dateFrom]stringRetrieve statistics starting from the specified date and time.
Format: YYYY-MM-DD HH:MM:SS.
criteria[dateTo]stringRetrieve statistics up to the specified date and time.
Format: YYYY-MM-DD HH:MM:SS.

Important: if the search criteria dateFrom and dateTo are not set, the type field statistics will be retrieved for the last maximum possible interval.

If only one criterion dateFrom is set or the time interval between dateFrom and dateTo exceeds the maximum allowed interval, statistics will be retrieved for the maximum allowed interval starting from the dateFrom date.

If only the dateTo criterion is set, statistics will be retrieved for the maximum possible period up to the dateTo date.

Server Response

Array of data:

FieldTypeDescription
itemsarrayStatistical data.
totalsstringTotal number of clicks for the requested period.

API Response Codes

CodeDescription
0Statistics successfully retrieved.
12If more than 5 link identifiers are specified or the type of statistics is incorrectly specified.

Examples

curl -X POST \
  'https://api.mobizon.com.br/service/link/getStats?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/x-www-form-urlencoded' \
  -d 'ids%5B0%5D=123&ids%5B1%5D=455&ids%5B2%5D=567&type=monthly&criteria%5BdateFrom%5D=2018-01-21+13%3A30%3A00'
var data = "ids%5B0%5D=123&ids%5B1%5D=455&ids%5B2%5D=567&type=monthly&criteria%5BdateFrom%5D=2018-01-21+13%3A30%3A00";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});

xhr.open("POST", "https://api.mobizon.com.br/service/link/getStats?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK");
xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("cache-control", "no-cache");

xhr.send(data);
<?php
use Mobizon\MobizonApi;

$api = new MobizonApi('KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK', 'api.mobizon.com.br');

// API method call
if ($api->call(
    'link',
    'getStats',
    array(
        //link identifiers
        'ids' => array(
            '123',
            '455',
            '567'
        ),
        //type of statistics
        'type' => 'monthly',
        //search criteria
        'criteria' => array(
            'dateFrom' => '2018-01-21 13:30:00'
        )
    )
)
) {
    // Getting the result of an API request
    $result = $api->getData();
} else {
    // An error occurred during execution. Error code and message text output
    echo '[' . $api->getCode() . '] ' . $api->getMessage() . PHP_EOL;
}

Getting List of Links

https://api.mobizon.com.br/service/Link/List

This method allows you to get a list of created short links. The search can be performed by ID and short link fields.

Request Parameters

ParameterTypeDescription
criteriaarraySearch criteria (see the table Search Criteria).
paginationarrayPagination parameters (see the table Pagination Parameters).
sortarraySorting parameters (see the table Sorting Parameters).

Search Criteria

Information about the fields of the short link by which the search is performed. The search can be done by one field or a combination of fields.

ParameterTypeDescription
criteria[status]integerSearch by short link status:
0 – link is inactive;
1 – link is active.
criteria[moderatorStatus]integerSearch by link moderation status:
0 – blocked;
1 – approved.
criteria[createTsFrom]datetimeSearch by link creation date, starting from the specified date.
Format: YYYY-MM-DD.
criteria[createTsTo]datetimeSearch by link creation date and time up to the specified date and time.
Format: YYYY-MM-DD HH:MM:SS.
criteria[query]stringSearch by various link attributes.
The search can be performed by:
Short link code;
Recipient tracking code;
Short link comment.

Pagination Parameters

These parameters are intended for structured (partial) output of the requested information.

ParameterTypeDescription
pagination[pageSize]integerNumber of items displayed per page (25, 50, 100).
pagination[currentPage]integerCurrent page
Page numbering starts from 0.

Sorting Parameters

These parameters allow you to sort the search results by one of the fields in ascending (ASC) or descending (DESC) order.

For example:

Sort by short link code in ascending order – sort[code]=ASC.
Sort by original link in descending order – sort[fullLink]=DESC.

ParameterDescription
sort[createTs]Sort by link creation date and time.
Format: YYYY-MM-DD HH:MM:SS.
sort[expirationDate]Sort by link expiration date.
Format: YYYY-MM-DD.
sort[clickCnt]Sort by number of clicks.
sort[code]Sort by short link code.
sort[fullLink]Sort by original link.

Server Response

Array of data:

FieldTypeDescription
itemsarrayList of found links.
For a description of the short link fields, see the description of the Link/Get method.
totalItemCountintegerTotal number of found items.

Examples

curl -X POST \
  'https://api.mobizon.com.br/service/link/list?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/x-www-form-urlencoded' \
  -d 'criteria%5Bstatus%5D=1&criteria%5BmoderatorStatus%5D=1&pagination%5BcurrentPage%5D=2&pagination%5BpageSize%5D=50&sort%5BclickCnt%5D=ASC'
var data = "criteria%5Bstatus%5D=1&criteria%5BmoderatorStatus%5D=1&pagination%5BcurrentPage%5D=2&pagination%5BpageSize%5D=50&sort%5BclickCnt%5D=ASC";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});

xhr.open("POST", "https://api.mobizon.com.br/service/link/list?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK");
xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("cache-control", "no-cache");

xhr.send(data);
<?php
use Mobizon\MobizonApi;

$api = new MobizonApi('KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK', 'api.mobizon.com.br');

// API method call
if ($api->call(
    'link',
    'list',
    array(
        //search criteria
        'criteria' => array(
            //only active links
            'status' => '1',
            //links approved by the moderator
            'moderatorStatus' => '1'
        ),
        //pagination parameters
        'pagination' => array(
            //current page
            'currentPage' => '2',
            //number of items displayed per page
            'pageSize' => '50'
        ),
        //sorting parameters
        'sort' => array(
            //sort by number of clicks in ascending order
            'clickCnt' => 'ASC'
        )
    )
)
) {
    // Getting the result of an API request
    $result = $api->getData();
} else {
    // An error occurred during execution. Error code and message text output
    echo '[' . $api->getCode() . '] ' . $api->getMessage() . PHP_EOL;
}

Editing Short Link Data

https://api.mobizon.com.br/service/Link/Update

This method allows you to change the parameters of a created short link.

Request Parameters

ParameterTypeDescription
idintegerLink identifier.
dataintegerEditable link parameters specified in the table Link Parameters.

Link Parameters

ParameterTypeDescription
data[status]integerStatus of the short link:
0 – link inactive;
1 – link active.
data[expirationDate]dateExpiration date of the short link.
Format: YYYY-MM-DD.
If the value is not provided, the link will be valid indefinitely.
data[comment]stringComment on the link.
Maximum comment length is 255 characters.

Server Response

string – Short link.

API Response Codes

CodeDescription
0Parameters successfully changed.
1If any parameters contain invalid values.
2If the link with the specified identifier is not found.

Examples

curl -X POST \
  'https://api.mobizon.com.br/service/link/update?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/x-www-form-urlencoded' \
  -d 'id=123&data%5Bstatus%5D=0'
var data = "id=123&data%5Bstatus%5D=0";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});

xhr.open("POST", "https://api.mobizon.com.br/service/link/update?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK");
xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("cache-control", "no-cache");

xhr.send(data);
<?php
use Mobizon\MobizonApi;

$api = new MobizonApi('KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK', 'api.mobizon.com.br');

// API method call
if ($api->call(
    'link',
    'update',
    array(
        //link identifier
        'id' => '123',
        'data' => array(
            //link status
            'status' => '0'
        )
    )
)
) {
    // Getting the result of an API request
    $result = $api->getData();
} else {
    // An error occurred during execution. Error code and message text output
    echo '[' . $api->getCode() . '] ' . $api->getMessage() . PHP_EOL;
}