API Reference for Developers

Getting Started

An API key is required for requests to be processed by the system. Once a user registers, an API key is automatically generated for this user. The API key must be sent with each request (see full example below). If the API key is not sent or is expired, there will be an error. Please make sure to keep your API key secret to prevent abuse.

Authentication

To authenticate with the API system, you need to send your API key as an authorization token with each request. You can see sample code below.

curl --location --request POST 'https://linktw.in/api/account' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \ 
$curl = curl_init();
curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/account",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
));

$response = curl_exec($curl);
var request = require('request');
var options = {
    'method': 'POST',
    'url': 'https://linktw.in/api/account',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    body: ''
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Rate Limit

Our API has a rate limiter to safeguard against spike in requests to maximize its stability. Our rate limiter is currently caped at 120 requests per 1 minute.

Several headers will be sent alongside the response and these can be examined to determine various information about the request.

X-RateLimit-Limit: 120
X-RateLimit-Remaining: 119
X-RateLimit-Reset: TIMESTAMP
Response Handling

All API response are returned in JSON format by default. To convert this into usable data, the appropriate function will need to be used according to the language. In PHP, the function json_decode() can be used to convert the data to either an object (default) or an array (set the second parameter to true). It is very important to check the error key as that provides information on whether there was an error or not. You can also check the header code.

{
    "error": 1,
    "message": "An error occurred"
}
Date & Time

All date and time fields in API responses are returned in your account's configured timezone. You can set your timezone in your account settings. If no timezone is configured, dates default to UTC.

You can also override your account timezone per-request by adding a ?timezone= query parameter to most endpoints (e.g., ?timezone=America/New_York).

Date fields are formatted as YYYY-MM-DD HH:MM:SS (e.g. 2024-01-15 14:30:00).

The Account endpoint returns timezone_offset which is the current UTC offset in minutes for your configured timezone. This accounts for daylight saving time and can be used to convert dates to other timezones. For example, -300 means UTC-5 (Eastern Standard Time), 60 means UTC+1 (Central European Time).

{
    "settings": {
        "timezone": "America/New_York",
        "timezone_offset": -300
    },
    "date": "2024-01-15 14:30:00"
}

Reference Tables

Geo Targeting Country List

The location field in the geotarget array must use the exact full country name as shown below. Country names are case-sensitive. Click on any country to see its available states/regions for the optional state field.

CodeCountry Name (use this in location)
AD Andorra
AF Afghanistan
AG Antigua and Barbuda
AI Anguilla
AL Albania
AM Armenia
AN Netherlands Antilles
AO Angola
AQ Antarctica
AR Argentina
AS American Samoa
AT Austria
AU Australia
AW Aruba
AX Ã…land
AZ Azerbaijan
BA Bosnia and Herzegovina
BB Barbados
BD Bangladesh
BE Belgium
BF Burkina Faso
BG Bulgaria
BH Bahrain
BI Burundi
BJ Benin
BL Saint Barthélemy
BM Bermuda
BN Brunei
BO Bolivia
BQ Bonaire, Sint Eustatius and Saba
BR Brazil
BS Bahamas
BT Bhutan
BV Bouvet Island
BW Botswana
BY Belarus
BZ Belize
CA Canada
CC Cocos [Keeling] Islands
CD DR Congo
CF Central African Republic
CG Congo Republic
CH Switzerland
CI Ivory Coast
CK Cook Islands
CL Chile
CM Cameroon
CN China
CO Colombia
CR Costa Rica
CS Serbia and Montenegro
CU Cuba
CV Cabo Verde
CW Curaçao
CX Christmas Island
CY Cyprus
CZ Czechia
DE Germany
DJ Djibouti
DK Denmark
DM Dominica
DO Dominican Republic
DZ Algeria
EC Ecuador
EE Estonia
EG Egypt
EH Western Sahara
ER Eritrea
ES Spain
ET Ethiopia
FI Finland
FJ Fiji
FK Falkland Islands
FM Micronesia
FO Faroe Islands
FR France
GA Gabon
GB United Kingdom
GD Grenada
GE Georgia
GF French Guiana
GG Guernsey
GH Ghana
GI Gibraltar
GL Greenland
GM Gambia
GN Guinea
GP Guadeloupe
GQ Equatorial Guinea
GR Greece
GS South Georgia and South Sandwich Islands
GT Guatemala
GU Guam
GW Guinea-Bissau
GY Guyana
HK Hong Kong
HM Heard Island and McDonald Islands
HN Honduras
HR Croatia
HT Haiti
HU Hungary
ID Indonesia
IE Ireland
IL Israel
IM Isle of Man
IN India
IO British Indian Ocean Territory
IQ Iraq
IR Iran
IS Iceland
IT Italy
JE Jersey
JM Jamaica
JO Jordan
JP Japan
KE Kenya
KG Kyrgyzstan
KH Cambodia
KI Kiribati
KM Comoros
KN St Kitts and Nevis
KP North Korea
KR South Korea
KW Kuwait
KY Cayman Islands
KZ Kazakhstan
LA Laos
LB Lebanon
LC Saint Lucia
LI Liechtenstein
LK Sri Lanka
LR Liberia
LS Lesotho
LT Lithuania
LU Luxembourg
LV Latvia
LY Libya
MA Morocco
MC Monaco
MD Moldova
ME Montenegro
MF Saint Martin
MG Madagascar
MH Marshall Islands
MK North Macedonia
ML Mali
MM Myanmar
MN Mongolia
MO Macao
MP Northern Mariana Islands
MQ Martinique
MR Mauritania
MS Montserrat
MT Malta
MU Mauritius
MV Maldives
MW Malawi
MX Mexico
MY Malaysia
MZ Mozambique
NA Namibia
NC New Caledonia
NE Niger
NF Norfolk Island
NG Nigeria
NI Nicaragua
NL Netherlands
NO Norway
NP Nepal
NR Nauru
NU Niue
NZ New Zealand
OM Oman
PA Panama
PE Peru
PF French Polynesia
PG Papua New Guinea
PH Philippines
PK Pakistan
PL Poland
PM Saint Pierre and Miquelon
PN Pitcairn Islands
PR Puerto Rico
PS Palestine
PT Portugal
PW Palau
PY Paraguay
QA Qatar
RE Réunion
RO Romania
RS Serbia
RU Russia
RW Rwanda
SA Saudi Arabia
SB Solomon Islands
SC Seychelles
SD Sudan
SE Sweden
SG Singapore
SH Saint Helena
SI Slovenia
SJ Svalbard and Jan Mayen
SK Slovakia
SL Sierra Leone
SM San Marino
SN Senegal
SO Somalia
SR Suriname
SS South Sudan
ST São Tomé and Príncipe
SV El Salvador
SX Sint Maarten
SY Syria
SZ Eswatini
TC Turks and Caicos Islands
TD Chad
TF French Southern Territories
TG Togo
TH Thailand
TJ Tajikistan
TK Tokelau
TL Timor-Leste
TM Turkmenistan
TN Tunisia
TO Tonga
TR Turkey
TT Trinidad and Tobago
TV Tuvalu
TW Taiwan
TZ Tanzania
AE United Arab Emirates
UA Ukraine
UG Uganda
UM U.S. Minor Outlying Islands
US United States
UY Uruguay
UZ Uzbekistan
VA Vatican City
VC St Vincent and Grenadines
VE Venezuela
VG British Virgin Islands
VI U.S. Virgin Islands
VN Vietnam
VU Vanuatu
WF Wallis and Futuna
WS Samoa
XK Kosovo
YE Yemen
YT Mayotte
ZA South Africa
ZM Zambia
ZW Zimbabwe
Example usage:
"geotarget": [
  {"location": "Canada", "link": "https://example.ca"},
  {"location": "United States", "link": "https://example.us", "state": "California"},
  {"location": "United Kingdom", "link": "https://example.co.uk"}
]

1. Links


2. Domains

List All Domains
GET https://linktw.in/api/domains?limit=2&page=1

Get all available domains for shortening links. This includes standard (platform-provided) domains and your branded (custom) domains. Use the isStandard field to distinguish between them.

ParameterDescription
limit (optional) Per page data result for branded domains
page (optional) Current page request for branded domains
curl --location --request GET 'https://linktw.in/api/domains?limit=2&page=1' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/domains?limit=2&page=1",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'GET',
    'url': 'https://linktw.in/api/domains?limit=2&page=1',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": "0",
    "data": {
        "result": 4,
        "perpage": 15,
        "currentpage": 1,
        "nextpage": null,
        "maxpage": 1,
        "domains": [
            {
                "id": "default",
                "domain": "https:\/\/linktw.in",
                "redirectroot": null,
                "redirect404": null,
                "isStandard": true
            },
            {
                "id": "standard_abc123",
                "domain": "https:\/\/short.link",
                "redirectroot": null,
                "redirect404": null,
                "isStandard": true
            },
            {
                "id": 1,
                "domain": "https:\/\/mybrand.com",
                "redirectroot": "https:\/\/mybrand.com\/home",
                "redirect404": "https:\/\/mybrand.com\/404",
                "isStandard": false
            },
            {
                "id": 2,
                "domain": "https:\/\/mycompany.io",
                "redirectroot": "https:\/\/mycompany.io",
                "redirect404": "https:\/\/mycompany.io\/not-found",
                "isStandard": false
            }
        ]
    }
}
Create a Branded Domain
POST https://linktw.in/api/domain/add

