Integrations

ServiceNow Opsgenie Integration Guide

intermediateAPI Key in Authorization headerOpsgenie

The ServiceNow Opsgenie integration connects ITSM incident management with modern alerting and on-call management, enabling organizations to automatically escalate critical incidents to the right responders while maintaining centralized ticket tracking. This integration is essential for DevOps teams, IT operations, and managed service providers who need to bridge traditional ITSM processes with modern incident response workflows. The integration supports bidirectional synchronization where ServiceNow incidents can automatically create Opsgenie alerts with proper team routing and escalation policies, while alert status changes in Opsgenie update corresponding ServiceNow incident states and work notes. Primary automation patterns include real-time incident-to-alert creation via REST API calls, webhook-based status synchronization, and scheduled batch updates, typically implemented through Flow Designer workflows, Business Rules, and Scripted REST APIs in the Integration Hub module.

Prerequisites

  • ServiceNow Paris release or later with Integration Hub Professional license
  • Opsgenie Standard or Enterprise plan with API access enabled
  • System Administrator role in ServiceNow with integration_hub_action_designer role
  • Opsgenie Admin or Configuration Manager permissions to create API keys
  • Active MID Server if ServiceNow instance is behind firewall (for inbound webhooks)
  • ITIL role for configuring incident management business rules and workflows
  • Knowledge of ServiceNow Flow Designer and REST Message configuration

Architecture Overview

The integration leverages ServiceNow's Integration Hub with custom REST Message records and Flow Designer actions to communicate with Opsgenie's REST API v2, as no official ServiceNow spoke exists for Opsgenie. Authentication is established using Opsgenie API keys stored in Connection & Credential Alias records with encrypted credential storage. Data flows bidirectionally with outbound calls triggered by ServiceNow incident state changes creating or updating Opsgenie alerts, while inbound webhook endpoints process Opsgenie alert status changes to update ServiceNow incidents. A MID Server is required only if the ServiceNow instance cannot receive direct inbound HTTPS traffic for webhook processing, otherwise cloud-to-cloud communication suffices. API rate limiting considerations include Opsgenie's default limit of 600 requests per minute per API key, requiring implementation of retry logic and request queuing for high-volume environments.

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 Opsgenie API Integration and retrieve credentials

