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

# Authentication

> Learn how to authenticate with the Meibel API

The Meibel API uses API keys to authenticate requests. All API requests must include your API key in the `Meibel-API-Key` header.

## API Keys

Your API key carries many privileges, so be sure to keep it secure. Do not share your API key in publicly accessible areas such as GitHub, client-side code, or in your applications.

### Obtaining an API Key

1. Sign in to your [Meibel Dashboard](https://app.meibel.ai)
2. Navigate to Settings > API Keys
3. Click "Create New API Key"
4. Give your key a descriptive name
5. Copy the key immediately -- you won't be able to see it again

<Warning>
  API keys should be stored securely in environment variables or a secrets management solution, never in your codebase.
</Warning>

## Making Authenticated Requests

All API requests must be made over HTTPS and include a `Meibel-API-Key` header with your API key.

### Using cURL

```bash theme={null}
curl -X GET https://api.meibel.ai/v2/datasources \
  -H "Meibel-API-Key: YOUR_API_KEY"
```

### Using the SDKs

The official SDKs handle authentication for you when provided with an API key:

<CodeGroup>
  ```python Python theme={null}
  from meibel import MeibelClient
  import os

  client = MeibelClient(api_key=os.getenv("MEIBEL_API_KEY"))

  datasources = client.datasources.list()
  ```

  ```python Python (Async) theme={null}
  from meibel import AsyncMeibelClient
  import asyncio
  import os

  async def main():
      client = AsyncMeibelClient(api_key=os.getenv("MEIBEL_API_KEY"))
      datasources = client.datasources.list()
      await client.close()

  asyncio.run(main())
  ```

  ```typescript TypeScript theme={null}
  import { MeibelClient } from 'meibel';

  const client = new MeibelClient({
    apiKey: process.env.MEIBEL_API_KEY,
  });

  const datasources = client.datasources.list();
  ```

  ```go Go theme={null}
  import meibelgo "github.com/meibel-ai/meibel-go"

  client := meibelgo.NewClient(
      meibelgo.WithAPIKey(os.Getenv("MEIBEL_API_KEY")),
  )
  ```

  ```bash CLI theme={null}
  export MEIBEL_API_KEY="your-api-key"
  meibel datasources list
  ```
</CodeGroup>

## API Key Security Best Practices

To keep your API keys secure:

<Steps>
  <Step title="Use environment variables">
    Store API keys in environment variables, not in your code
  </Step>

  <Step title="Implement key rotation">
    Rotate your API keys periodically
  </Step>

  <Step title="Set appropriate permissions">
    Create keys with the minimum necessary permissions
  </Step>

  <Step title="Monitor usage">
    Regularly review API key usage in the dashboard
  </Step>

  <Step title="Revoke compromised keys">
    Immediately revoke any keys that may have been compromised
  </Step>
</Steps>

## Troubleshooting Authentication

If you're experiencing authentication issues:

* Ensure your API key is valid and active in the dashboard
* Check that you're using the `Meibel-API-Key` header (not `Authorization`)
* Verify there are no extra spaces or characters in your key
* Confirm your API key has the necessary permissions

If problems persist, contact [support@meibel.ai](mailto:support@meibel.ai) for assistance.
