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

# Authentication

> Learn how to authenticate with the cloro API using Bearer tokens, manage API keys securely, and handle authentication errors in your requests.

The cloro API uses Bearer token authentication to secure API endpoints. You'll need to include your API key in the `Authorization` header of every request.

## Getting your API key

Manage your API keys in the [dashboard](https://dashboard.cloro.dev). You can create new keys, view usage, and manage your account settings.

Once you receive your API key:

1. **Store** your API key securely. Keep it confidential
2. **Never expose** your API key in client-side code or public repositories

<Warning>
  Never expose your API key in client-side code, public repositories, or share
  it with unauthorized users.
</Warning>

## Using your API key

Include your API key in the `Authorization` header with the `Bearer` prefix:

```
Authorization: Bearer YOUR_API_KEY
```

### Example requests

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.cloro.dev/v1/monitor \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"prompt": "Your prompt here", "model": "CHATGPT"}'
  ```

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

  headers = {
      "Authorization": "Bearer YOUR_API_KEY",
      "Content-Type": "application/json"
  }

  response = requests.post(
      "https://api.cloro.dev/v1/monitor",
      headers=headers,
      json={"prompt": "Your prompt here", "model": "CHATGPT"}
  )
  ```

  ```javascript JavaScript theme={null}
  const headers = {
    Authorization: "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
  };

  const response = await fetch("https://api.cloro.dev/v1/monitor", {
    method: "POST",
    headers: headers,
    body: JSON.stringify({ prompt: "Your prompt here", model: "CHATGPT" }),
  });
  ```

  ```go Go theme={null}
  client := &http.Client{}
  req, _ := http.NewRequest("POST", "https://api.cloro.dev/v1/monitor", body)
  req.Header.Add("Authorization", "Bearer YOUR_API_KEY")
  req.Header.Add("Content-Type", "application/json")
  resp, _ := client.Do(req)
  ```
</CodeGroup>

## Authentication errors

If authentication fails, you'll receive a `401 Unauthorized` response:

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

Common authentication issues:

* **Missing Bearer prefix**: Make sure to include `Bearer` before your API key
* **Invalid API key**: Check that you're using the correct API key
* **Expired API key**: Some API keys may have expiration dates
* **Rate limit exceeded**: You've exceeded your plan's rate limit

## Environment variables

We recommend storing your API key in environment variables:

<CodeGroup>
  ```bash .env theme={null}
  CLORO_API_KEY=your_api_key_here
  ```

  ```python Python theme={null}
  import os
  api_key = os.getenv('CLORO_API_KEY')
  ```

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

  ```go Go theme={null}
  apiKey := os.Getenv("CLORO_API_KEY")
  ```
</CodeGroup>

## API key management

### Regenerating keys

If you suspect your API key has been compromised, you can revoke and generate new keys directly in the [dashboard](https://dashboard.cloro.dev).

### Multiple API keys

You can create multiple API keys in the dashboard for different purposes:

* **Production**: For your live application
* **Development**: For local development and testing
* **CI/CD**: For automated testing and deployment
* **Team members**: Individual keys for team access

## Need help?

If you're having trouble with authentication:

* Check our [API Reference](/api-reference)
* Contact support at [support@cloro.dev](mailto:support@cloro.dev)
