> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dashlink.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Creating links

> Every field create_shortlink accepts, and when each one matters.

```bash cURL theme={null}
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/spring-sale" \
  -F 'title=Spring sale'
```

```javascript Node.js theme={null}
const body = new FormData();
body.append("destination_url", "https://example.com/spring-sale");
body.append("title", "Spring sale");

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();
```

```python Python theme={null}
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/spring-sale',
        'title': 'Spring sale',
    },
)
payload = response.json()
```

```go Go theme={null}
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/spring-sale"},
		"title": {"Spring sale"},
	}
	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))
}

```

```ruby Ruby theme={null}
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/spring-sale", "title" => "Spring sale")
response0 = Net::HTTP.start(uri0.hostname, uri0.port, use_ssl: true) do |http|
  http.request(request0)
end
payload0 = JSON.parse(response0.body)
```

```php PHP theme={null}
<?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/spring-sale', 'title' => 'Spring sale']));
$payload0 = json_decode(curl_exec($ch0), true);
curl_close($ch0);
```

`destination_url` is the only required field. Everything else has a sensible default.

> [!NOTE]
>
> This endpoint takes `multipart/form-data` because it can carry a preview image. With cURL that means `-F` rather than `-d`.

## The fields that matter most

| Field | Default | Notes |
| - | - | - |
| `destination_url` | required | Where visitors end up |
| `title` | derived from the page | What you will recognise it by in lists |
| `domain` | your default domain | See [Branded links](https://docs.dashlink.ai/guides/branded-links/introduction.md) |
| `back_half` | generated | See [Custom back halves](https://docs.dashlink.ai/guides/links/custom-back-halves.md) |
| `qr_code_enabled` | `false` | Generates a QR code alongside the link |

## Grouped by what you are trying to do

> [accordion] Tag the destination for campaign tracking
>
> Set `utm_analytics_enabled=true` and the UTM fields are appended to the destination URL:
>
> ```bash theme={null}
> -F "utm_analytics_enabled=true" \
> -F "utm_source=newsletter" \
> -F "utm_medium=email" \
> -F "utm_campaign=spring-sale"
> ```
>
> Also available: `utm_term`, `utm_content`, `utm_id`. See [UTM parameters](https://docs.dashlink.ai/guides/links/utm-parameters.md).

> [accordion] Control how the link previews when shared
>
> Set `is_custom_preview=true`, then supply what should appear in Slack, WhatsApp, or a social post:
>
> ```bash theme={null}
> -F "is_custom_preview=true" \
> -F "preview_title=Spring sale is live" \
> -F "preview_description=30% off through Sunday" \
> -F "preview_image=@banner.png"
> ```
>
> Without `is_custom_preview=true` the other preview fields are ignored, and the destination page's own metadata is used.

> [accordion] Require a password
>
> ```bash theme={null}
> -F "password_protected=true" \
> -F "password=spring2026"
> ```
>
> Visitors see a password prompt before the redirect. See [Password protection](https://docs.dashlink.ai/guides/links/password-protection.md).

> [accordion] Expire the link
>
> ```bash theme={null}
> -F "link_expiration_enabled=true" \
> -F "expires_at=2026-06-30" \
> -F "expiration_url=https://example.com/offer-ended"
> ```
>
> See [Expiration](https://docs.dashlink.ai/guides/links/expiration.md).

> [accordion] Send different visitors to different places
>
> ```bash theme={null}
> -F "dynamic_routing_enabled=true" \
> -F 'routing_rules=[{"condition":"country","operator":"equals","value":"IN","destination_url":"https://example.com/in"}]'
> ```
>
> See [Routing rules](https://docs.dashlink.ai/guides/links/routing-rules.md).

## Updating

`update_shortlink` takes the same fields plus `name` to say which link:

```bash cURL theme={null}
curl -X POST "https://api.dashlink.ai/api/v1/shortlinks/update_shortlink" \
  -H "X-API-Key: $DASHLINK_API_KEY" \
  -F "name=SHORT-0001" \
  -F "destination_url=https://example.com/summer-sale"
```

```javascript Node.js theme={null}
const body = new FormData();
body.append("name", "SHORT-0001");
body.append("destination_url", "https://example.com/summer-sale");

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();
```

```python Python theme={null}
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',
        'destination_url': 'https://example.com/summer-sale',
    },
)
payload = response.json()
```

```go Go theme={null}
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"},
		"destination_url": {"https://example.com/summer-sale"},
	}
	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))
}

```

```ruby Ruby theme={null}
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", "destination_url" => "https://example.com/summer-sale")
response0 = Net::HTTP.start(uri0.hostname, uri0.port, use_ssl: true) do |http|
  http.request(request0)
end
payload0 = JSON.parse(response0.body)
```

```php PHP theme={null}
<?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', 'destination_url' => 'https://example.com/summer-sale']));
$payload0 = json_decode(curl_exec($ch0), true);
curl_close($ch0);
```

Only the fields you send are changed. Changing `destination_url` takes effect immediately for everyone, including people who saved the link months ago — which is the point of a Shortlink, and also the risk.

## Reading links back

| To | Use |
| - | - |
| Fetch one by id | `get_shortlink` |
| List with filters | `get_shortlinks` |
| Free-text search | `search_shortlinks` |

```bash cURL theme={null}
curl -X GET "https://api.dashlink.ai/api/v1/shortlinks/get_shortlinks?per_page=50&sort_by=most_recent&order=desc&enabled=true" \
  -H "X-API-Key: $DASHLINK_API_KEY"
```

```javascript Node.js theme={null}
const response = await fetch("https://api.dashlink.ai/api/v1/shortlinks/get_shortlinks?per_page=50&sort_by=most_recent&order=desc&enabled=true", {
  headers: { "X-API-Key": process.env.DASHLINK_API_KEY },
});
const payload = await response.json();
```

```python Python theme={null}
import os
import requests

response = requests.get(
    'https://api.dashlink.ai/api/v1/shortlinks/get_shortlinks?per_page=50&sort_by=most_recent&order=desc&enabled=true',
    headers={'X-API-Key': os.environ["DASHLINK_API_KEY"]},
)
payload = response.json()
```

```go Go theme={null}
package main

import (
	"fmt"
	"io"
	"net/http"
	"os"
)

func main() {
	endpoint0 := "https://api.dashlink.ai/api/v1/shortlinks/get_shortlinks?per_page=50&sort_by=most_recent&order=desc&enabled=true"
	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))
}

```

```ruby Ruby theme={null}
require "net/http"
require "json"
require "uri"

uri0 = URI("https://api.dashlink.ai/api/v1/shortlinks/get_shortlinks?per_page=50&sort_by=most_recent&order=desc&enabled=true")
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 PHP theme={null}
<?php
$ch0 = curl_init('https://api.dashlink.ai/api/v1/shortlinks/get_shortlinks?per_page=50&sort_by=most_recent&order=desc&enabled=true');
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);
```

## Deleting

Bulk-only, even for one link:

```bash cURL theme={null}
curl -X POST "https://api.dashlink.ai/api/v1/shortlinks/bulk_delete_shortlinks" \
  -H "X-API-Key: $DASHLINK_API_KEY" \
  -d 'shortlink_ids=["SHORT-0001"]'
```

```javascript Node.js theme={null}
const body = new URLSearchParams();
body.append("shortlink_ids", "[\"SHORT-0001\"]");

const response = await fetch("https://api.dashlink.ai/api/v1/shortlinks/bulk_delete_shortlinks", {
  method: "POST",
  headers: { "X-API-Key": process.env.DASHLINK_API_KEY },
  body,
});
const payload = await response.json();
```

```python Python theme={null}
import os
import requests

response = requests.post(
    'https://api.dashlink.ai/api/v1/shortlinks/bulk_delete_shortlinks',
    headers={'X-API-Key': os.environ["DASHLINK_API_KEY"]},
    data={
        'shortlink_ids': '["SHORT-0001"]',
    },
)
payload = response.json()
```

```go Go theme={null}
package main

import (
	"fmt"
	"io"
	"net/http"
	"os"
	"net/url"
	"strings"
)

func main() {
	endpoint0 := "https://api.dashlink.ai/api/v1/shortlinks/bulk_delete_shortlinks"
	form0 := url.Values{
		"shortlink_ids": {"[\"SHORT-0001\"]"},
	}
	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))
}

```

```ruby Ruby theme={null}
require "net/http"
require "json"
require "uri"

uri0 = URI("https://api.dashlink.ai/api/v1/shortlinks/bulk_delete_shortlinks")
request0 = Net::HTTP::Post.new(uri0)
request0["X-API-Key"] = ENV.fetch("DASHLINK_API_KEY")
request0.set_form_data("shortlink_ids" => "[\"SHORT-0001\"]")
response0 = Net::HTTP.start(uri0.hostname, uri0.port, use_ssl: true) do |http|
  http.request(request0)
end
payload0 = JSON.parse(response0.body)
```

```php PHP theme={null}
<?php
$ch0 = curl_init('https://api.dashlink.ai/api/v1/shortlinks/bulk_delete_shortlinks');
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(['shortlink_ids' => '["SHORT-0001"]']));
$payload0 = json_decode(curl_exec($ch0), true);
curl_close($ch0);
```

> [!WARNING]
>
> Deleting a link breaks it everywhere it has already been shared. If the goal is to stop it working but keep the record and its analytics, disable it instead: `bulk_edit` with `action="disable"`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.