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

# Authentication

> Learn how to authenticate with the VoiceCheap API

# Authentication

The VoiceCheap API uses API keys for authentication. All API requests must include your API key in the `x-api-key` header.

## Getting Your API Key

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

  <Step title="Navigate to API Page">
    Go to the **API** page at [app.voicecheap.ai/page-api](https://app.voicecheap.ai/page-api).
  </Step>

  <Step title="Generate API Key">
    Click **Create New Key** and give your key a name. Your full API key will be displayed only once - copy and securely store it immediately.
  </Step>
</Steps>

<Warning>
  **Important: Save Your Key Immediately**

  Your full API key is displayed **only once** when created. After closing the modal, you will only see a masked version (`vc_abc...xyz`). If you lose your key, you must delete it and create a new one.
</Warning>

## API Key Limits

* You can create a **maximum of 5 API keys** per account
* Each key can be named for easy identification (e.g., "Production", "Development")
* Keys can be deleted at any time from the API page

## Using Your API Key

Include your API key in the `x-api-key` header with every request:

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.voicecheap.ai/v1/translate \
    -H "x-api-key: vc_your-api-key-here" \
    -F "file=@video.mp4" \
    -F "targetLanguage=spanish"
  ```

  ```typescript TypeScript theme={null}
  const formData = new FormData();
  formData.append('file', videoFile);
  formData.append('targetLanguage', 'spanish');

  const response = await fetch('https://api.voicecheap.ai/v1/translate', {
    method: 'POST',
    headers: {
      'x-api-key': 'vc_your-api-key-here'
    },
    body: formData
  });

  const data = await response.json();
  ```

  ```javascript JavaScript theme={null}
  const formData = new FormData();
  formData.append('file', videoFile);
  formData.append('targetLanguage', 'spanish');

  const response = await fetch('https://api.voicecheap.ai/v1/translate', {
    method: 'POST',
    headers: {
      'x-api-key': 'vc_your-api-key-here'
    },
    body: formData
  });

  const data = await response.json();
  ```

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

  files = {'file': open('video.mp4', 'rb')}
  data = {'targetLanguage': 'spanish'}
  headers = {'x-api-key': 'vc_your-api-key-here'}

  response = requests.post(
      'https://api.voicecheap.ai/v1/translate',
      headers=headers,
      files=files,
      data=data
  )
  ```
</CodeGroup>

## Requirements

<Warning>
  **Paid Subscription Required**

  API access requires an active paid subscription. Free accounts cannot use the API. If you attempt to use the API without a valid subscription, you will receive a `403 Forbidden` error.
</Warning>

## API Key Security

<CardGroup cols={2}>
  <Card title="Keep it Secret" icon="lock">
    Never expose your API key in client-side code, public repositories, or any publicly accessible location.
  </Card>

  <Card title="Use Environment Variables" icon="shield">
    Store your API key in environment variables or a secure secrets manager.
  </Card>

  <Card title="Rotate Regularly" icon="rotate">
    Periodically rotate your API keys, especially if you suspect they may have been compromised.
  </Card>

  <Card title="Monitor Usage" icon="eye">
    Keep track of your API usage to detect any unauthorized access.
  </Card>
</CardGroup>

## Error Responses

If authentication fails, you will receive one of the following errors:

| Status Code | Error Code               | Description                                                  |
| ----------- | ------------------------ | ------------------------------------------------------------ |
| 401         | `MISSING_API_KEY`        | The `x-api-key` header was not provided                      |
| 401         | `INVALID_API_KEY_FORMAT` | The API key does not use the expected `vc_` prefix           |
| 401         | `INVALID_API_KEY`        | The provided API key is invalid                              |
| 403         | `API_ACCESS_REQUIRED`    | API access is not enabled for this account                   |
| 403         | `SUBSCRIPTION_REQUIRED`  | API access requires an active paid subscription              |
| 403         | `INSUFFICIENT_CREDITS`   | Your account does not have enough credits for this operation |

## Example Error Response

```json theme={null}
{
  "code": "INVALID_API_KEY",
  "message": "The provided API key is invalid. Please check your API key and try again."
}
```
