---
title: "API keys"
description: "Generate and revoke API keys that let scripts, CI jobs, and agents call the Baz API and MCP server as you."
canonical: "https://baz.ai/docs/admin/api-keys"
---

# API keys

Generate and revoke API keys that let scripts, CI jobs, and agents call the Baz API and MCP server as you.

API keys authenticate requests to the Baz API and the Baz MCP server without an interactive sign-in, for scripts, CI pipelines, and coding agents running unattended. Each key acts as you and carries your permissions: there is no separate scope picker. Any user can create keys for themselves in **Account Settings → API Keys**.

## Generate a key

<Steps>
  <Step title="Open API Keys" icon="key-round">
    Go to **Account Settings → API Keys** and select **Generate key**.
  </Step>
  <Step title="Name the key" icon="file-code">
    The **Generate API key** dialog says "The key acts as you and carries your permissions." Enter a **Key name**, for example `CI pipeline`, and select **Generate key**.
  </Step>
  <Step title="Copy the key" icon="lock">
    The dialog changes to **Your new API key**: "Copy this key now. You will not see it again." Copy the key into your secret store and select **Done**.
  </Step>
</Steps>

The table lists each key's **Name**, **Created** date, and **Status** (**Active** or **Revoked**). Keys do not expire; they stay active until revoked.

## Use a key

Send the key in the `x-api-key` header.

```bash title="Terminal"
curl https://baz.ai/api/v2/memories \
  -H "x-api-key: $BAZ_API_KEY"
```

Only endpoints that opt in to API keys accept them; any other endpoint rejects the request even with a valid key. See [REST API](/docs/reference/api) for the full list.

The same header authenticates the MCP server:

```bash title="Terminal"
claude mcp add --transport http baz https://baz.ai/mcp --header "x-api-key: $BAZ_API_KEY"
```

See [MCP](/docs/integrations/developer-tools/mcp) for other clients.

## Restrict a key to IP addresses

The API that creates keys accepts an optional list of permitted IP addresses (`permittedIps`). A key created with that list only works from those addresses. The **Generate API key** dialog does not expose this field. If you need an IP-restricted key, contact Baz support.

## Revoke a key

<Steps>
  <Step title="Find the key" icon="scan-search">
    In **Account Settings → API Keys**, select **Revoke** on the key's row.
  </Step>
  <Step title="Confirm" icon="check-check">
    The dialog asks "Revoke CI pipeline?" (with your key's name) and warns: "Every request that uses this key will fail. You cannot undo this." Select **Revoke**.
  </Step>
</Steps>

Revoking one key does not affect your other keys or your sign-in session. Admins can revoke any user's key through the API; other users can revoke only their own.

:::tip
Generate the replacement key first, update whatever uses the old key, then revoke it.
:::

## Related

<CardGroup cols={2}>
  <Card title="REST API" href="/docs/reference/api" icon="network">
    Endpoints that accept API keys.
  </Card>
  <Card title="MCP tools" href="/docs/reference/mcp-tools" icon="plug">
    Tools your agents can call with a key.
  </Card>
  <Card title="Users and permissions" href="/docs/admin/users-and-permissions" icon="users">
    The permissions a key inherits.
  </Card>
</CardGroup>
