billions-minister-2901
04/22/2025, 4:03 PMbrief-egg-61061
04/22/2025, 4:03 PMbrief-egg-61061
04/22/2025, 4:04 PMyaml selfservice: flows: registration: before: hooks: - hook: hook_name config: # hook-specific configuration
### Hook Execution Order The execution order of hooks follows a specific pattern: - before
hooks run when the user starts a flow - after
hooks run when the user submits or completes the flow - When an authentication method specifies hooks, it overrides the default hooks for the flow [Trigger Precedence](https://www.ory.sh/docs/kratos/hooks/configure-hooks#trigger-precedence) explains this in more detail. For more comprehensive information about hooks in general, including all available hook types and configuration options, you can refer to the [Hook Documentation](https://www.ory.sh/docs/kratos/hooks/configure-hooks).billions-minister-2901
04/22/2025, 4:04 PMbrief-egg-61061
04/22/2025, 4:04 PMbrief-egg-61061
04/22/2025, 4:04 PMbillions-minister-2901
04/22/2025, 4:05 PMbrief-egg-61061
04/22/2025, 4:05 PMbrief-egg-61061
04/22/2025, 4:06 PMyaml selfservice: flows: registration: after: password: hooks: - hook: session oidc: hooks: - hook: session
This is particularly important for OIDC flows to prevent users from having to log in again after registration [Registration](https://www.ory.sh/docs/kratos/self-service/flows/user-registration#successful-registration) 2. Show Verification UI Hook: Redirects users to verify their email after registration yaml selfservice/flows/registration/after/password/hooks=[{"hook": "show_verification_ui"}] selfservice/flows/registration/after/oidc/hooks=[{"hook": "show_verification_ui"}] selfservice/flows/registration/after/webauthn/hooks=[{"hook": "show_verification_ui"}]
[Login and registration webhooks and actions](https://www.ory.sh/docs/identities/sign-in/actions#show-verification-after-successful-registration) 3. Web Hooks: Call external services when users register - Can integrate with services like Mailchimp, Segment, Hubspot - Can be used for additional validation [Login and registration webhooks and actions](https://www.ory.sh/docs/identities/sign-in/actions#customize-login-and-registration-behavior) ### Important Note About Hook Order When using multiple hooks, the order matters. For example, if you're using both a web hook and the session hook, the web hook should come before the session hook: yaml password: hooks: - config: body: <https://storage.googleapis.com/bac-gcs-production/bar.jsonnet> can_interrupt: false method: POST response: ignore: false parse: false url: <https://webhook.site/foo> hook: web_hook - hook: session
If the session hook comes first, it may overwrite other hooks that run after it, preventing them from executing properly [Github Issue #361](https://github.com/ory/network/issues/361). ### Flow-Interrupting Webhooks You can use flow-interrupting webhooks to add validation to registration flows, allowing you to control who can sign up based on criteria like: - Email domain matching - IP address validation - Invite code verification [Login and registration webhooks and actions](https://www.ory.sh/docs/identities/sign-in/actions#customize-login-and-registration-behavior) This gives you fine-grained control over the registration process. ### Webhook Configuration in Ory Console When creating webhooks in the Ory Console, you need to select which authentication method the webhook applies to. If you want the webhook to fire for all flows, you need to create separate webhooks for each authentication method (password, OIDC, WebAuthn) rather than selecting "All" [Github Issue #361](https://github.com/ory/network/issues/361).