<@U04UQ68083H> is there a default body for the web...
# ory-copilot
f
@chilly-king-10285 is there a default body for the webhooks from login and registration with OIDC? if not, where can I see what's available to be used by the JSONNET ?
b
A message from kapa.ai
There is no single "default body" for webhooks triggered by login and registration flows (including OIDC) in Ory. Instead, the body of the webhook request is defined by a Jsonnet template, which you can customize. However, Ory provides a default context (
ctx
object) that is available to your Jsonnet template, containing information about the flow, the identity, request headers, and more. For the
after
execution path of all flows (including OIDC), the following objects are available in the Jsonnet template via the
ctx
object: - `flow`: Information about the current flow (e.g., registration, login). - `identity`: The identity object (user) involved in the flow. - `transient_payload`: Any additional data passed during the flow. -
request_headers
,
request_method
, `request_url`: Details about the HTTP request that initiated the flow. You can see a detailed example of the
ctx
object and its available properties in the documentation. Here’s a sample of how you might access these fields in Jsonnet:
Copy code
jsonnet function(ctx) {   userId: ctx.identity.id,   email: ctx.identity.traits.email,   flowId: ctx.flow.id,   method: ctx.request_method,   url: ctx.request_url }
For a full example of the
ctx
object and its structure, refer to the documentation's expanded example for registration flows. This will show you exactly what data is available to your Jsonnet template and, therefore, what can be included in the webhook body. If you do not provide a custom Jsonnet template, the webhook may send a minimal or empty payload, so it is best practice to define what you need explicitly in your Jsonnet file [Customizing request body with Jsonnet](https://www.ory.sh/docs/guides/integrate-with-ory-cloud-through-webhooks#define-http-request). Summary: - There is no fixed default body; you define it with Jsonnet. - The available data for Jsonnet is described in the documentation and accessible via the
ctx
object. - See the documentation for a full example of the available fields [Jsonnet templating](https://www.ory.sh/docs/guides/integrate-with-ory-cloud-through-webhooks#jsonnet-templating).
f
@chilly-king-10285 can you provide me a jsonnet that contains all the keys and values from the ctx ?
b
A message from kapa.ai
Certainly! The Ory documentation provides an example of the full structure of the
ctx
object available to Jsonnet templates in webhooks for registration flows. You can use this as a reference to create a Jsonnet function that outputs all keys and values from
ctx
. Here is a Jsonnet template that simply returns the entire
ctx
object, which will include all available keys and values:
Copy code
jsonnet function(ctx) ctx
If you want to explicitly list all keys and values as shown in the documentation's example, you can structure your Jsonnet like this (based on the provided sample):
Copy code
jsonnet function(ctx) {   flow: ctx.flow,   identity: ctx.identity,   request_cookies: ctx.request_cookies,   request_headers: ctx.request_headers,   request_method: ctx.request_method,   request_url: ctx.request_url }
This will output all the top-level keys from the
ctx
object, and their full values, as provided by Ory during the webhook execution. For a detailed example of the structure and available fields, see the documentation's expanded example under "Jsonnet templating" [Jsonnet templating](https://www.ory.sh/docs/guides/integrate-with-ory-cloud-through-webhooks#jsonnet-templating).