A domain can be added using this endpoint. Please make sure the domain is correctly pointed to our server.

ParameterDescription
domain (required) Branded domain including http or https
redirectroot (optional) Root redirect when someone visits your domain
redirect404 (optional) Custom 404 redirect
curl --location --request POST 'https://linktw.in/api/domain/add' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "domain": "https:\/\/domain1.com",
    "redirectroot": "https:\/\/rootdomain.com",
    "redirect404": "https:\/\/rootdomain.com\/404"
}'
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/domain/add",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode(array(
      'domain' => 'https://domain1.com',
      'redirectroot' => 'https://rootdomain.com',
      'redirect404' => 'https://rootdomain.com/404',
    )),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'POST',
    'url': 'https://linktw.in/api/domain/add',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
    "domain": "https:\/\/domain1.com",
    "redirectroot": "https:\/\/rootdomain.com",
    "redirect404": "https:\/\/rootdomain.com\/404"
}),
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": 0,
    "id": 1
}
Update Domain
PUT https://linktw.in/api/domain/:id/update

To update a branded domain, you need to send a valid data in JSON via a PUT request. The data must be sent as the raw body of your request as shown below. The example below shows all the parameters you can send but you are not required to send all (See table for more info).

ParameterDescription
redirectroot (optional) Root redirect when someone visits your domain
redirect404 (optional) Custom 404 redirect
curl --location --request PUT 'https://linktw.in/api/domain/:id/update' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "redirectroot": "https:\/\/rootdomain-new.com",
    "redirect404": "https:\/\/rootdomain-new.com\/404"
}'
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/domain/:id/update",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "PUT",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode(array(
      'redirectroot' => 'https://rootdomain-new.com',
      'redirect404' => 'https://rootdomain-new.com/404',
    )),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'PUT',
    'url': 'https://linktw.in/api/domain/:id/update',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
    "redirectroot": "https:\/\/rootdomain-new.com",
    "redirect404": "https:\/\/rootdomain-new.com\/404"
}),
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": 0,
    "message": "Domain has been updated successfully."
}
Delete Domain
DELETE https://linktw.in/api/domain/:id/delete

To delete a domain, you need to send a DELETE request.

curl --location --request DELETE 'https://linktw.in/api/domain/:id/delete' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/domain/:id/delete",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "DELETE",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'DELETE',
    'url': 'https://linktw.in/api/domain/:id/delete',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": 0,
    "message": "Domain has been deleted successfully."
}

3. Pixels

List Pixels
GET https://linktw.in/api/pixels?limit=2&page=1

To get your pixels codes via the API, you can use this endpoint. You can also filter data (See table for more info).

ParameterDescription
limit (optional) Per page data result
page (optional) Current page request
curl --location --request GET 'https://linktw.in/api/pixels?limit=2&page=1' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/pixels?limit=2&page=1",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'GET',
    'url': 'https://linktw.in/api/pixels?limit=2&page=1',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": "0",
    "data": {
        "result": 2,
        "perpage": 2,
        "currentpage": 1,
        "nextpage": 1,
        "maxpage": 1,
        "pixels": [
            {
                "id": 1,
                "type": "gtmpixel",
                "name": "GTM Pixel",
                "tag": "GA-123456789",
                "event": null,
                "date": "2023-11-10 18:00:00"
            },
            {
                "id": 2,
                "type": "fbpixel",
                "name": "Facebook Pixel",
                "tag": "1234567890123456",
                "event": "Lead",
                "date": "2023-11-10 18:10:00"
            }
        ]
    }
}
Create a Pixel
POST https://linktw.in/api/pixel/add

A pixel can be created using this endpoint. You need to send the pixel type and the tag.

ParameterDescription
type (required) gtmpixel | gapixel | fbpixel | adwordspixel | linkedinpixel | twitterpixel | adrollpixel | quorapixel | pinterest | bing | snapchat | reddit | tiktok
name (required) Custom name for your pixel
tag (required) The tag for the pixel
event (optional, Facebook only) Standard event to fire in addition to PageView on every link click. One of: Lead, CompleteRegistration, ViewContent, Search, AddToCart, AddToWishlist, InitiateCheckout, AddPaymentInfo, Purchase, Subscribe, StartTrial, Contact, Schedule, SubmitApplication, Donate. Defaults to PageView only.
curl --location --request POST 'https://linktw.in/api/pixel/add' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "type": "fbpixel",
    "name": "My Facebook Pixel",
    "tag": "1234567890123456",
    "event": "Lead"
}'
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/pixel/add",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode(array(
      'type' => 'fbpixel',
      'name' => 'My Facebook Pixel',
      'tag' => '1234567890123456',
      'event' => 'Lead',
    )),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'POST',
    'url': 'https://linktw.in/api/pixel/add',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
    "type": "fbpixel",
    "name": "My Facebook Pixel",
    "tag": "1234567890123456",
    "event": "Lead"
}),
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": 0,
    "id": 1
}
Update Pixel
PUT https://linktw.in/api/pixel/:id/update

To update a pixel, you need to send a valid data in JSON via a PUT request. The data must be sent as the raw body of your request as shown below. The example below shows all the parameters you can send but you are not required to send all (See table for more info).

ParameterDescription
name (optional) Custom name for your pixel
tag (required) The tag for the pixel
event (optional, Facebook only) Standard event to fire in addition to PageView. Send PageView (or omit) for PageView only. See "Create a Pixel" for the full list of allowed values.
curl --location --request PUT 'https://linktw.in/api/pixel/:id/update' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "My Facebook Pixel",
    "tag": "1234567890123456",
    "event": "Lead"
}'
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/pixel/:id/update",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "PUT",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode(array(
      'name' => 'My Facebook Pixel',
      'tag' => '1234567890123456',
      'event' => 'Lead',
    )),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'PUT',
    'url': 'https://linktw.in/api/pixel/:id/update',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
    "name": "My Facebook Pixel",
    "tag": "1234567890123456",
    "event": "Lead"
}),
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": 0,
    "message": "Pixel has been updated successfully."
}
Delete Pixel
DELETE https://linktw.in/api/pixel/:id/delete

