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

# Authentication

> API keys, credits, and managing your account.

All API requests require a Bearer token in the `Authorization` header:

```bash theme={null}
curl -H "Authorization: Bearer your-api-key" \
  "https://api.urltodata.ai/v1/youtube/video?id=dQw4w9WgXcQ"
```

## Getting an API key

When you register, you receive an API key and 100 free credits:

```bash theme={null}
curl -X POST "https://api.urltodata.ai/v1/auth/register" \
  -H "Content-Type: application/json" \
  -d '{"email": "you@example.com", "password": "your-password"}'
```

## Managing API keys

### Create an additional key

```bash theme={null}
curl -X POST "https://api.urltodata.ai/v1/keys/create" \
  -H "Authorization: Bearer your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"name": "production"}'
```

### List your keys

```bash theme={null}
curl -H "Authorization: Bearer your-api-key" \
  "https://api.urltodata.ai/v1/keys"
```

### Revoke a key

```bash theme={null}
curl -X DELETE "https://api.urltodata.ai/v1/keys/your-key-id" \
  -H "Authorization: Bearer your-api-key"
```

## Credits

Each API request costs credits. New accounts start with 100 free credits.

### Check your balance

```bash theme={null}
curl -H "Authorization: Bearer your-api-key" \
  "https://api.urltodata.ai/v1/account"
```

### View available packages

```bash theme={null}
curl "https://api.urltodata.ai/v1/credits/packages"
```

```json theme={null}
{
  "packages": [
    { "id": "credits_500", "credits": 500, "priceUsd": "5.00" },
    { "id": "credits_2000", "credits": 2000, "priceUsd": "15.00" },
    { "id": "credits_5000", "credits": 5000, "priceUsd": "35.00" },
    { "id": "credits_15000", "credits": 15000, "priceUsd": "100.00" }
  ]
}
```

### Purchase credits

```bash theme={null}
curl -X POST "https://api.urltodata.ai/v1/credits/purchase" \
  -H "Authorization: Bearer your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"package_id": "credits_2000"}'
```

This returns a checkout URL to complete the purchase.

### View usage history

```bash theme={null}
curl -H "Authorization: Bearer your-api-key" \
  "https://api.urltodata.ai/v1/account/usage?limit=20"
```
