Skip to main content

Creating your first short link on Short.io

Before you consider developing your own applications to interact with the Short.io API, we recommend exploring other optimization and automation options for your processes, including our Zapier integration. It enables seamless connectivity between different tools and services without writing a single line of code.

  1. To use our API, it is required to create a secret API key from the Integrations and API menu: https://app.short.io/settings/integrations/api-key
  2. Then you may need to install prerequisites for HTTP requests (if necessary, depending on your programming language and its version).
  3. Use the following code snippets to generate a short URL with an automatically created path for the specified long URL. If needed, you can customize the link slug by adding the Path parameter.

📘

We advise using the TTL parameter when generating a short link from our API.

Please replace {user.domain_name} with your actual domain name, {user.long_url} with the original URL, {user.ttl} with an appropriate value and {user.apiKey} with your secret API key.

<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.short.io/links",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'allowDuplicates' => false,
'originalURL' => '<<long_url>>',
'domain' => '<<domain_name>>',
'ttl' => '<<ttl>>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <<apiKey>>",
"accept: application/json",
"content-type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}

Once you run the above code, you will see a response similar to the following:

{
originalURL: 'YOUR_LONG_LINK',
path: 'LINK_PATH',
idString: 'LINK_ID',
id: 'LINK_ID',
shortURL: 'https://example.xyz/YOUR_PATH',
secureShortURL: 'https://example.xyz/YOUR_PATH',
cloaking: false,
tags: [],
createdAt: '2025-04-30T10:53:11.061Z',
skipQS: false,
archived: false,
DomainId: DOMAIN_ID,
OwnerId: OWNER_ID,
hasPassword: false,
source: 'api',
success: true,
duplicate: false
}

You have successfully established a connection with our API and created your first short link:

Screenshot

Most important keys in the response are shortURL (the URL of the newly-created short link) and idString (which you will need in case you would want to update or delete the created URL).

You can find more information on link creation parameters in the following page: https://developers.short.io/reference/post_links