To delete a pixel, you need to send a DELETE request.

curl --location --request DELETE 'https://linktw.in/api/pixel/:id/delete' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/pixel/:id/delete",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "DELETE",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'DELETE',
    'url': 'https://linktw.in/api/pixel/:id/delete',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": 0,
    "message": "Pixel has been deleted successfully."
}
Get Single Pixel
GET https://linktw.in/api/pixel/:id?limit=15&page=1

To get a single pixel with its assigned links via the API, you can use this endpoint. Returns the pixel details and a paginated list of links that have this pixel assigned.

ParameterDescription
:id (required) Pixel ID
limit (optional) Per page data result
page (optional) Current page request
curl --location --request GET 'https://linktw.in/api/pixel/:id?limit=15&page=1' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/pixel/:id?limit=15&page=1",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'GET',
    'url': 'https://linktw.in/api/pixel/:id?limit=15&page=1',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": 0,
    "data": {
        "result": 15,
        "perpage": 15,
        "currentpage": 1,
        "nextpage": 2,
        "maxpage": 3,
        "pixel": {
            "id": 1,
            "type": "gtmpixel",
            "name": "GTM Pixel",
            "tag": "GTM-XXXXX",
            "event": null,
            "date": "2024-01-15 12:00:00"
        },
        "links": [
            {
                "id": 101,
                "title": "Example Link",
                "shorturl": "https:\/\/linktw.in\/abc123",
                "longurl": "https:\/\/example.com",
                "clicks": 150,
                "date": "2024-01-10"
            }
        ]
    }
}
POST https://linktw.in/api/pixel/:id/links

Add or remove multiple links to/from a pixel in a single request. Send an array of link IDs to add and/or remove.

ParameterDescription
:id (required) Pixel ID
add (optional) Array of link IDs to add this pixel to
remove (optional) Array of link IDs to remove this pixel from
curl --location --request POST 'https://linktw.in/api/pixel/:id/links' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "add": [
        101,
        102,
        103
    ],
    "remove": [
        50,
        51
    ]
}'
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/pixel/:id/links",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode(array(
      'add' => 
  array(
        0 => 101,
        1 => 102,
        2 => 103,
      ),
      'remove' => 
  array(
        0 => 50,
        1 => 51,
      ),
    )),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'POST',
    'url': 'https://linktw.in/api/pixel/:id/links',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
    "add": [
        101,
        102,
        103
    ],
    "remove": [
        50,
        51
    ]
}),
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": 0,
    "pixel_id": 1,
    "added": [
        101,
        102,
        103
    ],
    "removed": [
        50,
        51
    ],
    "errors": []
}

4. QR Codes

List QR codes
GET https://linktw.in/api/qr?limit=2&page=1

To get your QR codes via the API, you can use this endpoint. You can also filter data (See table for more info).

ParameterDescription
limit (optional) Per page data result
page (optional) Current page request
curl --location --request GET 'https://linktw.in/api/qr?limit=2&page=1' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/qr?limit=2&page=1",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'GET',
    'url': 'https://linktw.in/api/qr?limit=2&page=1',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": "0",
    "data": {
        "result": 2,
        "perpage": 2,
        "currentpage": 1,
        "nextpage": 1,
        "maxpage": 1,
        "qrs": [
            {
                "id": 2,
                "link": "https:\/\/linktw.in\/qr\/a2d5e",
                "scans": 0,
                "name": "Google",
                "date": "2023-11-10 18:01:43"
            },
            {
                "id": 1,
                "link": "https:\/\/linktw.in\/qr\/b9edfe",
                "scans": 5,
                "name": "Google Canada",
                "date": "2023-11-10 18:00:25"
            }
        ]
    }
}
Get a single QR Code
GET https://linktw.in/api/qr/:id

To get details for a single QR code via the API, you can use this endpoint.

curl --location --request GET 'https://linktw.in/api/qr/:id' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/qr/:id",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'GET',
    'url': 'https://linktw.in/api/qr/:id',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": 0,
    "details": {
        "id": 1,
        "link": "https:\/\/linktw.in\/qr\/b9edfe",
        "scans": 5,
        "name": "Google Canada",
        "date": "2023-11-10 18:00:25"
    },
    "data": {
        "clicks": 1,
        "uniqueClicks": 1,
        "topCountries": {
            "Unknown": "1"
        },
        "topReferrers": {
            "Direct, email and other": "1"
        },
        "topBrowsers": {
            "Chrome": "1"
        },
        "topOs": {
            "Windows 10": "1"
        },
        "socialCount": {
            "facebook": 0,
            "twitter": 0,
            "instagram": 0
        }
    }
}
Create a QR Code
POST https://linktw.in/api/qr/add

To create a QR Code, you need to send a valid data in JSON via a POST request. The data must be sent as the raw body of your request as shown below. The example below shows all the parameters you can send but you are not required to send all (See table for more info).

ParameterDescription
type (required) text | vcard | link | email | phone | sms | wifi
data (required) Data to be embedded inside the QR code. The data can be string or array depending on the type
background (optional) RGB color e.g. rgb(255,255,255)
foreground (optional) RGB color e.g. rgb(0,0,0)
logo (optional) Path to the logo either png or jpg
curl --location --request POST 'https://linktw.in/api/qr/add' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "type": "link",
    "data": "https:\/\/google.com",
    "background": "rgb(255,255,255)",
    "foreground": "rgb(0,0,0)",
    "logo": "https:\/\/site.com\/logo.png"
}'
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/qr/add",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode(array(
      'type' => 'link',
      'data' => 'https://google.com',
      'background' => 'rgb(255,255,255)',
      'foreground' => 'rgb(0,0,0)',
      'logo' => 'https://site.com/logo.png',
    )),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'POST',
    'url': 'https://linktw.in/api/qr/add',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
    "type": "link",
    "data": "https:\/\/google.com",
    "background": "rgb(255,255,255)",
    "foreground": "rgb(0,0,0)",
    "logo": "https:\/\/site.com\/logo.png"
}),
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": 0,
    "id": 3,
    "link": "https:\/\/linktw.in\/qr\/a58f79"
}
Update QR Code
PUT https://linktw.in/api/qr/:id/update

To update a QR Code, you need to send a valid data in JSON via a PUT request. The data must be sent as the raw body of your request as shown below. The example below shows all the parameters you can send but you are not required to send all (See table for more info).

ParameterDescription
data (required) Data to be embedded inside the QR code. The data can be string or array depending on the type
background (optional) RGB color e.g. rgb(255,255,255)
foreground (optional) RGB color e.g. rgb(0,0,0)
logo (optional) Path to the logo either png or jpg
curl --location --request PUT 'https://linktw.in/api/qr/:id/update' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "type": "link",
    "data": "https:\/\/google.com",
    "background": "rgb(255,255,255)",
    "foreground": "rgb(0,0,0)",
    "logo": "https:\/\/site.com\/logo.png"
}'
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/qr/:id/update",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "PUT",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode(array(
      'type' => 'link',
      'data' => 'https://google.com',
      'background' => 'rgb(255,255,255)',
      'foreground' => 'rgb(0,0,0)',
      'logo' => 'https://site.com/logo.png',
    )),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'PUT',
    'url': 'https://linktw.in/api/qr/:id/update',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
    "type": "link",
    "data": "https:\/\/google.com",
    "background": "rgb(255,255,255)",
    "foreground": "rgb(0,0,0)",
    "logo": "https:\/\/site.com\/logo.png"
}),
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": 0,
    "message": "QR has been updated successfully."
}
Delete a QR Code
DELETE https://linktw.in/api/qr/:id/delete

