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

# Campaigns

> Group links so their performance reads as one number.

A campaign groups links that belong to the same piece of work, so you can ask how the campaign performed rather than adding up links by hand.

```bash cURL theme={null}
curl -X POST "https://api.dashlink.ai/api/v1/campaigns/create_campaign" \
  -H "X-API-Key: $DASHLINK_API_KEY" \
  -d 'campaign_name=Spring Sale 2026' \
  -d 'description=Q2 promotional push'
```

```javascript Node.js theme={null}
const body = new URLSearchParams();
body.append("campaign_name", "Spring Sale 2026");
body.append("description", "Q2 promotional push");

const response = await fetch("https://api.dashlink.ai/api/v1/campaigns/create_campaign", {
  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/campaigns/create_campaign',
    headers={'X-API-Key': os.environ["DASHLINK_API_KEY"]},
    data={
        'campaign_name': 'Spring Sale 2026',
        'description': 'Q2 promotional push',
    },
)
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/campaigns/create_campaign"
	form0 := url.Values{
		"campaign_name": {"Spring Sale 2026"},
		"description": {"Q2 promotional push"},
	}
	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/campaigns/create_campaign")
request0 = Net::HTTP::Post.new(uri0)
request0["X-API-Key"] = ENV.fetch("DASHLINK_API_KEY")
request0.set_form_data("campaign_name" => "Spring Sale 2026", "description" => "Q2 promotional push")
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/campaigns/create_campaign');
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(['campaign_name' => 'Spring Sale 2026', 'description' => 'Q2 promotional push']));
$payload0 = json_decode(curl_exec($ch0), true);
curl_close($ch0);
```

The response carries the campaign id, which everything else needs.

## The usual shape

**1. Create the campaign**

The container.

**2. Create channels within it**

Email, social, paid — however you want to compare. See [Channels](https://docs.dashlink.ai/guides/campaigns/channels.md).

**3. Add links to channels**

A link can be in more than one.

**4. Read the numbers**

`get_campaign_kpis` for headlines, the analytics endpoints for detail.

## Reading performance

```bash cURL theme={null}
curl -X GET "https://api.dashlink.ai/api/v1/campaigns/get_campaign_kpis?name=CAMP-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/campaigns/get_campaign_kpis?name=CAMP-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/campaigns/get_campaign_kpis?name=CAMP-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/campaigns/get_campaign_kpis?name=CAMP-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/campaigns/get_campaign_kpis?name=CAMP-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/campaigns/get_campaign_kpis?name=CAMP-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);
```

Total clicks, top country, top referrer, best-performing link, and the change against the preceding period.

For breakdowns, the analytics endpoints take the same filters:

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

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

## Listing

```bash cURL theme={null}
curl -X GET "https://api.dashlink.ai/api/v1/campaigns/get_campaigns?per_page=50" \
  -H "X-API-Key: $DASHLINK_API_KEY"
```

```javascript Node.js theme={null}
const response = await fetch("https://api.dashlink.ai/api/v1/campaigns/get_campaigns?per_page=50", {
  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/campaigns/get_campaigns?per_page=50',
    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/campaigns/get_campaigns?per_page=50"
	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/campaigns/get_campaigns?per_page=50")
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/campaigns/get_campaigns?per_page=50');
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);
```

`get_campaigns` accepts the analytics filters too, so you can list campaigns with their performance in one call rather than looping.

## Updating and deleting

```bash cURL theme={null}
curl -X POST "https://api.dashlink.ai/api/v1/campaigns/update_campaign" \
  -H "X-API-Key: $DASHLINK_API_KEY" \
  -d "campaign_id=CAMP-0001" \
  -d 'campaign_name=Spring Sale 2026 (extended)'
```

```javascript Node.js theme={null}
const body = new URLSearchParams();
body.append("campaign_id", "CAMP-0001");
body.append("campaign_name", "Spring Sale 2026 (extended)");

const response = await fetch("https://api.dashlink.ai/api/v1/campaigns/update_campaign", {
  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/campaigns/update_campaign',
    headers={'X-API-Key': os.environ["DASHLINK_API_KEY"]},
    data={
        'campaign_id': 'CAMP-0001',
        'campaign_name': 'Spring Sale 2026 (extended)',
    },
)
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/campaigns/update_campaign"
	form0 := url.Values{
		"campaign_id": {"CAMP-0001"},
		"campaign_name": {"Spring Sale 2026 (extended)"},
	}
	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/campaigns/update_campaign")
request0 = Net::HTTP::Post.new(uri0)
request0["X-API-Key"] = ENV.fetch("DASHLINK_API_KEY")
request0.set_form_data("campaign_id" => "CAMP-0001", "campaign_name" => "Spring Sale 2026 (extended)")
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/campaigns/update_campaign');
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(['campaign_id' => 'CAMP-0001', 'campaign_name' => 'Spring Sale 2026 (extended)']));
$payload0 = json_decode(curl_exec($ch0), true);
curl_close($ch0);
```

Campaigns have an ordinary single delete, unlike links:

```bash cURL theme={null}
curl -X POST "https://api.dashlink.ai/api/v1/campaigns/delete_campaign" \
  -H "X-API-Key: $DASHLINK_API_KEY" \
  -d "campaign_id=CAMP-0001"
```

```javascript Node.js theme={null}
const body = new URLSearchParams();
body.append("campaign_id", "CAMP-0001");

const response = await fetch("https://api.dashlink.ai/api/v1/campaigns/delete_campaign", {
  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/campaigns/delete_campaign',
    headers={'X-API-Key': os.environ["DASHLINK_API_KEY"]},
    data={
        'campaign_id': 'CAMP-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/campaigns/delete_campaign"
	form0 := url.Values{
		"campaign_id": {"CAMP-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/campaigns/delete_campaign")
request0 = Net::HTTP::Post.new(uri0)
request0["X-API-Key"] = ENV.fetch("DASHLINK_API_KEY")
request0.set_form_data("campaign_id" => "CAMP-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/campaigns/delete_campaign');
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(['campaign_id' => 'CAMP-0001']));
$payload0 = json_decode(curl_exec($ch0), true);
curl_close($ch0);
```

> [!NOTE]
>
> Deleting a campaign does not delete its links. They keep working and keep their own analytics; they are simply no longer grouped.

## Campaigns, tags and UTMs

Three ways of organising that are easy to confuse:

| | Groups | Read by | Good for |
| - | - | - | - |
| Campaign | Links, into channels | Dashlink | Measuring a piece of work as a unit |
| Tag | Links, flatly | Dashlink | Finding links again |
| UTM | Nothing — annotates the destination | Your analytics tool | Attributing sessions off-site |

They are complementary. A link is typically in one campaign, carries a few tags, and has UTM parameters on its destination.


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