# Watcher webhook custom json

**URL:** <https://discuss.elastic.co/t/watcher-webhook-custom-json/173541>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [March 22, 2019, 5:31pm UTC](https://discuss.elastic.co/t/watcher-webhook-custom-json/173541 "2019-03-22T17:31:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![forestnd](https://avatars.discourse-cdn.com/v4/letter/f/e47774/32.png) [@forestnd](https://discuss.elastic.co/u/forestnd)\
**Post date:** [March 22, 2019, 5:31pm UTC](https://discuss.elastic.co/t/watcher-webhook-custom-json/173541/1 "2019-03-22T17:31:29Z")

</div>

Hay all

I am trying to get my head around customise the body of an webhook so instead of just ctx i like to out put for example

{  
"name":"ctx.name",  
"date trigger":"ctx.date",  
"event level": "ctx.evlevel"  
}

thanks in advance

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [March 25, 2019, 1:33pm UTC](https://discuss.elastic.co/t/watcher-webhook-custom-json/173541/2 "2019-03-25T13:33:48Z")

</div>

Hey,

the correct way would be to create that object (as a hashmap) in a script via a `transform` and then use `"body":"{{#toJson}}ctx.my_object{{/toJson}}"` in the watch action.

See [https://www.elastic.co/guide/en/elastic-stack-overview/6.6/actions-webhook.html](https://www.elastic.co/guide/en/elastic-stack-overview/6.6/actions-webhook.html) and [https://www.elastic.co/guide/en/elasticsearch/reference/6.6/search-template.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.6/search-template.html)

hope this helps!

--Alex

---

<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:** [April 22, 2019, 1:33pm UTC](https://discuss.elastic.co/t/watcher-webhook-custom-json/173541/3 "2019-04-22T13:33:49Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
