> ## 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.

# Password protection

> Put a password in front of a link.

A password-protected link shows a prompt before redirecting. Useful for a document shared with one client, or an announcement going out before it is public.

```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/q2-board-deck.pdf" \
  -F "password_protected=true" \
  -F "password=spring2026"
```

```javascript Node.js theme={null}
const body = new FormData();
body.append("destination_url", "https://example.com/q2-board-deck.pdf");
body.append("password_protected", "true");
body.append("password", "spring2026");

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/q2-board-deck.pdf',
        'password_protected': 'true',
        'password': 'spring2026',
    },
)
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/q2-board-deck.pdf"},
		"password_protected": {"true"},
		"password": {"spring2026"},
	}
	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/q2-board-deck.pdf", "password_protected" => "true", "password" => "spring2026")
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/q2-board-deck.pdf', 'password_protected' => 'true', 'password' => 'spring2026']));
$payload0 = json_decode(curl_exec($ch0), true);
curl_close($ch0);
```

Both fields are needed: `password_protected=true` turns the feature on, `password` sets the value.

## Adding or changing one later

```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 "password_protected=true" \
  -F "password=newpassword"
```

```javascript Node.js theme={null}
const body = new FormData();
body.append("name", "SHORT-0001");
body.append("password_protected", "true");
body.append("password", "newpassword");

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',
        'password_protected': 'true',
        'password': 'newpassword',
    },
)
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"},
		"password_protected": {"true"},
		"password": {"newpassword"},
	}
	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", "password_protected" => "true", "password" => "newpassword")
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', 'password_protected' => 'true', 'password' => 'newpassword']));
$payload0 = json_decode(curl_exec($ch0), true);
curl_close($ch0);
```

Removing it:

```bash theme={null}
-F "password_protected=false"
```

## Passwords are never returned

Reading a link back tells you *whether* it is protected, never what the password is:

```json theme={null}
{
  "data": {
    "link": {
      "name": "SHORT-0001",
      "password_protected": true
    }
  }
}
```

Passwords are stored hashed. If you need to be able to tell someone the password later, keep your own record when you set it — the API cannot give it back.

## Monitoring attempts

`get_shortlink_password_attempts` reports attempts against a link, which is how you notice a link being guessed at:

```bash cURL theme={null}
curl -X GET "https://api.dashlink.ai/api/v1/analytics/get_shortlink_password_attempts?name=SHORT-0001&date_from=2026-01-01&date_to=2026-01-31" \
  -H "X-API-Key: $DASHLINK_API_KEY"
```

```javascript Node.js theme={null}
const response = await fetch("https://api.dashlink.ai/api/v1/analytics/get_shortlink_password_attempts?name=SHORT-0001&date_from=2026-01-01&date_to=2026-01-31", {
  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/analytics/get_shortlink_password_attempts?name=SHORT-0001&date_from=2026-01-01&date_to=2026-01-31',
    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/analytics/get_shortlink_password_attempts?name=SHORT-0001&date_from=2026-01-01&date_to=2026-01-31"
	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/analytics/get_shortlink_password_attempts?name=SHORT-0001&date_from=2026-01-01&date_to=2026-01-31")
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/analytics/get_shortlink_password_attempts?name=SHORT-0001&date_from=2026-01-01&date_to=2026-01-31');
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);
```

## What this is and is not

> [!WARNING]
>
> A password gates the *redirect*, not the destination. Anyone who learns the destination URL reaches it directly without the prompt, and anyone who knows the password can pass it on.
>
> It is a speed bump against casual access. For anything genuinely confidential, protect the destination itself.

Sensible use:

* A different password per recipient, so you can tell who shared it
* Combined with [expiration](https://docs.dashlink.ai/guides/links/expiration.md), so access ends on a date
* Rotated when someone leaves the group it was shared with


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