{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":49276,"path":"servicenow-platform/servicenow-platform/Chunk1136022586.md","title":"Automating creating tag-based relationship mapping within API Insights","bundle":null,"doc_type":null,"release":"australia","body":"\n# Automating creating tag-based relationship mapping within API Insights\n\nYou can configure and automate creating CMDB relationships between APIs and application services or business applications based on API tags.\n\nTag-based relationship mapping enables CMDB administrators and enterprise architects to define rules that automatically create CMDB relationships between APIs and application services or business applications based on API tags. Each rule specifies how a tag on a source CI is matched to a field on a target CI, and which relationship type and direction to create. Rules are stored in the Tag Based Relationship Mapping \\[sn\\_api\\_insights\\_ws\\_tag\\_relationship\\_mapping\\] table, enabling automatic mapping of multiple APIs to application services or business contexts.\n\nYou can use tag-based relationship mapping for:\n\n-   Relating APIs to application services using a tag, such as a service name.\n-   Linking APIs or components to business applications by matching a tag to an external ID field.\n-   Standardizing relationship creation across different environments.\n\nTo create CMDB relationships between APIs and application services or business applications based on API tags, follow these steps:\n\n1.  [Define tag-based mapping rules](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown).\n2.  [Schedule the tag-based mapping rule](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown).\n\n## Define tag-based mapping rules\n\nEstablish relationships between APIs and application services by defining tag-based mapping rules for APIs available within the API Insights application.\n\n### Before you begin\n\nRole required: sn\\_cmdb\\_admin or sn\\_api\\_insights\\_ws.api\\_mgmt\\_architect\n\n### About this task\n\nTag-based mapping rules enable you to automatically create relationships between APIs and application services or business applications based on tags. To define a tag-based mapping rule, you need to create a tag relationship mapping record that specifies the source and target CI classes and the relationship details.\n\n### Procedure\n\n1.  In the navigation filter of the application navigator, enter `sn_api_insights_ws_tag_relationship_mapping.list` and press the Enter key.\n\n2.  On the Tag Relationship Mappings page, select **New**.\n\n3.  On the form, fill in the fields.\n\n    |Field|Description|\n    |-----|-----------|\n    |Name|Name for the relationship.|\n    |Source Class|CI class including **API**, **API Component**, **API Frontend**, **API Backend**, or **Managed API** that contains the tag as the source of the relationship.|\n    |Target Class|CI class including **Application Service** or **Business Application** that the source CI is related to as the target of the relationship.|\n    |Relationship Type|Type of relationship established between the source CI and the target CI.|\n    |Tag Key|Key from the Key Value \\[cmdb\\_key\\_value\\] table that corresponds to the target CI field.|\n    |Target Match Field|Field on the target CI that matches the tag value.|\n    |Parent Class Role|CI that acts as the parent in the relationship, either source or target.|\n    |Active|Option to enable the relationship.|\n\n4.  Select **Submit**.\n\n\n## Scheduling the tag-based mapping rules\n\nYou can use a scheduled job to automatically create CMDB relationships between APIs and application services or business applications based on API tags.\n\nScheduled jobs automate tasks that run at a specific time or on a recurring schedule. You need the admin role to configure and run a scheduled job. For more information on configuring a scheduled job, see [Scheduled jobs](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/c_ScheduledJobs.md).\n\nThe **Tag based relationship mapping** scheduled job is available to schedule applying tag-based mapping rules between APIs and application services or business applications. By default, this job is inactive. As a user with the admin role, you can configure and activate it to run at regular intervals.\n\nFor each active tag-based relationship rule, the **Tag based relationship mapping** scheduled job processes active rules with the following workflow:\n\n-   Uses the specified tag key to retrieve relevant source CI tags.\n-   Identifies target CIs where the target CI's matching field matches the tag value.\n-   Creates the specified relationship type between the source and target CIs in the direction indicated by the `parent_class_role` setting.\n-   Avoids duplicating existing relationships.\n\nBy automating the process of creating relationships based on tags, the **Tag-based relationship mapping** scheduled job enables maintaining up-to-date and accurate mappings between APIs and related application services or business applications.\n\n"}}