This API allows to create and edit Smart Links
GET /smart-link/[link_hash]
- read Smart Link routing rules in JSON format.
Example response:
{
"error": {
"code": 0,
"message": ""
},
"version": "3.1",
"rules": [
{
"regexp": ".*",
"url": "https://example.com/$0.html",
"criterion": "regexp"
}
],
...
}
For links that are not Smart Links, this API call will return an empty "rules" array property.
If you have more than one domain in your account, you have to specify "domain" query parameter like this:
GET /smart-link/[link_hash]?domain=my-domain.com
.
POST /smart-link/[link_hash]
- set new Smart Link routing rules.
Request payload should contain routing rules in JSON format.
This API call will turn existing ordinary link into a Smart Link. If link is already a Smart Link, this API call will replace existing routing rules.
Input parameters example:
{
"rules": [
{
"arg": ["ios"],
"url": "https://example.com/ios",
"criterion": "platform"
}
]
}
Response to successful POST API call is the same as response to the GET request.
In case of rule validation errors you will get response like this:
{
"error": {
"code": 1317,
"message": "Error in Smart Link rules"
},
"version": "3.1",
"rules": [
{
"arg": [
"XX"
],
"url": "https://example2.com",
"criterion": "country",
"_errors": [
"Unsupported country: XX"
]
}
],
...
Note that every response rule object with errors will get it's own "_errors" property array.
Routing rule type determined by "criterion" property. List of supported routing rule types (criteria) as well as their allowed parameter values can be fetched through the Meta API.
Each routing rule type has it's own set of supported properties as follows:
Rule Type ("criterion" property) | Properties |
---|---|
country | arg - array or country ISO-codes |
url - redirect URL | |
browser | arg - array or browser codes |
url - redirect URL | |
platform | arg - array or platform codes |
url - redirect URL | |
language | arg - array or language ISO-codes |
url - redirect URL | |
date | start - date interval starting date in ISO format. Example: "2020-12-31" |
end - date interval end date in ISO format. Example: "2020-12-31" | |
url - redirect URL | |
time | start - time interval starting time in 24h ISO format HH:mm. Example: "22:30" |
end - time interval end time in 24h ISO format HH:mm. Example: "22:30" | |
url - redirect URL | |
clicks | total_clicks - Short link total number of clicks |
unique_clicks - Short link number of unique visitors | |
url - redirect URL | |
ip | match - array of IP-address matches |
url - redirect URL | |
regexp | regexp - REGEXP pattern string (learn more) |
url - redirect URL template |
In order to create subordinate (nested) rules you should use "children" property of the rule object.
Example of Country rule with two subordinate Browser rules:
{
"rules": [
{
"arg": [
"GB"
],
"url": "https://gb.example.com",
"criterion": "country",
"children": [
{
"arg": [
"ch"
],
"url": "https://gb.example.com/chrome",
"criterion": "browser"
},
{
"arg": [
"ff"
],
"url": "https://gb.example.com/firefox",
"criterion": "browser"
}
]
}
]
}