Based on the knowledge sources, there is no documented way to directly set or override the value of session.devices.location using hooks or webhooks in Ory. The documentation describes how you can use webhooks and Ory Actions to modify identity data (traits, metadata, etc.) during registration and settings flows, but it does not mention the ability to modify session or device information, including the location field in session.devices. Hooks and webhooks are primarily used for: - Modifying identity data during registration or settings flows. - Adding custom validation or business logic before/after login, registration, and other flows. - Integrating with external systems or triggering external logic on certain events. However, none of the sources indicate that you can inject or update the session.devices.location field via a hook or webhook, nor do they describe a mechanism for passing custom device or location data into the session object from your own logic or external service. The location field appears to be managed internally by Ory, possibly inferred from the IP address, but this is not explicitly documented or configurable via hooks or webhooks in the provided documentation [Trigger custom logic and integrate with external systems with webhooks](
https://www.ory.sh/docs/guides/integrate-with-ory-cloud-through-webhooks) [Overview: Ory Actions and Hooks](
https://www.ory.sh/docs/kratos/hooks/configure-hooks). If you need to store custom geolocation data, you may consider adding it to the identity's metadata fields (metadata_public or metadata_admin) via a webhook during registration or settings flows, but this would not affect the session.devices.location field.
Summary: There is no supported way, according to the current documentation, to set session.devices.location via hooks or webhooks. If this is a critical requirement, you may need to handle geolocation tracking in your own application logic outside of Ory's session management.