To delete a QR code, you need to send a DELETE request.

curl --location --request DELETE 'https://linktw.in/api/qr/:id/delete' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/qr/:id/delete",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "DELETE",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'DELETE',
    'url': 'https://linktw.in/api/qr/:id/delete',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": 0,
    "message": "QR Code has been deleted successfully."
}

5. Collections

List Collections
GET https://linktw.in/api/collections?limit=2&page=1

To get your collections via the API, you can use this endpoint. You can also filter data (See table for more info).

ParameterDescription
limit (optional) Per page data result
page (optional) Current page request
curl --location --request GET 'https://linktw.in/api/collections?limit=2&page=1' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/collections?limit=2&page=1",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'GET',
    'url': 'https://linktw.in/api/collections?limit=2&page=1',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": "0",
    "data": {
        "result": 2,
        "perpage": 2,
        "currentpage": 1,
        "nextpage": 1,
        "maxpage": 1,
        "collections": [
            {
                "id": 1,
                "name": "Social Media",
                "description": "All social media links",
                "color": "#1E88E5",
                "public": false,
                "rotator": false,
                "list": "https:\/\/domain.com\/u\/admin\/social-media-1",
                "starred": true,
                "views": 150,
                "clicks": 5420
            },
            {
                "id": 2,
                "name": "Marketing Campaign",
                "description": "Q4 Marketing Campaign",
                "color": "#00897B",
                "public": true,
                "rotator": "https:\/\/domain.com\/r\/marketing-campaign",
                "list": "https:\/\/domain.com\/u\/admin\/marketing-campaign-2",
                "starred": false,
                "views": 300,
                "clicks": 12580
            }
        ]
    }
}
Get Single Collection
GET https://linktw.in/api/collection/:id?limit=1&page=1

To get items in a selected collection via the API, you can use this endpoint. You can also filter data (See table for more info).

ParameterDescription
limit (optional) Per page data result
page (optional) Current page request
curl --location --request GET 'https://linktw.in/api/collection/:id?limit=1&page=1' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/collection/:id?limit=1&page=1",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'GET',
    'url': 'https://linktw.in/api/collection/:id?limit=1&page=1',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": "0",
    "data": {
        "result": 2,
        "perpage": 2,
        "currentpage": 1,
        "nextpage": 1,
        "maxpage": 1,
        "items": [
            {
                "type": "links",
                "id": 1,
                "title": "My Sample Link",
                "preview": "https:\/\/google.com",
                "link": "https:\/\/linktw.in\/google",
                "date": "2024-05-12"
            },
            {
                "type": "bio",
                "id": 1,
                "title": "My Sample Bio",
                "preview": "https:\/\/linktw.in\/mybio",
                "link": "https:\/\/linktw.in\/mybio",
                "date": "2024-06-01"
            },
            {
                "type": "qr",
                "id": 1,
                "title": "My QR Code",
                "preview": "https:\/\/example.com",
                "link": "https:\/\/linktw.in\/qr\/1",
                "date": "2024-06-15"
            }
        ]
    }
}
Create a Collection
POST https://linktw.in/api/collection/add

A collection can be added using this endpoint.

ParameterDescription
name (required) Collection name
slug (optional) Rotator Slug
description (optional) Collection description
color (optional) Collection badge color (HEX)
public (optional) Access (true or false)
starred (optional) Star the collection or not (true or false)
curl --location --request POST 'https://linktw.in/api/collection/add' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "NewCollection",
    "slug": "new-collection",
    "description": "My new collection",
    "color": "#1E88E5",
    "public": true,
    "starred": true
}'
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/collection/add",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode(array(
      'name' => 'NewCollection',
      'slug' => 'new-collection',
      'description' => 'My new collection',
      'color' => '#1E88E5',
      'public' => true,
      'starred' => true,
    )),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'POST',
    'url': 'https://linktw.in/api/collection/add',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
    "name": "NewCollection",
    "slug": "new-collection",
    "description": "My new collection",
    "color": "#1E88E5",
    "public": true,
    "starred": true
}),
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": 0,
    "id": 3,
    "name": "New Collection",
    "public": true,
    "rotator": "https:\/\/domain.com\/r\/new-collection",
    "list": "https:\/\/domain.com\/u\/admin\/new-collection-3"
}
POST https://linktw.in/api/collection/:collectionid/assign/:itemid

A link can be assigned to any collection by sending a request with the collection id and link id.

ParameterDescription
:collectionid (required) Collection ID
:itemid (required) Link ID
curl --location --request POST 'https://linktw.in/api/collection/:collectionid/assign/:itemid' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/collection/:collectionid/assign/:itemid",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'POST',
    'url': 'https://linktw.in/api/collection/:collectionid/assign/:itemid',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": 0,
    "message": "Link successfully added to the collection."
}
POST https://linktw.in/api/collection/:id/links

Add or remove multiple links to/from a collection in a single request. Send an array of link IDs to add and/or remove.

ParameterDescription
:id (required) Collection ID
add (optional) Array of link IDs to add to the collection
remove (optional) Array of link IDs to remove from the collection
curl --location --request POST 'https://linktw.in/api/collection/:id/links' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "add": [
        101,
        102,
        103
    ],
    "remove": [
        50,
        51
    ]
}'
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/collection/:id/links",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode(array(
      'add' => 
  array(
        0 => 101,
        1 => 102,
        2 => 103,
      ),
      'remove' => 
  array(
        0 => 50,
        1 => 51,
      ),
    )),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'POST',
    'url': 'https://linktw.in/api/collection/:id/links',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
    "add": [
        101,
        102,
        103
    ],
    "remove": [
        50,
        51
    ]
}),
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": 0,
    "collection_id": 5,
    "added": [
        101,
        102,
        103
    ],
    "removed": [
        50,
        51
    ],
    "errors": []
}
Update Collection
PUT https://linktw.in/api/collection/:id/update

To update a collection, you need to send a valid data in JSON via a PUT request. The data must be sent as the raw body of your request as shown below. The example below shows all the parameters you can send but you are not required to send all (See table for more info).

ParameterDescription
name (optional) Collection name
slug (optional) Rotator Slug
description (optional) Collection description
color (optional) Collection badge color (HEX)
public (optional) Access (true or false)
starred (optional) Star the collection or not (true or false)
curl --location --request PUT 'https://linktw.in/api/collection/:id/update' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "Updated Collection",
    "description": "Updated collection description",
    "color": "#FF5722",
    "public": false,
    "starred": true
}'
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/collection/:id/update",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "PUT",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode(array(
      'name' => 'Updated Collection',
      'description' => 'Updated collection description',
      'color' => '#FF5722',
      'public' => false,
      'starred' => true,
    )),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'PUT',
    'url': 'https://linktw.in/api/collection/:id/update',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
    "name": "Updated Collection",
    "description": "Updated collection description",
    "color": "#FF5722",
    "public": false,
    "starred": true
}),
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": 0,
    "message": "Collection has been updated successfully."
}
Delete Collection
DELETE https://linktw.in/api/collection/:id/delete

To delete a collection, you need to send a DELETE request. All items will be unassigned as well.

curl --location --request DELETE 'https://linktw.in/api/collection/:id/delete' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/collection/:id/delete",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "DELETE",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'DELETE',
    'url': 'https://linktw.in/api/collection/:id/delete',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": 0,
    "message": "Collection has been deleted successfully."
}

6. Statistics

Caching: Statistics endpoints use intelligent caching that automatically invalidates when new click data arrives. This means you always get fresh data while minimizing server load. Repeated requests with no new clicks will return cached results instantly.

Dashboard Statistics
GET https://linktw.in/api/statistics/dashboard?period=1m&timezone=America%2FNew_York