Log into your Opsgenie console and navigate to Settings > Integrations > Add Integration, then select 'API' integration type. Configure the integration with a descriptive name like 'ServiceNow ITSM Integration' and assign it to the appropriate team that will receive alerts. Copy the generated API Key and note the Opsgenie API endpoint URL (typically https://api.opsgenie.com for US instances or https://api.eu.opsgenie.com for EU instances). Ensure the integration has permissions to create, update, and close alerts, and verify the assigned team has proper escalation policies configured.

2

Configure ServiceNow Connection and Credential Alias for Opsgenie

Navigate to Connections & Credentials > Credentials in ServiceNow and create a new Basic Auth credential record with name 'Opsgenie API Credential'. Set the User name field to any placeholder value (Opsgenie API doesn't use username) and paste the Opsgenie API key in the Password field. Next, go to Connections & Credentials > Connection & Credential Aliases and create a new record named 'Opsgenie Connection' with Type set to 'Connection and Credential', Connection URL set to your Opsgenie API endpoint, and Credential reference pointing to the credential created above. Test the connection to ensure credentials are properly stored and encrypted.

3

Create REST Message for Opsgenie alert creation

Navigate to System Web Services > Outbound > REST Messages and create a new REST Message named 'Opsgenie Alert Management'. Set the Endpoint to '${endpoint}/v2/alerts' using variable substitution. Create an HTTP Method named 'CreateAlert' with HTTP method POST, and configure the Authentication tab to use the Connection Alias created in the previous step. In the HTTP Headers tab, add Content-Type header with value 'application/json' and ensure the Authorization header is automatically populated from the credential alias. Set up variable substitutions for endpoint, alert message, description, priority, and tags to make the message reusable across different incident types.

ServiceNow Script
// Example REST Message variable default values
// endpoint: https://api.opsgenie.com
// message: ${incident.short_description}
// description: ${incident.description}
// priority: ${incident.priority}
// tags: ServiceNow,${incident.category}
4

Configure REST Message request body and response handling

In the CreateAlert HTTP method, configure the Content field with a JSON payload structure that maps ServiceNow incident fields to Opsgenie alert properties. Include essential fields like message, description, priority mapping (P1-P5 to Opsgenie P1-P5), tags for categorization, and custom properties for ServiceNow incident number and sys_id. Add error handling in the HTTP method by setting up proper response parsing and checking for HTTP status codes 200-202 for successful alert creation. Configure additional HTTP methods for 'UpdateAlert', 'CloseAlert', and 'GetAlert' operations using appropriate HTTP verbs (PUT, DELETE, GET) with dynamic alert ID substitution in the endpoint path.

ServiceNow Script
{
  "message": "${message}",
  "description": "${description}",
  "priority": "${priority}",
  "tags": ["${tags}"],
  "details": {
    "ServiceNow Incident": "${incident_number}",
    "ServiceNow SysID": "${incident_sys_id}",
    "Assignment Group": "${assignment_group}"
  },
  "entity": "${incident_number}",
  "source": "ServiceNow"
}
5

Create Flow Designer workflow for incident to alert automation

Navigate to Process Automation > Flow Designer and create a new Flow named 'ServiceNow to Opsgenie Alert Sync'. Set the trigger to 'Record Updated' on the Incident table with conditions for Priority 1 or 2 incidents and State changes to 'In Progress', 'On Hold', or 'Resolved'. Add a 'REST Step' action that calls the Opsgenie REST Message created earlier, mapping incident field values to the REST message variables using Flow Designer's data mapper. Include error handling logic with conditional branches to retry failed API calls and log integration failures to the System Log. Configure additional flow logic to store the returned Opsgenie alert ID in a custom incident field for future reference and bidirectional updates.

ServiceNow Script
// Flow Designer script step for priority mapping
(function execute(inputs, outputs) {
    var incidentPriority = inputs.incident_priority;
    var opsgeniePriority = 'P3'; // default
    
    switch(incidentPriority) {
        case '1': opsgeniePriority = 'P1'; break;
        case '2': opsgeniePriority = 'P2'; break;
        case '3': opsgeniePriority = 'P3'; break;
        case '4': opsgeniePriority = 'P4'; break;
        case '5': opsgeniePriority = 'P5'; break;
    }
    
    outputs.opsgenie_priority = opsgeniePriority;
})(inputs, outputs);
6

Implement Scripted REST API for Opsgenie webhook processing

Navigate to System Web Services > Scripted Web Services > Scripted REST APIs and create a new API named 'OpsgenieWebhookProcessor' with API ID 'opsgenie_webhook'. Create a Resource with name 'ProcessAlert', HTTP method POST, and Relative path '/alert'. Implement the script to parse incoming Opsgenie webhook payloads, extract alert status changes, and locate corresponding ServiceNow incidents using the stored Opsgenie alert ID or incident number from alert details. Include proper authentication verification by checking webhook signatures or API key headers, and implement comprehensive error handling with appropriate HTTP response codes. Add logging functionality to track all webhook processing for debugging and audit purposes.

ServiceNow Script
(function process(request, response) {
    try {
        var payload = request.body.data;
        var alertId = payload.alert.id;
        var alertStatus = payload.action; // 'Create', 'Close', 'Acknowledge'
        
        // Find corresponding incident
        var incidentGR = new GlideRecord('incident');
        incidentGR.addQuery('u_opsgenie_alert_id', alertId);
        incidentGR.query();
        
        if (incidentGR.next()) {
            if (alertStatus === 'Close') {
                incidentGR.incident_state = '6'; // Resolved
                incidentGR.close_code = 'Resolved by Opsgenie';
            } else if (alertStatus === 'Acknowledge') {
                incidentGR.incident_state = '2'; // In Progress
            }
            incidentGR.work_notes = 'Updated by Opsgenie: ' + alertStatus;
            incidentGR.update();
            response.setStatus(200);
        } else {
            response.setStatus(404);
        }
    } catch (e) {
        gs.error('Opsgenie webhook error: ' + e.message);
        response.setStatus(500);
    }
})(request, response);
7

Configure Opsgenie webhook and routing rules

Return to Opsgenie console and navigate to Settings > Integrations, then edit your ServiceNow API integration to add webhook configuration. Set the webhook URL to your ServiceNow instance followed by the Scripted REST API endpoint (e.g., https://yourinstance.service-now.com/api/x_12345_opsgenie/opsgenie_webhook/alert). Configure webhook triggers for alert status changes including 'Alert acknowledged', 'Alert closed', and 'Alert escalated' events. Set up team routing rules in Opsgenie to automatically assign alerts to appropriate teams based on ServiceNow incident categories or assignment groups passed in the alert details. Test the webhook connectivity using Opsgenie's webhook test feature and verify ServiceNow receives and processes the test payload correctly.

8

Test integration and implement monitoring

Create a test incident in ServiceNow with Priority 1 or 2 to trigger the Flow Designer workflow and verify an alert is created in Opsgenie with correct details and team assignment. Acknowledge or close the Opsgenie alert and confirm the ServiceNow incident updates accordingly via webhook processing. Navigate to System Logs > Outbound HTTP Requests to review REST API call logs and verify successful authentication and data transmission. Set up monitoring by creating a scheduled job to regularly sync alert statuses, implementing notification Business Rules for integration failures, and establishing metrics collection for integration performance tracking. Document the integration configuration and create runbooks for troubleshooting common issues and performing routine maintenance.

ServiceNow Script
// Monitoring script for scheduled execution
(function() {
    var restMessage = new sn_ws.RESTMessageV2('Opsgenie Alert Management', 'GetAlert');
    restMessage.setStringParameterNoEscape('endpoint', 'https://api.opsgenie.com');
    
    var response = restMessage.execute();
    if (response.getStatusCode() !== 200) {
        gs.error('Opsgenie integration health check failed: ' + response.getErrorMessage());
        // Send notification to integration team
    } else {
        gs.info('Opsgenie integration health check passed');
    }
})();

Common Use Cases

Critical incident escalation to on-call teams

High-priority ServiceNow incidents automatically create Opsgenie alerts with appropriate team routing based on assignment groups or categories. The integration maps ServiceNow priority levels to Opsgenie priority and applies relevant escalation policies to ensure critical issues reach the right responders immediately. Business value includes reduced mean time to response (MTTR) and improved compliance with SLA requirements through automated escalation workflows.

Major incident bridge coordination

When ServiceNow incidents are marked as major incidents, the integration creates Opsgenie alerts with special tags and routes them to incident commander teams while simultaneously creating conference bridge details in both systems. The workflow includes automatic stakeholder notification through Opsgenie's communication features and maintains centralized documentation in ServiceNow. This ensures coordinated response for business-critical outages with proper communication channels established automatically.

DevOps pipeline failure alerting

ServiceNow incidents created from monitoring system integrations trigger Opsgenie alerts targeted to specific DevOps teams based on affected services or applications identified in incident categorization. Custom fields in ServiceNow incidents populate Opsgenie alert details with deployment information, affected environments, and rollback procedures. The integration enables rapid response to production issues while maintaining audit trails and change management processes in ServiceNow.

Vendor escalation and external communication

ServiceNow incidents requiring vendor engagement automatically create Opsgenie alerts for vendor management teams with embedded vendor contact information and escalation procedures from the ServiceNow CMDB. The integration includes automated status updates back to ServiceNow when vendors acknowledge or provide updates through Opsgenie mobile apps. This streamlines third-party incident management while maintaining comprehensive documentation of vendor interactions and response times.

Follow-the-sun support handoff automation

Time-based routing rules in the integration automatically assign Opsgenie alerts to appropriate regional support teams based on ServiceNow incident creation time and customer location data. When regional teams go off-duty, unresolved alerts automatically escalate to the next timezone's support team while updating ServiceNow incident assignment groups accordingly. This ensures continuous coverage for global organizations with detailed handoff documentation and response time tracking across all regions.

Troubleshooting

401 Unauthorized error when creating Opsgenie alerts from ServiceNow

First verify the API key is correctly stored in the ServiceNow credential record by navigating to the Connection & Credential Alias and testing the connection. Check that the Opsgenie API key has not expired and has proper permissions for alert creation in the Opsgenie integration settings. Review the Outbound HTTP Request logs in ServiceNow to confirm the Authorization header is being sent correctly, and ensure the API endpoint URL matches your Opsgenie instance region (US vs EU).

ServiceNow incidents not updating when Opsgenie alerts are acknowledged or closed

Verify the webhook URL is correctly configured in Opsgenie and accessible from the internet by testing it with a REST client or browser. Check the ServiceNow System Log for webhook processing errors and confirm the Scripted REST API is active and properly parsing incoming JSON payloads. Ensure the incident records contain the Opsgenie alert ID in the designated field for proper correlation, and verify webhook authentication is correctly implemented if required by your ServiceNow security policies.

Flow Designer workflow not triggering for incident updates

Review the Flow execution history in Flow Designer to identify if the workflow is being triggered but failing at specific steps, or not triggering at all due to condition mismatches. Verify the trigger conditions match your incident update scenarios, particularly checking field values for priority, state, and assignment group filters. Check for Business Rule conflicts that might be preventing the Flow from executing, and ensure the Flow is active and the executing user has appropriate permissions for REST Message execution.

Duplicate alerts created in Opsgenie for the same ServiceNow incident

Implement deduplication logic in your Flow Designer workflow by checking if an Opsgenie alert ID already exists in the incident record before creating new alerts. Review Business Rule execution order to ensure incident updates don't trigger multiple Flow executions, and consider adding a custom field to track integration processing status. Use Opsgenie's alias feature in alert creation to prevent duplicates based on ServiceNow incident number, and implement proper error handling to avoid retry loops on failed API calls.

REST Message execution fails with SSL certificate errors

Navigate to System Properties and verify the 'com.glide.communications.httpclient.verify_revoked_certificate' property is set appropriately for your security requirements. Check if your ServiceNow instance requires a MID Server for outbound HTTPS connections due to firewall restrictions, and configure the REST Message to use the MID Server if necessary. Verify the Opsgenie API endpoint SSL certificate is valid and trusted, and consider importing the certificate chain into ServiceNow's certificate store if using self-managed infrastructure.

Webhook payloads from Opsgenie returning HTTP 500 errors in ServiceNow

Enable debug logging for the Scripted REST API and review detailed error messages in the System Log to identify specific JavaScript execution failures. Verify the webhook payload structure matches your parsing logic by logging the raw request body and comparing it to Opsgenie's webhook documentation. Check for null reference errors when accessing nested JSON properties, implement proper try-catch blocks around all database operations, and ensure the processing user has sufficient permissions to update incident records.

Pro Tips

  • Implement exponential backoff retry logic in your Flow Designer REST steps to handle Opsgenie API rate limiting gracefully, using Flow Designer's built-in retry mechanisms combined with custom delay calculations based on HTTP response headers. Store retry counts in incident work notes for visibility and set maximum retry limits to prevent infinite loops during extended API outages.
  • Create custom ServiceNow incident fields to store Opsgenie-specific metadata like alert ID, team assignments, and escalation policy names, enabling rich bidirectional data correlation and advanced reporting on integration effectiveness. Use these fields in ServiceNow dashboards to track response times and escalation patterns across different teams and incident types.
  • Configure Opsgenie alert descriptions with deep links back to ServiceNow incidents using URL templates, and include dynamic content like current incident state, assignment group, and resolution notes to provide responders with immediate context without switching systems. This reduces context switching and improves response efficiency during critical incidents.
  • Implement webhook signature verification in your Scripted REST API using HMAC validation to ensure webhook authenticity and prevent unauthorized incident updates from malicious sources. Store the webhook secret in ServiceNow's encrypted credential store and validate each incoming payload's signature before processing any data.
  • Use ServiceNow's Event Management integration alongside Opsgenie to create a comprehensive alerting ecosystem where monitoring events flow through Event Management rules into incidents, which then create Opsgenie alerts with enriched context from the CMDB and service maps. This provides multi-layered incident correlation and reduces alert noise.
  • Set up automated metrics collection by creating scheduled jobs that query both ServiceNow and Opsgenie APIs to generate integration health reports, tracking metrics like API response times, failed synchronizations, and average incident-to-alert creation time. Use these metrics to optimize integration performance and demonstrate business value to stakeholders.

Known Limitations

  • Opsgenie API rate limits are set at 600 requests per minute per API key, which can be restrictive for large ServiceNow instances with high incident volumes during major outages. The integration requires careful implementation of request queuing and batching strategies to avoid hitting these limits during peak usage periods.
  • Real-time bidirectional synchronization is dependent on webhook reliability and network connectivity, with potential delays of several minutes during network issues or Opsgenie service disruptions. ServiceNow administrators should implement fallback polling mechanisms and status reconciliation processes to handle synchronization gaps.
  • The integration cannot automatically sync Opsgenie user assignments back to ServiceNow incident assigned_to fields due to user identity mapping complexities between the two systems. Organizations must implement custom user correlation logic or accept that detailed assignment tracking remains system-specific, requiring manual coordination for complete audit trails.
  • Complex Opsgenie routing rules and escalation policies cannot be directly replicated in ServiceNow's assignment group logic, creating potential inconsistencies between the systems' understanding of incident ownership and responsibility. Integration architects must carefully design team mapping strategies to maintain operational clarity across both platforms.
  • Historical alert data synchronization is not supported through standard webhook mechanisms, requiring custom batch processing solutions for organizations migrating from other alerting systems or needing to backfill correlation data. This limitation affects reporting continuity and may require separate data migration projects to achieve complete historical integration.

Frequently Asked Questions

Can the integration automatically assign ServiceNow incidents to specific users based on Opsgenie team rosters and on-call schedules?

While the integration can sync alert acknowledgments and team assignments from Opsgenie back to ServiceNow, automatically updating the incident's assigned_to field requires custom development to map Opsgenie users to ServiceNow users. You'll need to implement additional REST API calls to retrieve on-call schedule information from Opsgenie and maintain a user mapping table in ServiceNow. Most organizations choose to update assignment groups rather than individual assignees to avoid the complexity of real-time user synchronization and identity management between platforms.

How does the integration handle ServiceNow incident updates that don't require Opsgenie alert changes, like work notes or time tracking updates?

The Flow Designer workflow should be configured with specific field change conditions to prevent unnecessary API calls to Opsgenie for administrative updates that don't affect alert status or priority. Best practice is to trigger Opsgenie updates only for state changes, priority escalations, assignment group modifications, or resolution events. You can implement this by using Flow Designer's field change detection capabilities and creating conditional logic that evaluates whether the specific field changes warrant external alert updates, reducing API call volume and improving performance.

What happens if the Opsgenie service is unavailable when ServiceNow tries to create or update alerts?

ServiceNow's REST Message framework will return HTTP error codes that can be handled in Flow Designer through error handling branches and retry logic. Implement exponential backoff retry mechanisms with maximum retry counts to handle temporary outages, and consider creating a queue table for failed alert operations that can be processed when connectivity is restored. For critical incidents, configure alternative notification methods like email or SMS through ServiceNow's notification engine as a fallback when Opsgenie integration fails, ensuring incident response continuity during service disruptions.

Can multiple ServiceNow instances integrate with the same Opsgenie account without conflicts?

Yes, multiple ServiceNow instances can integrate with the same Opsgenie account by using different API integration keys and implementing proper alert tagging or alias strategies to prevent conflicts. Each ServiceNow instance should create alerts with unique identifiers (such as instance name prefixes) and use distinct Opsgenie teams or integration endpoints to maintain separation. Configure webhook URLs to point to the appropriate ServiceNow instance based on alert source, and implement routing rules in Opsgenie that direct alerts to the correct teams based on the originating ServiceNow instance identifier embedded in alert details.

How can I customize the integration to support different alert priorities and escalation policies for various incident categories?

Implement category-based routing logic in your Flow Designer workflow by creating conditional branches that map ServiceNow incident categories to specific Opsgenie teams and priority levels. Use Flow Designer's script steps to build dynamic team assignments and tag arrays based on incident attributes like category, subcategory, and business service affected. Create lookup tables in ServiceNow that map incident characteristics to Opsgenie team names and escalation policies, allowing business users to maintain routing rules without modifying the integration code, and enabling different service lines to have customized alert handling procedures.

Does the integration support ServiceNow's Event Management module for automated alert correlation?

The integration can be extended to work with Event Management by configuring event processing rules that create incidents from correlated events, which then trigger Opsgenie alert creation through the same Flow Designer workflows. This creates a three-tier alerting system where raw monitoring events are correlated in Event Management, converted to incidents with business context, and then escalated to Opsgenie with enriched CMDB information. You can also implement reverse correlation by updating event records when Opsgenie alerts are acknowledged or resolved, providing comprehensive status visibility across the entire monitoring and incident response chain.

What are the security considerations for implementing ServiceNow to Opsgenie webhooks and API integrations?

Security best practices include storing all API credentials in ServiceNow's encrypted Connection & Credential Alias records, implementing webhook signature verification using HMAC authentication, and restricting Scripted REST API access through ACLs and IP whitelisting where possible. Configure the integration to use HTTPS for all communications, implement proper input validation and sanitization in webhook processors to prevent injection attacks, and regularly rotate API keys according to your security policies. Consider using ServiceNow's OAuth provider capabilities for more sophisticated authentication scenarios and implement comprehensive audit logging for all integration activities to support compliance and forensic analysis requirements.

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