The Unlayer 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 Unlayer dashboard. Once logged in, go to Project > Embed > 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:

  1. Get the API Key
  2. Build a string in the form of APIKey:Password where Password will always be empty. For example, if your API Key is XAyAztva4, you will just add a : at the end. XAyAztva4:
  3. BASE64 encode the string
  4. Supply an Authorization header with content Basic followed by the encoded string. For example, the string XAyAztva4: encodes to WEF5QXp0dmE0Og== 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}`
  }
};