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

# Authentication

> Authenticate your requests using your Scrapely API key.

Every request to the Scrapely API requires an API key. You can get yours from the [Dashboard](https://scrapely.io/dashboard).

## Passing your API key

<Tabs>
  <Tab title="Python SDK (Recommended)">
    If you're using Python, simply pass your API key when initializing the client. The SDK will automatically handle sending it in the headers for all subsequent requests.

    ```python theme={null}
    from scrapely import Scrapely

    # Initialize the client with your API key
    client = Scrapely(api_key="YOUR_API_KEY")
    ```
  </Tab>

  <Tab title="Header (cURL)">
    Pass your API key in the `X-API-Key` header.

    ```bash theme={null}
    curl -X POST https://api.scrapely.io/v2/tasks/create \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{ ... }'
    ```

    <Info>
      Using the header keeps your API key out of the request body and is the recommended approach for direct API calls.
    </Info>
  </Tab>

  <Tab title="JSON Body">
    Pass your API key as `api_key` in the request body.

    ```bash theme={null}
    curl -X POST https://api.scrapely.io/v2/tasks/create \
      -H "Content-Type: application/json" \
      -d '{
        "api_key": "YOUR_API_KEY",
        ...
      }'
    ```
  </Tab>
</Tabs>

<Warning>
  Never expose your API key in client-side code or public repositories.
</Warning>
