Updating an existing short URL

Update original URL, title or path for an existing short link by id.

📘

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

The instruction below shows how to edit a slug of the existing URL. In the same way, you can apply the guidance to edit another params (see Body params): https://developers.short.io/reference#linksbylinkidpost

Body Params

pathoptional path part of newly created link. If empty - it will be generated automaticallystring
titletitle of created URL to be shown in short.cm admin panelstring
tagsarray of strings
expiresAtLink expiration date, optional. Format is unix timestamp in milliseconds.

If no expiration date is given (default), link will never expire
milliseconds since the epoch started
expiredURLURL to redirect when the link is expiredurl
iphoneURLIf users open the URL with iPhone, they will be redirected to this URLurl
androidURLIf users open the URL with Android, they will be redirected to this URLurl
passwordRequires Personal plan. Password to be asked when user visits a link. This password will not be stored in plain text, we will hash it with saltpassword
utmSource, utmMedium, utmCampaign, utmTerm, utmContentstring
cloakingdouble

  • 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 edit a short URL with a new path.

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

📘

Please, replace YOUR_DOMAIN, YOUR_PATH, and LINK_ID with appropriate values.

import requests

url = "https://api.short.io/links/LINK_ID"

import json
payload = json.dumps({"allowDuplicates": False, "domain": "YOUR_DOMAIN", "path": "YOUR_PATH" })
headers = {
    'accept': "application/json",
    'content-type': "application/json",
    'authorization': "<<apiKey>>"
    }

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

print(response.text)
const axios = require('axios');

const data = {
    "allowDuplicates":false, 
    "domain":"YOUR_DOMAIN", 
    "path":"YOUR_PATH"
};

const options = {
  headers: {
    accept: 'application/json',
    'content-type': 'application/json',
    authorization: '<<apiKey>>'
  }
};

axios.post('https://api.short.io/links/LINK_ID', data, options)
.then(function (response) {
  console.log(response.data);
})
.catch(function (response) {
  console.log(response);
});
require 'uri'
require 'net/http'
require 'openssl'
require 'json'

url = URI("https://api.short.io/links/LINK_ID")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["accept"] = 'application/json'
request["content-type"] = 'application/json'
request["authorization"] = '<<apiKey>>'
request.body = JSON.generate({"allowDuplicates":false, "domain":"YOUR_DOMAIN", "path":"YOUT_PATH"})

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

5) Launch the file.

python filename.py
node filename.js
ruby filename.rb

6) JSON Response.

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

{
  "id":LINK_ID,
  "path":"YOUR_PATH",
  "title":null,
  "icon":null,
  "archived":false,
  "originalURL":"YOUR_LONG_LINK",
  "iphoneURL":null,
  "androidURL":null,
  "splitURL":null,
  "expiresAt":null,
  "expiredURL":null,
  "redirectType":null,
  "cloaking":null,
  "source":"public",
  "AutodeletedAt":null,
  "createdAt":"2020-04-02T11:54:16.000Z",
  "updatedAt":"2020-04-11T07:04:54.066Z",
  "DomainId":9026,
  "OwnerId":9346,
  "tags":[],
  "secureShortURL":"https://example.xyz/YOUR_PATH",
  "shortURL":"https://example.xyz/YOUR_PATH"
}

Most important parameters here are the "path" (the path of the edited short link) and "id".