Creating a new short link with a mobile targeting rule

This method creates a new short URL with a mobile targeting rule


Information below might be outdated - please visit our recently updated API Reference

The instruction below shows how to create a new short link with a rule for mobile targeting.

  • Click "Create API key".
  • Add a Secret key.

2) Iphone and Android URLs.

To create mobile targeting, you need to specify the URLs for iOS and Android.

3) Install prerequisites for requests.

pip install requests
npm install --save axios

Now everything is ready to run the following snippet. It will create a short URL with a mobile targeting rule.

4) Create a file: .js/ .rb. Use the code snippet below.


Please, replace domain, original URL, iphoneURL and androidURL with appropriate values.

import requests

url = ""

import json
payload = json.dumps({
headers = {
    'accept': "application/json",
    'content-type': "application/json",
    'authorization': "<<apiKey>>"

response = requests.request("POST", url, data=payload, headers=headers)

const axios = require('axios');

const data = {

const options = {
  headers: {
    accept: 'application/json',
    'content-type': 'application/json',
    authorization: '<<apiKey>>'
};'', data, options)
.then(function (response) {
.catch(function (response) {
require 'uri'
require 'net/http'
require 'openssl'
require 'json'

url = URI("")

http =, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request =
request["accept"] = 'application/json'
request["content-type"] = 'application/json'
request["authorization"] = '<<apiKey>>'
request.body = JSON.generate({"allowDuplicates":false,

response = http.request(request)
puts response.read_body

5) Launch the file.

node filename.js
ruby filename.rb

6) JSON Response (link with mobile targeting is created).

Once you run the code, you will see the response.

  id: 277740335,
  originalURL: '',
  DomainId: 9026,
  archived: false,
  path: 'rx1jPX',
  redirectType: null,
  androidURL: '',
  iphoneURL: '',
  createdAt: '2020-04-20T08:48:04.878Z',
  OwnerId: 9346,
  updatedAt: '2020-04-20T08:48:04.878Z',
  secureShortURL: '',
  shortURL: '',
  duplicate: false