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

# Authentication

> How to authenticate with the Snapopa API

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

## Getting Your API Key

1. Sign in to your [Snapopa Dashboard](https://snapopa.com/dashboard)
2. Navigate to **API Keys**
3. Click **Create New Key**
4. Copy and securely store your API key

<Warning>
  API keys are shown only once when created. Store them securely and never commit them to version control.
</Warning>

## Using Your API Key

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

```bash theme={null}
curl -X POST https://api.snapopa.com/capture \
  -H "Authorization: Bearer sk_live_abc123..." \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com"}'
```

## API Key Format

API keys follow this format:

| Prefix     | Environment | Example                   |
| ---------- | ----------- | ------------------------- |
| `sk_live_` | Production  | `sk_live_abc123def456...` |
| `sk_test_` | Testing     | `sk_test_xyz789...`       |

## Security Best Practices

1. **Never expose keys in client-side code** - API calls should be made from your backend
2. **Use environment variables** - Store keys in `.env` files, not in code
3. **Rotate keys regularly** - Generate new keys periodically
4. **Set key expiration** - Use expiring keys when possible
5. **Monitor usage** - Check your dashboard for unusual activity

## Environment Variables

```bash theme={null}
# .env
SNAPOPA_API_KEY=sk_live_your_api_key_here
```

```javascript theme={null}
// Use in your application
const apiKey = process.env.SNAPOPA_API_KEY;
```

## Error Responses

| Status | Error             | Description                           |
| ------ | ----------------- | ------------------------------------- |
| 401    | `Unauthorized`    | Missing or invalid API key            |
| 401    | `API key expired` | The API key has expired               |
| 403    | `Forbidden`       | Key doesn't have required permissions |

```json theme={null}
{
  "success": false,
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Invalid or missing API key"
  },
  "data": null
}
```
