Bug: refactor(users): Deprecate non-profile level user APIs



- Currently there are few APIs in Backend which are not at profile level. For example - Switch merchant.
- We have to remove those APIs.

- If there is any v2 counter part for those APIs, v1 APIs should be modified so that they will work the same way as v1.
diff --git a/crates/api_models/src/events/user.rs b/crates/api_models/src/events/user.rs
index 9b100a7321e..bb61a025180 100644
--- a/crates/api_models/src/events/user.rs
+++ b/crates/api_models/src/events/user.rs
@@ -12,25 +12,16 @@ use crate::user::{
     },
     AcceptInviteFromEmailRequest, AuthSelectRequest, AuthorizeResponse, BeginTotpResponse,
     ChangePasswordRequest, ConnectAccountRequest, CreateInternalUserRequest,
-    CreateUserAuthenticationMethodRequest, DashboardEntryResponse, ForgotPasswordRequest,
-    GetSsoAuthUrlRequest, GetUserAuthenticationMethodsRequest, GetUserDetailsResponse,
-    GetUserRoleDetailsRequest, GetUserRoleDetailsResponse, GetUserRoleDetailsResponseV2,
-    InviteUserRequest, ListUsersResponse, ReInviteUserRequest, RecoveryCodes, ResetPasswordRequest,
-    RotatePasswordRequest, SendVerifyEmailRequest, SignUpRequest, SignUpWithMerchantIdRequest,
-    SsoSignInRequest, SwitchMerchantRequest, SwitchOrganizationRequest, SwitchProfileRequest,
-    TokenResponse, TwoFactorAuthStatusResponse, UpdateUserAccountDetailsRequest,
-    UpdateUserAuthenticationMethodRequest, UserFromEmailRequest, UserMerchantCreate,
-    VerifyEmailRequest, VerifyRecoveryCodeRequest, VerifyTotpRequest,
+    CreateUserAuthenticationMethodRequest, ForgotPasswordRequest, GetSsoAuthUrlRequest,
+    GetUserAuthenticationMethodsRequest, GetUserDetailsResponse, GetUserRoleDetailsRequest,
+    GetUserRoleDetailsResponseV2, InviteUserRequest, ReInviteUserRequest, RecoveryCodes,
+    ResetPasswordRequest, RotatePasswordRequest, SendVerifyEmailRequest, SignUpRequest,
+    SignUpWithMerchantIdRequest, SsoSignInRequest, SwitchMerchantRequest,
+    SwitchOrganizationRequest, SwitchProfileRequest, TokenResponse, TwoFactorAuthStatusResponse,
+    UpdateUserAccountDetailsRequest, UpdateUserAuthenticationMethodRequest, UserFromEmailRequest,
+    UserMerchantCreate, VerifyEmailRequest, VerifyRecoveryCodeRequest, VerifyTotpRequest,
 };
 
