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

# Channels

> Subdivide a campaign so you can compare its parts.

A channel is a subdivision of a campaign — email, social, paid, print. Without them a campaign gives you one total; with them you can see which part earned it.

```bash cURL theme={null}
curl -X POST "https://api.dashlink.ai/api/v1/campaigns/create_channel" \
  -H "X-API-Key: $DASHLINK_API_KEY" \
  -d "campaign_id=CAMP-0001" \
  -d "channel_name=Email" \
  -d 'description=Newsletter and lifecycle sends'
```

```javascript Node.js theme={null}
const body = new URLSearchParams();
body.append("campaign_id", "CAMP-0001");
body.append("channel_name", "Email");
body.append("description", "Newsletter and lifecycle sends");

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

Links can be attached at creation:

```bash theme={null}
-d 'shortlinks=["SHORT-0001","SHORT-0002"]'
```

## Managing membership

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

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

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

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

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

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

Removing a link from a channel does not delete the link or its analytics.

## Listing

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

## Comparing channels

`get_campaign_analytics` accepts a `channels` filter, so you can pull one channel's numbers at a time and compare:

```bash cURL theme={null}
curl -X GET "https://api.dashlink.ai/api/v1/analytics/get_campaign_analytics?name=CAMP-0001&date_from=2026-01-01&date_to=2026-01-31&channels=["CHAN-0001"]" \
  -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_analytics?name=CAMP-0001&date_from=2026-01-01&date_to=2026-01-31&channels=[\"CHAN-0001\"]", {
  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_analytics?name=CAMP-0001&date_from=2026-01-01&date_to=2026-01-31&channels=["CHAN-0001"]',
    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_analytics?name=CAMP-0001&date_from=2026-01-01&date_to=2026-01-31&channels=[\"CHAN-0001\"]"
	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_analytics?name=CAMP-0001&date_from=2026-01-01&date_to=2026-01-31&channels=[\"CHAN-0001\"]")
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_analytics?name=CAMP-0001&date_from=2026-01-01&date_to=2026-01-31&channels=["CHAN-0001"]');
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);
```

```python theme={null}
def compare_channels(campaign_id, date_from, date_to):
    channels = requests.get(
        f"{BASE}/campaigns/fetch_channels",
        headers=HEADERS,
        params={"per_page": 100},
    ).json()["data"]["channels"]

    for channel in channels:
        analytics = requests.get(
            f"{BASE}/analytics/get_campaign_analytics",
            headers=HEADERS,
            params={
                "name": campaign_id,
                "date_from": date_from,
                "date_to": date_to,
                "channels": json.dumps([channel["name"]]),
            },
        ).json()["data"]

        yield channel["channel_name"], analytics
```

## Designing a channel scheme

> [accordion] Split by what you would act on
>
> Channels are worth having when knowing the split would change a decision. `Email` versus `Social` usually would. `Email — Tuesday` versus `Email — Thursday` usually would not, and can be a tag instead.

> [accordion] Use the same names across campaigns
>
> `Email` in every campaign is comparable across campaigns. `Email`, `email-channel` and `Newsletter` are three things that have to be reconciled by hand later.

> [accordion] A link can be in several
>
> A link shared in a newsletter and on social can sit in both channels. Its clicks count toward each, so channel totals can exceed the campaign total — which is correct, and worth knowing before someone queries the arithmetic.


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