From 2910260841786fcc1d47b39b8af6d18898562233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Beye?= Date: Sun, 26 Mar 2023 23:51:11 +0200 Subject: [PATCH] Improve webhook trigger documentation (#26689) --- source/_docs/automation/trigger.markdown | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/_docs/automation/trigger.markdown b/source/_docs/automation/trigger.markdown index bedca88e798..517d840273d 100644 --- a/source/_docs/automation/trigger.markdown +++ b/source/_docs/automation/trigger.markdown @@ -788,10 +788,10 @@ automation: webhook_id: "some_hook_id" ``` -You can run this automation by sending an HTTP POST request to `http://your-home-assistant:8123/api/webhook/some_hook_id`. Here is an example using the **curl** command line program, with an example data payload: +You can run this automation by sending an HTTP POST request to `http://your-home-assistant:8123/api/webhook/some_hook_id`. Here is an example using the **curl** command line program, with an example form data payload: ```shell -curl -X POST -d '{ "key": "value" }' https://your-home-assistant:8123/api/webhook/some_hook_id +curl -X POST -d 'key=value&key2=value2' https://your-home-assistant:8123/api/webhook/some_hook_id ``` Webhooks support HTTP POST, PUT, and HEAD requests; POST requests are recommended. HTTP GET requests are not supported. @@ -802,12 +802,12 @@ Note that a given webhook can only be used in one automation at a time. That is, ### Webhook data -You can send a data payload, either as encoded form data or JSON data. The payload is available in an automation template as either `trigger.json` or `trigger.data`. URL query parameters are available in the template as `trigger.query`. +Payloads may either be encoded as form data or JSON. Depending on that, its data will be available in an automation template as either `trigger.data` or `trigger.json`. URL query parameters are also available in the template as `trigger.query`. -In order to reference `trigger.json`, the `Content-Type` header must be specified with a value of `application/json`, e.g.: +Note that to use JSON encoded payloads, the `Content-Type` header must be set to `application/json`, e.g.: ```bash -curl -X POST -H "Content-Type: application/json" https://your-home-assistant:8123/api/webhook/some_hook_id +curl -X POST -H "Content-Type: application/json" -d '{ "key": "value" }' https://your-home-assistant:8123/api/webhook/some_hook_id ``` ### Webhook security