Integrations

ServiceNow MuleSoft Integration Guide

advancedOAuth 2.0 Client CredentialsMuleSoft Anypoint Platform

ServiceNow MuleSoft integration enables enterprise-grade API-led connectivity between ServiceNow and external systems through MuleSoft Anypoint Platform, solving complex data synchronization and workflow automation challenges across hybrid IT landscapes. Organizations use this integration to orchestrate incident management workflows, synchronize CMDB data with authoritative sources, and enable real-time service catalog provisioning across multiple backend systems. The integration supports bi-directional data flows using MuleSoft's API-led connectivity approach, with ServiceNow acting as both data producer and consumer through REST APIs and webhook patterns. Primary automation triggers include incident state changes, CMDB CI updates, and service request approvals, with the integration living primarily in the Integration Hub and Scripted REST API modules within ServiceNow.

Prerequisites

  • ServiceNow Utah or later with Integration Hub Professional license
  • MuleSoft Anypoint Platform subscription with API Manager access
  • ServiceNow admin role or equivalent (admin, integration_admin)
  • MuleSoft Anypoint Platform Organization Administrator or API Manager Environment Administrator role
  • Network connectivity between ServiceNow instance and MuleSoft CloudHub (ports 443, 8081-8082)
  • ServiceNow REST API access enabled (com.snc.integration.rest plugin activated)
  • MuleSoft Runtime Fabric or CloudHub deployment target configured

Architecture Overview

The integration utilizes MuleSoft's ServiceNow connector within Anypoint Studio Mule flows, combined with ServiceNow's outbound REST capabilities and Scripted REST APIs for bi-directional communication. Authentication is established using OAuth 2.0 Client Credentials flow, with MuleSoft API credentials stored in ServiceNow Connection & Credential Aliases and ServiceNow OAuth tokens managed within MuleSoft Secure Properties. Data flows are triggered by ServiceNow Business Rules calling outbound REST messages to MuleSoft APIs, while inbound data from MuleSoft is processed through ServiceNow Scripted REST APIs with JSON payload transformation. A MID Server is not required since communication occurs over HTTPS REST APIs directly between cloud instances, but network ACLs must allow ServiceNow instance IPs to reach CloudHub endpoints. Rate limiting follows ServiceNow's standard REST API quotas (10,000 requests per hour for admin users) and MuleSoft's API Manager policies, with Circuit Breaker and Retry policies implemented in Mule flows for resilience.

Sourdough
Chrome Extension

Sourdough: ServiceNow Monitoring and Analytics

A Chrome extension for ServiceNow Admins and Developers with essential tools, analytics, graphs and monitoring features.

Instance HealthGraphs & ChartsAPI HealthDeveloper ToolsQuick SearchInstance Switcher
Add to Chrome

Free to install. Pro $5/month after a 14-day no-card trial.
Pro requires the ServiceNow admin role. Upgrade inside the extension.

Overview
Tasks
CMDB
API
Metrics
Monitor
Internals
Instance:sourdoughdev·Version:Yokohama
Instance StateONLINE
System StatusFully Operational
Session Timeout90 minutes
Logged-In Sessions2 (20 active)
Build Nameyokohama-12-18-2024_p1
IP Address10.159.128.43
Instance HealthHealth Score: 90%
🔥 5dSourdough (Chrome Plugin)Dark Mode

Implementation Steps

1

Create MuleSoft Anypoint Platform API credentials and client application

Navigate to Anypoint Platform Access Management > Connected Apps and create a new Connected App with OAuth 2.0 Client Credentials grant type. Configure the app with appropriate scopes including 'Design Center Developer', 'Runtime Manager Read Applications', and 'API Manager Viewer' based on your integration requirements. Note the generated Client ID and Client Secret values as these will be stored in ServiceNow Connection & Credential Aliases. Enable the app for your target environment (Sandbox/Production) and ensure the app has access to the specific APIs your ServiceNow integration will consume.

2

Configure ServiceNow Connection and Credential Alias for MuleSoft authentication