Get aggregated statistics for your account, including KPIs (total clicks, unique clicks, top referrer, top country), links created, and performance metrics for the dashboard view. Chart data format varies by period: 1d returns 25 hourly entries with partial hours at start/end, other periods return complete time series with 0 clicks for empty periods. For periods longer than 90 days, data is grouped by month. All date/time values in the response will be adjusted to the specified timezone.

Hard Restrictions: The date range is automatically limited by: (1) Plan retention limit, (2) Account creation date, (3) Oldest link creation date. You cannot query data before any of these limits.

ParameterDescription
period (optional) Time period: 1d (1 day), 1w (1 week), 1m (1 month), 1y (1 year), or max (all time). Default: 1m
timezone (optional) Timezone for date calculations and display (e.g., "America/New_York", "Europe/London", "Asia/Bangkok"). If not provided, uses the user's default timezone or UTC as fallback. Must be a valid timezone from PHP's timezone database.
curl --location --request GET 'https://linktw.in/api/statistics/dashboard?period=1m&timezone=America%2FNew_York' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "period": "1w",
    "timezone": "Europe\/London"
}'
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/statistics/dashboard?period=1m&timezone=America%2FNew_York",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode(array(
      'period' => '1w',
      'timezone' => 'Europe/London',
    )),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'GET',
    'url': 'https://linktw.in/api/statistics/dashboard?period=1m&timezone=America%2FNew_York',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
    "period": "1w",
    "timezone": "Europe\/London"
}),
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": 0,
    "data": {
        "totalClicks": 15420,
        "totalUniqueClicks": 12340,
        "topReferrer": "Direct",
        "topReferrerClicks": 5234,
        "topCountry": "United States",
        "topCountryCode": "US",
        "topCountryClicks": 4521,
        "totalLinks": 156,
        "performanceGrowth": 12.5,
        "chartData": [
            {
                "date": "2025-06-14 10:00",
                "clicks": 45
            },
            {
                "date": "2025-06-14 11:00",
                "clicks": 62
            },
            {
                "date": "2025-06-14 12:00",
                "clicks": 89
            }
        ],
        "topPerformingLinks": [
            {
                "id": 123,
                "shortUrl": "http:\/\/linktwin.com\/abc123",
                "longUrl": "https:\/\/example.com\/my-product-landing-page",
                "title": "My Product Landing Page",
                "display_title": "Summer Campaign Link",
                "clicks": 1250,
                "uniqueClicks": 987
            }
        ]
    }
}
Detailed Statistics
GET https://linktw.in/api/statistics/detailed?date_range=30d&collections=%5B1%2C3%5D&timezone=Europe%2FLondon

Get comprehensive statistics including KPIs (total clicks, unique clicks, top referrer, top country), dashboard metrics, plus detailed breakdowns by countries, referrers, browsers, devices, languages, cities, and day trends (hourly/daily click distribution). Breakdown lists return the top 9 items plus an "Other" category aggregating all remaining items (useful for pie charts). This endpoint combines both dashboard data and detailed analytics in a single response. Chart data format varies by period: 1d returns 25 hourly entries with partial hours at start/end, other periods return complete time series with 0 clicks for empty periods. For periods longer than 90 days, data is grouped by month. When using timezone parameter, date boundaries are calculated based on the specified timezone. You can filter results by one or more collections using their IDs or names.

Numbers match the website statistics page: bio page views are not counted as clicks (they are returned separately as bioViews), and referrers are grouped by source (e.g. "Instagram"), with clicks from your bio pages listed as "@alias" (type "bio"). allTimeClicks and allTimeUniqueClicks cover all time, not the date range.

Hard Restrictions: The date range is automatically limited by: (1) Plan retention limit, (2) Account creation date, (3) Oldest link creation date (or oldest link in filtered collections). You cannot query data before any of these limits.

Click filter: the f_ parameters narrow every number to the matching clicks, like the Filter button on the website statistics pages. Several values of one parameter count any of them, several parameters must all match. While filtered, allTimeClicks and allTimeUniqueClicks are null because they cannot be filtered; filters returns the filter used ({} without one). A filtered request that takes too long is answered with HTTP 503 and code filter_timeout: try a shorter date range.

