Update a Short Link

PUT /api/v1/short-link/:id

Common errors include:

  • "Bad Request" if body parameters are not passed
  • "DNS_CONFIGURATION_ERROR" if custom domain DNS is misconfigured.

The `updateShortLinkData` function updates an existing short link with new data like destination URL, password protection, UTM parameters, and QR code settings. It handles different link types (regular short links, QR codes, bio links) and updates quotas accordingly.

Request

Method : PUT
Content-Type : Application/json

Request Body Schema

destinationUrl string
The original, long URL you want to shorten.
brandedDomain string Required
Custom domain for the short link.
slashTag string Required
Default: auto-generated
Custom slug for the shortened URL.
password string
Password protection for the link.
type enum Required
Default: SHORT_LINK
Link Type (SHORT_LINK, QR, BIO_LINK, QR_N_, BIO_PAGE).
bioPage number
ID of bio page to add link to.
isEdit boolean
Default: false
Whether this is an edit operation.
id string /number Required
Default: "Click Here"
Domain for the short link.
title string
Custom title for the link.
tags string
Comma-separated tags for the link.
expirationDate string
Default: null
Date when the link should expire.
utm_source string
UTM source parameter.
utm_medium string
UTM medium parameter.
utm_campaign string
UTM campaign parameter.
utm_term string
UTM term parameter.
utm_content string
UTM content parameter.
utm_id string
UTM ID parameter.
isQrGenerated boolean
Default: false
Whether to generate QR code.
isLinkInBio boolean
Default: #000000
Whether it's a bio link.
preset string
Default: #000000
QR code preset color.
color string
Default: #000000
QR code color.
LANGUAGE
REQUEST
 curl -X POST 'https://divsly-backend.vercel.app/api/v1/shortlinks' \
-H 'Content-Type: application/json' \
    -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
    -d '{
    "destinationUrl": "https://example.com/long-url",
    "brandedDomain": "custom.domain",
    "slashTag": "my-custom-slug",
    "utm_source": "twitter",
    "utm_medium": "social",
    "utm_campaign": "summer_2024",
    "public": false,
    "password": "optional_password", 
    "isQrGenerated": true,
    "qrSettings": {
        "color": "#000000",
        "bgColor": "#ffffff",
        "pattern": "classy",
        "corner": "square"
    }
    }'

API REQUEST
 const createShortlink = (linkData) => {
  return new Promise((resolve, reject) => {
	fetch('https://divsly-backend.vercel.app/api/v1/shortlinks', {
  	method: 'POST',
  	headers: {
    	'Content-Type': 'application/json',
    	'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
  	},
  	body: JSON.stringify({
    	destinationUrl: linkData.destinationUrl,
    	brandedDomain: linkData.brandedDomain,
    	slashTag: linkData.slashTag,
    	utm_source: linkData.utm_source,
    	utm_medium: linkData.utm_medium,
    	utm_campaign: linkData.utm_campaign,
    	public: linkData.public,
    	password: linkData.password,
    	isQrGenerated: linkData.isQrGenerated,
    	qrSettings: linkData.qrSettings
  	})
	})
  	.then(response => response.json())
  	.then(data => resolve(data))
  	.catch(error => reject(error));
  });
};

const linkData = {
  destinationUrl: 'https://example.com/long-url',
  brandedDomain: 'custom.domain',
  slashTag: 'my-custom-slug',
  utm_source: 'twitter',
  utm_medium: 'social',
  utm_campaign: 'summer_2024',
  public: false,
  password: 'optional_password',
  isQrGenerated: true,
  qrSettings: {
	color: '#000000',
	bgColor: '#ffffff',
	pattern: 'classy',
	corner: 'square'
  }
};

createShortlink(linkData)
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));
                   
API REQUEST
 const axios = require('axios');

const createShortlink = (linkData) => {
  return new Promise((resolve, reject) => {
	axios({
  	method: 'post',
  	url: 'https://divsly-backend.vercel.app/api/v1/shortlinks',
  	headers: {
    	'Content-Type': 'application/json',
    	'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
  	},
  	data: {
    	destinationUrl: linkData.destinationUrl,
    	brandedDomain: linkData.brandedDomain,
    	slashTag: linkData.slashTag,
    	utm_source: linkData.utm_source,
    	utm_medium: linkData.utm_medium,
    	utm_campaign: linkData.utm_campaign,
    	public: linkData.public,
    	password: linkData.password,
    	isQrGenerated: linkData.isQrGenerated,
    	qrSettings: linkData.qrSettings
  	}
	})
  	.then(response => resolve(response.data))
  	.catch(error => reject(error.response?.data || error));
  });
};
});

