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

# Partner API Authentication

> Learn how to create and use partner API keys to authenticate with Dub's Partner API.

Requests to the Partner API are authenticated with a partner API key, which is tied to your partner profile and gives access to your data across all the programs you're enrolled in.

Partner API keys follow the format:

```bash .env theme={null}
DUB_PARTNER_API_KEY=dpt_xxxxxxxx
```

> [!WARNING]
>
> Partner API keys are secret. Store them in your server-side code, such as in
> an environment variable, and never expose them on a website.

Partner API keys only work with the Partner API. [Workspace API keys](https://dub.co/docs/api-reference/authentication.md#api-keys) (`dub_`) are rejected by the Partner API, and partner API keys can't be used with the Dub API.

## Create an API key

**1. Go to API Keys**

In the partner dashboard, go to [**Settings** > **API Keys**](https://partners.dub.co/settings/tokens).

Only partner profile [owners](https://dub.co/help/article/managing-partner-teams.md) can create API keys.

**2. Create the key**

Give the key a name, select its [scopes](#scopes), and choose when it expires.

Keys can be set to never expire, or to expire after 7, 30, 60, or 90 days, or 1 year.

**3. Copy the key**

Copy your key and store it in a safe place. You won't be able to see it again.

**4. Use the key**

Send your key as a Bearer token in the `Authorization` header of your requests:

```
Authorization: Bearer dpt_xxxxxxxx
```

A partner profile can have up to 5 API keys at a time. Every owner of the partner profile receives an email when a new key is created.

## Scopes

Each key is limited to the scopes you select when you create or edit it. You must select at least one.

| Scope | Access | Endpoints |
| :- | :- | :- |
| `commissions.read` | Read your commissions. | [`GET /commissions`](https://dub.co/docs/partner-api-reference/commissions/list) |
| `payouts.read` | Read your payouts. | [`GET /payouts`](https://dub.co/docs/partner-api-reference/payouts/list) |
| `customers.read` | Read the customers you referred. | [`GET /customers`](https://dub.co/docs/partner-api-reference/customers/list) |
| `programs.read` | Read the programs you're enrolled in and browse the partner network. | [`GET /programs`](https://dub.co/docs/partner-api-reference/programs/list), [`GET /programs/network`](https://dub.co/docs/partner-api-reference/programs/list-network) |
| `messages.read` | Read your messages with programs. | [`GET /messages`](https://dub.co/docs/partner-api-reference/messages/list) |
| `messages.write` | Send messages to programs. | [`POST /messages`](https://dub.co/docs/partner-api-reference/messages/send) |

A request with a key that's missing a required scope returns a `403` error that names the scopes it needs.

> [!TIP]
>
> Give each key only the scopes it needs to reduce the impact if the key is ever
> exposed.

## Manage your API keys

Owners can edit a key's name, scopes, and expiration, or delete it, from the [API Keys page](https://partners.dub.co/settings/tokens). Other members of the partner profile can view the list of keys.

A key stops working as soon as it's deleted or expires. Requests with an expired key return a `401` error.

If your partner account isn't approved in the [Dub Partner Network](https://dub.co/help/article/program-marketplace.md#joining-the-dub-partner-network), you can still view and delete your existing keys, but you can't create or edit keys, and requests with them return a `403` error.

Keys are also deleted automatically when the person who created them is removed from the partner profile, is no longer an owner, or deletes their Dub account.


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