ParameterDescription
date_range (optional) Date range: 1d (last 24 hours), 7d, 30d or 1y (that many days including today), max, or custom. Default: 30d
start_date (optional) Start date in YYYY-MM-DD or ISO 8601 format (required if date_range is custom)
end_date (optional) End date in YYYY-MM-DD or ISO 8601 format (required if date_range is custom)
collection_id (optional) Filter statistics by a single collection ID (for backward compatibility)
collections (optional) Filter statistics by one or more collection IDs or names. Can be a single value, comma-separated string, or JSON array. Example: [1,2,3] or ["Marketing","Social Media"]
timezone (optional) Timezone for date calculations (e.g., "America/New_York", "Europe/London", "Asia/Bangkok"). If not provided, uses the user's default timezone or UTC as fallback. Must be a valid timezone from PHP's timezone database.
f_country[] (optional) Click filter: only clicks from these countries, values as shown in the dashboard's statistics filter. Repeat the parameter for several values.
f_referrer[] (optional) Click filter: only clicks from these sources, values as shown in the dashboard's statistics filter (for example instagram.com, or direct for clicks without a referrer).
f_os[] (optional) Click filter: only clicks from these operating systems.
f_browser[] (optional) Click filter: only clicks from these browsers.
f_language[] (optional) Click filter: only clicks with these browser languages (for example en).
curl --location --request GET 'https://linktw.in/api/statistics/detailed?date_range=30d&collections=%5B1%2C3%5D&timezone=Europe%2FLondon' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "date_range": "custom",
    "start_date": "2025-01-01",
    "end_date": "2025-06-14",
    "collections": [
        1,
        3
    ],
    "timezone": "America\/New_York"
}'
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/statistics/detailed?date_range=30d&collections=%5B1%2C3%5D&timezone=Europe%2FLondon",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode(array(
      'date_range' => 'custom',
      'start_date' => '2025-01-01',
      'end_date' => '2025-06-14',
      'collections' => 
  array(
        0 => 1,
        1 => 3,
      ),
      'timezone' => 'America/New_York',
    )),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'GET',
    'url': 'https://linktw.in/api/statistics/detailed?date_range=30d&collections=%5B1%2C3%5D&timezone=Europe%2FLondon',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
    "date_range": "custom",
    "start_date": "2025-01-01",
    "end_date": "2025-06-14",
    "collections": [
        1,
        3
    ],
    "timezone": "America\/New_York"
}),
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": 0,
    "data": {
        "totalClicks": 15420,
        "totalUniqueClicks": 12340,
        "topReferrer": "Direct",
        "topReferrerClicks": 5234,
        "topCountry": "United States",
        "topCountryCode": "US",
        "topCountryClicks": 4521,
        "allTimeClicks": 98210,
        "allTimeUniqueClicks": 70412,
        "bioViews": 2310,
        "totalLinks": 156,
        "performanceGrowth": 12.5,
        "chartData": [
            {
                "date": "2025-01-01",
                "clicks": 342
            },
            {
                "date": "2025-01-02",
                "clicks": 421
            },
            "\/\/ ... continues for all days in range ..."
        ],
        "topPerformingLinks": [
            {
                "id": 123,
                "shortUrl": "linktwin.com\/abc123",
                "longUrl": "https:\/\/example.com\/product-page",
                "title": "Product Landing Page",
                "display_title": "Q1 Promo Link",
                "clicks": 3542,
                "uniqueClicks": 2987
            },
            "\/\/ ... up to 5 top performing links ..."
        ],
        "topCountries": [
            {
                "country": "United States",
                "countryCode": "US",
                "count": 5423
            },
            {
                "country": "Canada",
                "countryCode": "CA",
                "count": 2341
            },
            "\/\/ ... up to 9 countries ...",
            {
                "country": "Other",
                "countryCode": null,
                "count": 1245
            }
        ],
        "topReferrers": [
            {
                "domain": "Direct",
                "count": 4521,
                "label": "Direct traffic",
                "host": null,
                "icon": "https:\/\/linktwin.com\/static\/images\/direct.svg",
                "type": "direct"
            },
            {
                "domain": "Google",
                "count": 3201,
                "label": "Google",
                "host": "google.com",
                "icon": "https:\/\/linktwin.com\/static\/images\/google.svg",
                "type": "domain"
            },
            {
                "domain": "@mybio",
                "count": 1288,
                "label": "@mybio",
                "host": null,
                "icon": "https:\/\/linktwin.com\/static\/images\/bio-page.svg",
                "type": "bio"
            },
            "\/\/ ... up to 9 referrers ...",
            {
                "domain": "Other",
                "count": 892,
                "label": "Other",
                "host": null,
                "icon": null,
                "type": "other"
            }
        ],
        "topBrowsers": [
            {
                "browser": "Chrome",
                "count": 8923
            },
            {
                "browser": "Safari",
                "count": 3421
            },
            "\/\/ ... up to 9 browsers ...",
            {
                "browser": "Other",
                "count": 456
            }
        ],
        "topDevices": [
            {
                "os": "Windows 10",
                "count": 6234
            },
            {
                "os": "iOS",
                "count": 4521
            },
            "\/\/ ... up to 9 devices ...",
            {
                "os": "Other",
                "count": 321
            }
        ],
        "topLanguages": [
            {
                "language": "English",
                "languageCode": "en",
                "count": 10234
            },
            {
                "language": "Spanish",
                "languageCode": "es",
                "count": 2341
            },
            "\/\/ ... up to 9 languages ...",
            {
                "language": "Other",
                "languageCode": null,
                "count": 567
            }
        ],
        "topCities": [
            {
                "city": "New York",
                "country": "United States",
                "countryCode": "US",
                "count": 1523
            },
            {
                "city": "Los Angeles",
                "country": "United States",
                "countryCode": "US",
                "count": 1234
            },
            "\/\/ ... up to 9 cities ...",
            {
                "city": "Other",
                "country": null,
                "countryCode": null,
                "count": 789
            }
        ],
        "dayTrend": {
            "hourlyTrend": [
                {
                    "hour": 0,
                    "label": "00:00",
                    "clicks": 45,
                    "uniqueClicks": 32
                },
                {
                    "hour": 1,
                    "label": "01:00",
                    "clicks": 23,
                    "uniqueClicks": 18
                },
                "\/\/ ... data for all 24 hours ...",
                {
                    "hour": 23,
                    "label": "23:00",
                    "clicks": 67,
                    "uniqueClicks": 51
                }
            ],
            "dailyTrend": [
                {
                    "day": 0,
                    "label": "Sunday",
                    "clicks": 234,
                    "uniqueClicks": 189
                },
                {
                    "day": 1,
                    "label": "Monday",
                    "clicks": 456,
                    "uniqueClicks": 367
                },
                "\/\/ ... data for all 7 days ...",
                {
                    "day": 6,
                    "label": "Saturday",
                    "clicks": 345,
                    "uniqueClicks": 278
                }
            ],
            "summary": {
                "totalClicks": 2456,
                "totalUniqueClicks": 1987,
                "peakHour": {
                    "hour": 14,
                    "label": "14:00",
                    "clicks": 234,
                    "uniqueClicks": 189
                },
                "peakDay": {
                    "day": 3,
                    "label": "Wednesday",
                    "clicks": 567,
                    "uniqueClicks": 456
                },
                "timezone": "Europe\/London",
                "period": "30d",
                "from": "2025-01-01 00:00:00",
                "to": "2025-01-31 23:59:59"
            }
        },
        "filters": {
            "country": [
                "Germany"
            ],
            "referrer": [
                "instagram.com"
            ]
        }
    }
}
GET https://linktw.in/api/statistics/link/:id?date_range=30d&timezone=Asia/Bangkok

