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

# Authentication

> How to authenticate with the SociaVault API

## Authentication

All API requests require authentication using your API key in the `X-API-Key` header.

### Getting Your API Key

1. Sign up at [sociavault.com](https://sociavault.com)
2. Navigate to your [Dashboard](https://sociavault.com/dashboard)
3. Copy your API key (starts with `sk_live_`)

### Using Your API Key

Include your API key in every request using the `X-API-Key` header:

<CodeGroup>
  ```bash cURL theme={null}
  curl --request GET \
    --url 'https://api.sociavault.com/v1/scrape/tiktok/profile?handle=stoolpresidente' \
    --header 'X-API-Key: sk_live_your_api_key_here'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(url, {
    headers: {
      'X-API-Key': 'sk_live_your_api_key_here'
    }
  });
  ```

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

  headers = {
      'X-API-Key': 'sk_live_your_api_key_here'
  }

  response = requests.get(url, headers=headers)
  ```

  ```php PHP theme={null}
  $headers = [
      'X-API-Key: sk_live_your_api_key_here'
  ];

  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  ```
</CodeGroup>

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

## API Performance

The SociaVault API is built to scale automatically with your needs.

<CardGroup cols={2}>
  <Card title="Auto-Scaling" icon="arrows-up-down">
    Our infrastructure automatically scales to handle your request volume
  </Card>

  <Card title="High Availability" icon="server">
    99.9% uptime with redundant systems and automatic failover
  </Card>

  <Card title="Global CDN" icon="globe">
    Fast response times from anywhere in the world
  </Card>

  <Card title="No Rate Limits" icon="infinity">
    Send as many requests as you need - we scale with you
  </Card>
</CardGroup>

<Info>
  **Enterprise-grade infrastructure** ensures your requests are handled quickly and reliably, no matter the volume.
</Info>

## Credit System

Each API endpoint consumes credits based on data complexity:

| Complexity | Credit Cost  | Examples                    |
| ---------- | ------------ | --------------------------- |
| Simple     | 1 credit     | Profile lookups, basic info |
| Moderate   | 5-10 credits | Posts, videos, comments     |
| Complex    | 20+ credits  | Demographics, analytics     |

<Info>
  Check individual endpoint documentation for specific credit costs.
</Info>

### Checking Your Balance

Monitor your credit balance in real-time via the [Dashboard](https://sociavault.com/dashboard).

<Tip>
  Each API response includes your remaining credits in the response headers for easy tracking.
</Tip>

## Error Responses

The API uses standard HTTP status codes and returns detailed error messages:

| Status Code | Description                               |
| ----------- | ----------------------------------------- |
| 200         | Success                                   |
| 400         | Bad Request - Invalid parameters          |
| 401         | Unauthorized - Invalid or missing API key |
| 403         | Forbidden - Insufficient credits          |
| 500         | Internal Server Error                     |

### Error Response Format

```json theme={null}
{
  "error": "Unauthorized",
  "message": "Invalid API key provided",
  "statusCode": 401
}
```

## Best Practices

<AccordionGroup>
  <Accordion title="Secure Your API Key" icon="lock">
    * Store API keys in environment variables
    * Never commit API keys to version control
    * Use different keys for development and production
    * Rotate keys regularly for security
  </Accordion>

  <Accordion title="Optimize Credit Usage" icon="coins">
    * Cache frequently accessed data
    * Use pagination for large datasets
    * Only request the data you need
    * Monitor your usage in the dashboard
  </Accordion>

  <Accordion title="Error Handling" icon="triangle-exclamation">
    * Always check response status codes
    * Implement proper error handling
    * Log errors for debugging
    * Retry failed requests with exponential backoff
  </Accordion>

  <Accordion title="Performance Optimization" icon="bolt">
    * Implement caching strategies
    * Use batch requests when possible
    * Monitor response times in your logs
    * Contact support for optimization advice
  </Accordion>
</AccordionGroup>

## Need Help?

<CardGroup cols={2}>
  <Card title="View Pricing" icon="credit-card" href="https://sociavault.com/pricing">
    See credit costs for each endpoint
  </Card>

  <Card title="Contact Support" icon="envelope" href="mailto:support@sociavault.com">
    Get help with authentication or API usage
  </Card>
</CardGroup>
