# 监控集成 API 参考

Source: https://instatus.com/help/zh/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` 枚举](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
{}
```