-impl ApiEventMetric for DashboardEntryResponse {
-    fn get_api_event_type(&self) -> Option<ApiEventsType> {
-        Some(ApiEventsType::User {
-            user_id: self.user_id.clone(),
-        })
-    }
-}
-
 #[cfg(feature = "recon")]
 impl ApiEventMetric for VerifyTokenResponse {
     fn get_api_event_type(&self) -> Option<ApiEventsType> {
@@ -55,7 +46,6 @@ common_utils::impl_api_event_type!(
         SwitchProfileRequest,
         CreateInternalUserRequest,
         UserMerchantCreate,
-        ListUsersResponse,
         AuthorizeResponse,
         ConnectAccountRequest,
         ForgotPasswordRequest,
@@ -69,7 +59,6 @@ common_utils::impl_api_event_type!(
         UpdateUserAccountDetailsRequest,
         GetUserDetailsResponse,
         GetUserRoleDetailsRequest,
-        GetUserRoleDetailsResponse,
         GetUserRoleDetailsResponseV2,
         TokenResponse,
         TwoFactorAuthStatusResponse,
diff --git a/crates/api_models/src/events/user_role.rs b/crates/api_models/src/events/user_role.rs
index eb09abd471c..a2c76ecc394 100644
--- a/crates/api_models/src/events/user_role.rs
+++ b/crates/api_models/src/events/user_role.rs
@@ -3,26 +3,21 @@ use common_utils::events::{ApiEventMetric, ApiEventsType};
 use crate::user_role::{
     role::{
         CreateRoleRequest, GetRoleRequest, ListRolesAtEntityLevelRequest, ListRolesRequest,
-        ListRolesResponse, RoleInfoResponseNew, RoleInfoWithGroupsResponse,
-        RoleInfoWithPermissionsResponse, UpdateRoleRequest,
+        RoleInfoResponseNew, RoleInfoWithGroupsResponse, UpdateRoleRequest,
     },
-    AcceptInvitationRequest, AuthorizationInfoResponse, DeleteUserRoleRequest,
-    ListUsersInEntityRequest, MerchantSelectRequest, UpdateUserRoleRequest,
+    AuthorizationInfoResponse, DeleteUserRoleRequest, ListUsersInEntityRequest,
+    UpdateUserRoleRequest,
 };
 
 common_utils::impl_api_event_type!(
     Miscellaneous,
     (
-        RoleInfoWithPermissionsResponse,
         GetRoleRequest,
         AuthorizationInfoResponse,
         UpdateUserRoleRequest,
-        MerchantSelectRequest,
-        AcceptInvitationRequest,
         DeleteUserRoleRequest,
         CreateRoleRequest,
         UpdateRoleRequest,
-        ListRolesResponse,
         ListRolesAtEntityLevelRequest,
         RoleInfoResponseNew,
         RoleInfoWithGroupsResponse,
diff --git a/crates/api_models/src/user.rs b/crates/api_models/src/user.rs
index 7b22387b3c3..d66f9f3bc03 100644
--- a/crates/api_models/src/user.rs
+++ b/crates/api_models/src/user.rs
@@ -1,6 +1,6 @@
 use std::fmt::Debug;
 
-use common_enums::{EntityType, PermissionGroup, RoleScope, TokenPurpose};
+use common_enums::{EntityType, TokenPurpose};
 use common_utils::{crypto::OptionalEncryptableName, id_type, pii};
 use masking::Secret;
 
@@ -25,19 +25,6 @@ pub struct SignUpRequest {
     pub password: Secret<String>,
 }
 
-#[derive(serde::Serialize, Debug, Clone)]
-pub struct DashboardEntryResponse {
-    pub token: Secret<String>,
-    pub merchant_id: id_type::MerchantId,
-    pub name: Secret<String>,
-    pub email: pii::Email,
-    pub verification_days_left: Option<i64>,
-    pub user_role: String,
-    //this field is added for audit/debug reasons
-    #[serde(skip_serializing)]
-    pub user_id: String,
-}
-
 pub type SignInRequest = SignUpRequest;
 
 #[derive(serde::Deserialize, Debug, Clone, serde::Serialize)]
@@ -131,20 +118,6 @@ pub struct UserMerchantCreate {
     pub company_name: String,
 }
 
-#[derive(Debug, serde::Serialize)]
-pub struct ListUsersResponse(pub Vec<UserDetails>);
-
-#[derive(Debug, serde::Serialize)]
-pub struct UserDetails {
-    pub email: pii::Email,
-    pub name: Secret<String>,
-    pub role_id: String,
-    pub role_name: String,
-    pub status: UserStatus,
-    #[serde(with = "common_utils::custom_serde::iso8601")]
-    pub last_modified_at: time::PrimitiveDateTime,
-}
-
 #[derive(serde::Serialize, Debug, Clone)]
 pub struct GetUserDetailsResponse {
     pub merchant_id: id_type::MerchantId,
@@ -167,19 +140,6 @@ pub struct GetUserRoleDetailsRequest {
     pub email: pii::Email,
 }
 
-#[derive(Debug, serde::Serialize)]
-pub struct GetUserRoleDetailsResponse {
-    pub email: pii::Email,
-    pub name: Secret<String>,
-    pub role_id: String,
-    pub role_name: String,
-    pub status: UserStatus,
-    #[serde(with = "common_utils::custom_serde::iso8601")]
-    pub last_modified_at: time::PrimitiveDateTime,
-    pub groups: Vec<PermissionGroup>,
-    pub role_scope: RoleScope,
-}
-
 #[derive(Debug, serde::Serialize)]
 pub struct GetUserRoleDetailsResponseV2 {
     pub role_id: String,
@@ -207,16 +167,6 @@ pub struct SendVerifyEmailRequest {
     pub email: pii::Email,
 }
 
-#[derive(Debug, serde::Serialize)]
-pub struct UserMerchantAccount {
-    pub merchant_id: id_type::MerchantId,
-    pub merchant_name: OptionalEncryptableName,
-    pub is_active: bool,
-    pub role_id: String,
-    pub role_name: String,
-    pub org_id: id_type::OrganizationId,
-}
-
 #[cfg(feature = "recon")]
 #[derive(serde::Serialize, Debug)]
 pub struct VerifyTokenResponse {
diff --git a/crates/api_models/src/user_role.rs b/crates/api_models/src/user_role.rs
index f2743d6a311..ab32651e729 100644
--- a/crates/api_models/src/user_role.rs
+++ b/crates/api_models/src/user_role.rs
@@ -54,42 +54,17 @@ pub enum ParentGroup {
     Recon,
 }
 
-#[derive(Debug, serde::Serialize)]
-pub enum PermissionModule {
-    Payments,
-    Refunds,
-    MerchantAccount,
-    Connectors,
-    Routing,
-    Analytics,
-    Mandates,
-    Customer,
-    Disputes,
-    ThreeDsDecisionManager,
-    SurchargeDecisionManager,
-    AccountCreate,
-    Payouts,
-    Recon,
-}
-
 #[derive(Debug, serde::Serialize)]
 pub struct AuthorizationInfoResponse(pub Vec<AuthorizationInfo>);
 
 #[derive(Debug, serde::Serialize)]
 #[serde(untagged)]
 pub enum AuthorizationInfo {
-    Module(ModuleInfo),
     Group(GroupInfo),
     GroupWithTag(ParentInfo),
 }
 
-#[derive(Debug, serde::Serialize)]
-pub struct ModuleInfo {
-    pub module: PermissionModule,
-    pub description: &'static str,
-    pub permissions: Vec<PermissionInfo>,
-}
-
+// TODO: To be deprecated
 #[derive(Debug, serde::Serialize)]
 pub struct GroupInfo {
     pub group: PermissionGroup,
@@ -122,16 +97,6 @@ pub enum UserStatus {
     InvitationSent,
 }
 
-#[derive(Debug, serde::Deserialize, serde::Serialize)]
-pub struct MerchantSelectRequest {
-    pub merchant_ids: Vec<common_utils::id_type::MerchantId>,
-}
-
-#[derive(Debug, serde::Deserialize, serde::Serialize)]
-pub struct AcceptInvitationRequest {
-    pub merchant_ids: Vec<common_utils::id_type::MerchantId>,
-}
-
 #[derive(Debug, serde::Deserialize, serde::Serialize)]
 pub struct DeleteUserRoleRequest {
     pub email: pii::Email,
diff --git a/crates/api_models/src/user_role/role.rs b/crates/api_models/src/user_role/role.rs
index be467421e65..885ec455e4c 100644
--- a/crates/api_models/src/user_role/role.rs
+++ b/crates/api_models/src/user_role/role.rs
@@ -1,8 +1,6 @@
 pub use common_enums::PermissionGroup;
 use common_enums::{EntityType, RoleScope};
 
-use super::Permission;
-
 #[derive(Debug, serde::Deserialize, serde::Serialize)]
 pub struct CreateRoleRequest {
     pub role_name: String,
@@ -16,17 +14,6 @@ pub struct UpdateRoleRequest {
     pub role_name: Option<String>,
 }
 
-#[derive(Debug, serde::Serialize)]
-pub struct ListRolesResponse(pub Vec<RoleInfoWithGroupsResponse>);
-
-#[derive(Debug, serde::Serialize)]
-pub struct RoleInfoWithPermissionsResponse {
-    pub role_id: String,
-    pub permissions: Vec<Permission>,
-    pub role_name: String,
-    pub role_scope: RoleScope,
-}
-
 #[derive(Debug, serde::Serialize)]
 pub struct RoleInfoWithGroupsResponse {
     pub role_id: String,
diff --git a/crates/router/src/core/user.rs b/crates/router/src/core/user.rs
index f36ecc18116..9f865c1071e 100644
--- a/crates/router/src/core/user.rs
+++ b/crates/router/src/core/user.rs
@@ -1135,121 +1135,6 @@ pub async fn create_internal_user(
     Ok(ApplicationResponse::StatusOk)
 }
 
-pub async fn switch_merchant_id(
-    state: SessionState,
-    request: user_api::SwitchMerchantRequest,
-    user_from_token: auth::UserFromToken,
-) -> UserResponse<user_api::DashboardEntryResponse> {
-    if user_from_token.merchant_id == request.merchant_id {
-        return Err(UserErrors::InvalidRoleOperationWithMessage(
-            "User switching to same merchant_id".to_string(),
-        )
-        .into());
-    }
-
-    let user = user_from_token.get_user_from_db(&state).await?;
-    let key_manager_state = &(&state).into();
-    let role_info = roles::RoleInfo::from_role_id_in_merchant_scope(
-        &state,
-        &user_from_token.role_id,
-        &user_from_token.merchant_id,
-        &user_from_token.org_id,
-    )
-    .await
-    .to_not_found_response(UserErrors::InternalServerError)?;
-
-    let (token, role_id) = if role_info.is_internal() {
-        let key_store = state
-            .store
-            .get_merchant_key_store_by_merchant_id(
-                key_manager_state,
-                &request.merchant_id,
-                &state.store.get_master_key().to_vec().into(),
-            )
-            .await
-            .map_err(|e| {
-                if e.current_context().is_db_not_found() {
-                    e.change_context(UserErrors::MerchantIdNotFound)
-                } else {
-                    e.change_context(UserErrors::InternalServerError)
-                }
-            })?;
-
-        let org_id = state
-            .store
-            .find_merchant_account_by_merchant_id(
-                key_manager_state,
-                &request.merchant_id,
-                &key_store,
-            )
-            .await
-            .map_err(|e| {
-                if e.current_context().is_db_not_found() {
-                    e.change_context(UserErrors::MerchantIdNotFound)
-                } else {
-                    e.change_context(UserErrors::InternalServerError)
-                }
-            })?
-            .organization_id;
-
-        let token = utils::user::generate_jwt_auth_token_with_attributes_without_profile(
-            &state,
-            user_from_token.user_id,
-            request.merchant_id.clone(),
-            org_id.clone(),
-            user_from_token.role_id.clone(),
-        )
-        .await?;
-
-        (token, user_from_token.role_id)
-    } else {
-        let user_roles = state
-            .store
-            .list_user_roles_by_user_id_and_version(&user_from_token.user_id, UserRoleVersion::V1)
-            .await
-            .change_context(UserErrors::InternalServerError)?;
-
-        let active_user_roles = user_roles
-            .into_iter()
-            .filter(|role| role.status == UserStatus::Active)
-            .collect::<Vec<_>>();
-
-        let user_role = active_user_roles
-            .iter()
-            .find_map(|role| {
-                let Some(ref merchant_id) = role.merchant_id else {
-                    return Some(Err(report!(UserErrors::InternalServerError)));
-                };
-                if merchant_id == &request.merchant_id {
-                    Some(Ok(role))
-                } else {
-                    None
-                }
-            })
-            .transpose()?
-            .ok_or(report!(UserErrors::InvalidRoleOperation))
-            .attach_printable("User doesn't have access to switch")?;
-
-        let token =
-            utils::user::generate_jwt_auth_token_without_profile(&state, &user, user_role).await?;
-        utils::user_role::set_role_permissions_in_cache_by_user_role(&state, user_role).await;
-
-        (token, user_role.role_id.clone())
-    };
-
-    let response = user_api::DashboardEntryResponse {
-        token: token.clone(),
-        name: user.get_name(),
-        email: user.get_email(),
-        user_id: user.get_user_id().to_string(),
-        verification_days_left: None,
-        user_role: role_id,
-        merchant_id: request.merchant_id,
-    };
-
-    auth::cookies::set_cookie_response(response, token)
-}
-
 pub async fn create_merchant_account(
     state: SessionState,
     user_from_token: auth::UserFromToken,
@@ -1282,142 +1167,6 @@ pub async fn create_merchant_account(
     Ok(ApplicationResponse::StatusOk)
 }
 
-pub async fn list_merchants_for_user(
-    state: SessionState,
-    user_from_token: auth::UserIdFromAuth,
-) -> UserResponse<Vec<user_api::UserMerchantAccount>> {
-    let user_roles = state
-        .store
-        .list_user_roles_by_user_id_and_version(
-            user_from_token.user_id.as_str(),
-            UserRoleVersion::V1,
-        )
-        .await
-        .change_context(UserErrors::InternalServerError)?;
-
-    let merchant_accounts_map = state
-        .store
-        .list_multiple_merchant_accounts(
-            &(&state).into(),
-            user_roles
-                .iter()
-                .map(|role| {
-                    role.merchant_id
-                        .clone()
-                        .ok_or(UserErrors::InternalServerError)
-                })
-                .collect::<Result<Vec<_>, _>>()?,
-        )
-        .await
-        .change_context(UserErrors::InternalServerError)?
-        .into_iter()
-        .map(|merchant_account| (merchant_account.get_id().clone(), merchant_account))
-        .collect::<HashMap<_, _>>();
-
-    let roles_map = futures::future::try_join_all(user_roles.iter().map(|user_role| async {
-        let Some(merchant_id) = &user_role.merchant_id else {
-            return Err(report!(UserErrors::InternalServerError))
-                .attach_printable("merchant_id not found for user_role");
-        };
-        let Some(org_id) = &user_role.org_id else {
-            return Err(report!(UserErrors::InternalServerError)
-                .attach_printable("org_id not found in user_role"));
-        };
-        roles::RoleInfo::from_role_id_in_merchant_scope(
-            &state,
-            &user_role.role_id,
-            merchant_id,
-            org_id,
-        )
-        .await
-        .change_context(UserErrors::InternalServerError)
-        .attach_printable("Unable to find role info for user role")
-    }))
-    .await?
-    .into_iter()
-    .map(|role_info| (role_info.get_role_id().to_owned(), role_info))
-    .collect::<HashMap<_, _>>();
-
-    Ok(ApplicationResponse::Json(
-        user_roles
-            .into_iter()
-            .map(|user_role| {
-                let Some(merchant_id) = &user_role.merchant_id else {
-                    return Err(report!(UserErrors::InternalServerError))
-                        .attach_printable("merchant_id not found for user_role");
-                };
-                let Some(org_id) = &user_role.org_id else {
-                    return Err(report!(UserErrors::InternalServerError)
-                        .attach_printable("org_id not found in user_role"));
-                };
-                let merchant_account = merchant_accounts_map
-                    .get(merchant_id)
-                    .ok_or(UserErrors::InternalServerError)
-                    .attach_printable("Merchant account for user role doesn't exist")?;
-
-                let role_info = roles_map
-                    .get(&user_role.role_id)
-                    .ok_or(UserErrors::InternalServerError)
-                    .attach_printable("Role info for user role doesn't exist")?;
-
-                Ok(user_api::UserMerchantAccount {
-                    merchant_id: merchant_id.to_owned(),
-                    merchant_name: merchant_account.merchant_name.clone(),
-                    is_active: user_role.status == UserStatus::Active,
-                    role_id: user_role.role_id,
-                    role_name: role_info.get_role_name().to_string(),
-                    org_id: org_id.to_owned(),
-                })
-            })
-            .collect::<Result<Vec<_>, _>>()?,
-    ))
-}
-
-pub async fn get_user_details_in_merchant_account(
-    state: SessionState,
-    user_from_token: auth::UserFromToken,
-    request: user_api::GetUserRoleDetailsRequest,
-    _req_state: ReqState,
-) -> UserResponse<user_api::GetUserRoleDetailsResponse> {
-    let required_user = utils::user::get_user_from_db_by_email(&state, request.email.try_into()?)
-        .await
-        .to_not_found_response(UserErrors::InvalidRoleOperation)?;
-
-    let required_user_role = state
-        .store
-        .find_user_role_by_user_id_merchant_id(
-            required_user.get_user_id(),
-            &user_from_token.merchant_id,
-            UserRoleVersion::V1,
-        )
-        .await
-        .to_not_found_response(UserErrors::InvalidRoleOperation)
-        .attach_printable("User not found in the merchant account")?;
-
-    let role_info = roles::RoleInfo::from_role_id_in_merchant_scope(
-        &state,
-        &required_user_role.role_id,
-        &user_from_token.merchant_id,
-        &user_from_token.org_id,
-    )
-    .await
-    .change_context(UserErrors::InternalServerError)
-    .attach_printable("User role exists but the corresponding role doesn't")?;
-
-    Ok(ApplicationResponse::Json(
-        user_api::GetUserRoleDetailsResponse {
-            email: required_user.get_email(),
-            name: required_user.get_name(),
-            role_id: role_info.get_role_id().to_string(),
-            role_name: role_info.get_role_name().to_string(),
-            status: required_user_role.status.foreign_into(),
-            last_modified_at: required_user_role.last_modified,
-            groups: role_info.get_permission_groups().to_vec(),
-            role_scope: role_info.get_scope(),
-        },
-    ))
-}
-
 pub async fn list_user_roles_details(
     state: SessionState,
     user_from_token: auth::UserFromToken,
@@ -1670,80 +1419,6 @@ pub async fn list_user_roles_details(
     Ok(ApplicationResponse::Json(role_details_list))
 }
 
-pub async fn list_users_for_merchant_account(
-    state: SessionState,
-    user_from_token: auth::UserFromToken,
-) -> UserResponse<user_api::ListUsersResponse> {
-    let user_roles: HashMap<String, _> = state
-        .store
-        .list_user_roles_by_merchant_id(&user_from_token.merchant_id, UserRoleVersion::V1)
-        .await
-        .change_context(UserErrors::InternalServerError)
-        .attach_printable("No user roles for given merchant_id")?
-        .into_iter()
-        .map(|role| (role.user_id.clone(), role))
-        .collect();
-
-    let user_ids = user_roles.keys().cloned().collect::<Vec<_>>();
-
-    let users = state
-        .global_store
-        .find_users_by_user_ids(user_ids)
-        .await
-        .change_context(UserErrors::InternalServerError)
-        .attach_printable("No users for given merchant_id")?;
-
-    let users_and_user_roles: Vec<_> = users
-        .into_iter()
-        .filter_map(|user| {
-            user_roles
-                .get(&user.user_id)
-                .map(|role| (user.clone(), role.clone()))
-        })
-        .collect();
-
-    let users_user_roles_and_roles =
-        futures::future::try_join_all(users_and_user_roles.into_iter().map(
-            |(user, user_role)| async {
-                roles::RoleInfo::from_role_id_in_merchant_scope(
-                    &state,
-                    &user_role.role_id.clone(),
-                    user_role
-                        .merchant_id
-                        .as_ref()
-                        .ok_or(UserErrors::InternalServerError)?,
-                    user_role
-                        .org_id
-                        .as_ref()
-                        .ok_or(UserErrors::InternalServerError)?,
-                )
-                .await
-                .map(|role_info| (user, user_role, role_info))
-                .to_not_found_response(UserErrors::InternalServerError)
-            },
-        ))
-        .await?;
-
-    let user_details_vec = users_user_roles_and_roles
-        .into_iter()
-        .map(|(user, user_role, role_info)| {
-            let user = domain::UserFromStorage::from(user);
-            user_api::UserDetails {
-                email: user.get_email(),
-                name: user.get_name(),
-                role_id: user_role.role_id.clone(),
-                role_name: role_info.get_role_name().to_string(),
-                status: user_role.status.foreign_into(),
-                last_modified_at: user_role.last_modified,
-            }
-        })
-        .collect();
-
-    Ok(ApplicationResponse::Json(user_api::ListUsersResponse(
-        user_details_vec,
-    )))
-}
-
 #[cfg(feature = "email")]
 pub async fn verify_email_token_only_flow(
     state: SessionState,
diff --git a/crates/router/src/core/user_role.rs b/crates/router/src/core/user_role.rs
index b841f88eca1..ad37176358b 100644
--- a/crates/router/src/core/user_role.rs
+++ b/crates/router/src/core/user_role.rs
@@ -26,6 +26,7 @@ pub mod role;
 use common_enums::{EntityType, PermissionGroup};
 use strum::IntoEnumIterator;
 
+// TODO: To be deprecated
 pub async fn get_authorization_info_with_groups(
     _state: SessionState,
 ) -> UserResponse<user_role_api::AuthorizationInfoResponse> {
@@ -38,6 +39,7 @@ pub async fn get_authorization_info_with_groups(
         ),
     ))
 }
+
 pub async fn get_authorization_info_with_group_tag(
 ) -> UserResponse<user_role_api::AuthorizationInfoResponse> {
     static GROUPS_WITH_PARENT_TAGS: Lazy<Vec<user_role_api::ParentInfo>> = Lazy::new(|| {
@@ -253,49 +255,6 @@ pub async fn update_user_role(
     Ok(ApplicationResponse::StatusOk)
 }
 
-pub async fn accept_invitation(
-    state: SessionState,
-    user_token: auth::UserFromToken,
-    req: user_role_api::AcceptInvitationRequest,
-) -> UserResponse<()> {
-    let merchant_accounts = state
-        .store
-        .list_multiple_merchant_accounts(&(&state).into(), req.merchant_ids)
-        .await
-        .change_context(UserErrors::InternalServerError)?;
-    let update_result =
-        futures::future::join_all(merchant_accounts.iter().map(|merchant_account| async {
-            let (update_v1_result, update_v2_result) =
-                utils::user_role::update_v1_and_v2_user_roles_in_db(
-                    &state,
-                    user_token.user_id.as_str(),
-                    &merchant_account.organization_id,
-                    merchant_account.get_id(),
-                    None,
-                    UserRoleUpdate::UpdateStatus {
-                        status: UserStatus::Active,
-                        modified_by: user_token.user_id.clone(),
-                    },
-                )
-                .await;
-
-            if update_v1_result.is_err_and(|err| !err.current_context().is_db_not_found())
-                || update_v2_result.is_err_and(|err| !err.current_context().is_db_not_found())
-            {
-                Err(report!(UserErrors::InternalServerError))
-            } else {
-                Ok(())
-            }
-        }))
-        .await;
-
-    if update_result.is_empty() || update_result.iter().all(Result::is_err) {
-        return Err(UserErrors::MerchantIdNotFound.into());
-    }
-
-    Ok(ApplicationResponse::StatusOk)
-}
-
 pub async fn accept_invitations_v2(
     state: SessionState,
     user_from_token: auth::UserFromToken,
@@ -348,67 +307,6 @@ pub async fn accept_invitations_v2(
     Ok(ApplicationResponse::StatusOk)
 }
 
-pub async fn merchant_select_token_only_flow(
-    state: SessionState,
-    user_token: auth::UserFromSinglePurposeToken,
-    req: user_role_api::MerchantSelectRequest,
-) -> UserResponse<user_api::TokenResponse> {
-    let merchant_accounts = state
-        .store
-        .list_multiple_merchant_accounts(&(&state).into(), req.merchant_ids)
-        .await
-        .change_context(UserErrors::InternalServerError)?;
-
-    let update_result =
-        futures::future::join_all(merchant_accounts.iter().map(|merchant_account| async {
-            let (update_v1_result, update_v2_result) =
-                utils::user_role::update_v1_and_v2_user_roles_in_db(
-                    &state,
-                    user_token.user_id.as_str(),
-                    &merchant_account.organization_id,
-                    merchant_account.get_id(),
-                    None,
-                    UserRoleUpdate::UpdateStatus {
-                        status: UserStatus::Active,
-                        modified_by: user_token.user_id.clone(),
-                    },
-                )
-                .await;
-
-            if update_v1_result.is_err_and(|err| !err.current_context().is_db_not_found())
-                || update_v2_result.is_err_and(|err| !err.current_context().is_db_not_found())
-            {
-                Err(report!(UserErrors::InternalServerError))
-            } else {
-                Ok(())
-            }
-        }))
-        .await;
-
-    if update_result.is_empty() || update_result.iter().all(Result::is_err) {
-        return Err(UserErrors::MerchantIdNotFound.into());
-    }
-
-    let user_from_db: domain::UserFromStorage = state
-        .global_store
-        .find_user_by_id(user_token.user_id.as_str())
-        .await
-        .change_context(UserErrors::InternalServerError)?
-        .into();
-
-    let current_flow =
-        domain::CurrentFlow::new(user_token, domain::SPTFlow::MerchantSelect.into())?;
-    let next_flow = current_flow.next(user_from_db.clone(), &state).await?;
-
-    let token = next_flow.get_token(&state).await?;
-
-    let response = user_api::TokenResponse {
-        token: token.clone(),
-        token_type: next_flow.get_flow().into(),
-    };
-    auth::cookies::set_cookie_response(response, token)
-}
-
 pub async fn accept_invitations_pre_auth(
     state: SessionState,
     user_token: auth::UserFromSinglePurposeToken,
@@ -644,20 +542,23 @@ pub async fn delete_user_role(
     }
 
     // Check if user has any more role associations
-    let user_roles_v2 = state
+    let remaining_roles = state
         .store
-        .list_user_roles_by_user_id_and_version(user_from_db.get_user_id(), UserRoleVersion::V2)
-        .await
-        .change_context(UserErrors::InternalServerError)?;
-
-    let user_roles_v1 = state
-        .store
-        .list_user_roles_by_user_id_and_version(user_from_db.get_user_id(), UserRoleVersion::V1)
+        .list_user_roles_by_user_id(ListUserRolesByUserIdPayload {
+            user_id: user_from_db.get_user_id(),
+            org_id: None,
+            merchant_id: None,
+            profile_id: None,
+            entity_id: None,
+            version: None,
+            status: None,
+            limit: None,
+        })
         .await
         .change_context(UserErrors::InternalServerError)?;
 
     // If user has no more role associated with him then deleting user
-    if user_roles_v2.is_empty() && user_roles_v1.is_empty() {
+    if remaining_roles.is_empty() {
         state
             .global_store
             .delete_user_by_user_id(user_from_db.get_user_id())
diff --git a/crates/router/src/core/user_role/role.rs b/crates/router/src/core/user_role/role.rs
index d5d655b4a89..b5b5cab421f 100644
--- a/crates/router/src/core/user_role/role.rs
+++ b/crates/router/src/core/user_role/role.rs
@@ -83,45 +83,6 @@ pub async fn create_role(
     ))
 }
 
-pub async fn list_invitable_roles_with_groups(
-    state: SessionState,
-    user_from_token: UserFromToken,
-) -> UserResponse<role_api::ListRolesResponse> {
-    let predefined_roles_map = PREDEFINED_ROLES
-        .iter()
-        .filter(|(_, role_info)| role_info.is_invitable())
-        .map(
-            |(role_id, role_info)| role_api::RoleInfoWithGroupsResponse {
-                groups: role_info.get_permission_groups().to_vec(),
-                role_id: role_id.to_string(),
-                role_name: role_info.get_role_name().to_string(),
-                role_scope: role_info.get_scope(),
-            },
-        );
-
-    let custom_roles_map = state
-        .store
-        .list_all_roles(&user_from_token.merchant_id, &user_from_token.org_id)
-        .await
-        .change_context(UserErrors::InternalServerError)?
-        .into_iter()
-        .filter_map(|role| {
-            let role_info = roles::RoleInfo::from(role);
-            role_info
-                .is_invitable()
-                .then_some(role_api::RoleInfoWithGroupsResponse {
-                    groups: role_info.get_permission_groups().to_vec(),
-                    role_id: role_info.get_role_id().to_string(),
-                    role_name: role_info.get_role_name().to_string(),
-                    role_scope: role_info.get_scope(),
-                })
-        });
-
-    Ok(ApplicationResponse::Json(role_api::ListRolesResponse(
-        predefined_roles_map.chain(custom_roles_map).collect(),
-    )))
-}
-
 pub async fn get_role_with_groups(
     state: SessionState,
     user_from_token: UserFromToken,
diff --git a/crates/router/src/db/kafka_store.rs b/crates/router/src/db/kafka_store.rs
index d14de8c2330..f6cbdd5bbc6 100644
--- a/crates/router/src/db/kafka_store.rs
+++ b/crates/router/src/db/kafka_store.rs
@@ -3037,37 +3037,6 @@ impl UserRoleInterface for KafkaStore {
         self.diesel_store.insert_user_role(user_role).await
     }
 
-    async fn find_user_role_by_user_id(
-        &self,
-        user_id: &str,
-        version: enums::UserRoleVersion,
-    ) -> CustomResult<user_storage::UserRole, errors::StorageError> {
-        self.diesel_store
-            .find_user_role_by_user_id(user_id, version)
-            .await
-    }
-
-    async fn find_user_role_by_user_id_merchant_id(
-        &self,
-        user_id: &str,
-        merchant_id: &id_type::MerchantId,
-        version: enums::UserRoleVersion,
-    ) -> CustomResult<user_storage::UserRole, errors::StorageError> {
-        self.diesel_store
-            .find_user_role_by_user_id_merchant_id(user_id, merchant_id, version)
-            .await
-    }
-
-    async fn list_user_roles_by_user_id_and_version(
-        &self,
-        user_id: &str,
-        version: enums::UserRoleVersion,
-    ) -> CustomResult<Vec<user_storage::UserRole>, errors::StorageError> {
-        self.diesel_store
-            .list_user_roles_by_user_id_and_version(user_id, version)
-            .await
-    }
-
     async fn find_user_role_by_user_id_and_lineage(
         &self,
         user_id: &str,
@@ -3127,16 +3096,6 @@ impl UserRoleInterface for KafkaStore {
             .await
     }
 
-    async fn list_user_roles_by_merchant_id(
-        &self,
-        merchant_id: &id_type::MerchantId,
-        version: enums::UserRoleVersion,
-    ) -> CustomResult<Vec<user_storage::UserRole>, errors::StorageError> {
-        self.diesel_store
-            .list_user_roles_by_merchant_id(merchant_id, version)
-            .await
-    }
-
     async fn list_user_roles_by_user_id<'a>(
         &self,
         payload: ListUserRolesByUserIdPayload<'a>,
diff --git a/crates/router/src/db/user_role.rs b/crates/router/src/db/user_role.rs
index d511010e6b5..9a5c7149b68 100644
--- a/crates/router/src/db/user_role.rs
+++ b/crates/router/src/db/user_role.rs
@@ -54,31 +54,6 @@ pub trait UserRoleInterface {
         user_role: InsertUserRolePayload,
     ) -> CustomResult<Vec<storage::UserRole>, errors::StorageError>;
 
-    async fn find_user_role_by_user_id(
-        &self,
-        user_id: &str,
-        version: enums::UserRoleVersion,
-    ) -> CustomResult<storage::UserRole, errors::StorageError>;
-
-    async fn find_user_role_by_user_id_merchant_id(
-        &self,
-        user_id: &str,
-        merchant_id: &id_type::MerchantId,
-        version: enums::UserRoleVersion,
-    ) -> CustomResult<storage::UserRole, errors::StorageError>;
-
-    async fn list_user_roles_by_user_id_and_version(
-        &self,
-        user_id: &str,
-        version: enums::UserRoleVersion,
-    ) -> CustomResult<Vec<storage::UserRole>, errors::StorageError>;
-
-    async fn list_user_roles_by_merchant_id(
-        &self,
-        merchant_id: &id_type::MerchantId,
-        version: enums::UserRoleVersion,
-    ) -> CustomResult<Vec<storage::UserRole>, errors::StorageError>;
-
     async fn find_user_role_by_user_id_and_lineage(
         &self,
         user_id: &str,
@@ -132,59 +107,6 @@ impl UserRoleInterface for Store {
             .map_err(|error| report!(errors::StorageError::from(error)))
     }
 
-    #[instrument(skip_all)]
-    async fn find_user_role_by_user_id(
-        &self,
-        user_id: &str,
-        version: enums::UserRoleVersion,
-    ) -> CustomResult<storage::UserRole, errors::StorageError> {
-        let conn = connection::pg_connection_write(self).await?;
-        storage::UserRole::find_by_user_id(&conn, user_id.to_owned(), version)
-            .await
-            .map_err(|error| report!(errors::StorageError::from(error)))
-    }
-
-    #[instrument(skip_all)]
-    async fn find_user_role_by_user_id_merchant_id(
-        &self,
-        user_id: &str,
-        merchant_id: &id_type::MerchantId,
-        version: enums::UserRoleVersion,
-    ) -> CustomResult<storage::UserRole, errors::StorageError> {
-        let conn = connection::pg_connection_write(self).await?;
-        storage::UserRole::find_by_user_id_merchant_id(
-            &conn,
-            user_id.to_owned(),
-            merchant_id.to_owned(),
-            version,
-        )
-        .await
-        .map_err(|error| report!(errors::StorageError::from(error)))
-    }
-
-    async fn list_user_roles_by_user_id_and_version(
-        &self,
-        user_id: &str,
-        version: enums::UserRoleVersion,
-    ) -> CustomResult<Vec<storage::UserRole>, errors::StorageError> {
-        let conn = connection::pg_connection_write(self).await?;
-        storage::UserRole::list_by_user_id(&conn, user_id.to_owned(), version)
-            .await
-            .map_err(|error| report!(errors::StorageError::from(error)))
-    }
-
-    #[instrument(skip_all)]
-    async fn list_user_roles_by_merchant_id(
-        &self,
-        merchant_id: &id_type::MerchantId,
-        version: enums::UserRoleVersion,
-    ) -> CustomResult<Vec<storage::UserRole>, errors::StorageError> {
-        let conn = connection::pg_connection_write(self).await?;
-        storage::UserRole::list_by_merchant_id(&conn, merchant_id.to_owned(), version)
-            .await
-            .map_err(|error| report!(errors::StorageError::from(error)))
-    }
-
     #[instrument(skip_all)]
     async fn find_user_role_by_user_id_and_lineage(
         &self,
@@ -335,96 +257,6 @@ impl UserRoleInterface for MockDb {
             .collect::<Result<Vec<_>, _>>()
     }
 
-    async fn find_user_role_by_user_id(
-        &self,
-        user_id: &str,
-        version: enums::UserRoleVersion,
-    ) -> CustomResult<storage::UserRole, errors::StorageError> {
-        let user_roles = self.user_roles.lock().await;
-        user_roles
-            .iter()
-            .find(|user_role| user_role.user_id == user_id && user_role.version == version)
-            .cloned()
-            .ok_or(
-                errors::StorageError::ValueNotFound(format!(
-                    "No user role available for user_id = {user_id}"
-                ))
-                .into(),
-            )
-    }
-
-    async fn find_user_role_by_user_id_merchant_id(
-        &self,
-        user_id: &str,
-        merchant_id: &id_type::MerchantId,
-        version: enums::UserRoleVersion,
-    ) -> CustomResult<storage::UserRole, errors::StorageError> {
-        let user_roles = self.user_roles.lock().await;
-
-        for user_role in user_roles.iter() {
-            let Some(user_role_merchant_id) = &user_role.merchant_id else {
-                continue;
-            };
-            if user_role.user_id == user_id
-                && user_role_merchant_id == merchant_id
-                && user_role.version == version
-            {
-                return Ok(user_role.clone());
-            }
-        }
-
-        Err(errors::StorageError::ValueNotFound(format!(
-            "No user role available for user_id = {} and merchant_id = {}",
-            user_id,
-            merchant_id.get_string_repr()
-        ))
-        .into())
-    }
-
-    async fn list_user_roles_by_user_id_and_version(
-        &self,
-        user_id: &str,
-        version: enums::UserRoleVersion,
-    ) -> CustomResult<Vec<storage::UserRole>, errors::StorageError> {
-        let user_roles = self.user_roles.lock().await;
-
-        Ok(user_roles
-            .iter()
-            .cloned()
-            .filter_map(|ele| {
-                if ele.user_id == user_id && ele.version == version {
-                    return Some(ele);
-                }
-                None
-            })
-            .collect())
-    }
-
-    async fn list_user_roles_by_merchant_id(
-        &self,
-        merchant_id: &id_type::MerchantId,
-        version: enums::UserRoleVersion,
-    ) -> CustomResult<Vec<storage::UserRole>, errors::StorageError> {
-        let user_roles = self.user_roles.lock().await;
-
-        let filtered_roles: Vec<_> = user_roles
-            .iter()
-            .filter_map(|role| {
-                if let Some(role_merchant_id) = &role.merchant_id {
-                    if role_merchant_id == merchant_id && role.version == version {
-                        Some(role.clone())
-                    } else {
-                        None
-                    }
-                } else {
-                    None
-                }
-            })
-            .collect();
-
-        Ok(filtered_roles)
-    }
-
     async fn find_user_role_by_user_id_and_lineage(
         &self,
         user_id: &str,
diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs
index d5f73921a9d..f7ea8cf3649 100644
--- a/crates/router/src/routes/app.rs
+++ b/crates/router/src/routes/app.rs
@@ -1791,26 +1791,11 @@ impl User {
             .service(
                 web::resource("/internal_signup").route(web::post().to(user::internal_user_signup)),
             )
-            .service(
-                web::resource("/switch_merchant").route(web::post().to(user::switch_merchant_id)),
-            )
             .service(
                 web::resource("/create_merchant")
                     .route(web::post().to(user::user_merchant_account_create)),
             )
-            // TODO: Remove this endpoint once migration to /merchants/list is done
-            .service(
-                web::resource("/switch/list").route(web::get().to(user::list_merchants_for_user)),
-            )
-            .service(
-                web::resource("/merchants/list")
-                    .route(web::get().to(user::list_merchants_for_user)),
-            )
-            // The route is utilized to select an invitation from a list of merchants in an intermediate state
-            .service(
-                web::resource("/merchants_select/list")
-                    .route(web::get().to(user::list_merchants_for_user)),
-            )
+            // TODO: To be deprecated
             .service(
                 web::resource("/permission_info")
                     .route(web::get().to(user_role::get_authorization_info)),
@@ -1952,12 +1937,13 @@ impl User {
         // User management
         route = route.service(
             web::scope("/user")
-                .service(web::resource("").route(web::get().to(user::get_user_role_details)))
+                .service(web::resource("").route(web::post().to(user::list_user_roles_details)))
+                // TODO: To be deprecated
                 .service(web::resource("/v2").route(web::post().to(user::list_user_roles_details)))
                 .service(
-                    web::resource("/list")
-                        .route(web::get().to(user::list_users_for_merchant_account)),
+                    web::resource("/list").route(web::get().to(user_role::list_users_in_lineage)),
                 )
+                // TODO: To be deprecated
                 .service(
                     web::resource("/v2/list")
                         .route(web::get().to(user_role::list_users_in_lineage)),
@@ -1970,8 +1956,11 @@ impl User {
                     web::scope("/invite/accept")
                         .service(
                             web::resource("")
-                                .route(web::post().to(user_role::merchant_select))
-                                .route(web::put().to(user_role::accept_invitation)),
+                                .route(web::post().to(user_role::accept_invitations_v2)),
+                        )
+                        .service(
+                            web::resource("/pre_auth")
+                                .route(web::post().to(user_role::accept_invitations_pre_auth)),
                         )
                         .service(
                             web::scope("/v2")
@@ -1996,36 +1985,38 @@ impl User {
         );
 
         // Role information
-        route = route.service(
-            web::scope("/role")
-                .service(
-                    web::resource("")
-                        .route(web::get().to(user_role::get_role_from_token))
-                        .route(web::post().to(user_role::create_role)),
-                )
-                .service(
-                    web::resource("/v2/list").route(web::get().to(user_role::list_roles_with_info)),
-                )
-                .service(
-                    web::scope("/list")
-                        .service(web::resource("").route(web::get().to(user_role::list_all_roles)))
-                        .service(
-                            web::resource("/invite").route(
+        route =
+            route.service(
+                web::scope("/role")
+                    .service(
+                        web::resource("")
+                            .route(web::get().to(user_role::get_role_from_token))
+                            .route(web::post().to(user_role::create_role)),
+                    )
+                    // TODO: To be deprecated
+                    .service(
+                        web::resource("/v2/list")
+                            .route(web::get().to(user_role::list_roles_with_info)),
+                    )
+                    .service(
+                        web::scope("/list")
+                            .service(
+                                web::resource("")
+                                    .route(web::get().to(user_role::list_roles_with_info)),
+                            )
+                            .service(web::resource("/invite").route(
                                 web::get().to(user_role::list_invitable_roles_at_entity_level),
-                            ),
-                        )
-                        .service(
-                            web::resource("/update").route(
+                            ))
+                            .service(web::resource("/update").route(
                                 web::get().to(user_role::list_updatable_roles_at_entity_level),
-                            ),
-                        ),
-                )
-                .service(
-                    web::resource("/{role_id}")
-                        .route(web::get().to(user_role::get_role))
-                        .route(web::put().to(user_role::update_role)),
-                ),
-        );
+                            )),
+                    )
+                    .service(
+                        web::resource("/{role_id}")
+                            .route(web::get().to(user_role::get_role))
+                            .route(web::put().to(user_role::update_role)),
+                    ),
+            );
 
         #[cfg(feature = "dummy_connector")]
         {
diff --git a/crates/router/src/routes/lock_utils.rs b/crates/router/src/routes/lock_utils.rs
index 482bc40c49f..18211b7fbb0 100644
--- a/crates/router/src/routes/lock_utils.rs
+++ b/crates/router/src/routes/lock_utils.rs
@@ -219,16 +219,13 @@ impl From<Flow> for ApiIdentifier {
             | Flow::VerifyPaymentConnector
             | Flow::InternalUserSignup
             | Flow::SwitchOrg
-            | Flow::SwitchMerchant
             | Flow::SwitchMerchantV2
             | Flow::SwitchProfile
             | Flow::UserMerchantAccountCreate
             | Flow::GenerateSampleData
             | Flow::DeleteSampleData
-            | Flow::UserMerchantAccountList
             | Flow::GetUserDetails
             | Flow::GetUserRoleDetails
-            | Flow::ListUsersForMerchantAccount
             | Flow::ForgotPassword
             | Flow::ResetPassword
             | Flow::RotatePassword
@@ -259,8 +256,7 @@ impl From<Flow> for ApiIdentifier {
             | Flow::ListInvitationsForUser
             | Flow::AuthSelect => Self::User,
 
-            Flow::ListRoles
-            | Flow::ListRolesV2
+            Flow::ListRolesV2
             | Flow::ListInvitableRolesAtEntityLevel
             | Flow::ListUpdatableRolesAtEntityLevel
             | Flow::GetRole
@@ -268,9 +264,7 @@ impl From<Flow> for ApiIdentifier {
             | Flow::UpdateUserRole
             | Flow::GetAuthorizationInfo
             | Flow::GetRolesInfo
-            | Flow::AcceptInvitation
             | Flow::AcceptInvitationsV2
-            | Flow::MerchantSelect
             | Flow::AcceptInvitationsPreAuth
             | Flow::DeleteUserRole
             | Flow::CreateRole
diff --git a/crates/router/src/routes/user.rs b/crates/router/src/routes/user.rs
index b1fbd2bb6df..4ed2280c6a3 100644
--- a/crates/router/src/routes/user.rs
+++ b/crates/router/src/routes/user.rs
@@ -228,24 +228,6 @@ pub async fn internal_user_signup(
     .await
 }
 
-pub async fn switch_merchant_id(
-    state: web::Data<AppState>,
-    http_req: HttpRequest,
-    json_payload: web::Json<user_api::SwitchMerchantRequest>,
-) -> HttpResponse {
-    let flow = Flow::SwitchMerchant;
-    Box::pin(api::server_wrap(
-        flow,
-        state.clone(),
-        &http_req,
-        json_payload.into_inner(),
-        |state, user, req, _| user_core::switch_merchant_id(state, req, user),
-        &auth::DashboardNoPermissionAuth,
-        api_locking::LockAction::NotApplicable,
-    ))
-    .await
-}
-
 pub async fn user_merchant_account_create(
     state: web::Data<AppState>,
     req: HttpRequest,
@@ -316,41 +298,6 @@ pub async fn delete_sample_data(
     .await
 }
 
-pub async fn list_merchants_for_user(state: web::Data<AppState>, req: HttpRequest) -> HttpResponse {
-    let flow = Flow::UserMerchantAccountList;
-    Box::pin(api::server_wrap(
-        flow,
-        state,
-        &req,
-        (),
-        |state, user, _, _| user_core::list_merchants_for_user(state, user),
-        &auth::SinglePurposeOrLoginTokenAuth(TokenPurpose::AcceptInvite),
-        api_locking::LockAction::NotApplicable,
-    ))
-    .await
-}
-
-pub async fn get_user_role_details(
-    state: web::Data<AppState>,
-    req: HttpRequest,
-    payload: web::Query<user_api::GetUserRoleDetailsRequest>,
-) -> HttpResponse {
-    let flow = Flow::GetUserDetails;
-    Box::pin(api::server_wrap(
-        flow,
-        state.clone(),
-        &req,
-        payload.into_inner(),
-        user_core::get_user_details_in_merchant_account,
-        &auth::JWTAuth {
-            permission: Permission::UsersRead,
-            minimum_entity_level: EntityType::Merchant,
-        },
-        api_locking::LockAction::NotApplicable,
-    ))
-    .await
-}
-
 pub async fn list_user_roles_details(
     state: web::Data<AppState>,
     req: HttpRequest,
@@ -372,26 +319,6 @@ pub async fn list_user_roles_details(
     .await
 }
 
-pub async fn list_users_for_merchant_account(
-    state: web::Data<AppState>,
-    req: HttpRequest,
-) -> HttpResponse {
-    let flow = Flow::ListUsersForMerchantAccount;
-    Box::pin(api::server_wrap(
-        flow,
-        state.clone(),
-        &req,
-        (),
-        |state, user, _, _| user_core::list_users_for_merchant_account(state, user),
-        &auth::JWTAuth {
-            permission: Permission::UsersRead,
-            minimum_entity_level: EntityType::Merchant,
-        },
-        api_locking::LockAction::NotApplicable,
-    ))
-    .await
-}
-
 pub async fn rotate_password(
     state: web::Data<AppState>,
     req: HttpRequest,
diff --git a/crates/router/src/routes/user_role.rs b/crates/router/src/routes/user_role.rs
index 922e7612b14..777cbe1fd95 100644
--- a/crates/router/src/routes/user_role.rs
+++ b/crates/router/src/routes/user_role.rs
@@ -16,6 +16,7 @@ use crate::{
     },
 };
 
+// TODO: To be deprecated
 pub async fn get_authorization_info(
     state: web::Data<AppState>,
     http_req: HttpRequest,
@@ -76,25 +77,6 @@ pub async fn create_role(
     .await
 }
 
-pub async fn list_all_roles(state: web::Data<AppState>, req: HttpRequest) -> HttpResponse {
-    let flow = Flow::ListRoles;
-    Box::pin(api::server_wrap(
-        flow,
-        state.clone(),
-        &req,
-        (),
-        |state, user, _, _| async move {
-            role_core::list_invitable_roles_with_groups(state, user).await
-        },
-        &auth::JWTAuth {
-            permission: Permission::UsersRead,
-            minimum_entity_level: EntityType::Merchant,
-        },
-        api_locking::LockAction::NotApplicable,
-    ))
-    .await
-}
-
 pub async fn get_role(
     state: web::Data<AppState>,
     req: HttpRequest,
@@ -167,25 +149,6 @@ pub async fn update_user_role(
     .await
 }
 
-pub async fn accept_invitation(
-    state: web::Data<AppState>,
-    req: HttpRequest,
-    json_payload: web::Json<user_role_api::AcceptInvitationRequest>,
-) -> HttpResponse {
-    let flow = Flow::AcceptInvitation;
-    let payload = json_payload.into_inner();
-    Box::pin(api::server_wrap(
-        flow,
-        state.clone(),
-        &req,
-        payload,
-        |state, user, req_body, _| user_role_core::accept_invitation(state, user, req_body),
-        &auth::DashboardNoPermissionAuth,
-        api_locking::LockAction::NotApplicable,
-    ))
-    .await
-}
-
 pub async fn accept_invitations_v2(
     state: web::Data<AppState>,
     req: HttpRequest,
@@ -205,27 +168,6 @@ pub async fn accept_invitations_v2(
     .await
 }
 
-pub async fn merchant_select(
-    state: web::Data<AppState>,
-    req: HttpRequest,
-    json_payload: web::Json<user_role_api::MerchantSelectRequest>,
-) -> HttpResponse {
-    let flow = Flow::MerchantSelect;
-    let payload = json_payload.into_inner();
-    Box::pin(api::server_wrap(
-        flow,
-        state.clone(),
-        &req,
-        payload,
-        |state, user, req_body, _| async move {
-            user_role_core::merchant_select_token_only_flow(state, user, req_body).await
-        },
-        &auth::SinglePurposeJWTAuth(TokenPurpose::AcceptInvite),
-        api_locking::LockAction::NotApplicable,
-    ))
-    .await
-}
-
 pub async fn accept_invitations_pre_auth(
     state: web::Data<AppState>,
     req: HttpRequest,
diff --git a/crates/router/src/services/authorization/info.rs b/crates/router/src/services/authorization/info.rs
index 822035c7925..7cfde3efeea 100644
--- a/crates/router/src/services/authorization/info.rs
+++ b/crates/router/src/services/authorization/info.rs
@@ -1,21 +1,17 @@
 use api_models::user_role::{GroupInfo, ParentGroup, PermissionInfo};
 use common_enums::PermissionGroup;
-use strum::{EnumIter, IntoEnumIterator};
+use strum::IntoEnumIterator;
 
 use super::{permission_groups::get_permissions_vec, permissions::Permission};
 
-pub fn get_module_authorization_info() -> Vec<ModuleInfo> {
-    PermissionModule::iter()
-        .map(|module| ModuleInfo::new(&module))
-        .collect()
-}
-
+// TODO: To be deprecated
 pub fn get_group_authorization_info() -> Vec<GroupInfo> {
     PermissionGroup::iter()
         .map(get_group_info_from_permission_group)
         .collect()
 }
 
+// TODO: To be deprecated
 pub fn get_permission_info_from_permissions(permissions: &[Permission]) -> Vec<PermissionInfo> {
     permissions
         .iter()
@@ -26,169 +22,7 @@ pub fn get_permission_info_from_permissions(permissions: &[Permission]) -> Vec<P
         .collect()
 }
 
-// TODO: Deprecate once groups are stable
-#[derive(PartialEq, EnumIter, Clone)]
-pub enum PermissionModule {
-    Payments,
-    Refunds,
-    MerchantAccount,
-    Connectors,
-    Routing,
-    Analytics,
-    Mandates,
-    Customer,
-    Disputes,
-    ThreeDsDecisionManager,
-    SurchargeDecisionManager,
-    AccountCreate,
-    Payouts,
-    Recon,
-}
-
-impl PermissionModule {
-    pub fn get_module_description(&self) -> &'static str {
-        match self {
-            Self::Payments => "Everything related to payments - like creating and viewing payment related information are within this module",
-            Self::Refunds => "Refunds module encompasses everything related to refunds - like creating and viewing payment related information",
-            Self::MerchantAccount => "Accounts module permissions allow the user to view and update account details, configure webhooks and much more",
-            Self::Connectors => "All connector related actions - like configuring new connectors, viewing and updating connector configuration lies with this module",
-            Self::Routing => "All actions related to new, active, and past routing stacks take place here",
-            Self::Analytics => "Permission to view and analyse the data relating to payments, refunds, sdk etc.",
-            Self::Mandates => "Everything related to mandates - like creating and viewing mandate related information are within this module",
-            Self::Customer => "Everything related to customers - like creating and viewing customer related information are within this module",
-            Self::Disputes => "Everything related to disputes - like creating and viewing dispute related information are within this module",
-            Self::ThreeDsDecisionManager => "View and configure 3DS decision rules configured for a merchant",
-            Self::SurchargeDecisionManager =>"View and configure surcharge decision rules configured for a merchant",
-            Self::AccountCreate => "Create new account within your organization",
-            Self::Payouts => "Everything related to payouts - like creating and viewing payout related information are within this module",
-            Self::Recon => "Everything related to recon - raise requests for activating recon and generate recon auth tokens",
-        }
-    }
-}
-
-// TODO: Deprecate once groups are stable
-pub struct ModuleInfo {
-    pub module: PermissionModule,
-    pub description: &'static str,
-    pub permissions: Vec<PermissionInfo>,
-}
-
-impl ModuleInfo {
-    pub fn new(module: &PermissionModule) -> Self {
-        let module_name = module.clone();
-        let description = module.get_module_description();
-
-        match module {
-            PermissionModule::Payments => Self {
-                module: module_name,
-                description,
-                permissions: get_permission_info_from_permissions(&[
-                    Permission::PaymentRead,
-                    Permission::PaymentWrite,
-                ]),
-            },
-            PermissionModule::Refunds => Self {
-                module: module_name,
-                description,
-                permissions: get_permission_info_from_permissions(&[
-                    Permission::RefundRead,
-                    Permission::RefundWrite,
-                ]),
-            },
-            PermissionModule::MerchantAccount => Self {
-                module: module_name,
-                description,
-                permissions: get_permission_info_from_permissions(&[
-                    Permission::MerchantAccountRead,
-                    Permission::MerchantAccountWrite,
-                ]),
-            },
-            PermissionModule::Connectors => Self {
-                module: module_name,
-                description,
-                permissions: get_permission_info_from_permissions(&[
-                    Permission::MerchantConnectorAccountRead,
-                    Permission::MerchantConnectorAccountWrite,
-                ]),
-            },
-            PermissionModule::Routing => Self {
-                module: module_name,
-                description,
-                permissions: get_permission_info_from_permissions(&[
-                    Permission::RoutingRead,
-                    Permission::RoutingWrite,
-                ]),
-            },
-            PermissionModule::Analytics => Self {
-                module: module_name,
-                description,
-                permissions: get_permission_info_from_permissions(&[Permission::Analytics]),
-            },
-            PermissionModule::Mandates => Self {
-                module: module_name,
-                description,
-                permissions: get_permission_info_from_permissions(&[
-                    Permission::MandateRead,
-                    Permission::MandateWrite,
-                ]),
-            },
-            PermissionModule::Customer => Self {
-                module: module_name,
-                description,
-                permissions: get_permission_info_from_permissions(&[
-                    Permission::CustomerRead,
-                    Permission::CustomerWrite,
-                ]),
-            },
-            PermissionModule::Disputes => Self {
-                module: module_name,
-                description,
-                permissions: get_permission_info_from_permissions(&[
-                    Permission::DisputeRead,
-                    Permission::DisputeWrite,
-                ]),
-            },
-            PermissionModule::ThreeDsDecisionManager => Self {
-                module: module_name,
-                description,
-                permissions: get_permission_info_from_permissions(&[
-                    Permission::ThreeDsDecisionManagerRead,
-                    Permission::ThreeDsDecisionManagerWrite,
-                ]),
-            },
-
-            PermissionModule::SurchargeDecisionManager => Self {
-                module: module_name,
-                description,
-                permissions: get_permission_info_from_permissions(&[
-                    Permission::SurchargeDecisionManagerRead,
-                    Permission::SurchargeDecisionManagerWrite,
-                ]),
-            },
-            PermissionModule::AccountCreate => Self {
-                module: module_name,
-                description,
-                permissions: get_permission_info_from_permissions(&[
-                    Permission::MerchantAccountCreate,
-                ]),
-            },
-            PermissionModule::Payouts => Self {
-                module: module_name,
-                description,
-                permissions: get_permission_info_from_permissions(&[
-                    Permission::PayoutRead,
-                    Permission::PayoutWrite,
-                ]),
-            },
-            PermissionModule::Recon => Self {
-                module: module_name,
-                description,
-                permissions: get_permission_info_from_permissions(&[Permission::ReconAdmin]),
-            },
-        }
-    }
-}
-
+// TODO: To be deprecated
 fn get_group_info_from_permission_group(group: PermissionGroup) -> GroupInfo {
     let description = get_group_description(group);
     GroupInfo {
@@ -198,6 +32,7 @@ fn get_group_info_from_permission_group(group: PermissionGroup) -> GroupInfo {
     }
 }
 
+// TODO: To be deprecated
 fn get_group_description(group: PermissionGroup) -> &'static str {
     match group {
         PermissionGroup::OperationsView => {
@@ -250,10 +85,10 @@ pub fn get_parent_group_description(group: ParentGroup) -> &'static str {
         ParentGroup::Operations => "Payments, Refunds, Payouts, Mandates, Disputes and Customers",
         ParentGroup::Connectors => "Create, modify and delete connectors like Payment Processors, Payout Processors and Fraud & Risk Manager",
         ParentGroup::Workflows => "Create, modify and delete Routing, 3DS Decision Manager, Surcharge Decision Manager",
-       ParentGroup::Analytics => "View Analytics",
+        ParentGroup::Analytics => "View Analytics",
         ParentGroup::Users =>  "Manage and invite Users to the Team",
-       ParentGroup::Merchant => "Create, modify and delete Merchant Details like api keys, webhooks, etc",
-       ParentGroup::Organization =>"Manage organization level tasks like create new Merchant accounts, Organization level roles, etc",
-       ParentGroup::Recon => "View and manage reconciliation reports",
+        ParentGroup::Merchant => "Create, modify and delete Merchant Details like api keys, webhooks, etc",
+        ParentGroup::Organization =>"Manage organization level tasks like create new Merchant accounts, Organization level roles, etc",
+        ParentGroup::Recon => "View and manage reconciliation reports",
     }
 }
diff --git a/crates/router/src/types/domain/user.rs b/crates/router/src/types/domain/user.rs
index 19d682aeef1..6361b82afb4 100644
--- a/crates/router/src/types/domain/user.rs
+++ b/crates/router/src/types/domain/user.rs
@@ -32,7 +32,7 @@ use crate::{
     },
     db::{user_role::InsertUserRolePayload, GlobalStorageInterface},
     routes::SessionState,
-    services::{self, authentication::UserFromToken, authorization::info},
+    services::{self, authentication::UserFromToken},
     types::transformers::ForeignFrom,
     utils::user::password,
 };
@@ -1019,37 +1019,6 @@ impl UserFromStorage {
     }
 }
 
-impl From<info::ModuleInfo> for user_role_api::ModuleInfo {
-    fn from(value: info::ModuleInfo) -> Self {
-        Self {
-            module: value.module.into(),
-            description: value.description,
-            permissions: value.permissions.into_iter().map(Into::into).collect(),
-        }
-    }
-}
-
-impl From<info::PermissionModule> for user_role_api::PermissionModule {
-    fn from(value: info::PermissionModule) -> Self {
-        match value {
-            info::PermissionModule::Payments => Self::Payments,
-            info::PermissionModule::Refunds => Self::Refunds,
-            info::PermissionModule::MerchantAccount => Self::MerchantAccount,
-            info::PermissionModule::Connectors => Self::Connectors,
-            info::PermissionModule::Routing => Self::Routing,
-            info::PermissionModule::Analytics => Self::Analytics,
-            info::PermissionModule::Mandates => Self::Mandates,
-            info::PermissionModule::Customer => Self::Customer,
-            info::PermissionModule::Disputes => Self::Disputes,
-            info::PermissionModule::ThreeDsDecisionManager => Self::ThreeDsDecisionManager,
-            info::PermissionModule::SurchargeDecisionManager => Self::SurchargeDecisionManager,
-            info::PermissionModule::AccountCreate => Self::AccountCreate,
-            info::PermissionModule::Payouts => Self::Payouts,
-            info::PermissionModule::Recon => Self::Recon,
-        }
-    }
-}
-
 impl ForeignFrom<UserStatus> for user_role_api::UserStatus {
     fn foreign_from(value: UserStatus) -> Self {
         match value {
diff --git a/crates/router/src/utils/user.rs b/crates/router/src/utils/user.rs
index 22edf6768c8..8975519fd97 100644
--- a/crates/router/src/utils/user.rs
+++ b/crates/router/src/utils/user.rs
@@ -5,8 +5,7 @@ use common_enums::UserAuthType;
 use common_utils::{
     encryption::Encryption, errors::CustomResult, id_type, type_name, types::keymanager::Identifier,
 };
-use diesel_models::user_role::UserRole;
-use error_stack::{report, ResultExt};
+use error_stack::ResultExt;
 use masking::{ExposeInterface, Secret};
 use redis_interface::RedisConnectionPool;
 
@@ -86,45 +85,6 @@ impl UserFromToken {
     }
 }
 
-pub async fn generate_jwt_auth_token_without_profile(
-    state: &SessionState,
-    user: &UserFromStorage,
-    user_role: &UserRole,
-) -> UserResult<Secret<String>> {
-    let token = AuthToken::new_token(
-        user.get_user_id().to_string(),
-        user_role
-            .merchant_id
-            .as_ref()
-            .ok_or(report!(UserErrors::InternalServerError))
-            .attach_printable("merchant_id not found for user_role")?
-            .clone(),
-        user_role.role_id.clone(),
-        &state.conf,
-        user_role
-            .org_id
-            .as_ref()
-            .ok_or(report!(UserErrors::InternalServerError))
-            .attach_printable("org_id not found for user_role")?
-            .clone(),
-        None,
-    )
-    .await?;
-    Ok(Secret::new(token))
-}
-
-pub async fn generate_jwt_auth_token_with_attributes_without_profile(
-    state: &SessionState,
-    user_id: String,
-    merchant_id: id_type::MerchantId,
-    org_id: id_type::OrganizationId,
-    role_id: String,
-) -> UserResult<Secret<String>> {
-    let token =
-        AuthToken::new_token(user_id, merchant_id, role_id, &state.conf, org_id, None).await?;
-    Ok(Secret::new(token))
-}
-
 pub async fn generate_jwt_auth_token_with_attributes(
     state: &SessionState,
     user_id: String,
diff --git a/crates/router_env/src/logger/types.rs b/crates/router_env/src/logger/types.rs
index 603c5cc91c1..2bae094fd96 100644
--- a/crates/router_env/src/logger/types.rs
+++ b/crates/router_env/src/logger/types.rs
@@ -364,8 +364,6 @@ pub enum Flow {
     InternalUserSignup,
     /// Switch org
     SwitchOrg,
-    /// Switch merchant
-    SwitchMerchant,
     /// Switch merchant v2
     SwitchMerchantV2,
     /// Switch profile
@@ -374,8 +372,6 @@ pub enum Flow {
     GetAuthorizationInfo,
     /// Get Roles info
     GetRolesInfo,
-    /// List roles
-    ListRoles,
     /// List roles v2
     ListRolesV2,
     /// List invitable roles at entity level
@@ -394,14 +390,10 @@ pub enum Flow {
     GenerateSampleData,
     /// Delete Sample Data
     DeleteSampleData,
-    /// List merchant accounts for user
-    UserMerchantAccountList,
     /// Get details of a user
     GetUserDetails,
     /// Get details of a user role in a merchant account
     GetUserRoleDetails,
-    /// List users for merchant account
-    ListUsersForMerchantAccount,
     /// PaymentMethodAuth Link token create
     PmAuthLinkTokenCreate,
     /// PaymentMethodAuth Exchange token create
@@ -434,12 +426,8 @@ pub enum Flow {
     VerifyEmailRequest,
     /// Update user account details
     UpdateUserAccountDetails,
-    /// Accept user invitation using merchant_ids
-    AcceptInvitation,
     /// Accept user invitation using entities
     AcceptInvitationsV2,
-    /// Select merchant from invitations
-    MerchantSelect,
     /// Accept user invitation using entities before user login
     AcceptInvitationsPreAuth,
     /// Initiate external authentication for a payment

## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [ ] Bugfix
- [ ] New feature
- [ ] Enhancement
- [x] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
<!-- Describe your changes in detail -->
Deletions
  - `/user/switch_merchant`
  - `/user/switch/list`
  - `/user/merchants/list`
  - `/user/merchant_select/list`
 
Modifications
  - `/user/user` will work same as `/user/user/v2`
  - `/user/user/list` will work same as `/user/user/v2/list`
  - `/user/user/invite/accept` will work same as `/user/user/invite/accept/v2`
  - `/user/user/invite/accept/pre_auth` will work same as `/user/user/invite/accept/v2/pre_auth`
  - `/user/role/list` will work same as `/user/role/v2/list`

### Additional Changes

- [x] This PR modifies the API contract
- [ ] This PR modifies the database schema
- [ ] This PR modifies application configuration/environment variables

<!--
Provide links to the files with corresponding changes.

Following are the paths where you can find config files:
1. `config`
2. `crates/router/src/configs`
3. `loadtest/config`
-->


## Motivation and Context
<!--
Why is this change required? What problem does it solve?
If it fixes an open issue, please link to the issue here.

If you don't have an issue, we'd recommend starting with one first so the PR
can focus on the implementation (unless it is an obvious bug or documentation fix
that will have little conversation).
-->
Closes [#6112](https://github.com/juspay/hyperswitch/issues/6112).

## How did you test it?
<!--
Did you write an integration/unit/API test to verify the code changes?
Or did you test this change manually (provide relevant screenshots)?
-->
All the below APIs with throw 404.
  - `/user/switch_merchant`
  - `/user/switch/list`
  - `/user/merchants/list`
  - `/user/merchant_select/list`
 
All the below APIs with behave differently.
  - `/user/user` will work same as `/user/user/v2`
  - `/user/user/list` will work same as `/user/user/v2/list`
  - `/user/user/invite/accept` will work same as `/user/user/invite/accept/v2`
  - `/user/user/invite/accept/pre_auth` will work same as `/user/user/invite/accept/v2/pre_auth`
  - `/user/role/list` will work same as `/user/role/v2/list`


## Checklist
<!-- Put an `x` in the boxes that apply -->

- [x] I formatted the code `cargo +nightly fmt --all`
- [x] I addressed lints thrown by `cargo clippy`
- [x] I reviewed the submitted code
- [ ] I added unit tests for my changes where possible
