# PagerDuty

PagerDuty is an incident management and response platform that helps teams detect, triage, and resolve infrastructure and application issues. The Sling PagerDuty connector extracts data from the PagerDuty REST API v2, supporting incidents, services, users, teams, escalation policies, schedules, on-calls, log entries, notifications, and more.

{% hint style="success" %}
**CLI Pro Required**: APIs require a [CLI Pro token](https://docs.slingdata.io/sling-cli/cli-pro) or [Platform Plan](https://docs.slingdata.io/sling-platform/platform).
{% endhint %}

## Setup

The following credentials and inputs are accepted:

**Secrets:**

* `api_key` **(required)** -> Your PagerDuty REST API Key

**Inputs:**

* `anchor_date` (optional) -> The starting date for historical data extraction (default: 1 year ago). Format: `YYYY-MM-DDTHH:MM:SSZ`

### Getting Your API Key

1. Log in to your PagerDuty account
2. Navigate to **Integrations** > **API Access Keys** (or go to `https://<your-subdomain>.pagerduty.com/api_keys`)
3. Click **Create New API Key**
4. Enter a description (e.g., "Sling Integration")
5. Check **Read-only API Key** (recommended for data extraction)
6. Click **Create Key** and copy the key immediately (it won't be shown again)

### Using `sling conns`

{% code overflow="wrap" %}

```bash
sling conns set PAGERDUTY type=api spec=pagerduty \
  secrets='{ api_key: your_api_key_here }'
```

{% endcode %}

### Environment Variable

See [here](https://docs.slingdata.io/sling-cli/environment#dot-env-file-.env.sling) to learn more about the `.env.sling` file.

{% code overflow="wrap" %}

```bash
export PAGERDUTY='{ type: api, spec: pagerduty, secrets: { api_key: "your_api_key_here" } }'
```

{% endcode %}

### Sling Env File YAML

See [here](https://docs.slingdata.io/sling-cli/environment#sling-env-file-env.yaml) to learn more about the sling `env.yaml` file.

```yaml
connections:
  PAGERDUTY:
    type: api
    spec: pagerduty
    secrets:
      api_key: "your_api_key_here"
```

**With anchor date for historical data:**

```yaml
connections:
  PAGERDUTY:
    type: api
    spec: pagerduty
    secrets:
      api_key: "your_api_key_here"
    inputs:
      anchor_date: "2024-01-01T00:00:00Z"
```

## Replication

Here's an example replication configuration to sync PagerDuty data to a PostgreSQL database:

```yaml
source: PAGERDUTY
target: MY_POSTGRES

defaults:
  mode: full-refresh
  object: pagerduty.{stream_name}

streams:
  # Reference data
  users:
  teams:
  services:
  escalation_policies:
  schedules:
  priorities:
  tags:
  business_services:
  oncalls:
  vendors:

  # Incremental event data
  incidents:
    mode: incremental
  log_entries:
    mode: incremental
  notifications:
    mode: incremental
```

**Sync all endpoints:**

```yaml
source: PAGERDUTY
target: MY_POSTGRES

defaults:
  mode: full-refresh
  object: pagerduty.{stream_name}

streams:
  '*':
```

## Endpoints

| Endpoint              | Description                                   | Incremental |
| --------------------- | --------------------------------------------- | ----------- |
| `users`               | All users in the account                      | No          |
| `teams`               | All teams                                     | No          |
| `services`            | All services (monitored resources)            | No          |
| `escalation_policies` | All escalation policies                       | No          |
| `schedules`           | All on-call schedules                         | No          |
| `priorities`          | All priority levels                           | No          |
| `vendors`             | Available integration vendors                 | No          |
| `tags`                | All tags                                      | No          |
| `business_services`   | All business services                         | No          |
| `oncalls`             | Current on-call entries (flattened)           | No          |
| `incidents`           | All incidents, filtered by last status change | Yes         |
| `log_entries`         | Incident log entries (audit trail)            | Yes         |
| `notifications`       | Notifications sent to users                   | Yes         |

To discover available endpoints:

```bash
sling conns discover PAGERDUTY
```

## Rate Limiting

The PagerDuty API has rate limits that vary by plan. The connector automatically:

* Uses conservative rate limiting (5 requests/second)
* Limits concurrency to 3 parallel requests
* Retries with exponential backoff on 429 (rate limit) responses
* Retries on 5xx server errors

## EU Region

For PagerDuty accounts hosted in the EU region, the API base URL is different (`https://api.eu.pagerduty.com`). Contact support if you need EU region support.

If you are facing issues connecting, please reach out to us at <support@slingdata.io>, on [discord](https://discord.gg/q5xtaSNDvp) or open a Github Issue [here](https://github.com/slingdata-io/sling-cli/issues).