Get detailed statistics for a specific link, including click data, geographic distribution, referrers, devices, browsers, languages, cities, day trends (hourly/daily click distribution), and recent activity (5 most recent clicks). You can pass either the link ID (e.g., 123) or the full short URL (e.g., https://linktw.in/abc123). Chart data format varies by period: 1d returns 25 hourly entries with partial hours at start/end, other periods return complete time series with 0 clicks for empty periods. For periods longer than 90 days, data is grouped by month. All date/time values in the response will be adjusted to the specified timezone. For free plan users, the response also includes missedClicks (total clicks that exceeded the plan limit).

Hard Restrictions: The date range is automatically limited by: (1) Plan retention limit, (2) Account creation date, (3) Link creation date. You cannot query data before any of these limits.

Click filter: the f_ parameters narrow every number to the matching clicks, like the Filter button on the website statistics pages. Several values of one parameter count any of them, several parameters must all match. While filtered, allTimeClicks and allTimeUniqueClicks are null because they cannot be filtered; filters returns the filter used ({} without one). A filtered request that takes too long is answered with HTTP 503 and code filter_timeout: try a shorter date range.

ParameterDescription
date_range (required) Date range: 1d (last 24 hours), 7d, 30d or 1y (that many days including today), max, or custom
start_date (optional) Start date in YYYY-MM-DD or ISO 8601 format (required if date_range is custom)
end_date (optional) End date in YYYY-MM-DD or ISO 8601 format (required if date_range is custom)
timezone (optional) Timezone for date calculations and display (e.g., "America/New_York", "Europe/London", "Asia/Bangkok"). If not provided, uses the user's default timezone or UTC as fallback. Must be a valid timezone from PHP's timezone database.
f_country[] (optional) Click filter: only clicks from these countries, values as shown in the dashboard's statistics filter. Repeat the parameter for several values.
f_referrer[] (optional) Click filter: only clicks from these sources, values as shown in the dashboard's statistics filter (for example instagram.com, or direct for clicks without a referrer).
f_os[] (optional) Click filter: only clicks from these operating systems.
f_browser[] (optional) Click filter: only clicks from these browsers.
f_language[] (optional) Click filter: only clicks with these browser languages (for example en).
curl --location --request GET 'https://linktw.in/api/statistics/link/:id?date_range=30d&timezone=Asia/Bangkok' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "date_range": "1d",
    "timezone": "Asia\/Bangkok"
}'
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/statistics/link/:id?date_range=30d&timezone=Asia/Bangkok",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode(array(
      'date_range' => '1d',
      'timezone' => 'Asia/Bangkok',
    )),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'GET',
    'url': 'https://linktw.in/api/statistics/link/:id?date_range=30d&timezone=Asia/Bangkok',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
    "date_range": "1d",
    "timezone": "Asia\/Bangkok"
}),
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": 0,
    "data": {
        "link": {
            "id": 180,
            "shortUrl": "linktwin.com\/abc123",
            "longUrl": "https:\/\/example.com\/product-page",
            "title": "Product Landing Page",
            "display_title": "Main Product Link",
            "absoluteClicks": 5234,
            "createdAt": "2024-12-01 10:30:00"
        },
        "totalClicks": 523,
        "totalUniqueClicks": 421,
        "topReferrer": "google.com",
        "topReferrerClicks": 156,
        "topCountry": "United States",
        "topCountryCode": "US",
        "topCountryClicks": 234,
        "performanceGrowth": 15.4,
        "missedClicks": 42,
        "chartData": [
            {
                "date": "2025-05-15",
                "clicks": 23
            },
            {
                "date": "2025-05-16",
                "clicks": 18
            },
            {
                "date": "2025-05-17",
                "clicks": 0
            },
            "\/\/ ... all days in the range included, even with 0 clicks ..."
        ],
        "topCountries": [
            {
                "country": "United States",
                "countryCode": "US",
                "count": 234
            },
            {
                "country": "Canada",
                "countryCode": "CA",
                "count": 89
            },
            "\/\/ ... up to 9 countries ...",
            {
                "country": "Other",
                "countryCode": null,
                "count": 45
            }
        ],
        "topReferrers": [
            {
                "domain": "Google",
                "count": 156,
                "label": "Google",
                "host": "google.com",
                "icon": "https:\/\/linktwin.com\/static\/images\/google.svg",
                "type": "domain"
            },
            {
                "domain": "@mybio",
                "count": 98,
                "label": "@mybio",
                "host": null,
                "icon": "https:\/\/linktwin.com\/static\/images\/bio-page.svg",
                "type": "bio"
            },
            "\/\/ ... up to 9 referrers ...",
            {
                "domain": "Other",
                "count": 32,
                "label": "Other",
                "host": null,
                "icon": null,
                "type": "other"
            }
        ],
        "topBrowsers": [
            {
                "browser": "Chrome",
                "count": 312
            },
            {
                "browser": "Safari",
                "count": 134
            },
            "\/\/ ... up to 9 browsers ...",
            {
                "browser": "Other",
                "count": 21
            }
        ],
        "topDevices": [
            {
                "os": "iOS",
                "count": 234
            },
            {
                "os": "Android",
                "count": 189
            },
            "\/\/ ... up to 9 devices ...",
            {
                "os": "Other",
                "count": 15
            }
        ],
        "topLanguages": [
            {
                "language": "English",
                "languageCode": "en",
                "count": 423
            },
            {
                "language": "French",
                "languageCode": "fr",
                "count": 67
            },
            "\/\/ ... up to 9 languages ...",
            {
                "language": "Other",
                "languageCode": null,
                "count": 18
            }
        ],
        "topCities": [
            {
                "city": "New York",
                "country": "United States",
                "countryCode": "US",
                "count": 89
            },
            {
                "city": "London",
                "country": "United Kingdom",
                "countryCode": "GB",
                "count": 67
            },
            "\/\/ ... up to 9 cities ...",
            {
                "city": "Other",
                "country": null,
                "countryCode": null,
                "count": 28
            }
        ],
        "dayTrend": {
            "hourlyTrend": [
                {
                    "hour": 0,
                    "label": "00:00",
                    "clicks": 12,
                    "uniqueClicks": 9
                },
                {
                    "hour": 1,
                    "label": "01:00",
                    "clicks": 8,
                    "uniqueClicks": 6
                },
                "\/\/ ... data for all 24 hours ...",
                {
                    "hour": 23,
                    "label": "23:00",
                    "clicks": 15,
                    "uniqueClicks": 11
                }
            ],
            "dailyTrend": [
                {
                    "day": 0,
                    "label": "Sunday",
                    "clicks": 67,
                    "uniqueClicks": 52
                },
                {
                    "day": 1,
                    "label": "Monday",
                    "clicks": 89,
                    "uniqueClicks": 71
                },
                "\/\/ ... data for all 7 days ...",
                {
                    "day": 6,
                    "label": "Saturday",
                    "clicks": 78,
                    "uniqueClicks": 61
                }
            ],
            "summary": {
                "totalClicks": 523,
                "totalUniqueClicks": 421,
                "peakHour": {
                    "hour": 14,
                    "label": "14:00",
                    "clicks": 45,
                    "uniqueClicks": 36
                },
                "peakDay": {
                    "day": 2,
                    "label": "Tuesday",
                    "clicks": 112,
                    "uniqueClicks": 89
                },
                "timezone": "Asia\/Bangkok",
                "period": "30d",
                "from": "2025-04-15 00:00:00",
                "to": "2025-05-15 23:59:59"
            }
        },
        "recentActivity": [
            {
                "date": "2025-05-15 14:32:18",
                "country": "United States",
                "countryCode": "US",
                "city": "New York",
                "os": "iOS",
                "browser": "Safari",
                "referrer": "https:\/\/facebook.com\/post\/123",
                "referrerDomain": "facebook.com",
                "language": "English",
                "languageCode": "en",
                "missedClick": false
            },
            {
                "date": "2025-05-15 13:21:05",
                "country": "Germany",
                "countryCode": "DE",
                "city": "Berlin",
                "os": "Windows",
                "browser": "Chrome",
                "referrer": null,
                "referrerDomain": null,
                "language": "German",
                "languageCode": "de",
                "missedClick": false
            },
            "\/\/ ... up to 5 recent clicks ..."
        ]
    }
}
Day Trend - Hourly & Daily Click Distribution
GET https://linktw.in/api/statistics/daytrend?timezone=America%2FNew_York

Get hourly and daily click distribution to identify peak activity times. This endpoint shows when users are most active throughout the day (by hour) and week (by day of week), helping you optimize your content scheduling and marketing campaigns. Returns click data for each hour (0-23) and each day of the week (Sunday-Saturday).

Hard Restrictions: The date range is automatically limited by: (1) Plan retention limit, (2) Account creation date, (3) Oldest link creation date. You cannot query data before any of these limits.

ParameterDescription
period (optional) Time period for statistics. Options: "1d" (24 hours), "7d" or "1w" (7 days), "30d" or "1m" (30 days, default), "1y" (365 days), "max" (all time), "custom" (requires start_date and end_date)
start_date (optional) Start date for custom period (Y-m-d format, e.g., "2025-01-01"). Required when period is "custom"
end_date (optional) End date for custom period (Y-m-d format, e.g., "2025-01-31"). Required when period is "custom"
timezone (optional) Timezone for hour calculations (e.g., "America/New_York", "Europe/London", "Asia/Bangkok"). If not provided, uses the user's default timezone or UTC as fallback. Must be a valid timezone from PHP's timezone database.
collection_id (optional) Filter statistics by a single collection ID (for backward compatibility)
collections (optional) Filter statistics by one or more collection IDs or names. Can be a single value, comma-separated string, or JSON array. Example: [1,2,3] or ["Marketing","Social Media"]
curl --location --request GET 'https://linktw.in/api/statistics/daytrend?timezone=America%2FNew_York' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "period": "30d",
    "timezone": "Europe\/Berlin",
    "collections": [
        "Marketing",
        "Social Media"
    ]
}'
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/statistics/daytrend?timezone=America%2FNew_York",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode(array(
      'period' => '30d',
      'timezone' => 'Europe/Berlin',
      'collections' => 
  array(
        0 => 'Marketing',
        1 => 'Social Media',
      ),
    )),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'GET',
    'url': 'https://linktw.in/api/statistics/daytrend?timezone=America%2FNew_York',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
    "period": "30d",
    "timezone": "Europe\/Berlin",
    "collections": [
        "Marketing",
        "Social Media"
    ]
}),
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": 0,
    "data": {
        "hourlyTrend": [
            {
                "hour": 0,
                "label": "00:00",
                "clicks": 145,
                "uniqueClicks": 98
            },
            {
                "hour": 1,
                "label": "01:00",
                "clicks": 87,
                "uniqueClicks": 54
            },
            "\/\/ ... data for all 24 hours ...",
            {
                "hour": 23,
                "label": "23:00",
                "clicks": 234,
                "uniqueClicks": 156
            }
        ],
        "dailyTrend": [
            {
                "day": 0,
                "label": "Sunday",
                "clicks": 1234,
                "uniqueClicks": 890
            },
            {
                "day": 1,
                "label": "Monday",
                "clicks": 1567,
                "uniqueClicks": 1123
            },
            "\/\/ ... data for all 7 days ...",
            {
                "day": 6,
                "label": "Saturday",
                "clicks": 1345,
                "uniqueClicks": 967
            }
        ],
        "summary": {
            "totalClicks": 12043,
            "totalUniqueClicks": 8765,
            "peakHour": {
                "hour": 15,
                "label": "15:00",
                "clicks": 1043,
                "uniqueClicks": 789
            },
            "peakDay": {
                "day": 3,
                "label": "Wednesday",
                "clicks": 2156,
                "uniqueClicks": 1567
            },
            "timezone": "Europe\/Berlin",
            "period": "30d",
            "from": "2025-01-01 00:00:00",
            "to": "2025-01-31 23:59:59"
        }
    }
}

