# 監控整合 API 參考

Source: https://instatus.com/help/zh-tw/api/monitoring-integrations

你可以透過 REST API 以程式方式建立第三方監控整合。

## 建立整合

**端點：**

```bash
POST /v3/integrations
```

**內容參數**

| 欄位 | 型別 | 說明 |
| ----- | ---- | ----------- |
| `pageId` | `string` | 狀態頁的 ID |
| `integrationType` | `string` | 整合類型，例如 `PINGDOM`、`NEWRELIC` |
| `components` | `string[]` | 要附加的元件 ID |

**請求範例**

```json
{
  "pageId": "page123",
  "integrationType": "PINGDOM",
  "components": ["component1", "component2"]
}
```

**回應範例**

```json
{
  "integration": {
    "id": "int_abc",
    "monitoringTool": "PINGDOM"
  },
  "message": "Integration created successfully."
}
```

這個端點接受我們的 [`MonitoringTool` enum](https://github.com/instatushq/instatus/blob/master/packages/backend/prisma/schema.prisma) 中列出的任何監控工具。

## 更新整合

**端點：**

```bash
PUT /v3/integrations/:integration_id
```

你可以送出建立端點中的任何欄位，或提供新的範本資料來自訂事件的建立與解決方式。

**請求範例**

```json
{
  "label": "Pingdom Primary",
  "createTemplate": { "name": "New incident" },
  "resolveTemplate": { "name": "Incident resolved" }
}
```

**回應範例**

```json
{
  "integration": {
    "id": "int_abc",
    "label": "Pingdom Primary"
  }
}
```

## 刪除整合

**端點：**

```bash
DELETE /v3/integrations/:integration_id
```

**回應範例**

```json
{}
```
