{"openapi":"3.1.0","info":{"title":"Link Platform API","version":"1.0.0","description":"Create and manage short links and read their click statistics."},"servers":[{"url":"https://linkrail.io/api/v1"}],"security":[{"bearer":[]}],"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer","description":"Workspace API key (lk_...) from Dashboard → API keys."}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}}}}},"Link":{"type":"object","properties":{"id":{"type":"string","example":"aB3dE5fG7h"},"shortUrl":{"type":"string","example":"https://lkrl.ink/spring-sale"},"domain":{"type":"string"},"slug":{"type":"string"},"destinationUrl":{"type":"string"},"title":{"type":"string","nullable":true},"tags":{"type":"array","items":{"type":"string"}},"folderId":{"type":"string","nullable":true},"redirectCode":{"type":"integer"},"hasPassword":{"type":"boolean"},"expiresAt":{"type":"string","format":"date-time","nullable":true},"expiredRedirectUrl":{"type":"string","nullable":true},"maxClicks":{"type":"integer","nullable":true},"archived":{"type":"boolean"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"LinkCreate":{"type":"object","properties":{"destinationUrl":{"type":"string","format":"uri","example":"https://shop.example.com/product?id=7"},"domain":{"type":"string","description":"Hostname of a domain available to the workspace. Defaults to lkrl.ink."},"slug":{"type":"string","nullable":true,"description":"Custom short path. Random if omitted.","example":"spring-sale"},"title":{"type":"string","nullable":true},"tags":{"type":"array","items":{"type":"string"}},"folderId":{"type":"string","nullable":true},"redirectCode":{"type":"integer","enum":[301,302],"default":302},"password":{"type":"string","nullable":true,"description":"Write-only. null removes it."},"expiresAt":{"type":"string","format":"date-time","nullable":true},"expiredRedirectUrl":{"type":"string","format":"uri","nullable":true},"maxClicks":{"type":"integer","minimum":1,"nullable":true}},"required":["destinationUrl"]},"LinkUpdate":{"type":"object","properties":{"destinationUrl":{"type":"string","format":"uri","example":"https://shop.example.com/product?id=7"},"domain":{"type":"string","description":"Hostname of a domain available to the workspace. Defaults to lkrl.ink."},"slug":{"type":"string","nullable":true,"description":"Custom short path. Random if omitted.","example":"spring-sale"},"title":{"type":"string","nullable":true},"tags":{"type":"array","items":{"type":"string"}},"folderId":{"type":"string","nullable":true},"redirectCode":{"type":"integer","enum":[301,302],"default":302},"password":{"type":"string","nullable":true,"description":"Write-only. null removes it."},"expiresAt":{"type":"string","format":"date-time","nullable":true},"expiredRedirectUrl":{"type":"string","format":"uri","nullable":true},"maxClicks":{"type":"integer","minimum":1,"nullable":true},"archived":{"type":"boolean"}}}}},"paths":{"/links":{"get":{"summary":"List links","parameters":[{"name":"q","in":"query","schema":{"type":"string"},"description":"Search slug, destination and title"},{"name":"tag","in":"query","schema":{"type":"string"}},{"name":"folderId","in":"query","schema":{"type":"string"}},{"name":"domain","in":"query","schema":{"type":"string"}},{"name":"archived","in":"query","schema":{"type":"boolean","default":false}},{"name":"limit","in":"query","schema":{"type":"integer","default":50,"maximum":500}},{"name":"offset","in":"query","schema":{"type":"integer","default":0}}],"responses":{"200":{"description":"Links, newest first","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Link"}}}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited (120 requests/minute per key)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"summary":"Create a link","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LinkCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Link"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited (120 requests/minute per key)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/links/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"get":{"summary":"Get a link","responses":{"200":{"description":"The link","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Link"}}}},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited (120 requests/minute per key)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"summary":"Update a link","description":"Only fields present are changed. Changing the destination keeps the short URL.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LinkUpdate"}}}},"responses":{"200":{"description":"Updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Link"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited (120 requests/minute per key)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"summary":"Delete a link","responses":{"204":{"description":"Deleted"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited (120 requests/minute per key)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/links/{id}/stats":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"from","in":"query","schema":{"type":"string","format":"date-time"},"description":"Default: 30 days before `to`"},{"name":"to","in":"query","schema":{"type":"string","format":"date-time"},"description":"Default: now"},{"name":"interval","in":"query","schema":{"type":"string","enum":["hour","day","month"]}},{"name":"bots","in":"query","schema":{"type":"boolean","default":false}}],"get":{"summary":"Click statistics for a link","responses":{"200":{"description":"Totals, time series (UTC buckets) and breakdowns"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited (120 requests/minute per key)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/links/{id}/tracking-template":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"get":{"summary":"Google Ads tracking template","description":"Available once a tracking domain is certified by Google.","responses":{"200":{"description":"One template per available tracking domain"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not available","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited (120 requests/minute per key)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/domains":{"get":{"summary":"List domains available for links","responses":{"200":{"description":"Platform and custom domains"},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited (120 requests/minute per key)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}