Adding Tags to an Existing URL

Add tags to a short link that is already shortened

📘

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

The instruction below shows how to add tags to the existing URL.

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

2) Copy an ID of a short link you want to which you want to add a tag.

  • 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 add tags.

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

📘

Please, replace LinkId and a tag with appropriate values.

import requests
url = "https://api.short.io/tags"
payload = {"LinkId": 297594333, "tag": "social"}
headers = {
    'accept': "application/json",
    'content-type': "application/json",
    'authorization': "<<apiKey>>"
    }
response = requests.request("POST", url, json=payload, headers=headers)
print(response.text)
const axios = require('axios');
const data = {
    "LinkId":297594333,
    "tag":"social",
};
const options = {
    headers: {
      'content-type': 'application/json',
      authorization: '<<apiKey>>'
    }
  };
  axios.post('https://api.short.io/tags', 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/tags")
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["content-type"] = 'application/json'
request["authorization"] = '<<apiKey>>'
request.body = JSON.generate({"LinkId":297594333, "tag": "social"})
response = http.request(request)
puts response.read_body

5) Launch the file.

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

6) JSON Response (tag is added).

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

{
  id: 47815290,
  LinkId: 297594333,
  tag: 'social',
  DomainId: 9026,
  updatedAt: '2020-06-12T08:22:23.007Z',
  createdAt: '2020-06-12T08:22:23.007Z'
}