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

# Authentication

> How to authenticate with the emma API

# Authentication

Learn how to authenticate your requests to the emma API.

## API Keys

All API requests must include an API key in the Authorization header.

```bash theme={null}
Authorization: Bearer YOUR_API_KEY
```

## Getting Your API Key

<Steps>
  <Step title="Sign in to emma">
    Go to [app.emma.ai](https://app.emma.ai) and sign in to your account.
  </Step>

  <Step title="Navigate to Settings">
    Click on your profile and select **Settings**.
  </Step>

  <Step title="Go to API section">
    Select the **API** tab in the settings menu.
  </Step>

  <Step title="Generate a key">
    Click **Create API Key** and give it a descriptive name.
  </Step>
</Steps>

<Warning>
  Keep your API key secure! Never expose it in client-side code or public repositories.
</Warning>

## Example Request

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    curl -X POST "https://api.emma.ai/v1/sessions" \
      -H "Authorization: Bearer YOUR_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"prompt": "Hello, emma!"}'
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    import requests

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

    response = requests.post(
        "https://api.emma.ai/v1/sessions",
        headers=headers,
        json={"prompt": "Hello, emma!"}
    )
    ```
  </Tab>

  <Tab title="JavaScript">
    ```javascript theme={null}
    const response = await fetch("https://api.emma.ai/v1/sessions", {
      method: "POST",
      headers: {
        "Authorization": "Bearer YOUR_API_KEY",
        "Content-Type": "application/json"
      },
      body: JSON.stringify({ prompt: "Hello, emma!" })
    });
    ```
  </Tab>
</Tabs>

## Key Management

### Rotating Keys

For security, we recommend rotating your API keys periodically:

1. Create a new API key
2. Update your applications to use the new key
3. Revoke the old key

### Revoking Keys

To revoke an API key:

1. Go to **Settings > API**
2. Find the key you want to revoke
3. Click **Revoke**

<Note>
  Revoking a key is immediate and cannot be undone. Make sure you've updated all applications using that key before revoking.
</Note>

## Security Best Practices

<CardGroup cols={2}>
  <Card title="Use Environment Variables" icon="lock">
    Store API keys in environment variables, not in code.
  </Card>

  <Card title="Limit Permissions" icon="shield">
    Create keys with only the permissions you need.
  </Card>

  <Card title="Rotate Regularly" icon="rotate">
    Rotate keys periodically and after any potential exposure.
  </Card>

  <Card title="Monitor Usage" icon="chart-line">
    Review API usage logs for unusual activity.
  </Card>
</CardGroup>
