Unlayer Cloud API uses HTTP Basic Authentication.
All requests require you to authenticate using a Unlayer Project API Key as the username
with an empty string as the password
:
curl -u YOUR-API-KEY: https://api.unlayer.com/v2/templates
All API calls must use HTTPS. Any calls made using HTTP will return an appropriate error code.
Get your API Key
You can get your Project API key by logging in to developer console. Once logged in, go to Project > Settings. You can find your API Key on that page.
Basic Auth
If you need to, you may construct and send basic auth headers yourself. To do this you need to perform the following steps:
- Get the API Key
- Build a string in the form of
APIKey:Password
wherePassword
will always be empty. For example, if your API Key isXAyAztva4
, you will just add a:
at the end.XAyAztva4:
- BASE64 encode the string
- Supply an
Authorization
header with contentBasic
followed by the encoded string. For example, the stringXAyAztva4:
encodes toWEF5QXp0dmE0Og==
in base64. Here's how the request would look:
curl -D- \
-X GET \
-H "Authorization: Basic WEF5QXp0dmE0Og==" \
"https://api.unlayer.com/v1/templates"
// Convert API key to base64 first
const token = Buffer.from("YOUR-API-KEY").toString('base64');
// Your http options should be like this
const httpOptions = {
headers: {
authorization: `Basic ${token}`
}
};