This createShortLink route handles the creation of customized short URLs with optional features like password protection, QR code generation, and link-in-bio functionality. It validates inputs, checks for unique slugs, and manages user quotas while supporting UTM parameters for tracking. The endpoint accepts POST requests and returns either the created short link data or appropriate error responses.
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"
}
}'
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));
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));
// 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);
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()
{
"success": true,
"message": "Short Link Created Successfully.",
"data": {
"id": 1162,
"type": "shortlink",
"type2": null,
"userId": 92,
"clicks": 0,
"lbClicks": 0,
"scans": 0,
"destinationUrl": "https://jsdev.org/",
"faviconUrl": "",
"title": "JS dev",
"titleLabel": "js dev",
"btnLabel": "Click Here",
"brandedDomain": "kut.lt",
"slashTag": "tw9e1",
"edit": 0,
"utm_id": null,
"utm_content": null,
"utm_term": null,
"utm_campaign": null,
"utm_medium": null,
"utm_source": null,
"preset": null,
"bgColor": null,
"color": null,
"pattern": null,
"corner": null,
"logo": null,
"qr": null,
"qrLogoId": null,
"tags": "",
"linkInBioId": null,
"uniqueTagId": 1221,
"isActive": true,
"isStarred": false,
"expirationDate": "2025-06-25T04:30:15.979Z",
"createdAt": "2025-03-27T04:30:25.542Z",
"updatedAt": "2025-03-27T04:30:25.542Z",
"fieldData": null,
"frame": null,
"isadminblocked": false,
"isEdit": false,
"password": null,
"passwordProtectionEnabled": false,
"primary": null,
"qrType": null,
"secondary": null,
"text": null,
"textColor": null
}
}
{
"message": "Unauthorized!"
}
{
error: true,
data: {
message: 'Qr Code Limit Exceeded for your current plan. Please upgrade!',
},
}
{
error: true,
data: {
message: `Link Limit Exceeded for your current plan. Please upgrade!`,
},
}
{
error: true,
data: {
message: 'Bio Page Limit Exceeded for your current plan. Please upgrade!',
},
}
{
error: true,
data: {
message: `Link Limit Exceeded for your current plan. Please upgrade!`,
},
}