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

# Custom Headers

> Set custom HTTP headers for screenshot requests

## Custom Headers

Set custom HTTP headers to modify how the target page behaves or responds.

## Basic usage

<CodeGroup dropdown>
  ```bash bash theme={null}
  curl "https://api.domshot.com/shot?key=YOUR_API_KEY&url=https://example.com&customHeaders=%7B%22Accept-Language%22%3A%22en-US%22%7D" \
    --output screenshot.png
  ```

  ```typescript typescript theme={null}
  const headers = {
    'Accept-Language': 'en-US'
  };

  const params = new URLSearchParams({
    key: 'YOUR_API_KEY',
    url: 'https://example.com',
    customHeaders: JSON.stringify(headers)
  });

  await fetch(`https://api.domshot.com/shot?${params}`)
    .then(res => res.blob())
    .then(blob => fs.writeFile('screenshot.png', blob));
  ```

  ```php php theme={null}
  $headers = [
    'Accept-Language' => 'en-US'
  ];

  $params = [
    'key' => 'YOUR_API_KEY',
    'url' => 'https://example.com',
    'customHeaders' => json_encode($headers)
  ];

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, 'https://api.domshot.com/shot?' . http_build_query($params));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  $result = curl_exec($ch);
  file_put_contents('screenshot.png', $result);
  curl_close($ch);
  ```

  ```go go theme={null}
  package main

  import (
      "encoding/json"
      "net/http"
      "net/url"
  )

  func main() {
      headers := map[string]string{
          "Accept-Language": "en-US",
      }

      params := url.Values{}
      params.Set("key", "YOUR_API_KEY")
      params.Set("url", "https://example.com")

      headersJSON, _ := json.Marshal(headers)
      params.Set("customHeaders", string(headersJSON))

      resp, _ := http.Get("https://api.domshot.com/shot?" + params.Encode())
      defer resp.Body.Close()

      // Save response to file
  }
  ```
</CodeGroup>

## Multiple headers

<CodeGroup dropdown>
  ```bash bash theme={null}
  curl "https://api.domshot.com/shot?key=YOUR_API_KEY&url=https://example.com&customHeaders=%7B%22Accept-Language%22%3A%22en-US%22%2C%22Accept-Encoding%22%3A%22gzip%2C%20deflate%22%7D" \
    --output screenshot.png
  ```

  ```typescript typescript theme={null}
  const headers = {
    'Accept-Language': 'en-US',
    'Accept-Encoding': 'gzip, deflate',
    'Authorization': 'Bearer token'
  };

  const params = new URLSearchParams({
    key: 'YOUR_API_KEY',
    url: 'https://example.com',
    customHeaders: JSON.stringify(headers)
  });

  await fetch(`https://api.domshot.com/shot?${params}`)
    .then(res => res.blob())
    .then(blob => fs.writeFile('screenshot.png', blob));
  ```

  ```php php theme={null}
  $headers = [
    'Accept-Language' => 'en-US',
    'Accept-Encoding' => 'gzip, deflate',
    'Authorization' => 'Bearer token'
  ];

  $params = [
    'key' => 'YOUR_API_KEY',
    'url' => 'https://example.com',
    'customHeaders' => json_encode($headers)
  ];

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, 'https://api.domshot.com/shot?' . http_build_query($params));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  $result = curl_exec($ch);
  file_put_contents('screenshot.png', $result);
  curl_close($ch);
  ```

  ```go go theme={null}
  package main

  import (
      "encoding/json"
      "net/http"
      "net/url"
  )

  func main() {
      headers := map[string]string{
          "Accept-Language": "en-US",
          "Accept-Encoding":  "gzip, deflate",
          "Authorization":   "Bearer token",
      }

      params := url.Values{}
      params.Set("key", "YOUR_API_KEY")
      params.Set("url", "https://example.com")

      headersJSON, _ := json.Marshal(headers)
      params.Set("customHeaders", string(headersJSON))

      resp, _ := http.Get("https://api.domshot.com/shot?" + params.Encode())
      defer resp.Body.Close()

      // Save response to file
  }
  ```
</CodeGroup>

## Common use cases

| Use case              | Example header                |
| --------------------- | ----------------------------- |
| Language preference   | `Accept-Language: en-US`      |
| Content negotiation   | `Accept: application/json`    |
| Custom authentication | `Authorization: Bearer token` |
| Geographic targeting  | `X-Forwarded-For: 1.2.3.4`    |

<Warning>
  Custom headers override browser defaults. Some headers like `User-Agent` have a dedicated parameter (see [Custom User Agent](/guides/advanced/user-agent)).
</Warning>

## Parameters

| Parameter       | Type   | Description                 |
| --------------- | ------ | --------------------------- |
| `customHeaders` | string | JSON object of HTTP headers |

## See also

* [Custom User Agent](/guides/advanced/user-agent) - Set custom user agent
* [Custom Cookies](/guides/advanced/cookies) - Set custom cookies
