Shlink REST API
v3.0{scheme}://{host}scheme- default
https; one ofhttps,http host- default
s.test
Shlink, the self-hosted URL shortener
Authentication
ApiKeyapiKeyA valid shlink API key
API Key: X-Api-Key in header
Short URLs
Operations that can be performed on short URLs
List short URLs
Returns the list of short URLs.
Parameters
versionstring321requiredpathThe API version to be consumed
pageintegerqueryThe page to be displayed. Defaults to 1
itemsPerPagenumberqueryThe amount of items to return on every page. Defaults to 10
searchTermstringqueryA query used to filter results by searching for it on the longUrl and shortCode fields.
tags[]Array<string>queryA list of tags used to filter the result set. Only short URLs with these tags will be returned.
tagsModestringanyallqueryTells how the filtering by tags should work, returning short URLs containing “any” of the tags, or “all” the tags. Defaults to “any”.
It’s ignored if tags is not provided.
excludeTags[]Array<string>queryA list of tags used to filter the result set. Only short URLs without these tags will be returned.
excludeTagsModestringanyallqueryTells how the filtering by excludeTags should work, returning short URLs not containing “any” of the tags, or not containing “all” the tags. Defaults to “any”.
It’s ignored if excludeTags is not provided.
orderBystringlongUrl-ASClongUrl-DESCshortCode-ASCshortCode-DESCdateCreated-ASCdateCreated-DESCtitle-ASCtitle-DESCvisits-ASCvisits-DESCnonBotVisits-ASCnonBotVisits-DESCqueryThe field from which you want to order the result.
startDatestringqueryThe date (in ISO-8601 format) from which we want to get short URLs.
endDatestringqueryThe date (in ISO-8601 format) until which we want to get short URLs.
excludeMaxVisitsReachedstringtruefalsequeryIf true, short URLs which already reached their maximum amount of visits will be excluded.
excludePastValidUntilstringtruefalsequeryIf true, short URLs which validUntil date is on the past will be excluded.
domainstringqueryGet short URLs for this particular domain only. Use DEFAULT keyword for default domain.
apiKeyNamestringqueryOnly get short URLs created with this API key.
This value is ignored if the request is performed with a non-admin API key that does not match this name.
Response
The list of short URLs
Unexpected error.
Authorization
ApiKeyapiKey in headerA valid shlink API key
Create short URL
Creates a new short URL.
Param findIfExists: This new param allows to force shlink to return existing short URLs when found based on provided params, instead of creating a new one. However, it might add complexity and have unexpected outputs.
These are the use cases:
- Only the long URL is provided: It will return the newest match or create a new short URL if none is found.
- Long url and custom slug are provided: It will return the short URL when both params match, return an error when the slug is in use for another long URL, or create a new short URL otherwise.
- Any of the above but including other params (tags, validSince, validUntil, maxVisits): It will behave the same as the previous two cases, but it will try to exactly match existing results using all the params. If any of them does not match, it will try to create a new short URL.
Body
Request body.
longUrlstringThe long URL this short URL will redirect to
validSincestring | nullThe date (in ISO-8601 format) from which this short code will be valid
validUntilstring | nullThe date (in ISO-8601 format) until which this short code will be valid
maxVisitsnumber | nullThe maximum number of allowed visits for this short code
tagsArray<string>The list of tags to set to the short URL.
titlestring | nullA descriptive title of the short URL.
crawlablebooleanTells if this URL will be included as ‘Allow’ in Shlink’s robots.txt.
forwardQuerybooleanTells if the query params should be forwarded from the short URL to the long one, as explained in the docs.
customSlugstringA unique custom slug to be used instead of the generated short code
pathPrefixstringA prefix that will be prepended to provided custom slug or auto-generated short code
findIfExistsbooleanWill force existing matching URL to be returned if found, instead of creating a new one
domainstringThe domain to which the short URL will be attached
shortCodeLengthnumberThe length for generated short code. It has to be at least 4 and defaults to 5. It will be ignored when customSlug is provided
Parameters
versionstring321requiredpathThe API version to be consumed
Response
The result of parsing the long URL
Some of provided data is invalid. Check extra fields to know exactly what.
Unexpected error.
Authorization
ApiKeyapiKey in headerA valid shlink API key
Create a short URL
deprecated[Deprecated] Use Create short URL instead
Parameters
versionstring321requiredpathThe API version to be consumed
apiKeystringrequiredqueryThe API key used to authenticate the request
longUrlstringrequiredqueryThe URL to be shortened
formatstringtxtjsonqueryThe format in which you want the response to be returned. You can also use the “Accept” header instead of this
Response
The list of short URLs
Unexpected error.
Parse short code
Get the long URL behind a short URL’s short code.
Parameters
versionstring321requiredpathThe API version to be consumed
shortCodestringrequiredpathThe short code for the short URL.
domainstringqueryThe domain in which the short code should be searched for.
Response
The URL info behind a short code.
No URL was found for provided short code.
Unexpected error.
Authorization
ApiKeyapiKey in headerA valid shlink API key
Delete short URL
Deletes the short URL for provided short code.
Parameters
versionstring321requiredpathThe API version to be consumed
shortCodestringrequiredpathThe short code for the short URL.
domainstringqueryThe domain in which the short code should be searched for.
Response
The short URL has been properly deleted.
No URL was found for provided short code.
The visits threshold in shlink does not allow this short URL to be deleted.
Unexpected error.
Authorization
ApiKeyapiKey in headerA valid shlink API key
Edit short URL
Update certain meta arguments from an existing short URL.
Body
Request body.
longUrlstringThe long URL this short URL will redirect to
validSincestring | nullThe date (in ISO-8601 format) from which this short code will be valid
validUntilstring | nullThe date (in ISO-8601 format) until which this short code will be valid
maxVisitsnumber | nullThe maximum number of allowed visits for this short code
tagsArray<string>The list of tags to set to the short URL.
titlestring | nullA descriptive title of the short URL.
crawlablebooleanTells if this URL will be included as ‘Allow’ in Shlink’s robots.txt.
forwardQuerybooleanTells if the query params should be forwarded from the short URL to the long one, as explained in the docs.
Parameters
versionstring321requiredpathThe API version to be consumed
shortCodestringrequiredpathThe short code for the short URL.
domainstringqueryThe domain in which the short code should be searched for.
Response
The short URL has been properly updated.
Provided meta arguments are invalid.
No URL was found for provided short code.
Unexpected error.
Authorization
ApiKeyapiKey in headerA valid shlink API key
Redirect rules
Handle dynamic rule-based redirects
List short URL redirect rules
Returns the list of redirect rules for a short URL.
Parameters
versionstring321requiredpathThe API version to be consumed
shortCodestringrequiredpathThe short code for the short URL.
domainstringqueryThe domain in which the short code should be searched for.
Response
The list of rules
No URL was found for provided short code.
Unexpected error.
Authorization
ApiKeyapiKey in headerA valid shlink API key
Set short URL redirect rules
Sets redirect rules for a short URL, with priorities matching the order in which they are provided.
Body
Request body.
redirectRulesArray<object>Parameters
versionstring321requiredpathThe API version to be consumed
shortCodestringrequiredpathThe short code for the short URL.
domainstringqueryThe domain in which the short code should be searched for.
Response
The list of rules
No URL was found for provided short code.
Unexpected error.
Authorization
ApiKeyapiKey in headerA valid shlink API key
Visits
Operations to manage visits on short URLs
Get general visits stats
Get general visits stats not linked to one specific short URL.
Parameters
versionstring321requiredpathThe API version to be consumed
Response
Visits stats.
Unexpected error.
Authorization
ApiKeyapiKey in headerA valid shlink API key
List visits for short URL
Get the list of visits on the short URL behind provided short code.
Parameters
versionstring321requiredpathThe API version to be consumed
shortCodestringrequiredpathThe short code for the short URL.
domainstringqueryThe domain in which the short code should be searched for.
startDatestringqueryThe date (in ISO-8601 format) from which we want to get visits.
endDatestringqueryThe date (in ISO-8601 format) until which we want to get visits.
pagenumberqueryThe page to display. Defaults to 1
itemsPerPagenumberqueryThe amount of items to return on every page. Defaults to all the items
excludeBotsstringtruequeryTells if visits from potential bots should be excluded from the result set
Response
List of visits.
The short code does not belong to any short URL.
Unexpected error.
Authorization
ApiKeyapiKey in headerA valid shlink API key
Delete visits for short URL
Delete all existing visits on the short URL behind provided short code.
Parameters
versionstring321requiredpathThe API version to be consumed
shortCodestringrequiredpathThe short code for the short URL.
domainstringqueryThe domain in which the short code should be searched for.
Response
Deleted visits
The short code does not belong to any short URL.
Unexpected error.
Authorization
ApiKeyapiKey in headerA valid shlink API key
List visits for domain
Get the list of visits on any short URL which belongs to provided domain.
Parameters
versionstring321requiredpathThe API version to be consumed
domainstringrequiredpathThe domain from which we want to get the visits, or DEFAULT keyword for default domain.
startDatestringqueryThe date (in ISO-8601 format) from which we want to get visits.
endDatestringqueryThe date (in ISO-8601 format) until which we want to get visits.
pagenumberqueryThe page to display. Defaults to 1
itemsPerPagenumberqueryThe amount of items to return on every page. Defaults to all the items
excludeBotsstringtruequeryTells if visits from potential bots should be excluded from the result set
Response
List of visits.
The domain does not exist.
Unexpected error.
Authorization
ApiKeyapiKey in headerA valid shlink API key
List orphan visits
Get the list of visits to invalid short URLs, the base URL or any other 404.
Parameters
versionstring321requiredpathThe API version to be consumed
startDatestringqueryThe date (in ISO-8601 format) from which we want to get visits.
endDatestringqueryThe date (in ISO-8601 format) until which we want to get visits.
pagenumberqueryThe page to display. Defaults to 1
itemsPerPagenumberqueryThe amount of items to return on every page. Defaults to all the items
excludeBotsstringtruequeryTells if visits from potential bots should be excluded from the result set
typestringinvalid_short_urlbase_urlregular_404queryThe type of visits to return. All visits are returned when not provided.
domainstringqueryThe domain in which the short code should be searched for.
Response
List of visits.
Provided query arguments are invalid.
Unexpected error.
Authorization
ApiKeyapiKey in headerA valid shlink API key
Delete orphan visits
Delete all visits to invalid short URLs, the base URL or any other 404.
Parameters
versionstring321requiredpathThe API version to be consumed
Response
Deleted visits
Unexpected error.
Authorization
ApiKeyapiKey in headerA valid shlink API key
List non-orphan visits
Get the list of visits to any short URL.
Parameters
versionstring321requiredpathThe API version to be consumed
startDatestringqueryThe date (in ISO-8601 format) from which we want to get visits.
endDatestringqueryThe date (in ISO-8601 format) until which we want to get visits.
pagenumberqueryThe page to display. Defaults to 1
itemsPerPagenumberqueryThe amount of items to return on every page. Defaults to all the items
excludeBotsstringtruequeryTells if visits from potential bots should be excluded from the result set
domainstringqueryThe domain in which the short code should be searched for.
Response
List of visits.
Unexpected error.
Authorization
ApiKeyapiKey in headerA valid shlink API key
Domains
Operations to manage domains used on short URLs
List configured domains
Returns the list of all domains that have been either used for some short URL, or have explicitly configured redirects.
It also includes the domain redirects, plus the default redirects that will be used for any non-explicitly-configured one.
Parameters
versionstring321requiredpathThe API version to be consumed
Response
The list of domains
Unexpected error.
Authorization
ApiKeyapiKey in headerA valid shlink API key
Sets domain “not found” redirects
Sets the URLs that you want a visitor to get redirected to for “not found” URLs for a specific domain
Body
Request body.
domainstringrequiredThe domain’s authority for which you want to set redirects
baseUrlRedirectstring | nullURL to redirect to when a user hits the domain’s base URL
regular404Redirectstring | nullURL to redirect to when a user hits a not found URL other than an invalid short URL
invalidShortUrlRedirectstring | nullURL to redirect to when a user hits an invalid short URL
Parameters
versionstring321requiredpathThe API version to be consumed
Response
The domain’s redirects after the update, when existing redirects have been merged with provided ones.
Provided data is invalid.
Unexpected error.
Authorization
ApiKeyapiKey in headerA valid shlink API key
Integrations
Handle services with which shlink is integrated
Get mercure integration info
Returns information to consume updates published by Shlink on a mercure hub. https://mercure.rocks/
Parameters
versionstring321requiredpathThe API version to be consumed
Response
The mercure integration info
This Shlink instance is not integrated with a mercure hub
Unexpected error.
Authorization
ApiKeyapiKey in headerA valid shlink API key
Monitoring
Public endpoints designed to monitor the service
Check healthiness
Checks the healthiness of the service, making sure it can access required resources.
Response
The passing health status
The failing health status
Unexpected error.
URL Shortener
Non-rest endpoints, used to be publicly exposed
Short URL
Represents a short URL. Tracks the visit and redirects tio the corresponding long URL
Parameters
shortCodestringrequiredpathThe short code for the short URL.
Response
Visit properly tracked and redirected
Short URL tracking pixel
Generates a 1px transparent image which can be used to track emails with a short URL
Parameters
shortCodestringrequiredpathThe short code for the short URL.
Response
Image in GIF format
[Deprecated] Short URL QR code
deprecated[Deprecated] Use an external mechanism to generate QR codes. Shlink dashboard and shlink-web-client provide their own.
Parameters
shortCodestringrequiredpathThe short code for the short URL.
sizeinteger[50, 1000]300queryThe size of the image to be returned.
formatstringpngsvgpngqueryThe format for the QR code image, being valid values png and svg. Not providing the param or providing any other value will fall back to png.
margininteger>= 00queryThe margin around the QR code image.
errorCorrectionstringLMQHLqueryThe error correction level to apply to the QR code: **[L]**ow, **[M]**edium, **[Q]**uartile or **[H]**igh. See docs.
roundBlockSizestringtruefalsefalsequeryAllows to disable block size rounding, which might reduce the readability of the QR code, but ensures no extra margin is added.
colorstring#000000queryThe QR code foreground color. It should be an hex representation of a color, in 3 or 6 characters, optionally preceded by the “#” character.
bgColorstring#ffffffqueryThe QR code background color. It should be an hex representation of a color, in 3 or 6 characters, optionally preceded by the “#” character.
logostringdisablequeryCurrently used to disable the logo that was set via configuration options. It may be used in future to dynamically choose from multiple logos.
Response
QR code in PNG format