Create a short link
https://api.t.ly/api/v1/link/shorten
Shortens a long URL. You can also set a custom ending, an expiry, a password, tags and pixels, and add Smart URLs or A/B rotation in the same call.
curl -X POST https://api.t.ly/api/v1/link/shorten \
-H 'Authorization: Bearer YOUR_API_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"long_url": "https://example.com/",
"domain": "https://t.ly/",
"description": "Social Media Link",
"expire_at_datetime": "2035-01-17 15:00:00",
"public_stats": true,
"meta": {
"expiration_url": "https://example.com/expired",
"smart_urls": [
{
"conditions": [
"US",
"Android"
],
"url": "https://example.com/us-android"
}
]
}
}'const url = new URL(
"https://api.t.ly/api/v1/link/shorten"
);
const headers = {
"Authorization": "Bearer YOUR_API_TOKEN",
"Content-Type": "application/json",
"Accept": "application/json",
};
let body = {
"long_url": "https:\/\/example.com\/",
"domain": "https:\/\/t.ly\/",
"description": "Social Media Link",
"expire_at_datetime": "2035-01-17 15:00:00",
"public_stats": true,
"meta": {
"expiration_url": "https:\/\/example.com\/expired",
"smart_urls": [
{
"conditions": [
"US",
"Android"
],
"url": "https:\/\/example.com\/us-android"
}
]
}
};
fetch(url, {
method: "POST",
headers,
body: JSON.stringify(body),
}).then(response => response.json());$client = new \GuzzleHttp\Client();
$url = 'https://api.t.ly/api/v1/link/shorten';
$response = $client->post(
$url,
[
'headers' => [
'Authorization' => 'Bearer YOUR_API_TOKEN',
'Content-Type' => 'application/json',
],
'json' => [
'long_url' => 'https://example.com/',
'domain' => 'https://t.ly/',
'description' => 'Social Media Link',
'expire_at_datetime' => '2035-01-17 15:00:00',
'public_stats' => true,
'meta' => [
'expiration_url' => 'https://example.com/expired',
'smart_urls' => [
[
'conditions' => [
'US',
'Android',
],
'url' => 'https://example.com/us-android',
],
],
],
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));import requests
import json
url = 'https://api.t.ly/api/v1/link/shorten'
payload = {
"long_url": "https:\/\/example.com\/",
"domain": "https:\/\/t.ly\/",
"description": "Social Media Link",
"expire_at_datetime": "2035-01-17 15:00:00",
"public_stats": true,
"meta": {
"expiration_url": "https:\/\/example.com\/expired",
"smart_urls": [
{
"conditions": [
"US",
"Android"
],
"url": "https:\/\/example.com\/us-android"
}
]
}
}
headers = {
'Authorization': 'Bearer YOUR_API_TOKEN',
'Content-Type': 'application/json'
}
response = requests.request('POST', url, headers=headers, json=payload)
response.json(){
"short_url": "https://t.ly/c55j",
"description": "Social Media Link",
"long_url": "https://example.com/",
"domain": "https://t.ly/",
"short_id": "c55j",
"expire_at_views": null,
"expire_at_datetime": "2035-01-17 15:00:00",
"public_stats": true,
"created_at": "2026-11-07T12:00:00.000000Z",
"updated_at": "2026-11-07T12:00:00.000000Z",
"meta": {
"expiration_url": "https://example.com/expired",
"smart_urls": [
{
"conditions": [
"US",
"Android"
],
"url": "https://example.com/us-android"
}
],
"rotation_urls": []
}
}
Body parameters
-
long_urlstring RequiredThe page the short link sends visitors to. -
domainstringThe domain for the short link:https://t.ly/or one of your custom domains. -
short_idstringThe ending after the domain, likefall-sale. Leave it out for a random one. -
descriptionstringA private note to help you find the link later, up to 200 characters. -
expire_at_datetimestringWhen the link stops working, in UTC. Use YYYY-MM-DD HH:mm:ss. -
expire_at_viewsintegerStop working after this many visits. Integer from 1 to 100000. -
passwordstringVisitors must enter this password before they are sent on. Use 5 to 100 characters. -
public_statsbooleanLet anyone see the link's stats. -
tagsarray of integersIDs of tags to add to the link. See List tags. -
pixelsarray of integersIDs of retargeting pixels to add to the link. See List pixels. -
metaobjectAn expiration URL, Smart URLs or rotation URLs for A/B tests. Smart URLs and rotation URLs can't be used together; sending both returns a 422. Rotation URLs are the full set of A/B destinations, so includelong_urlif it should be one of them. A Smart URL can set a singletype, or severalconditionsthat must all match. See the Smart URL options. -
include_qr_codebooleanAlso return the link's QR code asqr_code_urlandqr_code_base64. -
formatstringtextreturns only the short URL as plain text.