Webhooks

Get events the moment they happen: LinkTwin sends a signed POST request with JSON to your address for each event you subscribe to. Subscribe and unsubscribe with these endpoints (REST hooks, as Zapier and Make do), or on the Webhooks page of your dashboard.

Every request carries the headers X-LinkTwin-Event, X-LinkTwin-Delivery and X-LinkTwin-Signature (t=timestamp,v1=signature, an HMAC-SHA256 of the timestamp, a dot and the raw body, keyed with the signing secret). Drop duplicates by the event id. Failed deliveries are tried again for up to a day; a webhook that keeps failing is turned off.

API keys: you can make several keys on the same page, each with Full access or Read only. A read-only key answers 403 to every request other than GET. Your original key keeps working as the Default key.

List Webhooks
GET https://linktw.in/api/webhooks

List the webhooks of your account. Signing secrets are never listed.

curl --location --request GET 'https://linktw.in/api/webhooks' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/webhooks",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'GET',
    'url': 'https://linktw.in/api/webhooks',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": 0,
    "data": {
        "result": 1,
        "limit": 25,
        "webhooks": [
            {
                "id": 5,
                "name": "Zapier",
                "url": "https:\/\/hooks.zapier.com\/hooks\/standard\/123\/abc",
                "events": [
                    "link.clicked"
                ],
                "filters": {
                    "collection_ids": [
                        7
                    ]
                },
                "status": "active",
                "source": "api",
                "failures": 0,
                "disabled_reason": null,
                "disabled_at": null,
                "last_delivery_at": "2026-11-12T10:15:02+00:00",
                "last_status": 200,
                "created_at": "2026-11-12T09:00:00+00:00"
            }
        ]
    }
}
Subscribe a Webhook
POST https://linktw.in/api/webhooks

Create a webhook. The answer carries its signing secret once: keep it to check the X-LinkTwin-Signature header.

ParameterDescription
url (required) The https address that receives the events
events (required) A list of events, for example ["link.clicked"]. See List Events.
name (optional) A name to tell your webhooks apart
filters (optional) {"link_ids": [...], "collection_ids": [...]}: only these links, or links in these collections
curl --location --request POST 'https://linktw.in/api/webhooks' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "url": "https:\/\/example.com\/linktwin-hook",
    "events": [
        "link.created",
        "link.clicked"
    ],
    "name": "My server",
    "filters": {
        "collection_ids": [
            7
        ]
    }
}'
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/webhooks",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode(array(
      'url' => 'https://example.com/linktwin-hook',
      'events' => 
  array(
        0 => 'link.created',
        1 => 'link.clicked',
      ),
      'name' => 'My server',
      'filters' => 
  array(
        'collection_ids' => 
    array(
          0 => 7,
        ),
      ),
    )),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'POST',
    'url': 'https://linktw.in/api/webhooks',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
    "url": "https:\/\/example.com\/linktwin-hook",
    "events": [
        "link.created",
        "link.clicked"
    ],
    "name": "My server",
    "filters": {
        "collection_ids": [
            7
        ]
    }
}),
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": 0,
    "data": {
        "id": 6,
        "name": "My server",
        "url": "https:\/\/example.com\/linktwin-hook",
        "events": [
            "link.created",
            "link.clicked"
        ],
        "filters": {
            "collection_ids": [
                7
            ]
        },
        "status": "active",
        "source": "api",
        "created_at": "2026-11-12T09:00:00+00:00",
        "secret": "whsec_3f9a..."
    }
}
Get a Webhook
GET https://linktw.in/api/webhooks/:id

Get one webhook.

curl --location --request GET 'https://linktw.in/api/webhooks/:id' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/webhooks/:id",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'GET',
    'url': 'https://linktw.in/api/webhooks/:id',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
null
Delete a Webhook
DELETE https://linktw.in/api/webhooks/:id

Delete a webhook (unsubscribe). Its delivery log is deleted too.

curl --location --request DELETE 'https://linktw.in/api/webhooks/:id' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/webhooks/:id",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "DELETE",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'DELETE',
    'url': 'https://linktw.in/api/webhooks/:id',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": 0,
    "message": "Webhook deleted."
}
Send a Test Event
POST https://linktw.in/api/webhooks/:id/test

Send a sample of the webhook's first event to its address now, marked "test": true, and get the status code and the response time.

curl --location --request POST 'https://linktw.in/api/webhooks/:id/test' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/webhooks/:id/test",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'POST',
    'url': 'https://linktw.in/api/webhooks/:id/test',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": 0,
    "data": {
        "delivered": true,
        "status": 200,
        "duration_ms": 182
    },
    "message": "HTTP 200 in 182 ms"
}
List Events
GET https://linktw.in/api/webhooks/events

Every event you can subscribe to, with a sample of its data: link.created, link.clicked (QR code scans have "qr": true) and email.captured (emails left on bio pages).

curl --location --request GET 'https://linktw.in/api/webhooks/events' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/webhooks/events",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'GET',
    'url': 'https://linktw.in/api/webhooks/events',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": 0,
    "data": {
        "events": [
            {
                "event": "link.clicked",
                "name": "New click",
                "description": "Someone clicks a link or scans a QR code.",
                "sample": {
                    "link_id": 123,
                    "alias": "spring-sale",
                    "short_url": "https:\/\/linktw.in\/spring-sale",
                    "url": "https:\/\/example.com\/spring-sale",
                    "collections": [
                        7
                    ],
                    "country": "United States",
                    "city": "Austin",
                    "device": "iOS",
                    "browser": "Safari",
                    "referrer": "https:\/\/www.instagram.com\/",
                    "language": "en",
                    "qr": false,
                    "qr_id": null,
                    "bio_id": null,
                    "clicked_at": "2026-11-12T10:15:00+00:00"
                }
            }
        ]
    }
}
Recent Events
GET https://linktw.in/api/webhooks/events/link.clicked/recent

The latest events of one kind, newest first, exactly as they were sent. Before anything has happened you get one sample built from your latest link, or an example ("sample": true). Zapier and Make show these as sample data.

ParameterDescription
:event (required) The event, for example link.clicked
limit (optional) How many, from 1 to 25 (default 3)
curl --location --request GET 'https://linktw.in/api/webhooks/events/link.clicked/recent' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://linktw.in/api/webhooks/events/link.clicked/recent",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ],
    
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
    'method': 'GET',
    'url': 'https://linktw.in/api/webhooks/events/link.clicked/recent',
    'headers': {
        'Authorization': 'Bearer YOURAPIKEY',
        'Content-Type': 'application/json'
    },
    
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
Server response
{
    "error": 0,
    "data": {
        "event": "link.clicked",
        "sample": false,
        "events": [
            {
                "id": "evt_9812",
                "event": "link.clicked",
                "created_at": "2026-11-12T10:15:00+00:00",
                "account_id": 42,
                "test": false,
                "data": {
                    "link_id": 123,
                    "short_url": "https:\/\/linktw.in\/spring-sale",
                    "country": "United States",
                    "device": "iOS"
                }
            }
        ]
    }
}