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

# Authentication and API key overview

> Understand OMOPHub authentication options including API keys and bearer tokens, scopes, header usage, and security best practices for API access.

## API Key Authentication

API keys are used for all programmatic access to the OMOPHub API. They provide:

* **Long-lived access**: No expiration for continuous integration
* **Granular permissions**: Control access to specific resources
* **Usage tracking**: Monitor API consumption per key
* **Multiple keys**: Create keys for different environments

### API Key Types

> [accordion] Personal API Keys
>
> Individual developer keys
>
> * Tied to your user account
> * Inherit your account permissions
> * Usage counts toward personal quota
> * Can be revoked anytime

> [accordion] Team API Keys
>
> Shared keys for team collaboration (Coming Soon)
>
> * Associated with team/organization
> * Shared usage limits
> * Role-based access control
> * Audit logging per team member

## Authentication Flow

### API Authentication Flow

```mermaid theme={null}
sequenceDiagram
    participant Client
    participant API
    participant Auth Service
    
    Client->>API: Request with API key
    API->>Auth Service: Validate API key
    Auth Service->>API: Return permissions
    API->>Client: Process request
```

### API Key Security

1. **Environment Variables**: Store keys in environment variables
   ```bash theme={null}
   export OMOPHUB_API_KEY="oh_xxxxxxxxx"
   ```

2. **Key Rotation**: Regularly rotate keys (every 90 days recommended)

3. **Separate Environments**: Use different keys for dev/staging/production

4. **Monitor Usage**: Check API key usage regularly for anomalies

## Authentication Headers

### API Key Authentication

Include your API key in the Authorization header:

```bash cURL theme={null}
curl -H "Authorization: Bearer oh_xxxxxxxxx" \
  https://api.omophub.com/v1/vocabularies
```

```python Python theme={null}
client = OMOPHubClient(api_key="oh_xxxxxxxxx")
```

```r R theme={null}
client <- omophub_client(api_key = "oh_xxxxxxxxx")
```

## Troubleshooting

> [accordion] API Key Not Working
>
> * Check the key hasn't been revoked
> * Verify you're using the correct environment
> * Confirm proper Authorization header format

> [accordion] Rate Limit Exceeded
>
> * Check X-RateLimit headers in responses
> * Implement exponential backoff
> * Consider upgrading your plan
> * Use caching to reduce requests

## Next Steps

> [card] [Generate API Keys](https://dashboard.omophub.com/api-keys)
>
> Create keys for API access


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.