Skip to main content
Logo.dev gives you two keys. The publishable key works only on the Logo.dev CDN and is safe in client code. The secret key works only on the Logo.dev API and stays on your server.

Get your API keys

Your dashboard has a publishable key for the Logo.dev CDN and a secret key for the Logo.dev API. Every plan includes both.

Test keys

Logo.dev has no test or sandbox keys. Use your publishable and secret keys while you develop. The publishable key is safe in client code, so you can ship it in a browser or mobile build.

Key types

Each key works on its own host only. A secret key on the CDN, or a publishable key on the API, returns 401.

Publishable key (pk_)

Put the publishable key in the image URL:
You can ship this key in client code. It cannot read brand data or spend API credits, because the API rejects it. To stop other sites from using it, turn on domain restrictions. A publishable key is for browser and app requests only, so server code uses the secret key with the Logo.dev API, as self-hosting shows.

Secret key (sk_)

Send the secret key from your server on every API request:
Never put this key in a browser, a mobile app, or a public repository. Anyone with it can spend your API credits.

Domain restrictions

Domain restrictions limit your publishable key to the sites you list. Logo.dev compares the host in each request’s Referer header with your list. A request from any other host returns 401. Secret key requests are not restricted.
With domain restrictions on, a request with no Referer header returns 401. Make sure your pages send the header before you turn restrictions on.

Turn on domain restrictions

1

Open your key

Go to API keys in the dashboard and open your key.
2

Turn on the restriction

Turn on Allowed domains only.
3

Add your domains

Enter one domain per line. Add localhost if you develop locally.
4

Save

Click Save and close.

Domain format

  • example.com matches example.com only. If your site uses www.example.com, add that domain too.
  • *.example.com matches example.com and every subdomain, such as app.example.com.
The match ignores the port and the path, so localhost covers localhost:3000. Enter localhost, not localhost:3000, because an entry with a port never matches.

Make sure your pages send a Referer

Browsers send the Referer header by default, but a strict Referrer-Policy removes it. These policies work with domain restrictions: To set the policy for a whole page, add a meta tag to the <head>:
To set it for one image, use the referrerpolicy attribute:
In Next.js, set the header in next.config.js:
A proxy or a CDN in front of your site can add a stricter Referrer-Policy header, so check the header on your live pages. To test, open the Network tab in your browser’s developer tools and load a page with a logo. Select an img.logo.dev request and confirm that its Referer header shows your domain. The response can show a via header with cloudfront.net. That header comes from the Logo.dev CDN and does not affect domain restrictions. Logos that browsers and the CDN already cached can still show until their cache expires.

Native and mobile apps

Native mobile apps and other clients outside a browser send no Referer header by default, so domain restrictions reject their requests with 401. You cannot add an app to the domain list. To use Logo.dev in an app and keep your website’s key restricted:
1

Create a key for the app

On the API keys page, click Create API keys.
2

Leave the app's key unrestricted

Use the new publishable key in your app, and leave Allowed domains only off.
3

Restrict your website's key

Keep Allowed domains only on for the key that your website uses.

What domain restrictions do not stop

Domain restrictions make misuse harder, but they are not authentication. A browser sets the Referer header, so another website cannot use your key from its pages. A script or a server can send any Referer header, so anyone who has your publishable key can get past the check. Your publishable key is visible in your client code, and domain restrictions do not hide it. Someone who copies it can load logos, and those requests count toward your monthly CDN requests. They cannot read brand data or spend API credits, because the API rejects the key. If you see misuse, rotate your keys.

Key rotation

To rotate your keys, create a new key pair and move your app to it:
1

Create new keys

On the API keys page, click Create API keys.
2

Deploy the new keys

Replace the old keys in your app and your server, then deploy.
3

Disable the old keys

Open the old key and click Disable keys. New requests with those keys fail at once. Logo images that browsers and the CDN already cached can still show until their cache expires.

Key creation errors

On a team, only an admin can create keys. If you see Failed to create token, wait a minute and try again. If the error continues, contact support@logo.dev.