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

# Authentication

> Authenticating with the Replyify API

All Replyify API requests require authentication using a Bearer token in the Authorization header.

## API Keys

API keys provide secure access to your workspace data. Each key:

* Is scoped to a single workspace
* Has full read/write access to workspace data
* Never expires (unless manually revoked)
* Can be revoked at any time

## Creating an API Key

<Steps>
  <Step title="Go to API Settings">
    Navigate to **Settings → API Keys** in your Replyify dashboard.
  </Step>

  <Step title="Create a new key">
    Click **Create API Key** and enter a descriptive name (e.g., "Production Integration").
  </Step>

  <Step title="Copy your key">
    Copy the generated key immediately. It's only shown once for security.

    <Warning>
      If you lose your key, you'll need to create a new one. Old keys cannot be retrieved.
    </Warning>
  </Step>
</Steps>

## Using Your API Key

Include your API key in the `Authorization` header of every request:

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

### Example Request

```bash cURL theme={null}
curl -X GET "https://app.replyify.ai/api/replies" \
  -H "Authorization: Bearer rpl_abc123def456" \
  -H "Content-Type: application/json"
```

```javascript JavaScript theme={null}
const response = await fetch('https://app.replyify.ai/api/replies', {
  headers: {
    'Authorization': 'Bearer rpl_abc123def456',
    'Content-Type': 'application/json'
  }
});
```

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

response = requests.get(
    'https://app.replyify.ai/api/replies',
    headers={'Authorization': 'Bearer rpl_abc123def456'}
)
```

## Authentication Errors

### 401 Unauthorized

Returned when authentication fails:

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

**Common causes:**

* Missing `Authorization` header
* Incorrect or malformed API key
* Revoked API key

### 403 Forbidden

Returned when the key is valid but lacks permission:

```json theme={null}
{
  "error": "Insufficient permissions"
}
```

**Common causes:**

* Trying to access another workspace's data
* API key restrictions (if configured)

## Managing API Keys

### Viewing Keys

Go to **Settings → API Keys** to see all keys:

* Key name
* Key prefix (first few characters)
* Created date
* Last used date

### Revoking Keys

To revoke a key:

1. Find the key in **Settings → API Keys**
2. Click **Revoke**
3. Confirm the action

<Warning>
  Revoking a key immediately invalidates it. Any integrations using that key will stop working.
</Warning>

## Security Best Practices

<CardGroup cols={2}>
  <Card title="Use Environment Variables" icon="shield">
    Never hardcode API keys in your source code. Use environment variables instead.
  </Card>

  <Card title="Rotate Keys Regularly" icon="rotate">
    Create new keys periodically and revoke old ones, especially after team changes.
  </Card>

  <Card title="One Key Per Integration" icon="key">
    Use separate keys for different integrations so you can revoke individually.
  </Card>

  <Card title="Monitor Usage" icon="eye">
    Check "Last Used" dates to identify unused keys that can be safely revoked.
  </Card>
</CardGroup>

### Storing Keys Securely

**Do:**

* Store in environment variables
* Use secrets management (AWS Secrets Manager, HashiCorp Vault, etc.)
* Encrypt at rest if storing in a database

**Don't:**

* Commit to version control
* Share in plain text (email, Slack, etc.)
* Expose in client-side code
* Log in application logs

## Example: Environment Variables

```bash .env theme={null}
REPLYIFY_API_KEY=rpl_abc123def456
```

```javascript Node.js theme={null}
const apiKey = process.env.REPLYIFY_API_KEY;

const response = await fetch('https://app.replyify.ai/api/replies', {
  headers: {
    'Authorization': `Bearer ${apiKey}`,
    'Content-Type': 'application/json'
  }
});
```

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

api_key = os.environ.get('REPLYIFY_API_KEY')

response = requests.get(
    'https://app.replyify.ai/api/replies',
    headers={'Authorization': f'Bearer {api_key}'}
)
```
