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:
| Scope | Allows |
|---|---|
links:read | listing and reading links and campaigns, QR codes |
links:write | creating, changing and deleting links and campaigns |
stats:read | click 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.
Create a link
POST/v1/links
| Field | Type | Notes |
|---|---|---|
url | string, required | Destination, http or https, up to 2,048 characters |
slug | string | Custom slug; omit for a readable generated one |
title | string | Internal label, up to 500 characters |
rules | array | Routing rules (see below): up to 2 on Free, 20 on Pro and Business |
utm | object | source, medium, campaign, term, content |
campaignId | string | Put the link in a campaign (cmp_…) |
expiresAt | ISO date | Stop redirecting after this time |
A rule is { "condition": {…}, "url": "…", "priority": 0 }. Conditions use device, os, country and language — see routing rules. priority is optional (0–1000, lower first).
curl https://api.dil.im/v1/links \
-H "Authorization: Bearer dlm_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"url": "https://acme.com/spring",
"slug": "spring-sale",
"title": "Spring sale",
"utm": { "source": "newsletter", "medium": "email", "campaign": "spring" },
"rules": [
{ "condition": { "os": ["ios"] }, "url": "https://apps.apple.com/app/acme/id123" }
]
}'Responds 201 with the link. Destinations are checked before the link is saved; a refused destination returns 422 blocked_url with a reason (for example url_shortener). Deeper safety checks run right after creation and can freeze or block the link.
{
"id": "lnk_8Xk2pQ9rT4vW1yZb3cDe",
"shortUrl": "https://dil.im/spring-sale",
"domain": "dil.im",
"slug": "spring-sale",
"url": "https://acme.com/spring",
"title": "Spring sale",
"campaignId": null,
"status": "active",
"riskScore": 0,
"expiresAt": null,
"createdAt": "2026-10-26T09:12:44.120Z",
"updatedAt": "2026-10-26T09:12:44.120Z",
"rules": [
{ "priority": 0, "condition": { "os": ["ios"] }, "url": "https://apps.apple.com/app/acme/id123" }
]
}List and read links
GET/v1/links
| Query | Notes |
|---|---|
limit | 1–100, default 25 |
cursor | Pass nextCursor from the previous page |
q | Search in slug, title and destination |
campaignId | Only links in this campaign |
include=clicks | Add each link’s clicks in the last 30 days (needs stats:read) |
Returns { "items": [...], "nextCursor": "…" | null }. List items leave out rules; fetch one link to get them:
GET/v1/links/{id}
Update or delete a link
PATCH/v1/links/{id}
Send any of url, title, rules and expiresAt. rules replaces all existing rules — send [] to remove them; null clears title or expiresAt. The slug can’t be changed, and blocked links can’t be edited.
DELETE/v1/links/{id}
Responds 204. The short link stops working.
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.
| Status | Code | Meaning |
|---|---|---|
| 400 | invalid_request | A field is missing or invalid; the message names it |
| 400 | invalid_json | The body isn’t valid JSON |
| 400 | invalid_range | Bad from/to dates for statistics |
| 400 | batch_too_large | Too many campaign links in one request |
| 401 | unauthorized | Missing or invalid API key |
| 403 | insufficient_scope | The key lacks the needed scope |
| 403 | forbidden | Not allowed, e.g. editing a blocked link |
| 403 | plan_limit | Beyond your plan, e.g. too many routing rules for the plan |
| 404 | not_found | No such link, campaign or endpoint |
| 409 | slug_taken | The slug is already in use |
| 422 | invalid_url | The destination isn’t a valid http(s) URL |
| 422 | blocked_url | The destination isn’t allowed; see reason |
| 422 | invalid_slug | The slug breaks the slug rules or is reserved |
| 422 | invalid_rule | A routing rule is invalid |
| 429 | rate_limited | Too many requests; see Retry-After |
| 429 | quota_exceeded | Monthly (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.