---
title: "Connect Dub to ChatGPT: Manage Short Links and Track Analytics"
slug: connect-dub-to-chatgpt-manage-short-links-and-track-analytics
date: 2026-06-10
author: Uday Gajavalli
categories: ["AI & Agents"]
excerpt: "Learn how to connect Dub to ChatGPT using a managed MCP server. Automate link generation, extract click analytics, and manage partner commissions with AI."
tldr: "Connecting Dub to ChatGPT via a Model Context Protocol (MCP) server allows AI agents to read link analytics, generate short links, and manage commissions. This guide covers how to bypass custom API boilerplate by using Truto to generate a secure, authenticated MCP server, including setup via API and UI, tool execution, and secure access control."
canonical: https://truto.one/blog/connect-dub-to-chatgpt-manage-short-links-and-track-analytics/
---

# Connect Dub to ChatGPT: Manage Short Links and Track Analytics


If you need to connect Dub to ChatGPT to automate short link generation, extract click analytics, or manage partner programs, you need a [Model Context Protocol (MCP) server](https://truto.one/what-is-mcp-and-mcp-servers-and-how-do-they-work/). This server acts as the translation layer between ChatGPT's tool calls and Dub's REST APIs. You can either spend weeks building and maintaining this infrastructure yourself, or use a managed integration platform like Truto to dynamically generate a secure, authenticated MCP server URL. 

If your team uses Claude, check out our guide on [connecting Dub to Claude](https://truto.one/connect-dub-to-claude-oversee-partner-programs-and-commissions/), or explore our broader architectural overview on [connecting Dub to AI Agents](https://truto.one/connect-dub-to-ai-agents-automate-link-creation-and-lead-tracking/).

Giving a Large Language Model (LLM) read and write access to a link management platform like Dub is an engineering challenge. You have to handle API token lifecycles, map complex analytics query schemas to MCP tool definitions, and deal with strict rate limits. Every time Dub updates an endpoint, you have to update your server code, redeploy, and test the integration. This guide breaks down exactly how to use Truto to generate a secure, managed MCP server for Dub, connect it natively to ChatGPT, and execute complex workflows using natural language.

## The Engineering Reality of the Dub API

A custom MCP server is a self-hosted integration layer. While the open MCP standard provides a predictable way for models to discover tools, the reality of implementing it against specific vendor APIs is painful. If you decide to [build a custom MCP server](https://truto.one/the-hands-on-guide-to-building-mcp-servers-for-ai-agents-2026/) for Dub, you own the entire API lifecycle. Here are the specific integration challenges that break standard CRUD assumptions when working with Dub:

**The Silent Bulk Operations Trap**
When you build automation to update tracking links at scale, you naturally gravitate toward bulk endpoints. Dub supports bulk creating, updating, and deleting up to 100 links per request. However, there is a critical architectural quirk: bulk operations in Dub do *not* trigger webhooks. If your internal systems rely on event-driven updates from Dub to sync link states to your data warehouse, giving an LLM access to bulk endpoints will create a silent data drift. Your custom MCP server must either intercept and fan out these events manually, or you must restrict the LLM to single-link operations.

**Multi-Dimensional Analytics Queries**
Querying analytics in Dub is not a flat `GET /stats` call. The data is highly dimensional. To get meaningful insights, your AI agent must understand how to pair `event` types (clicks, leads, sales) with `groupBy` parameters (countries, devices, browsers, timeseries). If you do not explicitly map the enum values and dependencies in the JSON schema for your MCP tools, the LLM will hallucinate unsupported dimensions or fail to pass the necessary intervals, resulting in 400 Bad Request errors.

**Domain and Key Coupling**
In many link management platforms, a short link has a single unique identifier. In Dub, while a UUID exists, operations frequently require the specific coupling of a `domain` (e.g., `d.to`) and the `key` (the short slug). If an LLM tries to look up a link by just the slug without specifying the domain, the request fails. Your MCP layer needs to enforce these parameter dependencies in the query schema.

**Rate Limits and 429 Handling**
Dub enforces rate limits on API requests. A common misconception is that middleware will automatically absorb these limits. Factual note on rate limits: Truto does not retry, throttle, or apply backoff on rate limit errors. When Dub returns an HTTP 429 Too Many Requests, Truto passes that error directly to the caller. Truto normalizes the upstream rate limit information into standardized headers (`ratelimit-limit`, `ratelimit-remaining`, `ratelimit-reset`) per the IETF spec. The caller (your LLM agent or framework) is completely responsible for handling the retry and exponential backoff logic.

## Creating the MCP Server for Dub

Rather than hand-coding tool definitions, Truto derives them dynamically from Dub's resource definitions and API documentation. Each MCP server is scoped to a single connected Dub account. The generated server URL contains a cryptographic token that encodes the account, tool filters, and expiration. 

You can create an MCP server via the Truto UI or programmatically via the API.

### Method 1: Via the Truto UI

This is the fastest method for internal operational setups.

1. Navigate to the **Integrated Accounts** page in your Truto dashboard and select your connected Dub workspace.
2. Click the **MCP Servers** tab.
3. Click **Create MCP Server**.
4. Configure the server (e.g., name it "Dub Analytics Agent", select allowed methods like `read`, and set an optional expiry date).
5. Click Save and **copy the generated MCP server URL** (e.g., `https://api.truto.one/mcp/a1b2c3d4...`).

### Method 2: Via the Truto API

For teams embedding AI agents into their own products, you must generate MCP servers programmatically. 

Make a POST request to `/integrated-account/:id/mcp`. You can pass a `config` object to filter exactly which tools the LLM can see.

```bash
curl -X POST https://api.truto.one/integrated-account/<dub_account_id>/mcp \
  -H "Authorization: Bearer YOUR_TRUTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Dub ChatGPT Agent",
    "config": {
      "methods": ["read", "write"],
      "tags": ["analytics", "links"]
    },
    "expires_at": "2026-12-31T23:59:59Z"
  }'
```

The response returns a secure, ready-to-use URL:

```json
{
  "id": "mcp_8f7d6e5c",
  "name": "Dub ChatGPT Agent",
  "config": { 
    "methods": ["read", "write"], 
    "tags": ["analytics", "links"] 
  },
  "expires_at": "2026-12-31T23:59:59Z",
  "url": "https://api.truto.one/mcp/a1b2c3d4e5f67890"
}
```

## Connecting the MCP Server to ChatGPT

Once you have the URL, connecting it to your AI client requires zero additional coding. The MCP protocol handles the initialization and capability handshakes automatically.

### Option A: Connecting via the ChatGPT UI

If you are using ChatGPT Pro, Plus, Enterprise, or Education accounts, you can add [custom connectors](https://truto.one/bring-100-custom-connectors-to-chatgpt-with-superai-by-truto/) directly in the interface.

1. Open ChatGPT and go to **Settings -> Apps -> Advanced settings**.
2. Enable **Developer mode** (MCP support is gated behind this toggle).
3. Under **MCP servers / Custom connectors**, click to add a new server.
4. **Name:** "Dub Integration"
5. **Server URL:** Paste the Truto MCP URL (`https://api.truto.one/mcp/...`).
6. Click **Save**. ChatGPT will connect, execute the `initialize` handshake, and list the available Dub tools.

### Option B: Connecting via Configuration File

If you are using a desktop client that relies on local MCP server configuration (like Claude Desktop or Cursor, which follow standard MCP specs), you use the Server-Sent Events (SSE) transport wrapper. Create or edit your configuration JSON file:

```json
{
  "mcpServers": {
    "dub-agent": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-sse",
        "https://api.truto.one/mcp/a1b2c3d4e5f67890"
      ]
    }
  }
}
```

## Dub Hero Tools for AI Agents

When the agent requests tools via `tools/list`, Truto dynamically generates them based on Dub's documentation records. Here are the highest-leverage operations your ChatGPT agent can now execute.

### Extract Multi-Dimensional Analytics (`list_all_dub_analytics`)
Retrieves time-series or aggregated data for links, domains, or workspaces. The agent can use this to group clicks by country, device, or browser over a specific interval.

> "Pull the click analytics for the domain 'd.to' for the last 30 days, grouped by country. I need to know our top 3 geographies."

### Create Tracking Links (`create_a_dub_link`)
Generates a new short link. The agent can automatically append UTM parameters, assign a specific domain, and apply tags for campaign tracking.

> "Create a new short link for 'https://example.com/winter-sale'. Set the UTM source to 'newsletter' and tag it with 'Q4-Promo'."

### Batch Update Links (`dub_links_bulk_update`)
Applies the same metadata updates to up to 100 links simultaneously. Ideal for bulk-expiring links or appending universal tags. Note that this bypasses webhooks.

> "Take this list of 45 link IDs and bulk update them to have an expiration date of next Friday at midnight."

### Audit Partner Commissions (`list_all_dub_commissions`)
Fetches commission data for your partner program. The LLM can filter by status, partner ID, or date range to calculate payouts or flag anomalies.

> "List all pending commissions for partner ID 'prt_12345' from the last quarter and calculate the total payout amount owed."

### Track Conversion Events (`create_a_dub_track_sale`)
Submits sale data tied to a specific short link or customer external ID. The AI can process a CSV of offline sales and push the attribution data back into Dub.

> "I have a sale of $150 from customer external ID 'usr_8899'. Track this sale in Dub and mark the currency as USD."

### Query Customer Profiles (`list_all_dub_customers`)
Retrieves customer records associated with a workspace, returning names, emails, and aggregate sale amounts. Useful for enriching CRM context before drafting emails.

> "Find the customer record for 'jane.doe@example.com' in Dub and tell me their total historical sale amount."

To view the complete schema definitions, required parameters, and the full list of available operations, refer to the [Dub integration page](https://truto.one/integrations/detail/dub).

## Workflows in Action

By giving ChatGPT access to these tools, you can move beyond simple Q&A and automate multi-step operational workflows. Here is how a standard agent executes complex tasks using the Truto MCP server.

### Workflow 1: Campaign Launch and Distribution Setup

Marketing operations teams spend hours manually creating tracked links for new campaigns. An AI agent can ingest a brief and generate the entire tracking infrastructure.

> "We are launching the 'Spring Release' blog post. The URL is 'https://ourcompany.com/blog/spring-release'. Generate three separate short links for Twitter, LinkedIn, and our Email Newsletter. Make sure the UTM sources match the platforms, and UTM campaign is 'spring_release'. Return the final short links to me in a table."

**Execution Steps:**
1. The agent calls `create_a_dub_link` with the destination URL, setting `utm_source=twitter` and `utm_campaign=spring_release`.
2. The agent calls `create_a_dub_link` again for `utm_source=linkedin`.
3. The agent calls `create_a_dub_link` a third time for `utm_source=newsletter`.
4. ChatGPT processes the JSON responses, extracts the `shortLink` values, and formats them into a markdown table for the user.

### Workflow 2: Automated Affiliate Commission Auditing

Partner managers need to quickly identify top performers and resolve commission disputes without writing SQL or navigating complex dashboard filters.

> "Look up the total earnings for our partner 'john.smith@example.com' this month. First find his partner ID, then pull all his 'approved' commissions and sum up the payout amounts. Finally, tell me his top converting link."

**Execution Steps:**
1. The agent calls `list_all_dub_partners` with a search filter for the provided email to extract the internal `partnerId`.
2. The agent calls `list_all_dub_commissions` using the `partnerId` and filters the request for `status=approved` within the current month.
3. It sums the `amount` fields from the returned commission objects.
4. The agent calls `list_all_dub_analytics`, grouping by `linkId` and filtering by the `partnerId` to determine which specific URL drove the highest volume of sales.
5. ChatGPT returns a concise financial summary and the exact URL driving the partner's success.

```mermaid
sequenceDiagram
    participant User
    participant ChatGPT
    participant MCP Router (Truto)
    participant Dub API

    User->>ChatGPT: "Calculate earnings for John Smith..."
    ChatGPT->>MCP Router: call tool `list_all_dub_partners` (email: john.smith@example.com)
    MCP Router->>Dub API: GET /partners?email=...
    Dub API-->>MCP Router: Returns partnerId: prt_99x
    MCP Router-->>ChatGPT: JSON result
    ChatGPT->>MCP Router: call tool `list_all_dub_commissions` (partnerId: prt_99x, status: approved)
    MCP Router->>Dub API: GET /commissions?partnerId=prt_99x...
    Dub API-->>MCP Router: Returns array of commission objects
    MCP Router-->>ChatGPT: JSON result
    ChatGPT-->>User: "John Smith has 14 approved commissions totaling $1,250."
```

## Security and Access Control

When connecting enterprise APIs to an LLM, security cannot be an afterthought. The Truto MCP architecture is designed with strict boundaries to ensure agents only access what you explicitly permit.

*   **Method Filtering:** By defining `config.methods` (e.g., `["read"]`), you can physically block the LLM from executing destructive operations like `delete_a_dub_link_by_id`. The MCP server simply will not generate write tools during the `tools/list` handshake.
*   **Tag Filtering:** Use `config.tags` to restrict access by business domain. If you only want an agent to access partner data, setting the tag to `["partners"]` ensures tools related to general workspace links or domains are hidden.
*   **Time-to-Live (TTL):** MCP servers can be configured with an `expires_at` timestamp. Once the limit is reached, Cloudflare KV automatically drops the token and a Durable Object alarm permanently deletes the database record. Ideal for granting contractors temporary agentic access.
*   **Dual Authentication:** By setting `require_api_token_auth: true`, possession of the MCP URL is no longer enough. The connecting client must also pass a valid Truto API token in the Authorization header, preventing leaked URLs from being exploited.

## Moving Fast Without Breaking Infrastructure

Integrating Dub with ChatGPT via standard OAuth and hardcoded functions is an exercise in boilerplate engineering. Every endpoint update, schema change, or new parameter forces your team back into the codebase.

By leveraging an MCP server through Truto, tool generation becomes dynamic and documentation-driven. Your LLMs always have the most up-to-date access to Dub's APIs, secured by robust filtering and access controls. You focus on prompting and workflow design; the infrastructure handles the translation layer.

> Stop wasting sprint cycles on API maintenance. Automate your AI integrations with Truto's dynamic MCP servers today.
>
> [Talk to us](https://cal.com/truto/partner-with-truto)
