> For the complete documentation index, see [llms.txt](https://docs.webscrapingapi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.webscrapingapi.com/webstealthproxy/advanced-proxy-requests/custom-headers.md).

# Custom Headers

Custom HTTP headers are useful when you want to provide additional information to your request. If your request requires passing custom HTTP headers, all you have to do is to append `WSA-` to your header's name and add them to your request.

### Web Stealth Proxy Custom Headers Examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```bash
curl -k -x "http://stealthproxy.webscrapingapi.com:80" -U "<YOUR-PROXY-USERNAME>:<YOUR-PROXY-PASSWORD>" -X GET "https://httpbin.org/get" --header "WSA-random-header: random" "
```

{% endcode %}
{% endtab %}

{% tab title="NodeJS" %}

<pre class="language-javascript" data-overflow="wrap"><code class="lang-javascript">const axios = require('axios');
const https = require('https');

const instance = axios.create({
  httpsAgent: new https.Agent({  
    rejectUnauthorized: false
  })
});

instance.get('https://httpbin.org/get', {
      proxy: {
          host: 'stealthproxy.webscrapingapi.com',
          port: 8000,
          auth: {
            username: '&#x3C;YOUR-PROXY-USERNAME>',
            password: '&#x3C;YOUR-PROXY-PASSWORD>'
          },
<strong>          headers: {
</strong>            "WSA-random-header": "random"
          }    
      }
    }).then(function (response) {
        console.log(response.data);
    }, (err) => {
      console.log(err)
})
</code></pre>

{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
import requests

USERNAME = '<YOUR-PROXY-USERNAME>'
PASSWORD = '<YOUR-PROXY-PASSWORD>'

TARGET_URL = 'https://httpbin.org/get'

PROXY = {
   "http": f"https://{ USERNAME }:{ PASSWORD }@stealthproxy.webscrapingapi.com:80"
}

headers = {'WSA-random-header': "random"}

response = requests.get(
   url=TARGET_URL,
   proxies=PROXY,
   headers=headers,
   verify=False
)

print(response.text)
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code overflow="wrap" %}

```php
<?php
$ch = curl_init();

$headers = [
    'WSA-random-header: random',
];

curl_setopt($ch, CURLOPT_URL, 'https://httpbin.org/get');

curl_setopt($ch, CURLOPT_PROXY, 'http://<YOUR-PROXY-USERNAME>:<YOUR-PROXY-PASSWORD>@stealthproxy.webscrapingapi.com:80');

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);



curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

$response = curl_exec($ch);

if (!$response) {
  die('Error: "'.curl_error($ch).'" - Code: '.curl_errno($ch));
}

echo 'HTTP Status Code: '.curl_getinfo($ch, CURLINFO_HTTP_CODE) . PHP_EOL;
echo 'Response Body: '.$response . PHP_EOL;

curl_close($ch);
?>
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code overflow="wrap" %}

```go
package main

import (
    "crypto/tls"
    "fmt"
    "io/ioutil"
    "net/http"
    "net/url"
)

func send_proxy() {
    proxyStr := "https://<YOUR-PROXY-USERNAME>:<YOUR-PROXY-PASSWORD>@stealthproxy.webscrapingapi.com:8000"
    proxyURL, err := url.Parse(proxyStr)

    if err != nil {
        fmt.Println(err)
    }

    transport := &http.Transport{
        Proxy:           http.ProxyURL(proxyURL),
        TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
    }

    client := &http.Client{
        Transport: transport,
    }

    req, err := http.NewRequest("GET", "https://httpbin.org/get", nil)
    
    req.Header.Add("WSA-random-header", "random")

    parseFormErr := req.ParseForm()
    if parseFormErr != nil {
        fmt.Println(parseFormErr)
    }

    res, err := client.Do(req)

    if err != nil {
        fmt.Println("Failure : ", err)
    }

    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))
}

func main() {
    send_proxy()
}
```

{% endcode %}
{% endtab %}

{% tab title=".NET" %}
{% code overflow="wrap" %}

```csharp
using System;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;

class Program
{
    static async Task Main() {

        var proxy = new WebProxy("http://stealthproxy.webscrapingapi.com:80")
        {
            Credentials = new NetworkCredential("<YOUR-PROXY-USERNAME>", "<YOUR-PROXY-PASSWORD>"),
        };

        var clientHandler = new HttpClientHandler
        {
            Proxy = proxy,
        };

        var client = new HttpClient(clientHandler);
        client.DefaultRequestHeaders.Add("WSA-random-header", "random");

        var response = await client.GetAsync("http://httpbin.org/get");
        Console.WriteLine(await response.Content.ReadAsStringAsync());
    }
}
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code overflow="wrap" %}

```ruby
require 'uri'
require 'net/http'
require 'openssl'

proxy_host = "stealthproxy.webscrapingapi.com"
proxy_port = 80
proxy_user = "<YOUR-PROXY-USERNAME>"
proxy_pass = "<YOUR-PROXY-PASSWORD>"

url = URI("http://httpbin.org/get")

proxy = Net::HTTP::Proxy(proxy_host,
                         proxy_port,
                         proxy_user,
                         proxy_pass)

req = Net::HTTP::Get.new(url.path)

req.add_field("WSA-random-header", "random")

response = proxy.start(url.host,url.port) do |http|
  http.request(req)
end
    
puts response.body
```

{% endcode %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.webscrapingapi.com/webstealthproxy/advanced-proxy-requests/custom-headers.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