const linkData = {
  destinationUrl: 'https://example.com/long-url',
  brandedDomain: 'custom.domain',
  slashTag: 'my-custom-slug',
  utm_source: 'twitter',
  utm_medium: 'social',
  utm_campaign: 'summer_2024',
  public: false,
  password: 'optional_password',
  isQrGenerated: true,
  qrSettings: {
	color: '#000000',
	bgColor: '#ffffff',
	pattern: 'classy',
	corner: 'square'
  }
};

createShortlink(linkData)
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

API REQUEST
 // PHP
$ch = curl_init();

$payload = array(
	'destinationUrl' => 'https://example.com/long-url',
	'brandedDomain' => 'custom.domain',
	'slashTag' => 'my-custom-slug',
	'utm_source' => 'twitter',
	'utm_medium' => 'social',
	'utm_campaign' => 'summer_2024',
	'public' => false,
	'password' => 'optional_password',
	'isQrGenerated' => true,
	'qrSettings' => array(
    	'color' => '#000000',
    	'bgColor' => '#ffffff',
    	'pattern' => 'classy',
    	'corner' => 'square'
	)
);

curl_setopt_array($ch, array(
	CURLOPT_URL => 'https://divsly-backend.vercel.app/api/v1/shortlinks',
	CURLOPT_RETURNTRANSFER => true,
	CURLOPT_POST => true,
      CURLOPT_SSL_VERIFYPEER => false,  // Disable SSL peer verification
      CURLOPT_SSL_VERIFYHOST => false,
	CURLOPT_POSTFIELDS => json_encode($payload),
	CURLOPT_HTTPHEADER => array(
    	'Content-Type: application/json',
    	'Authorization: Bearer YOUR_ACCESS_TOKEN'
	)
));

$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);

API REQUEST
 import requests
import json

url = "https://divsly-backend.vercel.app/api/v1/shortlinks"
headers = {
	"Content-Type": "application/json",
	"Authorization": "Bearer YOUR_ACCESS_TOKEN"
}
payload = {
	"destinationUrl": "https://example.com/long-url",
	"brandedDomain": "custom.domain",
	"slashTag": "my-custom-slug",
	"utm_source": "twitter",
	"utm_medium": "social",
	"utm_campaign": "summer_2024",
	"public": False,
	"password": "optional_password",
	"isQrGenerated": True,
	"qrSettings": {
    	"color": "#000000",
    	"bgColor": "#ffffff",
    	"pattern": "classy",
    	"corner": "square"
	}
}

response = requests.post(url, headers=headers, json=payload)
data = response.json()
RESPONSE
 {
  "success": true,
  "message": "Short Link update Successfull.",
  "data": {
	"id": 1165,
	"type": "shortlink",
	"type2": null,
	"userId": 92,
	"clicks": 0,
	"lbClicks": 0,
	"scans": 0,
	"destinationUrl": "https://example.com/page1",
	"faviconUrl": "",
	"title": "Example Page 1",
	"titleLabel": "example page 1",
	"btnLabel": null,
	"brandedDomain": "your-domain.com",
	"slashTag": "9zqpq",
	"edit": 1,
	"utm_id": "",
	"utm_content": "",
	"utm_term": "",
	"utm_campaign": "summer2024",
	"utm_medium": "import",
	"utm_source": "bulk",
	"preset": null,
	"bgColor": null,
	"color": null,
	"pattern": null,
	"corner": null,
	"logo": null,
	"qr": null,
	"qrLogoId": null,
	"tags": "",
	"linkInBioId": null,
	"uniqueTagId": 1224,
	"isActive": true,
	"isStarred": false,
	"expirationDate": "2025-06-25T05:52:49.715Z",
	"createdAt": "2025-03-27T05:52:49.718Z",
	"updatedAt": "2025-03-27T06:04:00.736Z",
	"fieldData": null,
	"frame": null,
	"isadminblocked": false,
	"isEdit": false,
	"password": null,
	"passwordProtectionEnabled": false,
	"primary": null,
	"qrType": null,
	"secondary": null,
	"text": null,
	"textColor": null
  }
}

        
{
    success: false,
    message: 'Failed to create short link.',
    }
      
{
    "message": "Unauthorized!"
    }

        
{
       error: true,
        data: {
        message: `Link Edit Limit Exceeded for your current plan. Please upgrade!`,
    },
    }

        

   { success: false, error: error.message }