# How do i add a custom HTTP header using the python client?

**URL:** https://discuss.elastic.co/t/how-do-i-add-a-custom-http-header-using-the-python-client/38907
**Category:** Elasticsearch
**Created:** [January 11, 2016, 7:10pm UTC](https://discuss.elastic.co/t/how-do-i-add-a-custom-http-header-using-the-python-client/38907 "2016-01-11T19:10:40Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![danaronson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danaronson/32/7043_2.png) [@danaronson](https://discuss.elastic.co/u/danaronson)
#### Post date: [January 11, 2016, 7:10pm UTC](https://discuss.elastic.co/t/how-do-i-add-a-custom-http-header-using-the-python-client/38907/1 "2016-01-11T19:10:40Z")

</div>

I'm currently looking thought the code, but haven't found a way to do it yet. I want to add a constant custom header to each of the HTTP requests. I'm using RequestsHttpConnection.

My use case is that i am trying to talk to an AWS ES server from an amazon lamda which uses a temporary credential in a header. The header is X-Amz-Security-Token (see: [http://docs.aws.amazon.com/IAM/latest/UserGuide/id\_credentials\_temp\_use-resources.html#RequestWithSTS](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_use-resources.html#RequestWithSTS))

---

<div class="post-metadata">

### Author: ![danaronson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danaronson/32/7043_2.png) [@danaronson](https://discuss.elastic.co/u/danaronson)
#### Post date: [January 12, 2016, 11:14pm UTC](https://discuss.elastic.co/t/how-do-i-add-a-custom-http-header-using-the-python-client/38907/2 "2016-01-12T23:14:36Z")

</div>

Figured it out:

```
   es.transport.connection_pool.connection.session.headers.update({'x-amz-security-token': os.environ['AWS_SESSION_TOKEN']})
```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 5, 2017, 11:25pm UTC](https://discuss.elastic.co/t/how-do-i-add-a-custom-http-header-using-the-python-client/38907/3 "2017-07-05T23:25:05Z")

</div>


