# Authentication

> Authenticate Lemu AI API requests with an organization API key

URL: https://docs.lemuai.com/api-reference/authentication

## API keys

Every request is authenticated with an API key that belongs to your organization. Anything you read or create with a key belongs to that organization.

### Create a key

Create keys in the Lemu AI dashboard under **Settings → API Keys** (see [API Keys](https://docs.lemuai.com/configurations/api-keys)). The full key is shown **only once**, when you create it. Store it straight away in a secrets manager or an environment variable. Keys start with `lemu_`.

You can also archive a key from the same page. An archived key stops working immediately.

### Send the key

Pass the key in the `X-API-Key` header:

**cURL**

```bash
curl https://app.lemuai.com/api/v1/workflow/fetch \
  -H "X-API-Key: lemu_your_api_key"
```

**JavaScript**

```js
const res = await fetch("https://app.lemuai.com/api/v1/workflow/fetch", {
  method: "GET",
  headers: {
    "X-API-Key": process.env.LEMU_API_KEY,
  },
});
if (!res.ok) throw new Error(`LemuAI API ${res.status}: ${await res.text()}`);
const data = await res.json();
console.log(data);
```

**Python**

```python
import os

import requests

response = requests.get(
    "https://app.lemuai.com/api/v1/workflow/fetch",
    headers={
        "X-API-Key": os.environ["LEMU_API_KEY"],
    },
    timeout=30,
)
response.raise_for_status()
print(response.json())
```

The `Authorization: Bearer lemu_your_api_key` header is also accepted, except on [Trigger an outbound call](https://docs.lemuai.com/api-reference/calls/trigger), which only reads `X-API-Key`. Use `X-API-Key` everywhere to keep things simple.

### What a key can do

An API key acts for your organization, not for a team member, so team roles don't limit it: a key can use every endpoint in this reference. One exception: the [contacts endpoints](https://docs.lemuai.com/api-reference/contacts/overview#hidden-phone-numbers) show full phone numbers only if the team member who created the key may view personal data.

**Warning:** An API key can act on your whole organization. Keep it on your server. Never put it in a browser, a mobile app, or a public repository.

## Authentication errors

| Status | Meaning |
|---|---|
| `401 Unauthorized` | The key is missing, wrong, or archived |
| `403 Forbidden` | The key is valid, but the resource belongs to another organization |
```json
{
  "detail": "Invalid API key"
}
```
