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

# Unauthorized Error

> 401 Unauthorized (Missing or Invalid API Key)

If your API requests are failing with the HTTP status code `401 Unauthorized`, it means the `x-api-key` header is either missing entirely or doesn't match a valid API key on your account.

## Sample Responses

**Missing API key:**

```json theme={null}
{
  "apiCode": 401,
  "message": "Missing x-api-key header"
}
```

**Invalid API key:**

```json theme={null}
{
  "apiCode": 401,
  "message": "Invalid x-api-key"
}
```

## How to Resolve

1. **Check the header name and casing.** The key must be sent in a header literally named `x-api-key` — not `Authorization`, `api-key`, or as a query parameter.

   ```bash theme={null}
   curl -X POST https://api.geekflare.com/webscraping \
     -H "x-api-key: YOUR_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{"url": "https://example.com"}'
   ```

2. **Confirm the key itself is correct.** Copy it fresh from your [Dashboard](https://dash.geekflare.com/) rather than reusing a value from an old `.env` file or notes — a single missing character will trigger this error.

3. **Check for accidental whitespace or quotes.** A trailing newline or wrapping quotes copied from a config file can silently break the header value.

4. **Make sure the key belongs to the right workspace.** If you're a member of multiple [Teams & Workspaces](/teams), confirm you're using a key generated in the workspace you intend to bill against.

<Info>
  API keys are generated automatically when you create your Geekflare account
  and shown on your Dashboard. There is currently no key rotation or multiple-key
  support — each account has a single active key.
</Info>

## Need Help?

If you've confirmed your key is correct and still see this error, [contact support](https://geekflare.com/contact/?product=api).
