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:
Secret key (sk_)
Send the secret key from your server on every API request:
Domain restrictions
Domain restrictions limit your publishable key to the sites you list. Logo.dev compares the host in each request’sReferer header with your list. A request from any other host returns 401. Secret key requests are not restricted.
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.commatchesexample.comonly. If your site useswww.example.com, add that domain too.*.example.commatchesexample.comand every subdomain, such asapp.example.com.
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 theReferer 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>:
referrerpolicy attribute:
next.config.js:
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 noReferer 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 theReferer 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.