curl -X POST "https://api.dashlink.ai/api/v1/shortlinks/create_shortlink" \
-H "X-API-Key: $DASHLINK_API_KEY" \
-F "destination_url=https://example.com/early-bird" \
-F "link_expiration_enabled=true" \
-F "expires_at=2026-06-30" \
-F "expiration_url=https://example.com/registration-closed"
const body = new FormData();
body.append("destination_url", "https://example.com/early-bird");
body.append("link_expiration_enabled", "true");
body.append("expires_at", "2026-06-30");
body.append("expiration_url", "https://example.com/registration-closed");
const response = await fetch("https://api.dashlink.ai/api/v1/shortlinks/create_shortlink", {
method: "POST",
headers: { "X-API-Key": process.env.DASHLINK_API_KEY },
body,
});
const payload = await response.json();
import os
import requests
response = requests.post(
'https://api.dashlink.ai/api/v1/shortlinks/create_shortlink',
headers={'X-API-Key': os.environ["DASHLINK_API_KEY"]},
data={
'destination_url': 'https://example.com/early-bird',
'link_expiration_enabled': 'true',
'expires_at': '2026-06-30',
'expiration_url': 'https://example.com/registration-closed',
},
)
payload = response.json()
package main
import (
"fmt"
"io"
"net/http"
"os"
"net/url"
"strings"
)
func main() {
endpoint0 := "https://api.dashlink.ai/api/v1/shortlinks/create_shortlink"
form0 := url.Values{
"destination_url": {"https://example.com/early-bird"},
"link_expiration_enabled": {"true"},
"expires_at": {"2026-06-30"},
"expiration_url": {"https://example.com/registration-closed"},
}
req0, err0 := http.NewRequest("POST", endpoint0, strings.NewReader(form0.Encode()))
if err0 != nil {
panic(err0)
}
req0.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req0.Header.Set("X-API-Key", os.Getenv("DASHLINK_API_KEY"))
resp0, err0b := http.DefaultClient.Do(req0)
if err0b != nil {
panic(err0b)
}
defer resp0.Body.Close()
body0, _ := io.ReadAll(resp0.Body)
fmt.Println(string(body0))
}
require "net/http"
require "json"
require "uri"
uri0 = URI("https://api.dashlink.ai/api/v1/shortlinks/create_shortlink")
request0 = Net::HTTP::Post.new(uri0)
request0["X-API-Key"] = ENV.fetch("DASHLINK_API_KEY")
request0.set_form_data("destination_url" => "https://example.com/early-bird", "link_expiration_enabled" => "true", "expires_at" => "2026-06-30", "expiration_url" => "https://example.com/registration-closed")
response0 = Net::HTTP.start(uri0.hostname, uri0.port, use_ssl: true) do |http|
http.request(request0)
end
payload0 = JSON.parse(response0.body)
<?php
$ch0 = curl_init('https://api.dashlink.ai/api/v1/shortlinks/create_shortlink');
curl_setopt($ch0, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch0, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch0, CURLOPT_HTTPHEADER, [
"X-API-Key: " . getenv("DASHLINK_API_KEY"),
]);
curl_setopt($ch0, CURLOPT_POSTFIELDS, http_build_query(['destination_url' => 'https://example.com/early-bird', 'link_expiration_enabled' => 'true', 'expires_at' => '2026-06-30', 'expiration_url' => 'https://example.com/registration-closed']));
$payload0 = json_decode(curl_exec($ch0), true);
curl_close($ch0);
| Field | Required | Does |
|---|---|---|
link_expiration_enabled | yes | Turns Link Expiration on |
expires_at | yes | The date, YYYY-MM-DD |
expiration_url | no | Where visitors go afterwards |
Set expiration_url
It is optional, and worth setting every time. Without it, a visitor after the date gets a generic page that tells them nothing — after they have already decided to click.
A page that says what expired and what to do next turns a dead end into a redirect that still works for you:
-F "expiration_url=https://example.com/early-bird-closed"
Changing or removing an expiration
curl -X POST "https://api.dashlink.ai/api/v1/shortlinks/update_shortlink" \
-H "X-API-Key: $DASHLINK_API_KEY" \
-F "name=SHORT-0001" \
-F "expires_at=2026-07-31"
const body = new FormData();
body.append("name", "SHORT-0001");
body.append("expires_at", "2026-07-31");
const response = await fetch("https://api.dashlink.ai/api/v1/shortlinks/update_shortlink", {
method: "POST",
headers: { "X-API-Key": process.env.DASHLINK_API_KEY },
body,
});
const payload = await response.json();
import os
import requests
response = requests.post(
'https://api.dashlink.ai/api/v1/shortlinks/update_shortlink',
headers={'X-API-Key': os.environ["DASHLINK_API_KEY"]},
data={
'name': 'SHORT-0001',
'expires_at': '2026-07-31',
},
)
payload = response.json()
package main
import (
"fmt"
"io"
"net/http"
"os"
"net/url"
"strings"
)
func main() {
endpoint0 := "https://api.dashlink.ai/api/v1/shortlinks/update_shortlink"
form0 := url.Values{
"name": {"SHORT-0001"},
"expires_at": {"2026-07-31"},
}
req0, err0 := http.NewRequest("POST", endpoint0, strings.NewReader(form0.Encode()))
if err0 != nil {
panic(err0)
}
req0.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req0.Header.Set("X-API-Key", os.Getenv("DASHLINK_API_KEY"))
resp0, err0b := http.DefaultClient.Do(req0)
if err0b != nil {
panic(err0b)
}
defer resp0.Body.Close()
body0, _ := io.ReadAll(resp0.Body)
fmt.Println(string(body0))
}
require "net/http"
require "json"
require "uri"
uri0 = URI("https://api.dashlink.ai/api/v1/shortlinks/update_shortlink")
request0 = Net::HTTP::Post.new(uri0)
request0["X-API-Key"] = ENV.fetch("DASHLINK_API_KEY")
request0.set_form_data("name" => "SHORT-0001", "expires_at" => "2026-07-31")
response0 = Net::HTTP.start(uri0.hostname, uri0.port, use_ssl: true) do |http|
http.request(request0)
end
payload0 = JSON.parse(response0.body)
<?php
$ch0 = curl_init('https://api.dashlink.ai/api/v1/shortlinks/update_shortlink');
curl_setopt($ch0, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch0, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch0, CURLOPT_HTTPHEADER, [
"X-API-Key: " . getenv("DASHLINK_API_KEY"),
]);
curl_setopt($ch0, CURLOPT_POSTFIELDS, http_build_query(['name' => 'SHORT-0001', 'expires_at' => '2026-07-31']));
$payload0 = json_decode(curl_exec($ch0), true);
curl_close($ch0);
-F "link_expiration_enabled=false"
Finding links that are about to expire
get_shortlinks filters on expiration, which is what you want for a job that warns owners in advance:
curl -X GET "https://api.dashlink.ai/api/v1/shortlinks/get_shortlinks?link_expiration_enabled=true&per_page=100" \
-H "X-API-Key: $DASHLINK_API_KEY"
const response = await fetch("https://api.dashlink.ai/api/v1/shortlinks/get_shortlinks?link_expiration_enabled=true&per_page=100", {
headers: { "X-API-Key": process.env.DASHLINK_API_KEY },
});
const payload = await response.json();
import os
import requests
response = requests.get(
'https://api.dashlink.ai/api/v1/shortlinks/get_shortlinks?link_expiration_enabled=true&per_page=100',
headers={'X-API-Key': os.environ["DASHLINK_API_KEY"]},
)
payload = response.json()
package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
endpoint0 := "https://api.dashlink.ai/api/v1/shortlinks/get_shortlinks?link_expiration_enabled=true&per_page=100"
req0, err0 := http.NewRequest("GET", endpoint0, nil)
if err0 != nil {
panic(err0)
}
req0.Header.Set("X-API-Key", os.Getenv("DASHLINK_API_KEY"))
resp0, err0b := http.DefaultClient.Do(req0)
if err0b != nil {
panic(err0b)
}
defer resp0.Body.Close()
body0, _ := io.ReadAll(resp0.Body)
fmt.Println(string(body0))
}
require "net/http"
require "json"
require "uri"
uri0 = URI("https://api.dashlink.ai/api/v1/shortlinks/get_shortlinks?link_expiration_enabled=true&per_page=100")
request0 = Net::HTTP::Get.new(uri0)
request0["X-API-Key"] = ENV.fetch("DASHLINK_API_KEY")
response0 = Net::HTTP.start(uri0.hostname, uri0.port, use_ssl: true) do |http|
http.request(request0)
end
payload0 = JSON.parse(response0.body)
<?php
$ch0 = curl_init('https://api.dashlink.ai/api/v1/shortlinks/get_shortlinks?link_expiration_enabled=true&per_page=100');
curl_setopt($ch0, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch0, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch0, CURLOPT_HTTPHEADER, [
"X-API-Key: " . getenv("DASHLINK_API_KEY"),
]);
$payload0 = json_decode(curl_exec($ch0), true);
curl_close($ch0);
from datetime import date, timedelta
def expiring_within(days=7):
cutoff = date.today() + timedelta(days=days)
response = requests.get(
f"{BASE}/shortlinks/get_shortlinks",
headers=HEADERS,
params={"link_expiration_enabled": "true", "per_page": 100},
)
for link in response.json()["data"]["links"]:
expires_at = link.get("expires_at")
if expires_at and date.fromisoformat(expires_at[:10]) <= cutoff:
yield link
Expiration versus deleting versus disabling
| Link keeps working | Analytics kept | Can be undone | |
|---|---|---|---|
| Expire | Until the date | Yes | Yes |
| Disable | No | Yes | Yes |
| Delete | No | No | No |