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

# Authentication

> API key authentication for REST API access

## API Keys

All API requests require authentication via API key.

### Creating an API Key

1. Go to **Settings → API Keys**
2. Click **Create API Key**
3. Name your key (e.g., "GitHub Actions", "Jenkins")
4. Copy the key **immediately** (only shown once)
5. Store securely in your environment

## Using API Keys

### Request Header

Include your API key in the `Authorization` header:

```bash theme={null}
Authorization: Bearer YOUR_API_KEY
```

### Example Request

```bash theme={null}
curl -X POST https://backend.revyl.ai/api/v1/tests/execute \
  -H "Authorization: Bearer rev_1234567890abcdef" \
  -H "Content-Type: application/json" \
  -d '{
    "test_id": "test-abc-123"
  }'
```

## Environment Variables

Store API keys as environment variables:

### Bash

```bash theme={null}
export REVYL_API_KEY="rev_1234567890abcdef"

curl -H "Authorization: Bearer $REVYL_API_KEY" \
  https://backend.revyl.ai/api/v1/tests
```

### GitHub Actions

```yaml theme={null}
env:
  REVYL_API_KEY: ${{ secrets.REVYL_API_KEY }}

steps:
  - name: Run Test
    run: |
      curl -H "Authorization: Bearer $REVYL_API_KEY" \
        https://backend.revyl.ai/api/v1/tests/execute
```

### Python

```python theme={null}
import os
import requests

api_key = os.environ['REVYL_API_KEY']

headers = {
    'Authorization': f'Bearer {api_key}',
    'Content-Type': 'application/json'
}

response = requests.post(
    'https://backend.revyl.ai/api/v1/tests/execute',
    headers=headers,
    json={'test_id': 'test-abc-123'}
)
```

## Security Best Practices

### ✅ Do

* Store keys in environment variables or secret managers
* Use different keys for different environments (dev, staging, prod)
* Rotate keys regularly
* Delete unused keys

### ❌ Don't

* Commit keys to version control
* Share keys in plaintext (Slack, email)
* Use the same key across multiple projects
* Log or print keys in application code

## Key Management

### Rotating Keys

1. Create new API key
2. Update environment variables in CI/CD
3. Test with new key
4. Delete old key

### Deleting Keys

1. Go to **Settings → API Keys**
2. Click **Delete** on the key
3. Confirm deletion
4. Update any services using that key

## Error Responses

### Invalid Key

```json theme={null}
{
  "detail": "Invalid API key"
}
```

**Status**: `401 Unauthorized`

### Missing Key

```json theme={null}
{
  "detail": "Authorization header missing"
}
```

**Status**: `401 Unauthorized`

### Expired Key

```json theme={null}
{
  "detail": "API key expired"
}
```

**Status**: `401 Unauthorized`

## Related

* [API Quickstart](/api-reference/quickstart)
* [API Reference](/api-reference/index)
