Creating a new short URL with Link Expiration

This method creates a short URL with expiration

The instruction below shows how to create a short URL with expiration.

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

2) Copy an ID of a short link you want to edit.

  • Open the statistics of the short link.
  • Copy the link ID.

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 expiration.

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


Please, replace domain, original URL, expiresAt and expiredURL with appropriate values.

import requests
import time
import datetime

url = ""

import json
payload = json.dumps({
      "expiresAt":time.mktime(datetime.datetime.strptime("22.05.2020 15:56:53", "%d.%m.%Y %H:%M:%S").timetuple()) * 1000,
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 = {
  "expiresAt":new Date("2020-05-22T15:56:53").valueOf(),

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'
require 'time'

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,
"expiresAt":Time.parse("22.05.2020 15:56:53").to_i * 1000,

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

5) Launch the file.

node filename.js
ruby filename.rb

6) JSON Response (link expiration is created).

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

  id: 281221653,
  originalURL: '',
  DomainId: 902,
  archived: false,
  path: 'H2uuRk',
  expiresAt: '2020-05-22T12:56:53.000Z',
  expiredURL: '',
  redirectType: null,
  createdAt: '2020-04-27T07:39:21.558Z',
  OwnerId: 9346,
  updatedAt: '2020-04-27T07:39:21.558Z',
  secureShortURL: '',
  shortURL: '',
  duplicate: false

Here's how it looks on