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

# API keys

> How API keys authenticate your Persistence REST API requests, and how to store and rotate them safely.

API keys authenticate your requests to the Persistence REST API.

<Frame caption="API Keys exposes environment, scope, status, creator, and creation metadata without revealing complete key values.">
  <img src="https://mintcdn.com/persistence-ai/vTPO-R7syJyo2N_1/images/dashboard/settings-api-keys.png?fit=max&auto=format&n=vTPO-R7syJyo2N_1&q=85&s=19c3586b2870eecc1eeadf30e5a03642" alt="Persistence API Keys settings with masked keys, environments, scopes, and statuses" width="640" height="360" data-path="images/dashboard/settings-api-keys.png" />
</Frame>

An API key belongs to a workspace and uses the scopes you select when you create it. A workspace can have one API key at a time.

## Create a key

<Steps>
  <Step title="Open API Keys">
    In **Settings**, open **API Keys** and select **Create API key**.
  </Step>

  <Step title="Describe its use">
    Enter a key name and description, then select at least one scope. Grant only the scopes the integration needs.
  </Step>

  <Step title="Save the key">
    Create the key, then copy or download it immediately. Persistence shows the full key only once.
  </Step>
</Steps>

## Authentication

Include your API key in the request headers:

```http theme={null}
x-api-key: YOUR_API_KEY
```

## Storing keys safely

<Note>
  Keep your API keys secure. Never commit them to public repositories or expose
  them in client-side code.
</Note>

Store keys in environment variables or a secrets manager.

## Replace a key

Revoke the existing key before you create a replacement. Revocation takes effect immediately, so integrations that still use the old key will fail.

Plan the change, revoke the key, create and store the replacement, then update every integration that authenticates to the workspace.
