# Introducing Workspace API Keys

We're excited to announce Workspace API Keys – a new and improved way for you to build integrations with the Dub API.

- Published: July 2, 2024
- Last updated: May 6, 2025
- Authors: [Kiran Krishnan](https://dub.co/authors/kiran), [Steven Tey](https://dub.co/authors/steven)
- Category: [Engineering](https://dub.co/blog/category/engineering)
- Source: https://dub.co/blog/workspace-api-keys

At Dub, we're constantly striving to improve the security of our products, whilst upholding the best developer experience for our users.

Today, we're excited to announce **Workspace API Keys** – a new and improved way for you to build integrations with the [Dub API](https://dub.co/docs/api-reference/introduction).

## Why the change?

Previously, API keys on Dub were created as a 24-character `nanoid` pattern on the user account level:

```bash title=".env"
DUB_API_KEY=PMj357f2FFqKL11DwvWOo5MP
```

This had several limitations:

- **Security vulnerabilities**: An API key gives you unfettered access to all workspaces in your account, which poses a security risk if compromised.
- **Confusing UX**: Users would often struggle to find where to create a new API key – as they expect it to be created in their workspace.
- **Lack of a prefix**: API keys do not have a prefix, which makes it harder for git scanning tools like GitGuardian to detect compromised Dub API keys in packages and GitHub repositories.

## What's changed?

With this new update, API keys on Dub now live on the workspace level. This also means that you no longer need to pass the `workspaceId` parameter to your API requests:

**cURL**

```bash
# [!code word:?workspaceId=ws_xxx] # no longer need to pass workspaceId param
curl -X POST [https://api.dub.co/links?workspaceId=ws_xxx](https://api.dub.co/links?workspaceId=ws_xxx) \ 
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://dub.co"}'
```

**TypeScript**

```ts
import { Dub } from "dub";

export const dub = new Dub({
  token: "<token>",
- workspaceId: "ws_xxx" // no longer need to pass workspaceId param // [!code highlight]
});
```

**Go**

```go
import dub "github.com/dubinc/dub-go"

d := dub.New(
  token: "<token>",
- workspace_id: "ws_xxx" // no longer need to pass workspaceId param // [!code highlight]
)
```

**Python**

```python
import dub

d = dub.Dub(
  token="<token>",
- workspace_id="ws_xxx" # no longer need to pass workspaceId param # [!code highlight]
)
```

> With this change, we've also deprecated User API Keys – while all your old
> keys will still work, you won't be able to create new ones. We also recommend
> revoking your old user API keys and creating new [workspace API
> keys](https://dub.co/docs/api-reference/tokens) instead.

API keys also start with an identifiable prefix: `dub_`. This makes it easier to distinguish them from other keys and revoke them if compromised:

```bash title=".env"
DUB_API_KEY=dub_PMj357f2FFqKL11DwvWOo5MP
```

On top of that, we'e also rolled out 3 improvements to our API setup:

1. [**Restricted scopes**](https://dub.co/blog/workspace-api-keys#1-restricted-scopes): Set fine-grained permission scopes for your API keys.
2. [**Machine users**](https://dub.co/blog/workspace-api-keys#2-machine-users): Create machine users to associate API keys with.
3. [**Custom rate limits**](https://dub.co/blog/workspace-api-keys#3-custom-rate-limits): Different plans now have different API rate limits.

### 1. Restricted scopes

Depending on your integration needs, you can now set fine-grained permission scopes for your API keys. This means you can now create API keys that have access to only a subset of the Dub API.

For example, you can create an API key with **write** access to the [`links` resource](https://dub.co/docs/data-model#links), and **read-only** access to the [`analytics` resource](https://dub.co/docs/api-reference/endpoint/retrieve-analytics).

![Screenshot of the Dub API creation modal with write access to Links and read-only access to Analytics.](https://assets.dub.co/blog/restricted-api-keys.png)

This lets you secure your integrations and only expose the data you need.

### 2. Machine users

On Dub, you can now create API keys that are associated with a “Machine user”.

This is particularly helpful when you don't want to associate the API key with a particular user in your workspace, which helps you avoid security risks when the user leaves the company or if there's a change in project ownership.

![Creating a machine user to associate API keys with.](https://assets.dub.co/blog/api-machine-users.png)

These machine users will show up on your workspace's People tab, but will not contribute to your workspace's user count. Learn more about [machine users](https://dub.co/docs/api-reference/tokens#machine-users).

### 3. Custom rate limits

We now offer [custom rate limits](https://dub.co/docs/api-reference/rate-limits) for each of our plans. This gives you higher rate limits on [Pro](https://dub.co/help/article/pro-plan) and [Business](https://dub.co/help/article/business-plan) plans.

Depending on your Dub.co plan, you can expect the following rate limits:

| Plan                                    | Rate limit                                                           |
| --------------------------------------- | -------------------------------------------------------------------- |
| Free                                    | 60 requests per minute                                               |
| [Pro](https://dub.co/pricing)           | 600 requests per minute                                              |
| [Business](https://dub.co/pricing)      | 1,200 requests per minute                                            |
| [Advanced](https://dub.co/pricing)      | 3,000 requests per minute                                            |
| [Enterprise](https://dub.co/enterprise) | Custom – [reach out to sales](https://dub.co/enterprise) for details |

## What this means for you?

With these changes, you can now build more secure and scalable integrations with the Dub API.

We recommend you to revoke your old user API keys and replace them with [workspace API keys](https://dub.co/docs/api-reference/tokens) instead. Depending on your integration, you might also want to set [custom permission scopes](https://dub.co/docs/api-reference/tokens#api-key-permissions) to limit the access of your API keys.

We hope you find this new feature useful, and we're looking forward to hearing your feedback – feel free to [send us an email](mailto:support@dub.co?subject=Feedback%20for%20Dub%20Workspace%20API%20Keys) or [tweet at us](https://twitter.com/dubdotco)!

## Related articles

- [Introducing Dub Analytics 2.0](https://dub.co/blog/introducing-analytics-2.0.md)

See [all blog posts](https://dub.co/blog.md).
