Issue:
Bug: [REFACTOR] add domain type for routing id



add domain type for routing id

Pull request description:
## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [ ] Bugfix
- [ ] New feature
- [ ] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
add domain type for Routing id


### Additional Changes

- [ ] 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).
-->


## How did you test it?

Tested Manually

Create, Update & Retrieve of outing and subsequent flows like payments sanity

## Checklist
<!-- Put an `x` in the boxes that apply -->

- [ ] I formatted the code `cargo +nightly fmt --all`
- [ ] I addressed lints thrown by `cargo clippy`
- [ ] I reviewed the submitted code
- [ ] I added unit tests for my changes where possible


Testing:
Tested Manually

Create, Update & Retrieve of outing and subsequent flows like payments sanity

Patch:
diff --git a/crates/api_models/src/routing.rs b/crates/api_models/src/routing.rs
index f9bcf3901b9..1416e985523 100644
--- a/crates/api_models/src/routing.rs
+++ b/crates/api_models/src/routing.rs
@@ -89,7 +89,8 @@ pub enum LinkedRoutingConfigRetrieveResponse {
 #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
 /// Routing Algorithm specific to merchants
 pub struct MerchantRoutingAlgorithm {
-    pub id: String,
+    #[schema(value_type = String)]
+    pub id: common_utils::id_type::RoutingId,
     #[schema(value_type = String)]
     pub profile_id: common_utils::id_type::ProfileId,
     pub name: String,
@@ -422,14 +423,14 @@ impl RoutingAlgorithm {
 
 #[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
 pub struct RoutingAlgorithmRef {
-    pub algorithm_id: Option<String>,
+    pub algorithm_id: Option<common_utils::id_type::RoutingId>,
     pub timestamp: i64,
     pub config_algo_id: Option<String>,
     pub surcharge_config_algo_id: Option<String>,
 }
 
 impl RoutingAlgorithmRef {
-    pub fn update_algorithm_id(&mut self, new_id: String) {
+    pub fn update_algorithm_id(&mut self, new_id: common_utils::id_type::RoutingId) {
         self.algorithm_id = Some(new_id);
         self.timestamp = common_utils::date_time::now_unix_timestamp();
     }
@@ -456,7 +457,8 @@ impl RoutingAlgorithmRef {
 #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
 
 pub struct RoutingDictionaryRecord {
-    pub id: String,
+    #[schema(value_type = String)]
+    pub id: common_utils::id_type::RoutingId,
     #[schema(value_type = String)]
     pub profile_id: common_utils::id_type::ProfileId,
     pub name: String,
@@ -484,7 +486,8 @@ pub enum RoutingKind {
 
 #[derive(serde::Serialize, serde::Deserialize, Debug, Clone, ToSchema)]
 pub struct RoutingAlgorithmId {
-    pub routing_algorithm_id: String,
+    #[schema(value_type = String)]
+    pub routing_algorithm_id: common_utils::id_type::RoutingId,
 }
 
 #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
diff --git a/crates/common_utils/src/id_type.rs b/crates/common_utils/src/id_type.rs
index b6de37fab4f..5182c821d0f 100644
--- a/crates/common_utils/src/id_type.rs
+++ b/crates/common_utils/src/id_type.rs
@@ -8,6 +8,7 @@ mod merchant;
 mod merchant_connector_account;
 mod organization;
 mod profile;
+mod routing;
 
 mod global_id;
 
@@ -23,6 +24,7 @@ pub use merchant::MerchantId;
 pub use merchant_connector_account::MerchantConnectorAccountId;
 pub use organization::OrganizationId;
 pub use profile::ProfileId;
+pub use routing::RoutingId;
 use serde::{Deserialize, Serialize};
 use thiserror::Error;
 
diff --git a/crates/common_utils/src/id_type/routing.rs b/crates/common_utils/src/id_type/routing.rs
new file mode 100644
index 00000000000..cb6597174a2
--- /dev/null
+++ b/crates/common_utils/src/id_type/routing.rs
@@ -0,0 +1,21 @@
+crate::id_type!(
+    RoutingId,
+    " A type for routing_id that can be used for routing ids"
+);
+
+crate::impl_id_type_methods!(RoutingId, "routing_id");
+
+// This is to display the `RoutingId` as RoutingId(abcd)
+crate::impl_debug_id_type!(RoutingId);
+crate::impl_try_from_cow_str_id_type!(RoutingId, "routing_id");
+
+crate::impl_generate_id_id_type!(RoutingId, "routing");
+crate::impl_serializable_secret_id_type!(RoutingId);
+crate::impl_queryable_id_type!(RoutingId);
+crate::impl_to_sql_from_sql_id_type!(RoutingId);
+
+impl crate::events::ApiEventMetric for RoutingId {
+    fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> {
+        Some(crate::events::ApiEventsType::Routing)
+    }
+}
diff --git a/crates/common_utils/src/lib.rs b/crates/common_utils/src/lib.rs
index f51ed6eab05..3bf3db11ba3 100644
--- a/crates/common_utils/src/lib.rs
+++ b/crates/common_utils/src/lib.rs
@@ -233,6 +233,12 @@ pub fn generate_profile_id_of_default_length() -> id_type::ProfileId {
     id_type::ProfileId::generate()
 }
 
+/// Generate a routing id with default length, with prefix as `routing`
+pub fn generate_routing_id_of_default_length() -> id_type::RoutingId {
+    use id_type::GenerateId;
+
+    id_type::RoutingId::generate()
+}
 /// Generate a merchant_connector_account id with default length, with prefix as `mca`
 pub fn generate_merchant_connector_account_id_of_default_length(
 ) -> id_type::MerchantConnectorAccountId {
diff --git a/crates/diesel_models/src/business_profile.rs b/crates/diesel_models/src/business_profile.rs
index 5a4f4fa0b49..2096779262e 100644
--- a/crates/diesel_models/src/business_profile.rs
+++ b/crates/diesel_models/src/business_profile.rs
@@ -269,11 +269,11 @@ pub struct BusinessProfile {
     pub outgoing_webhook_custom_http_headers: Option<Encryption>,
     pub always_collect_billing_details_from_wallet_connector: Option<bool>,
     pub always_collect_shipping_details_from_wallet_connector: Option<bool>,
-    pub routing_algorithm_id: Option<String>,
+    pub routing_algorithm_id: Option<common_utils::id_type::RoutingId>,
     pub order_fulfillment_time: Option<i64>,
     pub order_fulfillment_time_origin: Option<common_enums::OrderFulfillmentTimeOrigin>,
     pub frm_routing_algorithm_id: Option<String>,
-    pub payout_routing_algorithm_id: Option<String>,
+    pub payout_routing_algorithm_id: Option<common_utils::id_type::RoutingId>,
     pub default_fallback_routing: Option<pii::SecretSerdeValue>,
     pub tax_connector_id: Option<String>,
     pub is_tax_connector_enabled: Option<bool>,
@@ -310,11 +310,11 @@ pub struct BusinessProfileNew {
     pub outgoing_webhook_custom_http_headers: Option<Encryption>,
     pub always_collect_billing_details_from_wallet_connector: Option<bool>,
     pub always_collect_shipping_details_from_wallet_connector: Option<bool>,
-    pub routing_algorithm_id: Option<String>,
+    pub routing_algorithm_id: Option<common_utils::id_type::RoutingId>,
     pub order_fulfillment_time: Option<i64>,
     pub order_fulfillment_time_origin: Option<common_enums::OrderFulfillmentTimeOrigin>,
     pub frm_routing_algorithm_id: Option<String>,
-    pub payout_routing_algorithm_id: Option<String>,
+    pub payout_routing_algorithm_id: Option<common_utils::id_type::RoutingId>,
     pub default_fallback_routing: Option<pii::SecretSerdeValue>,
     pub tax_connector_id: Option<String>,
     pub is_tax_connector_enabled: Option<bool>,
@@ -348,11 +348,11 @@ pub struct BusinessProfileUpdateInternal {
     pub outgoing_webhook_custom_http_headers: Option<Encryption>,
     pub always_collect_billing_details_from_wallet_connector: Option<bool>,
     pub always_collect_shipping_details_from_wallet_connector: Option<bool>,
-    pub routing_algorithm_id: Option<String>,
+    pub routing_algorithm_id: Option<common_utils::id_type::RoutingId>,
     pub order_fulfillment_time: Option<i64>,
     pub order_fulfillment_time_origin: Option<common_enums::OrderFulfillmentTimeOrigin>,
     pub frm_routing_algorithm_id: Option<String>,
-    pub payout_routing_algorithm_id: Option<String>,
+    pub payout_routing_algorithm_id: Option<common_utils::id_type::RoutingId>,
     pub default_fallback_routing: Option<pii::SecretSerdeValue>,
     pub tax_connector_id: Option<String>,
     pub is_tax_connector_enabled: Option<bool>,
diff --git a/crates/diesel_models/src/query/routing_algorithm.rs b/crates/diesel_models/src/query/routing_algorithm.rs
index f0fc75430e8..c4d56736aa2 100644
--- a/crates/diesel_models/src/query/routing_algorithm.rs
+++ b/crates/diesel_models/src/query/routing_algorithm.rs
@@ -19,7 +19,7 @@ impl RoutingAlgorithm {
 
     pub async fn find_by_algorithm_id_merchant_id(
         conn: &PgPooledConn,
-        algorithm_id: &str,
+        algorithm_id: &common_utils::id_type::RoutingId,
         merchant_id: &common_utils::id_type::MerchantId,
     ) -> StorageResult<Self> {
         generics::generic_find_one::<<Self as HasTable>::Table, _, _>(
@@ -33,7 +33,7 @@ impl RoutingAlgorithm {
 
     pub async fn find_by_algorithm_id_profile_id(
         conn: &PgPooledConn,
-        algorithm_id: &str,
+        algorithm_id: &common_utils::id_type::RoutingId,
         profile_id: &common_utils::id_type::ProfileId,
     ) -> StorageResult<Self> {
         generics::generic_find_one::<<Self as HasTable>::Table, _, _>(
@@ -47,7 +47,7 @@ impl RoutingAlgorithm {
 
     pub async fn find_metadata_by_algorithm_id_profile_id(
         conn: &PgPooledConn,
-        algorithm_id: &str,
+        algorithm_id: &common_utils::id_type::RoutingId,
         profile_id: &common_utils::id_type::ProfileId,
     ) -> StorageResult<RoutingProfileMetadata> {
         Self::table()
@@ -69,7 +69,7 @@ impl RoutingAlgorithm {
             .limit(1)
             .load_async::<(
                 common_utils::id_type::ProfileId,
-                String,
+                common_utils::id_type::RoutingId,
                 String,
                 Option<String>,
                 enums::RoutingAlgorithmKind,
@@ -128,7 +128,7 @@ impl RoutingAlgorithm {
             .limit(limit)
             .offset(offset)
             .load_async::<(
-                String,
+                common_utils::id_type::RoutingId,
                 common_utils::id_type::ProfileId,
                 String,
                 Option<String>,
@@ -189,7 +189,7 @@ impl RoutingAlgorithm {
             .order(dsl::modified_at.desc())
             .load_async::<(
                 common_utils::id_type::ProfileId,
-                String,
+                common_utils::id_type::RoutingId,
                 String,
                 Option<String>,
                 enums::RoutingAlgorithmKind,
@@ -251,7 +251,7 @@ impl RoutingAlgorithm {
             .order(dsl::modified_at.desc())
             .load_async::<(
                 common_utils::id_type::ProfileId,
-                String,
+                common_utils::id_type::RoutingId,
                 String,
                 Option<String>,
                 enums::RoutingAlgorithmKind,
diff --git a/crates/diesel_models/src/routing_algorithm.rs b/crates/diesel_models/src/routing_algorithm.rs
index 6be0be3d5e4..5f5a0560811 100644
--- a/crates/diesel_models/src/routing_algorithm.rs
+++ b/crates/diesel_models/src/routing_algorithm.rs
@@ -1,3 +1,4 @@
+use common_utils::id_type;
 use diesel::{Identifiable, Insertable, Queryable, Selectable};
 use serde::{Deserialize, Serialize};
 
@@ -6,9 +7,9 @@ use crate::{enums, schema::routing_algorithm};
 #[derive(Clone, Debug, Identifiable, Insertable, Queryable, Selectable, Serialize, Deserialize)]
 #[diesel(table_name = routing_algorithm, primary_key(algorithm_id), check_for_backend(diesel::pg::Pg))]
 pub struct RoutingAlgorithm {
-    pub algorithm_id: String,
-    pub profile_id: common_utils::id_type::ProfileId,
-    pub merchant_id: common_utils::id_type::MerchantId,
+    pub algorithm_id: id_type::RoutingId,
+    pub profile_id: id_type::ProfileId,
+    pub merchant_id: id_type::MerchantId,
     pub name: String,
     pub description: Option<String>,
     pub kind: enums::RoutingAlgorithmKind,
@@ -19,7 +20,7 @@ pub struct RoutingAlgorithm {
 }
 
 pub struct RoutingAlgorithmMetadata {
-    pub algorithm_id: String,
+    pub algorithm_id: id_type::RoutingId,
     pub name: String,
     pub description: Option<String>,
     pub kind: enums::RoutingAlgorithmKind,
@@ -29,8 +30,8 @@ pub struct RoutingAlgorithmMetadata {
 }
 
 pub struct RoutingProfileMetadata {
-    pub profile_id: common_utils::id_type::ProfileId,
-    pub algorithm_id: String,
+    pub profile_id: id_type::ProfileId,
+    pub algorithm_id: id_type::RoutingId,
     pub name: String,
     pub description: Option<String>,
     pub kind: enums::RoutingAlgorithmKind,
diff --git a/crates/hyperswitch_domain_models/src/business_profile.rs b/crates/hyperswitch_domain_models/src/business_profile.rs
index 9a6edc50e73..4f9c562a565 100644
--- a/crates/hyperswitch_domain_models/src/business_profile.rs
+++ b/crates/hyperswitch_domain_models/src/business_profile.rs
@@ -479,11 +479,11 @@ pub struct BusinessProfile {
     pub outgoing_webhook_custom_http_headers: OptionalEncryptableValue,
     pub always_collect_billing_details_from_wallet_connector: Option<bool>,
     pub always_collect_shipping_details_from_wallet_connector: Option<bool>,
-    pub routing_algorithm_id: Option<String>,
+    pub routing_algorithm_id: Option<common_utils::id_type::RoutingId>,
     pub order_fulfillment_time: Option<i64>,
     pub order_fulfillment_time_origin: Option<common_enums::OrderFulfillmentTimeOrigin>,
     pub frm_routing_algorithm_id: Option<String>,
-    pub payout_routing_algorithm_id: Option<String>,
+    pub payout_routing_algorithm_id: Option<common_utils::id_type::RoutingId>,
     pub default_fallback_routing: Option<pii::SecretSerdeValue>,
     pub tax_connector_id: Option<String>,
     pub is_tax_connector_enabled: bool,
@@ -536,8 +536,8 @@ pub struct BusinessProfileGeneralUpdate {
 pub enum BusinessProfileUpdate {
     Update(Box<BusinessProfileGeneralUpdate>),
     RoutingAlgorithmUpdate {
-        routing_algorithm_id: Option<String>,
-        payout_routing_algorithm_id: Option<String>,
+        routing_algorithm_id: Option<common_utils::id_type::RoutingId>,
+        payout_routing_algorithm_id: Option<common_utils::id_type::RoutingId>,
     },
     DefaultRoutingFallbackUpdate {
         default_fallback_routing: Option<pii::SecretSerdeValue>,
diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rs
index cb95feee9e9..eeaf1ddc02e 100644
--- a/crates/router/src/core/admin.rs
+++ b/crates/router/src/core/admin.rs
@@ -4128,7 +4128,7 @@ impl BusinessProfileWrapper {
         db: &dyn StorageInterface,
         key_manager_state: &KeyManagerState,
         merchant_key_store: &domain::MerchantKeyStore,
-        algorithm_id: String,
+        algorithm_id: common_utils::id_type::RoutingId,
         transaction_type: &storage::enums::TransactionType,
     ) -> RouterResult<()> {
         let routing_cache_key = self.clone().get_routing_config_cache_key();
@@ -4169,7 +4169,7 @@ impl BusinessProfileWrapper {
     pub fn get_routing_algorithm_id<'a, F>(
         &'a self,
         transaction_data: &'a routing::TransactionData<'_, F>,
-    ) -> Option<String>
+    ) -> Option<id_type::RoutingId>
     where
         F: Send + Clone,
     {
diff --git a/crates/router/src/core/payments/routing.rs b/crates/router/src/core/payments/routing.rs
index 6f1912d7c65..1c8a58662f1 100644
--- a/crates/router/src/core/payments/routing.rs
+++ b/crates/router/src/core/payments/routing.rs
@@ -114,7 +114,7 @@ impl Default for MerchantAccountRoutingAlgorithm {
 #[derive(Debug, serde::Serialize, serde::Deserialize)]
 #[serde(untagged)]
 enum MerchantAccountRoutingAlgorithm {
-    V1(Option<String>),
+    V1(Option<common_utils::id_type::RoutingId>),
 }
 
 #[cfg(feature = "payouts")]
@@ -289,7 +289,7 @@ where
 pub async fn perform_static_routing_v1<F: Clone>(
     state: &SessionState,
     merchant_id: &common_utils::id_type::MerchantId,
-    algorithm_id: Option<String>,
+    algorithm_id: Option<common_utils::id_type::RoutingId>,
     business_profile: &domain::BusinessProfile,
     transaction_data: &routing::TransactionData<'_, F>,
 ) -> RoutingResult<Vec<routing_types::RoutableConnectorChoice>> {
@@ -352,7 +352,7 @@ pub async fn perform_static_routing_v1<F: Clone>(
 async fn ensure_algorithm_cached_v1(
     state: &SessionState,
     merchant_id: &common_utils::id_type::MerchantId,
-    algorithm_id: &str,
+    algorithm_id: &common_utils::id_type::RoutingId,
     profile_id: common_utils::id_type::ProfileId,
     transaction_type: &api_enums::TransactionType,
 ) -> RoutingResult<Arc<CachedAlgorithm>> {
@@ -437,7 +437,7 @@ fn execute_dsl_and_get_connector_v1(
 pub async fn refresh_routing_cache_v1(
     state: &SessionState,
     key: String,
-    algorithm_id: &str,
+    algorithm_id: &common_utils::id_type::RoutingId,
     profile_id: common_utils::id_type::ProfileId,
 ) -> RoutingResult<Arc<CachedAlgorithm>> {
     let algorithm = {
diff --git a/crates/router/src/core/routing.rs b/crates/router/src/core/routing.rs
index d5a3a96d155..b0cc088b0ff 100644
--- a/crates/router/src/core/routing.rs
+++ b/crates/router/src/core/routing.rs
@@ -14,8 +14,12 @@ use super::payments;
 use super::payouts;
 #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "routing_v2")))]
 use crate::utils::ValueExt;
+#[cfg(all(feature = "v2", feature = "routing_v2"))]
+use crate::{
+    core::{admin, errors::RouterResult},
+    db::StorageInterface,
+};
 use crate::{
-    consts,
     core::{
         errors::{self, RouterResponse, StorageErrorExt},
         metrics, utils as core_utils,
@@ -28,11 +32,6 @@ use crate::{
     },
     utils::{self, OptionExt},
 };
-#[cfg(all(feature = "v2", feature = "routing_v2"))]
-use crate::{
-    core::{admin, errors::RouterResult},
-    db::StorageInterface,
-};
 pub enum TransactionData<'a, F>
 where
     F: Clone,
@@ -53,10 +52,7 @@ impl RoutingAlgorithmUpdate {
         profile_id: common_utils::id_type::ProfileId,
         transaction_type: &enums::TransactionType,
     ) -> Self {
-        let algorithm_id = common_utils::generate_id(
-            consts::ROUTING_CONFIG_ID_LENGTH,
-            &format!("routing_{}", merchant_id.get_string_repr()),
-        );
+        let algorithm_id = common_utils::generate_routing_id_of_default_length();
         let timestamp = common_utils::date_time::now();
         let algo = RoutingAlgorithm {
             algorithm_id,
@@ -74,7 +70,7 @@ impl RoutingAlgorithmUpdate {
     }
     pub async fn fetch_routing_algo(
         merchant_id: &common_utils::id_type::MerchantId,
-        algorithm_id: &str,
+        algorithm_id: &common_utils::id_type::RoutingId,
         db: &dyn StorageInterface,
     ) -> RouterResult<Self> {
         let routing_algo = db
@@ -215,10 +211,7 @@ pub async fn create_routing_algorithm_under_profile(
         })
         .attach_printable("Algorithm of config not given")?;
 
-    let algorithm_id = common_utils::generate_id(
-        consts::ROUTING_CONFIG_ID_LENGTH,
-        &format!("routing_{}", merchant_account.get_id().get_string_repr()),
-    );
+    let algorithm_id = common_utils::generate_routing_id_of_default_length();
 
     let profile_id = request
         .profile_id
@@ -280,7 +273,7 @@ pub async fn link_routing_config_under_profile(
     merchant_account: domain::MerchantAccount,
     key_store: domain::MerchantKeyStore,
     profile_id: common_utils::id_type::ProfileId,
-    algorithm_id: String,
+    algorithm_id: common_utils::id_type::RoutingId,
     transaction_type: &enums::TransactionType,
 ) -> RouterResponse<routing_types::RoutingDictionaryRecord> {
     metrics::ROUTING_LINK_CONFIG.add(&metrics::CONTEXT, 1, &[]);
@@ -352,7 +345,7 @@ pub async fn link_routing_config(
     state: SessionState,
     merchant_account: domain::MerchantAccount,
     key_store: domain::MerchantKeyStore,
-    algorithm_id: String,
+    algorithm_id: common_utils::id_type::RoutingId,
     transaction_type: &enums::TransactionType,
 ) -> RouterResponse<routing_types::RoutingDictionaryRecord> {
     metrics::ROUTING_LINK_CONFIG.add(&metrics::CONTEXT, 1, &[]);
@@ -428,7 +421,7 @@ pub async fn retrieve_routing_algorithm_from_algorithm_id(
     state: SessionState,
     merchant_account: domain::MerchantAccount,
     key_store: domain::MerchantKeyStore,
-    algorithm_id: String,
+    algorithm_id: common_utils::id_type::RoutingId,
 ) -> RouterResponse<routing_types::MerchantRoutingAlgorithm> {
     metrics::ROUTING_RETRIEVE_CONFIG.add(&metrics::CONTEXT, 1, &[]);
     let db = state.store.as_ref();
@@ -461,7 +454,7 @@ pub async fn retrieve_routing_algorithm_from_algorithm_id(
     state: SessionState,
     merchant_account: domain::MerchantAccount,
     key_store: domain::MerchantKeyStore,
-    algorithm_id: String,
+    algorithm_id: common_utils::id_type::RoutingId,
 ) -> RouterResponse<routing_types::MerchantRoutingAlgorithm> {
     metrics::ROUTING_RETRIEVE_CONFIG.add(&metrics::CONTEXT, 1, &[]);
     let db = state.store.as_ref();
diff --git a/crates/router/src/db/kafka_store.rs b/crates/router/src/db/kafka_store.rs
index 403b79a0377..e3c9b1b85b0 100644
--- a/crates/router/src/db/kafka_store.rs
+++ b/crates/router/src/db/kafka_store.rs
@@ -2494,7 +2494,7 @@ impl RoutingAlgorithmInterface for KafkaStore {
     async fn find_routing_algorithm_by_profile_id_algorithm_id(
         &self,
         profile_id: &id_type::ProfileId,
-        algorithm_id: &str,
+        algorithm_id: &id_type::RoutingId,
     ) -> CustomResult<storage::RoutingAlgorithm, errors::StorageError> {
         self.diesel_store
             .find_routing_algorithm_by_profile_id_algorithm_id(profile_id, algorithm_id)
@@ -2503,7 +2503,7 @@ impl RoutingAlgorithmInterface for KafkaStore {
 
     async fn find_routing_algorithm_by_algorithm_id_merchant_id(
         &self,
-        algorithm_id: &str,
+        algorithm_id: &id_type::RoutingId,
         merchant_id: &id_type::MerchantId,
     ) -> CustomResult<storage::RoutingAlgorithm, errors::StorageError> {
         self.diesel_store
@@ -2513,7 +2513,7 @@ impl RoutingAlgorithmInterface for KafkaStore {
 
     async fn find_routing_algorithm_metadata_by_algorithm_id_profile_id(
         &self,
-        algorithm_id: &str,
+        algorithm_id: &id_type::RoutingId,
         profile_id: &id_type::ProfileId,
     ) -> CustomResult<storage::RoutingProfileMetadata, errors::StorageError> {
         self.diesel_store
diff --git a/crates/router/src/db/routing_algorithm.rs b/crates/router/src/db/routing_algorithm.rs
index 5672777bfa2..3849b9272e0 100644
--- a/crates/router/src/db/routing_algorithm.rs
+++ b/crates/router/src/db/routing_algorithm.rs
@@ -21,18 +21,18 @@ pub trait RoutingAlgorithmInterface {
     async fn find_routing_algorithm_by_profile_id_algorithm_id(
         &self,
         profile_id: &common_utils::id_type::ProfileId,
-        algorithm_id: &str,
+        algorithm_id: &common_utils::id_type::RoutingId,
     ) -> StorageResult<routing_storage::RoutingAlgorithm>;
 
     async fn find_routing_algorithm_by_algorithm_id_merchant_id(
         &self,
-        algorithm_id: &str,
+        algorithm_id: &common_utils::id_type::RoutingId,
         merchant_id: &common_utils::id_type::MerchantId,
     ) -> StorageResult<routing_storage::RoutingAlgorithm>;
 
     async fn find_routing_algorithm_metadata_by_algorithm_id_profile_id(
         &self,
-        algorithm_id: &str,
+        algorithm_id: &common_utils::id_type::RoutingId,
         profile_id: &common_utils::id_type::ProfileId,
     ) -> StorageResult<routing_storage::RoutingProfileMetadata>;
 
@@ -77,7 +77,7 @@ impl RoutingAlgorithmInterface for Store {
     async fn find_routing_algorithm_by_profile_id_algorithm_id(
         &self,
         profile_id: &common_utils::id_type::ProfileId,
-        algorithm_id: &str,
+        algorithm_id: &common_utils::id_type::RoutingId,
     ) -> StorageResult<routing_storage::RoutingAlgorithm> {
         let conn = connection::pg_connection_write(self).await?;
         routing_storage::RoutingAlgorithm::find_by_algorithm_id_profile_id(
@@ -92,7 +92,7 @@ impl RoutingAlgorithmInterface for Store {
     #[instrument(skip_all)]
     async fn find_routing_algorithm_by_algorithm_id_merchant_id(
         &self,
-        algorithm_id: &str,
+        algorithm_id: &common_utils::id_type::RoutingId,
         merchant_id: &common_utils::id_type::MerchantId,
     ) -> StorageResult<routing_storage::RoutingAlgorithm> {
         let conn = connection::pg_connection_write(self).await?;
@@ -108,7 +108,7 @@ impl RoutingAlgorithmInterface for Store {
     #[instrument(skip_all)]
     async fn find_routing_algorithm_metadata_by_algorithm_id_profile_id(
         &self,
-        algorithm_id: &str,
+        algorithm_id: &common_utils::id_type::RoutingId,
         profile_id: &common_utils::id_type::ProfileId,
     ) -> StorageResult<routing_storage::RoutingProfileMetadata> {
         let conn = connection::pg_connection_write(self).await?;
@@ -186,14 +186,14 @@ impl RoutingAlgorithmInterface for MockDb {
     async fn find_routing_algorithm_by_profile_id_algorithm_id(
         &self,
         _profile_id: &common_utils::id_type::ProfileId,
-        _algorithm_id: &str,
+        _algorithm_id: &common_utils::id_type::RoutingId,
     ) -> StorageResult<routing_storage::RoutingAlgorithm> {
         Err(errors::StorageError::MockDbError)?
     }
 
     async fn find_routing_algorithm_by_algorithm_id_merchant_id(
         &self,
-        _algorithm_id: &str,
+        _algorithm_id: &common_utils::id_type::RoutingId,
         _merchant_id: &common_utils::id_type::MerchantId,
     ) -> StorageResult<routing_storage::RoutingAlgorithm> {
         Err(errors::StorageError::MockDbError)?
@@ -201,7 +201,7 @@ impl RoutingAlgorithmInterface for MockDb {
 
     async fn find_routing_algorithm_metadata_by_algorithm_id_profile_id(
         &self,
-        _algorithm_id: &str,
+        _algorithm_id: &common_utils::id_type::RoutingId,
         _profile_id: &common_utils::id_type::ProfileId,
     ) -> StorageResult<routing_storage::RoutingProfileMetadata> {
         Err(errors::StorageError::MockDbError)?
diff --git a/crates/router/src/routes/routing.rs b/crates/router/src/routes/routing.rs
index ecce0f96198..aefc91f759c 100644
--- a/crates/router/src/routes/routing.rs
+++ b/crates/router/src/routes/routing.rs
@@ -60,7 +60,7 @@ pub async fn routing_create_config(
 pub async fn routing_link_config(
     state: web::Data<AppState>,
     req: HttpRequest,
-    path: web::Path<String>,
+    path: web::Path<common_utils::id_type::RoutingId>,
     transaction_type: &enums::TransactionType,
 ) -> impl Responder {
     let flow = Flow::RoutingLinkConfig;
@@ -139,7 +139,7 @@ pub async fn routing_link_config(
 pub async fn routing_retrieve_config(
     state: web::Data<AppState>,
     req: HttpRequest,
-    path: web::Path<String>,
+    path: web::Path<common_utils::id_type::RoutingId>,
 ) -> impl Responder {
     let algorithm_id = path.into_inner();
     let flow = Flow::RoutingRetrieveConfig;