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

# Authentication

> Learn how to authenticate your API requests

## API Keys

All API requests (both v1 and v2) must be authenticated using an API key. You can generate and manage API keys from your campaign's dashboard.

## Generating an API Key

<Steps>
  <Step title="Navigate to Settings">
    Go to your Settings in the dashboard

    <Frame>
      <img src="https://mintcdn.com/supafunnel/IifJb2kOW0R-JLoz/images/navigation-step1.jpg?fit=max&auto=format&n=IifJb2kOW0R-JLoz&q=85&s=48e1769c1f4a2702ea3357fc3cd33bfb" alt="Image" width="876" height="597" data-path="images/navigation-step1.jpg" />
    </Frame>
  </Step>

  <Step title="Access API Keys">
    Click on the "API Keys" tab

    <Frame>
      <img src="https://mintcdn.com/supafunnel/IifJb2kOW0R-JLoz/images/navigation-step2.jpg?fit=max&auto=format&n=IifJb2kOW0R-JLoz&q=85&s=fb9e77e9329d8c69e1b8f8112e2314f9" alt="Image" width="818" height="524" data-path="images/navigation-step2.jpg" />
    </Frame>
  </Step>

  <Step title="Open Generate API Key">
    Click on the "Generate API Key" button

    <Frame>
      <img src="https://mintcdn.com/supafunnel/IifJb2kOW0R-JLoz/images/navigation-step3.jpg?fit=max&auto=format&n=IifJb2kOW0R-JLoz&q=85&s=8a0e3146f4134445867bbadde51531ca" alt="Image" width="1499" height="477" data-path="images/navigation-step3.jpg" />
    </Frame>
  </Step>

  <Step title="Generate New Key">
    Click "Generate API Key" and give it a descriptive name

    <Frame>
      <img src="https://mintcdn.com/supafunnel/IifJb2kOW0R-JLoz/images/navigation-step4.jpg?fit=max&auto=format&n=IifJb2kOW0R-JLoz&q=85&s=e1893c7f917cdd60332a4c6f7add6835" alt="Image" width="751" height="457" data-path="images/navigation-step4.jpg" />
    </Frame>
  </Step>

  <Step title="Copy and Store">
    Copy and securely store your API key - you won't be able to see it again

    <Frame>
      <img src="https://mintcdn.com/supafunnel/IifJb2kOW0R-JLoz/images/navigation-step5.jpg?fit=max&auto=format&n=IifJb2kOW0R-JLoz&q=85&s=a36530e694d036f6204dcaec09ed7518" alt="Image" width="826" height="389" data-path="images/navigation-step5.jpg" />
    </Frame>
  </Step>
</Steps>

<Warning>
  **Security**: Keep your API keys secure and never share them publicly. If a key is compromised, disable it immediately and generate a new one.
</Warning>

## Using Your API Key

Include your API key in the `Authorization` header of every request:

<CodeGroup>
  ```bash cURL theme={null}
  curl --location 'https://api.voiceaiwrapper.app/api/v2/voice-campaigns/{campaignId}/leads' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data '{...}'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.voiceaiwrapper.app/api/v2/voice-campaigns/{campaignId}/leads', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer YOUR_API_KEY'
    },
    body: JSON.stringify({...})
  });
  ```

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

  url = 'https://api.voiceaiwrapper.app/api/v2/voice-campaigns/{campaignId}/leads'
  headers = {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer YOUR_API_KEY'
  }
  response = requests.post(url, headers=headers, json={...})
  ```
</CodeGroup>

## Finding Your Tenant ID (v1 Only)

<Note>
  **v2 Users**: You can skip this section. v2 automatically determines your tenant ID from your API key.
</Note>

If you're using API v1, you'll need to include your `tenant_id` in request bodies. You can find it:

1. In your dashboard URL: `https://dashboard.voiceaiwrapper.app/en/{tenant-id}`
2. In the API documentation panel
3. By contacting support

## Managing API Keys

### Viewing API Keys

All your API keys are listed in the API Keys tab with:

* Name
* Status (Active/Disabled)
* Masked key value (for security)

### Enabling/Disabling Keys

Toggle the switch next to each API key to enable or disable it instantly. Disabled keys cannot authenticate requests.

### Deleting API Keys

Click the actions menu next to a key to permanently delete it. This action cannot be undone.

<Tip>
  **Best Practice**: Create separate API keys for different applications or environments (development, staging, production). This makes key rotation easier and improves security.
</Tip>

## Testing Your Authentication

Try making a simple API call to verify your authentication is working:

<CodeGroup>
  ```bash cURL theme={null}
  curl --location 'https://api.voiceaiwrapper.app/api/v2/voice-campaigns/{campaignId}/leads' \
  --header 'Authorization: Bearer YOUR_API_KEY'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.voiceaiwrapper.app/api/v2/voice-campaigns/{campaignId}/leads', {
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY'
    }
  });

  console.log(response.status); // Should be 200 if authenticated
  ```

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

  response = requests.get(
      'https://api.voiceaiwrapper.app/api/v2/voice-campaigns/{campaignId}/leads',
      headers={'Authorization': 'Bearer YOUR_API_KEY'}
  )

  print(response.status_code)  # Should be 200 if authenticated
  ```
</CodeGroup>

## Troubleshooting

<AccordionGroup>
  <Accordion title="401 Unauthorized Error">
    * Verify your API key is correct and hasn't been disabled
    * Check that you're including the "Bearer " prefix
    * Ensure the key hasn't been deleted
  </Accordion>

  <Accordion title="403 Forbidden Error">
    * Confirm your API key has the necessary permissions
    * Verify you're accessing a campaign you have access to
    * Check that your tenant is active
  </Accordion>

  <Accordion title="API Key Not Working">
    * Generate a new API key and try again
    * Verify you copied the entire key without spaces
    * Check that the key is enabled in the dashboard
  </Accordion>
</AccordionGroup>
