## Overview

API keys are used to authenticate requests to the ModelStack API. Each key starts with `sk_` and can be given a descriptive name for easy identification.

## Creating an API Key

1. Navigate to **Dashboard → Settings → API Keys tab** or go directly to [modelstack.cc/dashboard/settings?tab=api-keys](https://modelstack.cc/dashboard/settings?tab=api-keys)
2. Click **Create API Key**
3. Enter a descriptive name (e.g., "Production Server", "Development", "CI/CD Pipeline")
4. Click **Create**
5. **Copy the key immediately** — it won't be shown again

<Warning>
  API keys are only displayed once at creation time. Store them securely. If you
  lose a key, you'll need to create a new one.
</Warning>

## Managing API Keys

Your API keys dashboard shows:

- **Key name** — The descriptive name you assigned
- **Key prefix** — First few characters of the key (e.g., `abc...`)
- **Created date** — When the key was created
- **Last used** — Timestamp of the most recent API call with this key

## Revoking an API Key

To revoke (delete) an API key:

1. Navigate to **Dashboard → Settings → API Keys tab**
2. Find the key you want to revoke
3. Click the **delete** button
4. Confirm the revocation

<Warning>
  Revoking a key is immediate and irreversible. Any application using that key
  will immediately receive `401 Unauthorized` errors.
</Warning>

## Best Practices

- **Use descriptive names** — Name keys after their use case (e.g., "Backend Production", "Testing")
- **One key per environment** — Use separate keys for development, staging, and production
- **Rotate regularly** — Periodically create new keys and revoke old ones
- **Revoke compromised keys immediately** — If a key is exposed, revoke it from your dashboard right away
