# How to Use the LinearB Incident API with PagerDuty | LinearB Blog

> Connect PagerDuty to LinearB to holistically track incidents across your organization. 

_This is a markdown rendering of a live HTML page on linearb.io, generated for AI/LLM consumption — it is not a markdown-only site. To get the full HTML page instead, request this URL with an explicit `Accept: text/html` header (no wildcard, no markdown preference)._


```json
{
  "@context": "https://schema.org",
  "@type": "BreadcrumbList",
  "itemListElement": [
    {
      "@type": "ListItem",
      "position": 1,
      "name": "Home",
      "item": "https://linearb.io/"
    },
    {
      "@type": "ListItem",
      "position": 2,
      "name": "Blog",
      "item": "https://linearb.io/blog"
    },
    {
      "@type": "ListItem",
      "position": 3,
      "name": "How to Use the LinearB Incident API with PagerDuty",
      "item": "https://linearb.io/blog/connect-pagerduty-to-linearb-incident-api"
    }
  ]
}
```

[Home](https://linearb.io/)

/

[Blog](https://linearb.io/blog)

/

How to Use the LinearB Incident API with PagerDuty

# How to Use the LinearB Incident API with PagerDuty

![Photo of Ben Lloyd Pearson](https://assets.linearb.io/image/upload/c_limit,w_3840/f_auto/q_auto/v1/blp_headshot_1_ee25d527aa?_a=BAVMn6ID0)

By [Ben Lloyd Pearson](https://linearb.io/blog/connect-pagerduty-to-linearb-incident-api#ben-lloyd-pearson)

|

February 14, 2024

![connect_pagerduty_14a3435dc1](https://assets.linearb.io/image/upload/c_limit,w_3840/f_auto/q_auto/v1/connect_pagerduty_14a3435dc1?_a=BAVMn6ID0)

Engineering leaders are constantly seeking new ways to gain deeper insights into their teams’ productivity and better understand the overall health of their engineering projects. LinearB provides a wealth of resources for engineering insights and intelligence, and we’ve tailored our dashboards to be the most configurable solution in the industry. One critical component of this flexibility is the Incident API, which enables you to upload custom incident reports into LinearB to give you a more holistic picture of your software delivery management, specifically related to metrics like change failure rate and mean time to restore.

PagerDuty is one of the most prevalent incident management solutions on the market, and it offers a ton of flexibility for alerting, on-call management, and incident resolution. PagerDuty provides outgoing webhooks for incident services. However, the data sent from PagerDuty doesn’t match the format that the LinearB API expects. This guide will show you how to connect PagerDuty to the LinearB Incident API so you can accurately track your team’s engineering efficiency.

## Overview

You'll need to set up a handful of services to connect PagerDuty to LinearB. We chose these services for this guide, but you can swap out most of the technologies in this list for your preferred solutions. This guide will show you how to orchestrate the following resources:

* [PagerDuty](https://www.pagerduty.com/) \- Generate incidents and transmit them to the ngrok server via webhooks for processing.
* [Ngrok](https://ngrok.com/) \- Maintain a publicly accessible web server that receives webhooks from PagerDuty.
* [Node.js](https://nodejs.org/en) \- Transform the data from PagerDuty to a format compatible with LinearB.
* [LinearB](http://linearb.io) \- Receive incident information via the API and make it available for tracking in dashboards.

Let’s get started!

## Ngrok Setup

[Ngrok](http://ngrok.com) is a popular ingress platform that makes it easy to set up web servers on your local machine that are publicly accessible via individualized URLs. Ngrok is an excellent tool for quickly testing and debugging new web services that need to integrate with external tools. We’ll use ngrok for this guide, but you can use any middleware solution or web server available. Whatever technology you use, ensure it can provide external API connections and run the code you need to transform the webhook data.

To start, [create an ngrok](https://dashboard.ngrok.com/) account and follow the [get started section](https://dashboard.ngrok.com/get-started/setup) of their dashboard to install and configure your local ngrok service. Once finished, you can then create a new ngrok ingress by running this command from your command line interface:

```
ngrok http 8080
```

You should now have a new ngrok ingress on port 8080\. Take note of the first URL in the Forwarding section because you’ll need it later.

![ngrok.png](https://assets.linearb.io/image/upload/v1720000000/ngrok_037d892491.png)

## LinearB Setup

To use the LinearB Incident API, you need to create a LinearB API token and configure LinearB to accept API requests for the Incident API. Here’s how to do it:

1. [Generate a LinearB API Token](https://linearb.helpdocs.io/article/79fmogrxw3-how-to-generate-release-api-tokens)
2. Enable the API Integration by going to Company Settings -> Advanced Settings -> Incidents Detection, and click API Integration. Remember to click Save!

![incident-api-config.gif](https://assets.linearb.io/image/upload/v1720000000/incident_api_config_7d2b39b08a.gif)

For more information about the LinearB Incident API, [visit the help docs](https://linearb.helpdocs.io/article/u7fbvwnqik-linear-b-incident-api).

You should also set up [service metrics](https://linearb.helpdocs.io/article/jndfgrkx0z-service-based-metrics) to map incidents to repositories, we recommend giving services the same name in PagerDuty and LinearB. This feature is only available to LinearB business and enterprise accounts. If you have a free LinearB account, this guide will provide an alternative solution later.

## PagerDuty Setup

In PagerDuty, ensure you have a [service configured to create incident alerts](https://support.pagerduty.com/docs/services-and-integrations). If you don’t, take a moment to create one now and configure it to your needs. Then, go to Integrations > Extensions, and click the New Extension button, and set the following parameters:

* **Extension Type** \- Select “Generic Webhook”
* **Name** \- Give the webhook a meaningful name.
* **Service** \- Select the incident service you want this webhook to trigger for.
* **URL** \- Your ngrok URL from earlier with “/webhook” appended to the end of it. For example: <https://7881-67-22-7-13.ngrok-free.app/webhook>

![Setup PagerDuty Webhooks.gif](https://assets.linearb.io/image/upload/v1720000000/Setup_Pager_Duty_Webhooks_2bc70d3f79.gif)

## Node.js

The last part of this demo is some JavaScript code to listen for PagerDuty webhooks, transform the data to the format LinearB expects, and submit it to the LinearB Incident API to include it in your analytics. 

Here is the full code example for this guide, we’ll dive into the details below.

```javascript
const axios = require('axios');
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const port = 8080; // Port your local server is running on
const apiKey = process.env.API_KEY; // Your LinearB API key
const apiUrl = 'https://public-api.linearb.io/api/v1/incidents';
  const headers = { // Set up the headers with the API token
    'x-api-key': apiKey,
    'Content-Type': 'application/json',
  };

// Middleware to parse incoming JSON data
app.use(bodyParser.json());

// Define the webhook endpoint
app.post('/webhook', (req, res) => {
  const webhookData = req.body; // Access the incoming webhook data
  const incident = webhookData.messages[0].incident;   // Access the properties of the PagerDuty incident object
  let requestURL = apiUrl;
  let requestData = {};

  if (incident.status === 'triggered') {   // Assign incident properties in the format LinearB expects
    console.log("Creating new incident: ", incident.id)
    requestData.provider_id = String(incident.id); // These properties are required
    requestData.http_url = String(incident.html_url);
    requestData.title = String(incident.title);
    requestData.issued_at = String(incident.created_at);
    requestData.services = [String(incident.service.name)];
  } else if (incident.status === 'acknowledged') {
    console.log("Updating existing incident: ", incident.id)
    requestData.started_at = String(incident.updated_at);
    requestURL += '/'+incident.id;
  } else if (incident.status === 'resolved') {
    console.log("Updating existing incident: ", incident.id)
    requestData.ended_at = String(incident.resolved_at);
    requestURL += '/'+incident.id;
  }
  console.log(requestData);
  // The LinearB API expects PATCH requests to update existing incidents and POST requests to create new incidents.
  if (incident.status === 'acknowledged' || incident.status === 'resolved') {
    axios.patch(requestURL, requestData, { headers })
      .then(response => {
        console.log('Incident ${incident.id} has been updated.');
      })
      .catch(error => {
        console.error('API error:', error.response.data);
      });
  } else if (incident.status === 'triggered') {
    axios.post(requestURL, requestData, { headers })
    .then(response => {
      console.log('Update Successful');
    })
    .catch(error => {
      console.error('API error:', error.response.data);
    });
  } else {
    console.log("No action taken for incident: ", incident.id)
  }
  // Respond to the webhook request if needed
  res.status(200).send('Webhook received successfully');
});
// Start the server
app.listen(port, () => {
  console.log(`Server is running on port ${port}`);
});
```

First, this code creates an Express.js app that listens for incoming webhooks to the /webhooks endpoint on port 8080.

```javascript
const app = express();
const port = 8080; // Port your local server is running on

// Middleware to parse incoming JSON data
app.use(bodyParser.json());

// Define the webhook endpoint
app.post('/webhook', (req, res) => {
});
app.listen(port, () => {
  console.log(`Server is running on port ${port}`);
});
```

When it receives a webhook, it ingests the PagedDuty incident information and detects if it is a new Incident, an incident acknowledgment, or an incident resolution, these values map to Open, In Progress, and Closed in LinearB. For each of these situations, the code extracts required data from PagerDuty and maps it to the values LinearB expects. For example, when something triggers a new incident, this code maps the id, html\_url, and created\_at values from PagerDuty to the provider\_id, http\_url, and issued\_at fields respectively and it passes through the title value without any modification; these are the fields LinearB requires to create a new incident. For example, here is the code that maps API data for a new PagerDuty incident.

```javascript
  if (incident.status === 'triggered') {   // Assign incident properties in the format LinearB expects
    console.log("Creating new incident: ", incident.id)
    requestData.provider_id = String(incident.id); // These properties are required
    requestData.http_url = String(incident.html_url);
    requestData.title = String(incident.title);
    requestData.issued_at = String(incident.created_at);
  }
```

Lastly, the code uses Axios to send the data to LinearB via the incident API. 

```javascript
// The LinearB API expects PATCH requests to update existing incidents and POST requests to create new incidents.
  if (incident.status === 'acknowledged' || incident.status === 'resolved') {
    axios.patch(requestURL, requestData, { headers })
      .then(response => {
        console.log('Incident ${incident.id} has been updated.');
      })
      .catch(error => {
        console.error('API error:', error.response.data);
      });
  } else if (incident.status === 'triggered') {
    axios.post(requestURL, requestData, { headers })
    .then(response => {
      console.log('Update Successful');
    })
    .catch(error => {
      console.error('API error:', error.response.data);
    });
  } else {
    console.log("No action taken for incident: ", incident.id)
  }
  // Respond to the webhook request if needed
  res.status(200).send('Webhook received successfully');
```

Here are a couple of additional things to note about this code:

* If you have port conflicts, you can change the port this runs on, but make sure you also update your ngrok ingress to forward to the port you specify.
* This code accesses your LinearB API key using an environment variable named API\_KEY. You can rename this variable to whatever works best for you; here is a guide on [working with environment variables in Node](https://www.twilio.com/blog/working-with-environment-variables-in-node-js-html).

## LinearB Free Users

If you are a free LinearB user, you won’t be able to use the Services feature in LinearB, so you’ll need to setup your integration to map PagerDuty services to repositories connected to LinearB. First, you need to remove this line from the code example:

```javascript
requestData.services = [String(incident.service.name)];
```

Then, at the top of the code, add this serviceMapping object that links git repos to specific PagerDuty services. Update the values to match your organization.

```javascript
// Update this list to map PagerDuty services to git repositories
const serviceMapping = {
  'Service1': ['https://github.com/org/repo1.git', 'https://github.com/org/repo1.git']
}
```

## Run the Code

For this guide, we’ll be the code in a file named server.js, but you can name the file anything you want. To run it, execute the following commands from your CLI:

```
npm init -y
npm install express --save
npm install body-parser --save
npm install axios --save
node server.js
```

You should now have a Node server running on the specified port.

## Reporting Incidents to LinearB

Now, you should have everything you need to begin receiving PagerDuty incident alerts inside LinearB. If you want to test this immediately, log into your PagerDuty dashboard and create a new incident for the service you configured in this guide. Once you create the incident, everything should automatically be handled on the backend to make the incident appear in LinearB.

![PagerDuty Test Incident.gif](https://assets.linearb.io/image/upload/v1720000000/Pager_Duty_Test_Incident_a12d8d193a.gif)

If you want to get started with LinearB, [sign up for a free account ](https://app.linearb.io/sign-up)today.

## Improve developer productivity with LinearB

Find us on

[](https://www.linkedin.com/company/linearb)
[](https://devinterrupted.substack.com/)

![blp_headshot_1_ee25d527aa](https://assets.linearb.io/image/upload/c_limit,w_3840/f_auto/q_auto/v1/blp_headshot_1_ee25d527aa?_a=BAVMn6ID0)

## Ben Lloyd Pearson

Ben hosts Dev Interrupted, a podcast and newsletter for engineering leaders, and is Director of DevEx Strategy at LinearB. Ben has spent the last decade working in platform engineering and developer advocacy to help teams improve workflows, foster internal and external communities, and deliver better developer experiences.

### Connect with

[](https://www.linkedin.com/in/benlloydpearson)
[](https://substack.com/@benlloydpearson)

## Your next read

[![Cover image for You can now measure AI ROI with LinearB](https://assets.linearb.io/image/upload/c_limit,w_3840/f_auto/q_auto/v1/Blog_Post_Name_2400x1256_1_dd1f47bae7?_a=BAVMn6ID0)](https://linearb.io/blog/ai-roi-dashboard)

Product

[You can now measure AI ROI with LinearB](https://linearb.io/blog/ai-roi-dashboard)

Today, we're launching the AI ROI dashboard in LinearB, live now for every customer with metrics builder enabled.

[![Cover image for AI ROI comes from measuring engineering outcomes on day one](https://assets.linearb.io/image/upload/c_limit,w_3840/f_auto/q_auto/v1/Blog_AI_ROI_comes_from_measuring_engineering_software_security_2400x1256_2c5eae0862?_a=BAVMn6ID0)](https://linearb.io/blog/kraken-nik-sudan-measure-ai-roi-engineering-outcomes)

Product

[AI ROI comes from measuring engineering outcomes on day one](https://linearb.io/blog/kraken-nik-sudan-measure-ai-roi-engineering-outcomes)

Kraken Engineering Operations Lead Nik Sudan details how to establish day-one data infrastructure to accurately measure AI ROI. Discover why raw token adoption...

[![Cover image for Best Appfire Flow alternatives in 2026](https://assets.linearb.io/image/upload/c_limit,w_3840/f_auto/q_auto/v1/Blog_Moving_beyond_flow_88c071e703?_a=BAVMn6ID0)](https://linearb.io/blog/flow-alternatives-2026)

Product

[Best Appfire Flow alternatives in 2026](https://linearb.io/blog/flow-alternatives-2026)

Flow provides DORA metrics, workflow diagnostics, and useful dashboards for engineering leadership. But it has real limitations, and the market has moved...

## Structured data

_Machine-readable metadata (JSON-LD) embedded in the page for search/AI context — not content rendered on the page itself._

```json
{
  "@context": "https://schema.org",
  "@type": "Organization",
  "name": "LinearB",
  "url": "https://linearb.io/",
  "logo": "https://assets.linearb.io/image/upload/v1715628027/logo-mark-lg.svg",
  "description": "LinearB is the engineering productivity platform that helps engineering leaders prove AI is improving throughput without sacrificing delivery confidence, flow efficiency, or developer experience.",
  "sameAs": [
    "https://www.linkedin.com/company/linearb"
  ],
  "award": [
    {
      "@type": "Award",
      "name": "LinearB is a Leader in the 2026 Gartner® Magic Quadrant™ for Developer Productivity Insight Platforms",
      "dateAwarded": "2026",
      "awardedBy": {
        "@type": "Organization",
        "name": "Gartner®"
      }
    },
    {
      "@type": "Award",
      "name": "Great Place to Work Certification",
      "dateAwarded": "2025-2027",
      "awardedBy": {
        "@type": "Organization",
        "name": "Great Place to Work"
      }
    },
    {
      "@type": "Award",
      "name": "America's Best Startup Employers 2025",
      "dateAwarded": "2025",
      "awardedBy": {
        "@type": "Organization",
        "name": "Forbes Magazine"
      }
    }
  ],
  "hasCertification": [
    {
      "@type": "Certification",
      "name": "SOC 1 Type 2"
    },
    {
      "@type": "Certification",
      "name": "SOC 2 Type 2"
    },
    {
      "@type": "Certification",
      "name": "GDPR Compliance certification"
    },
    {
      "@type": "Certification",
      "name": "ISO 27001"
    }
  ]
}
```

```json
{
  "@context": "https://schema.org",
  "@type": "Article",
  "headline": "How to Use the LinearB Incident API with PagerDuty",
  "url": "https://linearb.io/blog/connect-pagerduty-to-linearb-incident-api",
  "author": {
    "@type": "Person",
    "name": "Ben Lloyd Pearson"
  },
  "datePublished": "2024-02-14T15:55:21.809Z",
  "dateModified": "2024-02-14T15:55:21.809Z",
  "image": "https://assets.linearb.io/image/upload/v1720000000/connect_pagerduty_14a3435dc1.png",
  "publisher": {
    "@type": "Organization",
    "name": "LinearB",
    "logo": "https://assets.linearb.io/image/upload/v1777485755/linearb-logo-2026.png"
  },
  "description": "Connect PagerDuty to LinearB to holistically track incidents across your organization. "
}
```

## More on linearb.io

### Top navigation

- [Book a Demo](https://linearb.io/book-a-demo)
- [AI Code Reviews — Catch security risks, bugs, and spec mismatches](https://linearb.io/platform/ai-code-reviews)
- [AI & Productivity Insights — See how AI tools affect cycle time and delivery speed](https://linearb.io/platform/ai-developer-productivity-insights)
- [Measure AI Impact — Track AI adoption and tie it to delivery outcomes](https://linearb.io/use-case/measure-ai-impact)
- [MCP Server — Chat with your data to spot patterns and boost output](https://linearb.io/platform/mcp-server)
- [Resource Allocation — Cost initiatives and shape your investment strategy](https://linearb.io/platform/resource-allocation)
- [Cost Capitalization — Capitalize engineering costs with audit-ready reports](https://linearb.io/platform/cost-capitalization)
- [Dev Team Management — Set targets and tie throughput to business outcomes](https://linearb.io/platform/goals-and-reporting)
- [DevOps Workflow Automation — Policy-based PR routing, approvals, and tests](https://linearb.io/platform/ai-workflow-governance)
- [AI Powered Support — Unify AI and human code delivery in one clear view](https://linearb.io/use-case/ai-powered-support)
- [Optimization — Surface friction with feedback and MCP insights](https://linearb.io/platform/developer-experience)
- [Reporting — Spot what's working and what needs attention](https://linearb.io/use-case/measuring-developer-experience)
- [Surveys — Turn developer feedback into actionable signals](https://linearb.io/platform/developer-surveys)
- [Platform overview](https://linearb.io/platform/overview)
- [Register now](https://linearb.io/event/the-great-software-factory-debate-2)
- [Customers](https://linearb.io/customers)
- [Pricing](https://linearb.io/pricing)
- [Why choose LinearB — Explore your data. Measure performance. Act to improve it.](https://linearb.io/why-linearb)
- [APEX framework — The operating model for AI-era engineering teams](https://linearb.io/resources/apex-framework)
- [Anti-FAQ — The questions other vendors won't answer](https://linearb.io/why-linearb/anti-faq)
- [Security — Enterprise-grade compliance and zero code access](https://linearb.io/security)
- [Build vs. buy — The hidden cost of building it yourself](https://linearb.io/resources/build-vs-buy)
- [Dev Interrupted Podcast — Conversations with engineering leaders](https://linearb.io/dev-interrupted/podcasts)
- [Reports & Guides — Deep dives on productivity and delivery](https://linearb.io/resources)
- [Webinars — Expert sessions on productivity and AI](https://linearb.io/resources?category=workshops)
- [Metrics Benchmarks — See how your engineering org stacks up](https://linearb.io/resources/software-engineering-benchmarks-report)
- [Blog — Product updates and practical insights](https://linearb.io/blog)
- [Help Center — Documentation, setup, and support](https://linearb.helpdocs.io)
- [API Docs](https://docs.linearb.io/api-overview)
- [Status](https://www.linearbstatus.com/)
- [Integrations](https://linearb.io/integrations)
- [LinearB Library](https://linearb.io/library)
- [Engineering metrics](https://linearb.io/library/engineering-metrics)
- [Platform engineering](https://linearb.io/library/platform-engineering)
- [Engineering glossary](https://linearb.io/library/engineering-glossary)
- [Developer productivity](https://linearb.io/library/developer-productivity)
- [AI in software development](https://linearb.io/library/ai-in-software-development)
- [Engineering management](https://linearb.io/library/engineering-management)
- [Developer experience](https://linearb.io/library/developer-experience)
- [DevOps](https://linearb.io/library/devops)
- [Engineering operations and the context layer](https://linearb.io/library/engineering-operations)
- [Engineering efficiency](https://linearb.io/library/engineering-efficiency)
- [Software delivery](https://linearb.io/library/software-delivery)
- [Research and data](https://linearb.io/library/engineering-benchmarks-and-research)
- [LinearB is a Leader in the 2026 Gartner® Magic Quadrant™ for Developer Productivity Insight Platforms](https://linearb.io/resources/gartner-magic-quadrant-dpi-platforms-2026)
- [Sign in](https://app.linearb.io/login)
- [Enterprise](https://linearb.io/solutions/enterprise)
- [Contact](https://linearb.io/contact-us)
- [About us](https://linearb.io/about-us)
- [Careers](https://linearb.io/careers)
- [Service agreement](https://linearb.io/services-agreement)
- [Privacy policy](https://linearb.io/privacy-policy)
- [DPA](https://linearb.io/data-processing-agreement)
- [Security FAQ](https://linearb.io/security-faq)
- [Substack](https://devinterrupted.substack.com/)

### Footer

_Additional links from the site footer, not repeated from the top navigation above._

- [GitHub](https://github.com/linear-b)
- [LinkedIn](https://www.linkedin.com/company/linearb)
- [Twitter](https://twitter.com/LinearB_Inc)