Navigate to Connections & Credentials > Credentials and create a new Basic Auth Credential record with the MuleSoft Client ID as username and Client Secret as password. Create a Connection Alias record pointing to your MuleSoft API endpoint (typically https://your-org.us-e1.cloudhub.io) and associate it with the credential record. Test the connection using the 'Test Connection' related link to verify network connectivity and credential validity. Set the Connection Timeout to 30000ms and Read Timeout to 60000ms to handle MuleSoft API response times appropriately.

3

Design and deploy MuleSoft Mule application with ServiceNow connector

In Anypoint Studio, create a new Mule Project and add the ServiceNow Connector from Exchange to your project dependencies. Configure the ServiceNow connector with your ServiceNow instance URL, username/password or OAuth credentials in a global configuration element. Design Mule flows with HTTP Listener for inbound requests from ServiceNow and ServiceNow connector operations for querying/updating ServiceNow records. Deploy the application to CloudHub with appropriate worker size (0.1 vCore minimum) and enable persistent queues for reliable message processing.

ServiceNow Script
<serviceNow:config name="ServiceNow_Config" doc:name="ServiceNow Config">
  <serviceNow:basic-connection username="${servicenow.username}" password="${servicenow.password}" serviceEndpoint="https://your-instance.service-now.com" />
</serviceNow:config>

<flow name="sync-incident-flow">
  <http:listener config-ref="HTTP_Listener_config" path="/incidents" />
  <serviceNow:invoke config-ref="ServiceNow_Config" operation="insert" table="incident" />
</flow>
4

Create ServiceNow REST Message for outbound calls to MuleSoft APIs

Navigate to System Web Services > Outbound > REST Message and create a new REST Message record named 'MuleSoft Integration'. Add HTTP Methods for each MuleSoft API endpoint you need to call (GET, POST, PUT, DELETE) with appropriate endpoint URLs like '${endpoint}/api/incidents'. Configure Authentication using the Connection Alias created in step 2 and set HTTP Headers including Content-Type: application/json and Accept: application/json. Create REST Message Functions for each HTTP method to enable easy calling from Business Rules and other server-side scripts.

ServiceNow Script
var rm = new RESTMessage('MuleSoft Integration', 'POST Incident');
rm.setStringParameterNoEscape('incident_data', JSON.stringify({
  'number': current.number.toString(),
  'short_description': current.short_description.toString(),
  'state': current.state.getDisplayValue(),
  'priority': current.priority.getDisplayValue()
}));
rm.setRequestHeader('Content-Type', 'application/json');
var response = rm.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
5

Implement ServiceNow Business Rules for outbound incident synchronization

Navigate to System Definition > Business Rules and create a new async Business Rule on the Incident table with conditions for Insert and Update operations. Configure the rule to trigger 'After' the database operation to ensure data consistency, and add conditions to filter relevant incidents (e.g., Priority 1-2, Active = true). In the script section, implement the REST Message call to send incident data to MuleSoft, including proper error handling and logging to the System Log. Use gs.eventQueue() for async processing to avoid blocking the user interface and implement retry logic for failed API calls.

ServiceNow Script
(function executeRule(current, previous) {
  try {
    var rm = new RESTMessage('MuleSoft Integration', 'POST Incident');
    var incidentPayload = {
      sys_id: current.sys_id.toString(),
      number: current.number.toString(),
      state: current.state.toString(),
      priority: current.priority.toString(),
      assigned_to: current.assigned_to.getDisplayValue()
    };
    rm.setStringParameterNoEscape('incident_data', JSON.stringify(incidentPayload));
    var response = rm.execute();
    
    if (response.getStatusCode() != 200) {
      gs.error('MuleSoft API call failed: ' + response.getErrorMessage());
    }
  } catch (ex) {
    gs.error('Exception in MuleSoft integration: ' + ex.getMessage());
  }
})(current, previous);
6

Create ServiceNow Scripted REST API for inbound data from MuleSoft

Navigate to System Web Services > Scripted Web Services > Scripted REST APIs and create a new API named 'MuleSoft Inbound Services'. Add HTTP Method resources for POST operations with paths like '/incidents/{sys_id}' and '/cmdb/ci/{ci_class}' to handle different data types from MuleSoft. Configure security with Basic Authentication or OAuth and implement input validation to ensure data integrity. In the script implementation, use GlideRecord operations to create or update ServiceNow records based on the JSON payload, including field mapping and data transformation logic.

ServiceNow Script
(function process(request, response) {
  var requestBody = request.body.data;
  var payload = JSON.parse(requestBody);
  
  var gr = new GlideRecord('incident');
  if (gr.get(payload.sys_id)) {
    gr.setValue('work_notes', 'Updated from MuleSoft: ' + payload.external_notes);
    gr.setValue('u_external_ref', payload.external_reference);
    gr.update();
    
    response.setStatus(200);
    response.setBody({status: 'success', sys_id: gr.getUniqueValue()});
  } else {
    response.setStatus(404);
    response.setBody({error: 'Incident not found'});
  }
})(request, response);
7

Configure CMDB CI synchronization with MuleSoft data transformation

Create dedicated REST Message and Business Rule combinations for CMDB CI synchronization, focusing on cmdb_ci_server, cmdb_ci_service, and cmdb_ci_database tables. Navigate to Configuration > Base Items > Configuration Items and identify the CI classes that require external system synchronization through MuleSoft. Implement data mapping logic in your Mule flows to transform external CMDB data into ServiceNow's CI schema, including relationship mapping for CI dependencies. Configure the Business Rules to trigger on CI lifecycle events (Installed, In Use, Retired) and use the Discovery Status field to track synchronization state with external systems.

ServiceNow Script
var ciGr = new GlideRecord('cmdb_ci_server');
if (ciGr.get('name', payload.hostname)) {
  ciGr.setValue('cpu_count', payload.cpu_cores);
  ciGr.setValue('ram', payload.memory_gb * 1024);
  ciGr.setValue('os', payload.operating_system);
  ciGr.setValue('discovery_source', 'MuleSoft Integration');
  ciGr.setValue('last_discovered', new GlideDateTime());
  ciGr.update();
} else {
  ciGr.initialize();
  ciGr.setValue('name', payload.hostname);
  ciGr.setValue('ip_address', payload.primary_ip);
  ciGr.setValue('install_status', '1'); // Installed
  ciGr.insert();
}
8

Implement error handling and monitoring with ServiceNow Event Management

Navigate to Event Management > Events and create custom event definitions for MuleSoft integration failures, including 'mulesoft.api.timeout', 'mulesoft.auth.failure', and 'mulesoft.data.validation.error'. Configure Event Rules to automatically create incidents or notifications when integration errors occur, with appropriate assignment groups and escalation procedures. Implement comprehensive logging in your Business Rules and Scripted REST APIs using gs.info(), gs.warn(), and gs.error() with structured messages for easy monitoring. Set up CloudHub monitoring in MuleSoft to send alerts back to ServiceNow when Mule applications experience performance degradation or failures, creating a bi-directional monitoring feedback loop.

ServiceNow Script
// Error handling in Business Rule
try {
  var response = rm.execute();
  if (response.getStatusCode() >= 400) {
    gs.eventQueue('mulesoft.api.error', current, 
      response.getStatusCode(), response.getErrorMessage());
  }
} catch (ex) {
  var event = new GlideRecord('sysevent');
  event.initialize();
  event.setValue('event_name', 'mulesoft.integration.exception');
  event.setValue('source', 'Incident Business Rule');
  event.setValue('description', ex.getMessage());
  event.setValue('additional_info', current.getUniqueValue());
  event.insert();
}

Common Use Cases

Automated incident enrichment with external monitoring data

ServiceNow receives incident alerts from monitoring tools via MuleSoft, which enriches the incident with CI relationship data, historical performance metrics, and suggested resolution steps from knowledge bases. MuleSoft aggregates data from multiple monitoring sources (Nagios, SolarWinds, Datadog) and applies business logic to determine incident priority and assignment. The integration automatically updates incident work notes with real-time infrastructure status and creates parent-child incident relationships for related infrastructure failures. This reduces mean time to resolution by 40-60% through automated context gathering and intelligent routing to appropriate resolver groups.

Real-time CMDB synchronization with cloud infrastructure

MuleSoft polls cloud providers (AWS, Azure, Google Cloud) every 15 minutes to discover new instances, containers, and services, then synchronizes this data with ServiceNow CMDB CI tables. The integration maintains accurate CI relationships, tracks configuration changes, and updates CI lifecycle states based on cloud resource status. Business Rules trigger on CI state changes to automatically update dependent services and notify change management teams of infrastructure modifications. This ensures CMDB accuracy rates above 95% and enables automated impact analysis for change requests and incident management.

Service catalog provisioning with backend system orchestration

ServiceNow service catalog requests trigger MuleSoft workflows that orchestrate provisioning across multiple backend systems including Active Directory, VMware vCenter, and enterprise databases. MuleSoft handles complex approval workflows, resource allocation validations, and multi-system transaction coordination while updating ServiceNow request items with detailed provisioning status. The integration supports rollback procedures for failed provisioning attempts and maintains audit trails across all integrated systems. Request fulfillment time is reduced by 70% through automated orchestration and real-time status updates to end users.

Change management integration with CI/CD pipelines

Development teams create ServiceNow change requests through MuleSoft APIs that automatically populate technical details from Git repositories, Jenkins build information, and deployment target configurations. MuleSoft validates change request data against enterprise architecture standards and automatically schedules deployments based on change approval workflows. The integration updates change requests with deployment status, rollback procedures, and post-deployment validation results from automated testing frameworks. This creates seamless integration between ITIL change management processes and DevOps practices while maintaining compliance and audit requirements.

Customer service case escalation with enterprise system data

Customer service cases in external CRM systems trigger ServiceNow incident creation through MuleSoft when technical escalation is required, automatically including customer contract details, service entitlements, and product configuration data. MuleSoft enriches incidents with relevant customer interaction history, known product issues, and escalation procedures based on service level agreements. The integration maintains bi-directional updates between CRM and ServiceNow systems, ensuring customer service representatives have real-time visibility into technical resolution progress. This improves customer satisfaction scores by 25-30% through faster escalation and better communication between business and technical support teams.

Troubleshooting

OAuth token expiration causing 401 Unauthorized errors in MuleSoft ServiceNow connector

Check the MuleSoft application logs in CloudHub for authentication failures and verify the OAuth token refresh mechanism is configured correctly. Navigate to ServiceNow OAuth Application Registry and confirm the refresh token has not expired and the client application is still active. Implement proper token refresh logic in your Mule flows using the OAuth module's automatic refresh capability, and monitor the oauth2:authorization-code-grant-type configuration for proper client credentials and token endpoint URLs.

ServiceNow Business Rule REST Message calls timing out with MuleSoft CloudHub endpoints

Increase the REST Message timeout values by navigating to the REST Message record and setting Connection Timeout to 60000ms and Read Timeout to 120000ms to accommodate CloudHub response times. Review MuleSoft application performance in Anypoint Monitoring and consider increasing CloudHub worker size if CPU/memory utilization exceeds 80%. Implement async processing in ServiceNow using gs.eventQueue() to prevent user interface blocking, and add circuit breaker patterns in MuleSoft flows to handle downstream system latency.

CMDB CI data synchronization creates duplicate records despite unique key matching

Verify the CI identification rules in ServiceNow by navigating to Configuration > CI Class Manager and reviewing the Identification Rules for your CI classes to ensure proper matching attributes. Check MuleSoft data transformation logic to ensure consistent data formatting, especially for hostname, IP address, and serial number fields that commonly serve as unique identifiers. Implement data cleansing logic in Mule flows to handle variations in data format (uppercase/lowercase, leading/trailing spaces) and add duplicate detection using GlideRecord.get() with multiple matching criteria before creating new CI records.

Scripted REST API receiving malformed JSON payload from MuleSoft applications

Enable request/response logging in the Scripted REST API by adding gs.info() statements to capture the raw request body and validate JSON structure using try-catch blocks around JSON.parse() operations. Review MuleSoft DataWeave transformations to ensure proper JSON output format and validate against ServiceNow field types and length restrictions. Add input validation logic in the Scripted REST API to check for required fields and return meaningful error messages with HTTP 400 status codes for malformed requests, and implement schema validation using ServiceNow's GlideJSONParser for complex payload structures.

Integration Hub Connection Alias test failing with SSL certificate errors

Verify that MuleSoft CloudHub endpoints use valid SSL certificates by checking the certificate chain in a browser or using openssl commands from the ServiceNow instance. Navigate to Certificates in ServiceNow and import any intermediate certificates required for the MuleSoft endpoint if using private or internal certificate authorities. Configure the Connection Alias to skip certificate validation temporarily for testing, then implement proper certificate trust by adding the CloudHub certificate to ServiceNow's trusted certificate store, and ensure the Common Name or Subject Alternative Name matches the endpoint hostname exactly.

MuleSoft API rate limiting causing 429 Too Many Requests errors during bulk data synchronization

Implement rate limiting controls in ServiceNow Business Rules by adding delays using gs.sleep() or implementing queue-based processing to distribute API calls over time rather than sending bulk requests simultaneously. Configure MuleSoft API Manager policies including Rate Limiting and Throttling to set appropriate request limits per client and implement Spike Control policies to handle burst traffic. Add retry logic with exponential backoff in ServiceNow REST Message calls and MuleSoft flows, and consider implementing batch processing endpoints in MuleSoft that can handle multiple records per API call to reduce the total number of requests.

Pro Tips

  • Implement MuleSoft Object Store for caching ServiceNow session tokens and frequently accessed CI data to reduce API call volume by up to 60%, especially for real-time lookup operations during incident enrichment workflows.
  • Use ServiceNow Transform Maps with REST Message responses to automatically populate related tables and maintain referential integrity when synchronizing complex CI relationships through MuleSoft data aggregation flows.
  • Configure MuleSoft Anypoint MQ for reliable message delivery when processing high-volume ServiceNow events, implementing dead letter queues for failed processing attempts and enabling message persistence during CloudHub application deployments.
  • Leverage ServiceNow's Domain Separation feature with MuleSoft multi-tenant applications by implementing domain-specific REST endpoints and credential management to isolate data flows for different business units or customers.
  • Implement correlation IDs using ServiceNow's Correlation Display and MuleSoft's correlation-id header to enable end-to-end transaction tracing across distributed systems, making troubleshooting and performance analysis significantly easier.
  • Use MuleSoft's Secure Configuration Properties combined with ServiceNow's Encrypted Credentials to implement field-level encryption for sensitive data in transit, ensuring compliance with data protection regulations during cross-system synchronization.

Known Limitations

  • MuleSoft ServiceNow connector supports table operations but has limited support for complex ServiceNow features like Business Rules execution, Workflow activities, or Flow Designer actions, requiring custom REST API implementations for advanced functionality. The connector does not support ServiceNow's Import Set transformations or advanced ACL processing, potentially bypassing important data validation and security controls.
  • ServiceNow REST API rate limits apply to MuleSoft connections with standard limits of 10,000 requests per hour for admin users, but bulk operations may consume quotas rapidly during large-scale CMDB synchronization. CloudHub worker performance directly impacts integration throughput, with 0.1 vCore workers handling approximately 100-200 concurrent API calls, requiring careful capacity planning for high-volume scenarios.
  • Real-time data synchronization is limited by ServiceNow's outbound REST Message execution time limits (30 seconds default) and MuleSoft's timeout configurations, making true real-time integration challenging for complex data transformations. Async Business Rules and event-driven architectures introduce eventual consistency patterns that may not be suitable for all use cases requiring immediate data consistency.
  • ServiceNow Integration Hub Professional license is required for advanced connection management and credential encryption features, limiting organizations on Standard licenses to basic authentication methods and manual credential management. MuleSoft Anypoint Platform pricing scales with API call volume and data throughput, potentially creating significant costs for high-frequency synchronization scenarios.

Frequently Asked Questions

Can MuleSoft access ServiceNow attachment data and how should large file transfers be handled?

MuleSoft can access ServiceNow attachments through the Attachment API (/api/now/attachment), but file size limits apply based on CloudHub worker memory and ServiceNow instance limits (typically 25MB per attachment). For large files, implement streaming patterns using MuleSoft's file connector with temporary storage in Object Store or external file systems. Consider using ServiceNow's Export Sets for bulk attachment transfers and implement chunked upload patterns for files exceeding CloudHub memory limits.

How does the integration handle ServiceNow table access controls and field-level security?

The integration inherits ServiceNow ACL restrictions based on the authenticated user account, so MuleSoft API calls respect table-level and field-level security configured in ServiceNow. Create dedicated integration user accounts with appropriate roles (integration_admin, rest_service) and avoid using admin accounts to maintain security boundaries. Test ACL behavior thoroughly in sub-production instances and implement proper error handling for 403 Forbidden responses when accessing restricted data through MuleSoft flows.

What is the recommended approach for handling ServiceNow choice list values and reference fields in MuleSoft transformations?

Use ServiceNow's display value APIs by appending '?displayvalue=all' to REST endpoints to retrieve both internal values and display labels for choice lists and reference fields. Implement lookup tables in MuleSoft using DataWeave or Object Store to map external system values to ServiceNow choice list values, and validate reference field values using ServiceNow's Table API before inserting records. Consider using ServiceNow's Import Set tables with Transform Maps for complex field mappings that require server-side validation and coercion.

How can we implement bi-directional synchronization while avoiding infinite update loops between ServiceNow and external systems through MuleSoft?

Implement update flags or timestamp-based change detection using custom fields like 'u_last_mulesoft_sync' in ServiceNow records and corresponding tracking in external systems. Use ServiceNow Business Rule conditions to exclude updates triggered by MuleSoft integration user accounts, and implement idempotency checks in MuleSoft flows using correlation IDs and Object Store for duplicate detection. Configure different update pathways for human-initiated changes versus system-generated updates, and implement conflict resolution strategies with 'last writer wins' or manual review queues for conflicting updates.

What monitoring and alerting capabilities are available for ServiceNow-MuleSoft integration health?

ServiceNow Event Management can receive alerts from MuleSoft through custom REST endpoints, while Anypoint Monitoring provides application performance metrics and can send webhook notifications to ServiceNow for application failures or performance degradation. Implement custom health check endpoints in MuleSoft applications that ServiceNow can periodically probe using scheduled REST Message calls. Use ServiceNow's System Log and Outbound HTTP Request log tables for integration debugging, and configure MuleSoft Runtime Manager alerts for worker CPU, memory, and message processing failures to create incidents automatically in ServiceNow.

How should we handle ServiceNow instance upgrades and MuleSoft application compatibility?

Test MuleSoft applications against ServiceNow clone instances during upgrade preview periods, focusing on REST API compatibility and authentication methods that may change between ServiceNow versions. Implement versioned REST endpoints in ServiceNow Scripted REST APIs to maintain backward compatibility during transition periods, and use MuleSoft's environment promotion features to deploy updated applications to match ServiceNow upgrade timelines. Monitor ServiceNow release notes for REST API changes and deprecation notices, and maintain separate MuleSoft applications for different ServiceNow versions if running multi-instance environments with staggered upgrade schedules.

What are the best practices for testing ServiceNow-MuleSoft integrations in development and staging environments?

Use ServiceNow's clone refresh capabilities to maintain realistic test data while ensuring MuleSoft applications point to appropriate development endpoints through environment-specific configuration properties. Implement comprehensive test suites in MUnit for MuleSoft applications that mock ServiceNow responses and validate data transformation logic independently of ServiceNow connectivity. Create test scenarios that cover ServiceNow Business Rule execution, ACL enforcement, and error conditions like network timeouts or authentication failures, and use ServiceNow's ATF (Automated Test Framework) to validate integration endpoints and data consistency across system boundaries.

Test Your Knowledge

Quick 3-question quiz — see how your ServiceNow skills stack up.

Question 1 of 3Performance

A list view on a table with millions of records is slow. Best fix?

Select an answer to continue