# Could i run code in webhook?

**URL:** <https://discuss.elastic.co/t/could-i-run-code-in-webhook/59509>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [September 1, 2016, 8:11am UTC](https://discuss.elastic.co/t/could-i-run-code-in-webhook/59509 "2016-09-01T08:11:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yunfei\_Yang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yunfei_yang/32/11719_2.png) [@Yunfei\_Yang](https://discuss.elastic.co/u/Yunfei_Yang)\
**Post date:** [September 1, 2016, 8:11am UTC](https://discuss.elastic.co/t/could-i-run-code-in-webhook/59509/1 "2016-09-01T08:11:50Z")

</div>

I wanna send a HTTP request with a token.  
But the token need to be gotten from another request, because it will change after some time.

So,Could I run some code in webhook?  
like:  
`"params" : { "token" : "{{JSON.parse(Net::HTTP.get('a.com','/cgi-bin/token?xxx'))['token']}}" }`

---

<div class="post-metadata">

**Author:** ![skearns](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/skearns/32/125945_2.png) [@skearns](https://discuss.elastic.co/u/skearns)\
**Post date:** [September 1, 2016, 12:22pm UTC](https://discuss.elastic.co/t/could-i-run-code-in-webhook/59509/2 "2016-09-01T12:22:08Z")

</div>

> [@Yunfei\_Yang](#):
>
> send a HTTP request with a token.But the token need to be gotten from another request, because it will change after some time.
> 
> So,Could I run some code in webhook?like:

A watch supports multiple inputs, using the chained input type. This would allow your watch to run the ES query, _and_ reach out to an external system to retrieve the current token. Then you can just template in the token in the webook.

---

<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 6, 2017, 1:43pm UTC](https://discuss.elastic.co/t/could-i-run-code-in-webhook/59509/3 "2017-07-06T13:43:12Z")

</div>


