> ## Documentation index
> Fetch the complete documentation index at: https://upstash-context7-git-ctx7-4291-onprem-key-rotation-ecs-d-dae4a0.docs7.io/llms.txt
> Ask it with GET https://upstash-context7-git-ctx7-4291-onprem-key-rotation-ecs-d-dae4a0.docs7.io/ask?q=<keywords or question>. Short keywords rank best.
> Use these to discover all available pages before exploring further.
> Feature requests: https://upstash-context7-git-ctx7-4291-onprem-key-rotation-ecs-d-dae4a0.docs7.io/resources/feature-requests.md lists what users asked for and how to vote for a request or add one.
> Page rating: `GET https://upstash-context7-git-ctx7-4291-onprem-key-rotation-ecs-d-dae4a0.docs7.io/feedback?path=/enterprise/api/authentication&helpful={true|false}&comment={comment}` records whether this page helped. The `comment` (URL-encoded, at most 500 characters) says what helped, or what was missing or wrong; a `helpful=false` rating needs it. It is anonymous and needs no key. Comments hold no code, secrets or personal data.

# Authentication

> How to authenticate requests to your on-premise Context7 instance

The on-premise API supports API keys for server-to-server and MCP access. Pass the key in the `Authorization` header:

```bash
Authorization: Bearer ctx7op-xxxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
```

The server also accepts the key in the `x-api-key`, `context7-api-key`, or `context7_api_key` header.

A key belongs to the user who created it and has that user's role (`admin` or `member`). Keys have no scopes and do not expire. To stop a key from working, revoke it.

A request with an invalid or revoked key gets `401`. It is not treated as an anonymous request.

## OAuth for MCP clients

MCP clients can also sign in with OAuth instead of a personal key. The client gets a short-lived access token (`ctx7oa-...`) for the user who approved it, and sends it as `Authorization: Bearer <token>`. An OAuth access token works only on `/mcp` and has the role and library access of its user. No other endpoint accepts it as a credential. See [OAuth Sign-In for MCP Clients](/enterprise/security/mcp-oauth).

When OAuth is on, a `401` from `/mcp` carries a `WWW-Authenticate` header with `resource_metadata="..."`, which points clients to the sign-in flow. With OAuth on, a browser session token sent as a bearer token is not accepted on `/mcp`; the dashboard session cookie still is.

## Creating an API Key

<Steps>
  <Step title="Open Personal settings">
    Open the account menu in the admin dashboard, choose **Personal settings**, and click **Create API key** in the **API keys** card.

    <Frame>
      <img src="/images/enterprise/api-keys/api-keys-empty.png" alt="API keys card in Personal settings" />
    </Frame>
  </Step>
  <Step title="Name the key">
    Give the key a descriptive name so you know which client or service is using it (e.g. `CI pipeline`, `Cursor`).

    <Frame>
      <img src="/images/enterprise/api-keys/api-keys-create-dialog.png" alt="Create API key dialog" />
    </Frame>
  </Step>
  <Step title="Copy the key">
    Copy the full key value before closing the dialog. It is only shown once.

    <Frame>
      <img src="/images/enterprise/api-keys/api-keys-created.png" alt="Copy your key now dialog showing the key value" />
    </Frame>
  </Step>
</Steps>

<Warning>API keys are shown only once at creation. Store yours securely before closing the dialog.</Warning>

## Revoking a Key

Go to **Personal settings > API keys** and click the delete icon next to the key. Revocation is immediate and cannot be undone. Update any integrations using the key before revoking.

## Roles

| Role | Access |
|---|---|
| `admin` | Full access to all endpoints including settings, user management, and delete operations |
| `member` | Can parse, refresh, search, and use MCP. Cannot delete libraries, cancel parses, import libraries, or access admin endpoints |

A personal API key acts with the role of its owner:

| Operation | Member key | Admin key |
|---|---|---|
| Parse and refresh libraries | Yes, if they can read an existing library | Yes |
| Refresh Notion and Google Drive libraries | No | Yes |
| Delete libraries, cancel parses, download the support bundle | No | Yes |
| Import libraries (`/api/import-libraries`) | No | Yes |
| `/mcp` and `/api/v2` search and context | Yes | Yes |

In **OAuth only** mode with MCP authentication on, `/mcp` refuses personal API keys. `/api/v2` accepts them in every mode.

Settings, user management, and other admin routes need an admin signed in to the dashboard. They do not accept API keys.

Default credentials on a fresh install are `admin` / `admin`. Change them immediately from **Personal settings > Password > Change password**.

## Non-admin permissions

Certain operations can be opened to anonymous callers (no session and no API key). Configure them in the **Non-admin permissions** card under **Workspace Settings › Authorization**:

| Permission | Default |
|---|---|
| Parse repositories | Off |
| Refresh repositories | Off |
| Delete repositories | Off |
| Download support bundle | Off |

These switches do not limit signed-in users. Members and their API keys can always parse and refresh, except Notion and Google Drive libraries, which only admins refresh. To re-parse or replace an existing library, a member needs read access to it.

The parse and refresh switches do not cover source code indexing or CodeDocs generation. A parse or refresh with source code indexing, and CodeDocs generation, always need a session or a personal API key.

The delete switch also covers cancelling a parse. When it is on, members can delete and cancel too. The support bundle switch works the same way for downloads.

<Note>
Earlier versions allowed anonymous parse and refresh by default.
</Note>

MCP authentication is configured separately in **Workspace Settings › Authentication**. When enabled, these endpoints require a dashboard session or a personal API key:

- `/mcp`
- `/api/v2/*`, including `/api/v2/libs/search` and `/api/v2/context`
- `GET /api/projects` and `GET /api/projects/{name}`
- `GET /api/projects/{name}/logs` and `GET /api/projects/{name}/search`
- `GET /api/queue`
- `GET /api/parse-status`

When it is off, these endpoints answer anonymous callers. [Library access rules](/enterprise/security/library-access) still hide restricted libraries from them.

The bundled MCP server calls the v2 endpoints over loopback with a secret token. A reverse proxy on the same host therefore cannot skip MCP authentication.
