gorgeous-motorcycle-71764
05/06/2025, 3:07 AMbrief-egg-61061
05/06/2025, 3:07 AMbrief-egg-61061
05/06/2025, 3:07 AMjson { "hook": "web_hook", "config": { "url": "<https://your-webhook-endpoint>", "method": "POST", "response": { "ignore": true } // Add authentication or other config as needed } }
2. Add the webhook to your Ory Kratos configuration under the OIDC registration flow. For Ory Network, you can use the CLI: sh ory patch identity-config --project <project-id> --workspace <workspace-id> \ --add "/selfservice/flows/registration/after/oidc/hooks/0=$(cat webhook-action.json)" \ --format yaml
This command ensures the webhook is triggered only after successful registration via OIDC (e.g., Google, Facebook, etc.) and not for other registration methods like password-based sign-up. If you want the webhook to trigger for all registration methods, add it under /selfservice/flows/registration/after/hooks
instead. For more details and examples, see the official documentation on [HubSpot integration with Ory Actions](https://www.ory.sh/docs/actions/integrations/hubspot#create-a-hubspot-webhook), which demonstrates how to set up a webhook for OIDC registration flows. The same approach applies to any webhook endpoint, not just HubSpot. Note: The webhook will only be triggered after successful user creation via OIDC registration, not for OIDC logins where the user already exists. If you need to handle both registration and login, you may need to configure hooks for both flows as appropriate. [HubSpot integration with Ory Actions](https://www.ory.sh/docs/actions/integrations/hubspot#create-a-hubspot-webhook)gorgeous-motorcycle-71764
05/06/2025, 3:09 AMbrief-egg-61061
05/06/2025, 3:09 AMbrief-egg-61061
05/06/2025, 3:09 AMkratos.yaml
or similar) to add a webhook under the OIDC registration flow. The relevant section looks like this: yaml selfservice: flows: registration: after: oidc: hooks: - hook: web_hook config: url: <http://your-webhook-endpoint> method: POST can_interrupt: false # Optionally, add body, response, and auth config as needed
2. Restart your Kratos service to apply the configuration changes. This configuration ensures that your webhook is triggered only after a successful registration via the OIDC method. If you want the webhook to trigger for all registration methods, place the hook under the general after
section instead of under oidc
. Note: There are known issues where webhooks may not be triggered as expected in certain OIDC registration-to-login flows due to how Kratos handles the flow method internally. For example, if an account already exists and OIDC registration transitions to login, the post-login webhooks may not fire because the credentials type is not set correctly in the flow. There are discussions and proposed patches for this in the community, but as of now, this is a limitation you should be aware of in self-hosted environments. See the related issue for more details: [OIDC registration to login flow fails to invoke webhooks](https://github.com/ory/kratos/issues/3627). Example from a GitHub issue: yaml flows: registration: after: oidc: hooks: - hook: web_hook config: url: <http://backend:5000/activate/pre> method: POST can_interrupt: false body: file:///etc/config/kratos/webhook.activate.jsonnet response: parse: true
[source](https://github.com/ory/kratos/issues/3627) If you need more advanced payloads, you can use a Jsonnet file for the body, as shown above. Summary: - Add your webhook under selfservice.flows.registration.after.oidc.hooks
in your Kratos config. - Restart Kratos. - Be aware of current limitations with OIDC registration-to-login transitions. If you need further details on configuring hooks, refer to the [official Kratos hooks documentation](https://www.ory.sh/docs/kratos/hooks/configure-hooks#available-actions).gorgeous-motorcycle-71764
05/06/2025, 3:44 AMbrief-egg-61061
05/06/2025, 3:45 AMbrief-egg-61061
05/06/2025, 3:45 AMgorgeous-motorcycle-71764
05/06/2025, 3:47 AMbody: json://{"identity_id":"${identity.id}","traits":${identity.traits}}
brief-egg-61061
05/06/2025, 3:47 AMbrief-egg-61061
05/06/2025, 3:47 AMbody: json://{"identity_id":"${identity.id}","traits":${identity.traits}}
is valid for configuring a webhook request body in self-hosted Ory Kratos. The documentation does mention that you can use Jsonnet files to customize the webhook request body, and that the identity object (including traits and id) is available in the context for templating. However, it does not provide an example using the json://
URI scheme or the ${...}
variable interpolation syntax in the configuration file. Instead, the recommended approach for customizing the webhook body is to use a Jsonnet file referenced by a file path, such as: yaml body: file:///etc/config/kratos/webhook.activate.jsonnet
and in the Jsonnet file, you would use the context object, e.g.: jsonnet { identity_id: ctx.identity.id, traits: ctx.identity.traits, }
[Trigger custom logic and integrate with external systems with webhooks](https://www.ory.sh/docs/guides/integrate-with-ory-cloud-through-webhooks#define-http-request) Therefore, based on the available knowledge sources, your example does not match the documented or recommended configuration style, and its validity cannot be confirmed. If you want to ensure compatibility, use a Jsonnet file as shown in the documentation.gorgeous-motorcycle-71764
05/06/2025, 6:53 AMbrief-egg-61061
05/06/2025, 6:53 AMbrief-egg-61061
05/06/2025, 6:53 AMgorgeous-motorcycle-71764
05/06/2025, 8:55 AMbrief-egg-61061
05/06/2025, 8:55 AMbrief-egg-61061
05/06/2025, 8:55 AMwebhook.activate.jsonnet
for a webhook body, based on the documented examples for customizing webhook payloads in Ory Kratos. This Jsonnet template will include the identity ID and traits in the request body: jsonnet function(ctx) { identity_id: ctx.identity.id, traits: ctx.identity.traits, }
This format is supported and recommended for customizing webhook request bodies in Ory Kratos. You reference this file in your Kratos config like so: yaml body: file:///etc/config/kratos/webhook.activate.jsonnet
This approach is documented in the official guides for integrating with webhooks and customizing request bodies using Jsonnet templates [Trigger custom logic and integrate with external systems with webhooks](https://www.ory.sh/docs/guides/integrate-with-ory-cloud-through-webhooks#define-http-request).gorgeous-motorcycle-71764
05/06/2025, 11:05 AMbrief-egg-61061
05/06/2025, 11:05 AMbrief-egg-61061
05/06/2025, 11:06 AMctx
) within your Jsonnet template. However, based on the current documentation, only identity-related data is guaranteed to be present in the webhook payload. Summary: There is no documented way in the provided knowledge sources to pass the OIDC client to a webhook in self-hosted Ory Kratos. If this is a critical requirement, you may need to explore the Kratos source code or open a feature request with the Ory team. [Trigger custom logic and integrate with external systems with webhooks](https://www.ory.sh/docs/guides/integrate-with-ory-cloud-through-webhooks)gorgeous-motorcycle-71764
05/07/2025, 5:22 AMbrief-egg-61061
05/07/2025, 5:22 AMbrief-egg-61061
05/07/2025, 5:23 AMid
field from your OIDC provider configuration) within the webhook.activate.jsonnet
file for a webhook in self-hosted Ory Kratos. The documentation and examples focus on passing identity data (like ctx.identity.id
and ctx.identity.traits
) to the webhook, but do not mention the availability of OIDC provider details in the webhook context. If you require the OIDC provider ID in your webhook payload, the current documentation does not provide a method to access or map this value in the Jsonnet template. You may need to consult the Ory community or source code for further clarification. In summary: There is no information in the provided knowledge sources on how to get the OIDC provider ID in the webhook Jsonnet context.gorgeous-motorcycle-71764
05/07/2025, 7:05 AMbrief-egg-61061
05/07/2025, 7:05 AMbrief-egg-61061
05/07/2025, 7:06 AMctx
object available to the webhook Jsonnet template for the "after" execution path of registration flows (including OIDC) contains at least the following fields: - `ctx.identity`: The identity object, including fields like id
, traits
, etc. - `ctx.flow`: The registration flow object, which may include fields such as id
, expires_at
, issued_at
, request_url
, and transient_payload
. - `ctx.request_headers`: The HTTP request headers. - `ctx.request_method`: The HTTP request method. - `ctx.request_url`: The HTTP request URL. Here is an example structure of the ctx
object for a registration flow, as shown in the documentation: jsonnet { identity: { id: "3a5293f1-f4d6-49f4-b34f-6da62c360604", traits: { email: "[email protected]" }, // ... other identity fields }, flow: { id: "cec1c06e-48eb-4f9d-abf1-2e287371f4eb", expires_at: "2023-01-31T12:19:35.782238Z", issued_at: "2023-01-31T11:19:35.782238Z", request_url: "<https://playground.projects.oryapis.com/self-service/registration/browser?return_to=>", transient_payload: { custom_data: "test" }, // ... other flow fields }, request_headers: { Accept: ["text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"], // ... other headers }, request_method: "POST", request_url: "<https://playground.projects.oryapis.com/self-service/registration?flow=cec1c06e-48eb-4f9d-abf1-2e287371f4eb>" }
You can access these fields in your Jsonnet template, for example: jsonnet function(ctx) { identity_id: ctx.identity.id, traits: ctx.identity.traits, flow_id: ctx.flow.id, custom_data: ctx.flow.transient_payload.custom_data, }
Note: The knowledge sources do not show any OIDC-specific fields (such as the OIDC provider ID) in the ctx
object. Only the general registration flow and identity data are documented as available in the context for webhooks [Jsonnet templating](https://www.ory.sh/docs/guides/integrate-with-ory-cloud-through-webhooks#jsonnet-templating).gorgeous-motorcycle-71764
05/07/2025, 7:13 AMbrief-egg-61061
05/07/2025, 7:13 AMbrief-egg-61061
05/07/2025, 7:14 AMtransient_payload
, you can include the provider information in the registration request when starting or updating the registration flow. The transient_payload
field is designed to carry arbitrary data (such as the OIDC provider) through the flow and make it available to webhooks, without persisting it in the identity. How to do it: 1. Include the OIDC provider in the transient_payload
when updating the registration flow: json { "method": "oidc", "provider": "google", "traits": { "email": "<mailto:user@example.com|user@example.com>" }, "transient_payload": { "oidc_provider": "google" } }
2. In your webhook’s Jsonnet template (webhook.activate.jsonnet
), access it like this: jsonnet function(ctx) { oidc_provider: ctx.flow.transient_payload.oidc_provider, identity_id: ctx.identity.id, traits: ctx.identity.traits, }
Notes: - The transient_payload
is available in the webhook context as ctx.flow.transient_payload
and is not persisted in the identity, but is forwarded to webhooks as part of the flow context [see GitHub discussion](https://github.com/ory/network/issues/187). - You must ensure that your client includes the OIDC provider in the transient_payload
when initiating or updating the registration flow. This approach allows your webhook to receive the OIDC provider information as part of the payload, even though Ory Kratos does not natively expose the OIDC provider in the webhook context by default [see GitHub discussion](https://github.com/ory/network/issues/187).brief-egg-61061
05/07/2025, 7:14 AMbrief-egg-61061
05/07/2025, 7:14 AMtransient_payload
in Ory Kratos, you need to include the provider information in the transient_payload
field when you update the registration flow. This field is designed to carry arbitrary data through the flow and is made available to webhooks, but is not persisted in the identity. How to do it: 1. When updating the registration flow (for example, using the Ory SDK or API), include the OIDC provider ID in the `transient_payload`: json { "method": "oidc", "provider": "google", "traits": { "email": "<mailto:user@example.com|user@example.com>" }, "transient_payload": { "oidc_provider": "google" } }
2. In your webhook’s Jsonnet template (e.g., webhook.activate.jsonnet
), you can access it like this: jsonnet function(ctx) { oidc_provider: ctx.flow.transient_payload.oidc_provider, identity_id: ctx.identity.id, traits: ctx.identity.traits, }
This approach is supported and documented as a way to pass additional data to webhooks using the transient_payload
field, which is available in the webhook context as ctx.flow.transient_payload
[see GitHub issue discussion](https://github.com/ory/network/issues/187). Summary: Include the OIDC provider ID in the transient_payload
when updating the registration flow. It will then be available to your webhook in the context object.gorgeous-motorcycle-71764
05/07/2025, 8:11 AM{
"method": "oidc",
"provider": "google",
"traits": {
"email": "user@<http://example.com|example.com>"
},
"transient_payload": {
"oidc_provider": "google"
}
}
brief-egg-61061
05/07/2025, 8:11 AMbrief-egg-61061
05/07/2025, 8:12 AMupdateRegistrationFlow
endpoint after initiating a registration flow. The transient_payload
field is supported in the request body for this endpoint, and it will be available to webhooks as part of the flow context. This is confirmed in the API reference, which shows that transient_payload
is an optional field in the request body for updating the registration flow, including for the OIDC method [Kratos API Reference – updateRegistrationFlow](https://www.ory.sh/docs/kratos/reference/api): > 'transient_payload': {'description': 'Transient data to pass along to any webhooks', 'type': 'object'}
You would typically use this in your backend or frontend code when calling the API to complete the registration flow, for example: http POST /self-service/registration?flow=<flow-id> Content-Type: application/json { "method": "oidc", "provider": "google", "traits": { "email": "<mailto:user@example.com|user@example.com>" }, "transient_payload": { "oidc_provider": "google" } }
This ensures that the oidc_provider
value is available in the webhook context as ctx.flow.transient_payload.oidc_provider
[see GitHub discussion](https://github.com/ory/network/issues/187). Summary: You specify this object as the body of your request to the updateRegistrationFlow
endpoint when completing the OIDC registration flow in Ory Kratos.