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

# Authentication

> Learn how to authorize API requests using API keys

# Authorizing API Requests

All requests to the Anon API require authentication using an API key. This page serves as a centralized reference for all authentication-related information.

## API Key Management

### Creating an API Key

<Note>API keys can only be created by Anon admins.</Note>

1. Navigate directly to [Anon Dashboard: API Keys](https://dashboard.anon.com/keys). Ensure you are logged in using your work email.
2. Click the **Create New Key** button
3. Enter a description for your key (e.g., "Production Server", "Development Environment")
4. Click **Generate Key**
5. Copy and securely store your API key

<Warning>API keys are only displayed once when created. If you lose your key, you'll need to generate a new one.</Warning>

### Using Your API Key

Include your API key in the `Authorization` HTTP header for all API requests:

```bash theme={"system"}
Authorization: Bearer ANON_API_KEY
```

### API Key Best Practices

* **Never share your API key**: In publicly accessible areas such as GitHub or client-side code. Make requests to Anon server-side.
* **Separate Development from Production**: Create different keys for different environments (development, production).
* **Use secrets or environment variables**: To store API keys in your applications.

<Info>We recommend rotating your API keys at least every 90 days as a security best practice.</Info>

### Revoking API Keys

If an API key is no longer needed:

1. Log in to your [Anon Dashboard](https://dashboard.anon.com)
2. Navigate to **Settings** > **API Keys**
3. Find the key you want to revoke
4. Click **Revoke Key**
5. Confirm the action

Once revoked, a key cannot be restored. You'll need to create a new key if needed.

## Environments and Base URLs

Anon provides a single environment for production, with an API endpoint and dashboard:

| Environment    | Details                                                                                                                                                                                                                    |
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Production** | • Dashboard: [dashboard.anon.com](https://dashboard.anon.com)<br />• API Base URL: `https://worker.anon.com`<br />• Use for live applications<br />• API keys start with `anon_` and are required for production endpoints |

{/* <Note>API keys are environment-specific. Development keys cannot be used in production and vice versa.</Note> */}

You can use a *separate organization* for development and production environments.

## API Error Handling

The API returns standard HTTP status codes to indicate success or failure:

* `2xx` - Success
* `4xx` - Client error (e.g., invalid parameters, authentication error)
* `5xx` - Server error

Error responses include a JSON body with details:

```json theme={"system"}
{
  "error": {
    "code": "invalid_parameter",
    "message": "The provided migration ID is invalid"
  }
}
```

## cURL Example

```bash theme={"system"}
curl -X GET https://worker.anon.com/healthz \
  -H "Authorization: Bearer ANON_API_KEY" \
  -H "Content-Type: application/json"
```
