Authentication
All endpoints require authentication. In order to do it, always provide a X-Api-Key: {api_key}
header on every request.
Managing API keys
API keys are generated (and managed) from the command line. Run the api-key:generate
command to get a new and valid API key.
Warning
Starting with Shlink v4.3, API keys are hashed before being persisted, so it’s very important you save them once generated, as you won’t be able to get the value afterwards.
Providing the name is also a good idea to uniquely identify generated API keys afterwards.
This command optionally accepts an expiration date through the --expiration-date
|-e
modifier:
Disabling existing API keys is also possible, through the api-key:disable
command:
You can also rename an existing API key, but remember names have to be unique.
Listing API keys
You can see all existing APi keys by running shlink api-key:list
.
The output will allow you to see which API keys are expired or disabled, and what are their names.
Note
Starting with Shlink v4.3, all API keys that are created without a name will fall back to a redacted version of the key.
API key roles
Starting with Shlink v2.5.0, API keys can have a set of roles that will limit the operations they can do. Read the docs to learn how.
Errors during authentication
When performing an API call, if no API key is provided, or it is invalid/disabled/expired, the server will return this response payload, with status 401.