Docs
REST API

REST API

Create and manage smart links, campaigns and QR codes, and read click statistics, over HTTPS with an API key.

Basics

Base URL: https://api.dil.im/v1. Requests and responses are JSON; send Content-Type: application/json with a body. Times are ISO 8601 in UTC.

curl https://api.dil.im/v1/me \
  -H "Authorization: Bearer dlm_your_api_key"

Authentication

Create an API key in the dashboard under API keys. Keys start with dlm_ and are shown once, when you create them; we store only a hash. Send the key as a bearer token on every request. Keys can be revoked at any time from the same page.

Each key has one or more scopes:

ScopeAllows
links:readlisting and reading links and campaigns, QR codes
links:writecreating, changing and deleting links and campaigns
stats:readclick statistics

A request without a valid key returns 401 unauthorized; a key without the needed scope returns 403 insufficient_scope. Keep keys secret and only use them from servers — never in browser or mobile app code.

Account and limits

GET/v1/me

Returns the workspace, scopes, plan and current limits of the credential.

{
  "workspaceId": "ws_Ezet71OY6tROe37ovQgh",
  "auth": "api_key",
  "scopes": ["links:read", "links:write", "stats:read"],
  "plan": "free",
  "tier": "free",
  "limits": {"linksPerMonth":50,"trackedClicksPerMonth":5000,"rulesPerLink":2,"retentionDays":30,"customDomains":0,"campaignBatchSize":10,"requestsPerMinute":60},
  "newAccountLimits": null,
  "usage": { "period": "2026-10", "linksCreated": 12, "trackedClicks": 1840 }
}

newAccountLimits is set during an account’s first week. usage counts links created and clicks tracked this calendar month (UTC); trackedClicks is null if statistics are briefly unavailable.

Statistics

GET/v1/links/{id}/stats

Query: from and to (ISO dates; default the last 30 days, at most 366 days), includeBots=true to count bots and previews.

{
  "link": { "id": "lnk_…", "shortUrl": "https://dil.im/spring-sale" },
  "from": "2026-09-26T09:00:00.000Z",
  "to": "2026-10-26T09:00:00.000Z",
  "total": 1284,
  "timeseries": [{ "date": "2026-10-25", "clicks": 96 }],
  "countries": [{ "value": "TR", "clicks": 512 }],
  "devices": [{ "value": "mobile", "clicks": 803 }],
  "os": [{ "value": "ios", "clicks": 455 }],
  "browsers": [{ "value": "safari", "clicks": 431 }],
  "referrers": [{ "value": "instagram.com", "clicks": 377 }],
  "languages": [{ "value": "tr", "clicks": 498 }],
  "rules": [{ "value": "default", "clicks": 640 }, { "value": "0", "clicks": 455 }]
}

Breakdowns list the top 10 values. In rules, default is the main URL and 0, 1… are rules in order.

GET/v1/stats/top-links

The most-clicked links in the workspace. Same from/to as above, plus limit (1–100, default 10). Each item is a link with a clicks field.

QR codes

GET/v1/links/{id}/qr

Returns an SVG by default. Add format=png for a PNG, and scale for pixels per module (default 10).

Campaigns

GET/v1/campaigns

POST/v1/campaigns

Create with { "name": "Spring 2027", "utm": { "campaign": "spring" } }.

POST/v1/campaigns/{id}/links

Create several links in a campaign at once. Each item takes url and optionally slug, title and utm (overriding the campaign’s). Up to 10 links per request on Free, 100 on Pro and Business. Items are created independently: the response has one result per item.

{
  "links": [
    { "url": "https://acme.com/spring", "slug": "spring-ig", "utm": { "source": "instagram" } },
    { "url": "https://acme.com/spring", "slug": "spring-mail", "utm": { "source": "newsletter" } }
  ]
}
{
  "campaign": { "id": "cmp_…", "name": "Spring 2027", "utm": { "campaign": "spring" } },
  "results": [
    { "ok": true, "link": { "shortUrl": "https://dil.im/spring-ig" } },
    { "ok": false, "error": { "code": "slug_taken", "message": "\"spring-mail\" is already taken on this domain" } }
  ]
}

Errors

Errors use HTTP status codes and a JSON body: { "error": { "code": "…", "message": "…", "reason": "…" } } — reason appears only on some validation errors.

StatusCodeMeaning
400invalid_requestA field is missing or invalid; the message names it
400invalid_jsonThe body isn’t valid JSON
400invalid_rangeBad from/to dates for statistics
400batch_too_largeToo many campaign links in one request
401unauthorizedMissing or invalid API key
403insufficient_scopeThe key lacks the needed scope
403forbiddenNot allowed, e.g. editing a blocked link
403plan_limitBeyond your plan, e.g. too many routing rules for the plan
404not_foundNo such link, campaign or endpoint
409slug_takenThe slug is already in use
422invalid_urlThe destination isn’t a valid http(s) URL
422blocked_urlThe destination isn’t allowed; see reason
422invalid_slugThe slug breaks the slug rules or is reserved
422invalid_ruleA routing rule is invalid
429rate_limitedToo many requests; see Retry-After
429quota_exceededMonthly (or new-account daily) link limit reached

Rate limits

Requests are limited per API key, per minute: 60 on Free, 300 on Pro and 1,200 on Business (20 during an account’s first week). Over the limit you get 429 rate_limited with a Retry-After header in seconds.

Link creation is limited per workspace per calendar month (UTC): 50 on Free, 2,000 on Pro and 20,000 on Business. Deleted links still count. New accounts can also create at most 10 links a day in their first week. Over a limit you get 429 quota_exceeded with reason links_per_month or new_account_daily. More routing rules than the plan allows returns 403 plan_limit. Your current limits are in GET /v1/me.