Donutwork Docs

Shortlinks

Manage short URL redirection, monitor traffic attribution, and control shortlink lifecycle.

Shortlinks API

The Shortlinks API enables organizations to transform complex destination URLs into concise links. Beyond simple redirection, the system provides integrated telemetry for traffic attribution, enabling teams to monitor engagement performance in real time across distribution channels.


Retrieve a paginated directory of all shortlinks associated with your organization. This inventory includes current operational status and destination metadata.

GET
/2026-02-01/shortlinks.json
Required permissionshortlinks:readApiAccessPermission::SHORTLINKS_READ

Query Parameters

sizeinteger
Maximum records per page (max 100).
pageinteger
Target page index.

Responses

Shortlink inventory successfully retrieved.

{
  "entities": "Shortlink",
  "count": 42,
  "per_page": 100,
  "pages": {
    "current": 1,
    "max": 1
  },
  "elements": [
    {
      "id": "675d9fea...",
      "title": "Spring 2026 Campaign",
      "original_url": "https://marketing.acme.com/promo/spring",
      "short_code": "k9x2m-spr26",
      "url": "https://d.dw2.it/r/k9x2m-spr26",
      "is_active": true
    }
  ]
}

Generate a new shortlink for a target destination.
You can optionally provide a custom fragment (bitly-style suffix). The platform always prepends an auto-generated prefix to reduce collision risk.

POST
/2026-02-01/shortlinks.json
Required permissionshortlinks:writeApiAccessPermission::SHORTLINKS_WRITE

Query Parameters

No query parameters required.

Request Body

JSON
{
  "shortlink": {
    "title": "Product Launch Announcement",
    "original_url": "https://acme.com/products/new-gen-ai",
    "fragment": "launch-2026",
    "is_active": true
  }
}
shortlink.titlestringRequired
Administrative label for the link.
shortlink.original_urlstringRequired
The full destination URL (must include protocol).
shortlink.fragmentstring
Custom shortlink suffix (3-48 chars, letters/numbers/hyphens). Alias: `shortlink.short_code`.
shortlink.is_activeboolean
Operational status of the link. Defaults to true.

Responses

Shortlink successfully provisioned.

{
  "shortlink": {
    "id": "6768440..."
  },
  "short_code": "k9x2m-launch-2026",
  "url": "https://d.dw2.it/r/k9x2m-launch-2026"
}

Requested custom fragment is already in use.

{
  "error": "This shortlink fragment is already in use"
}

Fetch the detailed configuration and operational status for a specific shortlink.

GET
/2026-02-01/shortlinks/{shortlinkId}.json
Required permissionshortlinks:readApiAccessPermission::SHORTLINKS_READ

Query Parameters

shortlinkIdstringRequired
The unique identifier of the shortlink.

Responses

Shortlink configuration retrieved.

{
  "id": "675d9fea...",
  "title": "Spring 2026 Campaign",
  "original_url": "https://marketing.acme.com/promo/spring",
  "short_code": "k9x2m-spr26",
  "url": "https://d.dw2.it/r/k9x2m-spr26",
  "is_active": true
}

Operational Controls

Modify the destination URL, custom fragment, or operational status of an existing shortlink. Link updates are propagated across the redirection edge in near real-time.
When updating fragment, the existing auto-generated prefix is preserved.

PUT
/2026-02-01/shortlinks/{shortlinkId}.json
Required permissionshortlinks:writeApiAccessPermission::SHORTLINKS_WRITE

Query Parameters

shortlinkIdstringRequired
The unique identifier to update.

Request Body

JSON
{
  "shortlink": {
    "title": "Revised Spring Campaign",
    "original_url": "https://marketing.acme.com/promo/spring-final",
    "fragment": "spring-final",
    "is_active": true
  }
}
shortlink.titlestringRequired
Updated shortlink title.
shortlink.original_urlstringRequired
Updated destination URL.
shortlink.fragmentstring
Updated custom suffix (3-48 chars, letters/numbers/hyphens). Alias: `shortlink.short_code`.
shortlink.is_activeboolean
Enable or disable link redirection.

Responses

Configuration updated successfully.

{
  "shortlink": {
    "id": "675d9fea..."
  },
  "short_code": "k9x2m-spring-final",
  "url": "https://d.dw2.it/r/k9x2m-spring-final"
}

Requested custom fragment is already in use.

{
  "error": "This shortlink fragment is already in use"
}

Permanently revoke a shortlink and decommission its redirection service.

DELETE
/2026-02-01/shortlinks/{shortlinkId}.json
Required permissionshortlinks:writeApiAccessPermission::SHORTLINKS_WRITE

Query Parameters

shortlinkIdstringRequired
The identifier to decompose.

Responses

Shortlink successfully revoked.

{
  "id": "675d9fea...",
  "deleted": true
}

Analytics & Telemetry

Retrieve Interaction Metrics

Access real-time engagement telemetry for a specific shortlink. This include visit counts, unique interactions, and longitudinal performance data.

GET
/2026-02-01/shortlinks/{shortlinkId}/stats.json
Required permissionshortlinks:readApiAccessPermission::SHORTLINKS_READ

Query Parameters

shortlinkIdstringRequired
The shortlink identifier.

Responses

Engagement metrics successfully aggregated.

{
  "shortlink": {
    "id": "675d9fea...",
    "title": "Spring 2026 Campaign",
    "original_url": "https://marketing.acme.com/promo/spring",
    "short_code": "k9x2m-spr26",
    "is_active": true,
    "url": "https://d.dw2.it/r/k9x2m-spr26",
    "created_at": 1772536800
  },
  "metrics": {
    "summary": {
      "human": 1530,
      "bot": 12,
      "total": 1542
    },
    "view_density": [
      {
        "country": "IT",
        "count": 600
      },
      {
        "country": "US",
        "count": 420
      }
    ],
    "referrers": {
      "Direct": 900,
      "linkedin.com": 350,
      "newsletter.acme.com": 292
    },
    "bots": {
      "Google": 7,
      "Facebook": 5
    },
    "browsers": {
      "Chrome": 1100,
      "Safari": 320,
      "Firefox": 110
    },
    "os": {
      "Windows": 620,
      "macOS": 410,
      "iOS": 320,
      "Android": 180
    }
  }
}

Technical Implementation

const shortlinkId = "675d9fea...";
try {
  const stats = await sdk.dw2.getStats(shortlinkId);
  console.log(`Campaign Performance: ${stats.metrics.summary.total} total interactions.`);
} catch (error) {
  console.error(`Telemetry Error: ${error.message}`);
}

On this page