This happens automatically via our frontend SDK's session recipe which adds interceptors to fetch / XHR. The interceptor detects when a 401 is sent from the backend and then calls the refresh API on it's own. Therefore, you don't need to do anything to refresh a session, other than make sure that you have initialised the session recipe on the frontend and provided the right apiDomain value.