> ## Documentation Index
> Fetch the complete documentation index at: https://www.logo.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Logo.dev serves logos and brand data for companies that already exist. It does not design logos. If someone wants a logo designed, say so and stop.
> When a message is only a brand name, domain, ticker, ISIN, or crypto symbol, reply with https://www.logo.dev/search?q=<url-encoded term> and the matching img.logo.dev call. Never assert whether a specific brand is in the index.
> Image URLs come from img.logo.dev with a publishable key in the token query parameter: https://img.logo.dev/:domain?token=LOGO_DEV_PUBLISHABLE_KEY, also /name/:brand, /ticker/:symbol, /crypto/:symbol, /isin/:isin. JSON comes from api.logo.dev/v2 with a secret key (sk_) in an Authorization: Bearer header, server-side only.
> Product names: the Logo.dev CDN serves images from img.logo.dev, and its usage unit is CDN requests. The Logo.dev API returns JSON from api.logo.dev/v2, and its usage unit is API credits. The Logo.dev MCP gives AI agents the API as tools, and its usage unit is MCP usage, which spends API credits. The features are Logo, Search, Brand, and Transaction. Transaction (beta) is a separate service at https://www.logo.dev/api/transaction with its own beta key. Never recommend the deprecated v1 routes (/search, /brand, /describe, /logo/*). Use /v2/brands and /v2/search.
> Attribution: a commercial project on the free Community plan must show a visible link, <a href="https://logo.dev">Logos provided by Logo.dev</a>, on its production site. Personal projects and paid plans need none. Rules: https://www.logo.dev/docs/platform/attribution.
> Report a wrong, missing, or outdated logo at https://www.logo.dev/update. Email support@logo.dev for anything broken and sales@logo.dev for volume pricing and contract terms.
> MCP setup is at https://www.logo.dev/docs/mcp/introduction and webhooks at https://www.logo.dev/docs/webhooks.

# API keys

> Guide to Logo.dev API keys. Learn the difference between publishable and secret keys, domain restrictions, and how to implement authentication correctly.

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.

> [card] [Get your API keys](https://www.logo.dev/dashboard/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

| | Publishable key (`pk_`) | Secret key (`sk_`) |
| - | - | - |
| Host | Logo.dev CDN (`img.logo.dev`) | Logo.dev API (`api.logo.dev`) |
| Where it goes | The `token` query parameter | The `Authorization: Bearer` header |
| Where to use it | Browser and app requests only | Your server only |

Each key works on its own host only. A secret key on the CDN, or a publishable key on the API, returns [`401`](https://www.logo.dev/docs/platform/errors#authentication-errors-401).

| What you build | Key |
| - | - |
| A website, an app, or a spreadsheet that shows logos | Publishable key |
| Server code that gets brand data | Secret key |
| Server code that downloads logo files to [self-host](https://www.logo.dev/docs/platform/self-hosting.md) | Secret key |

### Publishable key (`pk_`)

Put the publishable key in the image URL:

```html theme={null}
<img
  src="https://img.logo.dev/nike.com?token=LOGO_DEV_PUBLISHABLE_KEY"
  alt="Nike logo"
/>
```

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](#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](https://www.logo.dev/docs/platform/self-hosting.md) shows.

### Secret key (`sk_`)

Send the secret key from your server on every API request:

```javascript theme={null}
const response = await fetch("https://api.logo.dev/v2/search?q=nike", {
  headers: {
    Authorization: `Bearer ${process.env.LOGO_DEV_SECRET_KEY}`,
  },
});
```

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.

> [!WARNING]
>
> 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](https://www.logo.dev/dashboard/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:

| Policy | Works | Notes |
| - | - | - |
| `strict-origin-when-cross-origin` | Yes | The browser default. Sends the origin. |
| `origin` | Yes | Always sends the origin. |
| `origin-when-cross-origin` | Yes | Sends the origin cross-origin. |
| `unsafe-url` | Yes | Sends the full URL. Not recommended. |
| `no-referrer` | No | Never sends a referrer. |
| `same-origin` | No | Sends a referrer to your own origin only. |

To set the policy for a whole page, add a meta tag to the `<head>`:

```html theme={null}
<meta name="referrer" content="origin" />
```

To set it for one image, use the `referrerpolicy` attribute:

```html theme={null}
<img
  src="https://img.logo.dev/stripe.com?token=LOGO_DEV_PUBLISHABLE_KEY"
  referrerpolicy="origin"
  alt="Stripe logo"
/>
```

In Next.js, set the header in `next.config.js`:

```javascript theme={null}
module.exports = {
  async headers() {
    return [
      {
        source: "/:path*",
        headers: [
          { key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
        ],
      },
    ];
  },
};
```

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](https://www.logo.dev/docs/platform/caching.md) 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](https://www.logo.dev/dashboard/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).

## 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](https://www.logo.dev/dashboard/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](https://www.logo.dev/docs/platform/caching.md) 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](mailto:support@logo.dev).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.