<@U04UQ68083H> is it possible to add a webhook wit...
# ory-copilot
b
@chilly-king-10285 is it possible to add a webhook without an empty body payload?
c
A message from kapa.ai
b
@chilly-king-10285 oops I meant "with"
c
A message from kapa.ai
Yes, it is possible to add a webhook without an empty body payload. In Ory, when handling the webhook in your endpoint, you can use the request payload to decide how Ory should proceed in the token exchange with the client. If you want to accept the token exchange without modification, you can return a
204
or
200
HTTP status code without a response body. Here is an example of how you can handle the webhook:
Copy code
python def handle_webhook(request):     # Use the request payload to decide how Ory should proceed     # If you want to accept the token exchange without modification     return 204  # or 200
However, if you want to modify the claims of the issued tokens and instruct Hydra to proceed with the token exchange, you need to return
200
with a JSON response body. For more details, you can refer to the [Ory documentation](https://www.ory.sh/docs/hydra/guides/claims-at-refresh#responding-to-the-webhook).
I'm sorry, but your question is not clear. Could you please provide more context or clarify what you're asking about? I'm here to provide information about Ory, an open-source identity and access management solution.
b
@chilly-king-10285 is it possible to add a webhook that utilises an empty payload on the request?
c
A message from kapa.ai
Yes, it is possible to add a webhook that utilizes an empty payload on the request. In Ory, the payload of the webhook request is customizable. You can define the body of the request using the
body
field in the webhook configuration. If you want to send an empty payload, you can simply not define the
body
field or set it as an empty string. Here is an example of a webhook configuration with an empty payload:
Copy code
yaml hook: web_hook config:   url: <https://your-webhook-url.com>   method: POST   body: ""
For more details, you can refer to the [Ory documentation](https://www.ory.sh/docs/guides/integrate-with-ory-cloud-through-webhooks#configuration-overview).
b
@chilly-king-10285 I tried that and got the error "message:got empty template path for request with body"
c
A message from kapa.ai
The error message "got empty template path for request with body" suggests that Ory Kratos is expecting a template for the body of the request but it's not finding one. In Ory Kratos, when you are self-hosting and using custom email templates, the
plaintext
and
html
fields are mandatory when defining the
body
key. If the system can't use the custom templates, it falls back to the built-in templates or to the
template_override_path
(if specified). Here is an example of how you can define the
body
key:
Copy code
yaml courier:     template_override_path: /conf/courier-template     templates:       verification:         valid:           email:             body:               html: <https://some-remote-resource/gotmpl>               plaintext: <base64://SGV5IHlvdSBkZWNvZGVkIG1lIDop>             subject: <file://some-file/subject.gotmpl>
If you are not providing these fields, you might encounter the error you mentioned. For more details, you can refer to the [Ory documentation](https://www.ory.sh/docs/kratos/self-hosted/mail-courier-templates#configuration).
b
@chilly-king-10285 this is in the context of an "after" webhook
c
A message from kapa.ai
New message text here