# お知らせ API リファレンス

Source: https://instatus.com/help/ja/api/generic-notices

お知らせは、ステータスページに常設で表示されるバナーです (インシデントやメンテナンスとは別のものです)。これらのエンドポイントを使うと、プログラムから管理できます。

## お知らせをすべて取得する

**エンドポイント:**

```bash
GET /v1/:page_id/generic-notices?page=:page&per_page=:per_page
```

- page の既定値は 1 です。
- per_page の既定値は 50 で、1 ページあたり最大 100 件です。

**レスポンスの例:**

```json
[
  {
    "id": "cl9mq0ah50646mpvlmbrvf979",
    "name": "Scheduled DNS migration",
    "message": "We are migrating our DNS provider over the next week.",
    "messageHtml": "<p>We are migrating our DNS provider over the next week.</p>",
    "notify": false,
    "isCollapsed": false,
    "createdAt": "2022-10-24T11:53:46.505Z",
    "updatedAt": "2022-10-24T11:53:46.505Z",
    "siteId": "cl9fzgilx14063qjvl5oqdtxtg",
    "importedFrom": null
  }
]
```

## お知らせを取得する

**エンドポイント:**

```bash
GET /v1/:page_id/generic-notices/:generic_notice_id
```

**レスポンスの例:**

```json
{
  "id": "cl9mq0ah50646mpvlmbrvf979",
  "name": "Scheduled DNS migration",
  "message": "We are migrating our DNS provider over the next week.",
  "messageHtml": "<p>We are migrating our DNS provider over the next week.</p>",
  "notify": false,
  "isCollapsed": false,
  "createdAt": "2022-10-24T11:53:46.505Z",
  "updatedAt": "2022-10-24T11:53:46.505Z",
  "siteId": "cl9fzgilx14063qjvl5oqdtxtg",
  "importedFrom": null
}
```

## お知らせを追加する

**エンドポイント:**

```bash
POST /v1/:page_id/generic-notices
```

**ボディのパラメーター:**

- `name` (必須) — お知らせのタイトル。
- `message` — お知らせの本文。HTML を使えます。
- `notify` — 購読者に通知するかどうか。既定値は `false` です。
- `isCollapsed` — お知らせを既定で折りたたむかどうか。既定値は `false` です。
- `translations` — `name` と `message` の翻訳 (任意)。言語コードをキーにします。

**リクエストの例:**

```json
{
  "name": "Scheduled DNS migration",
  "message": "We are migrating our DNS provider over the next week.",
  "notify": false,
  "isCollapsed": false,
  "translations": {
    "name": {
      "fr": "Migration DNS planifiée"
    },
    "message": {
      "fr": "Nous migrons notre fournisseur DNS au cours de la semaine prochaine."
    }
  }
}
```

**レスポンスの例:**

```json
{
  "id": "cl9xobpoe00614tvldhh90t0w",
  "name": "Scheduled DNS migration",
  "message": "We are migrating our DNS provider over the next week.",
  "messageHtml": "<p>We are migrating our DNS provider over the next week.</p>",
  "notify": false,
  "isCollapsed": false,
  "createdAt": "2022-11-01T03:52:08.126Z",
  "updatedAt": "2022-11-01T03:52:08.126Z",
  "siteId": "cl9fzgilx14063qjvl5oqdtxtg",
  "importedFrom": null,
  "translations": {
    "name": {
      "fr": "Migration DNS planifiée"
    },
    "message": {
      "fr": "Nous migrons notre fournisseur DNS au cours de la semaine prochaine."
    }
  }
}
```

## お知らせを更新する

**エンドポイント:**

```bash
PUT /v1/:page_id/generic-notices/:generic_notice_id
```

送信したフィールドのみが更新されます。

**リクエストの例:**

```json
{
  "name": "Scheduled DNS migration (rescheduled)",
  "message": "The migration has been rescheduled to next month.",
  "isCollapsed": true
}
```

**レスポンスの例:**

```json
{
  "id": "cl9xobpoe00614tvldhh90t0w",
  "name": "Scheduled DNS migration (rescheduled)",
  "message": "The migration has been rescheduled to next month.",
  "messageHtml": "<p>The migration has been rescheduled to next month.</p>",
  "notify": false,
  "isCollapsed": true,
  "createdAt": "2022-11-01T03:52:08.126Z",
  "updatedAt": "2022-11-02T09:14:22.501Z",
  "siteId": "cl9fzgilx14063qjvl5oqdtxtg",
  "importedFrom": null
}
```

## お知らせを削除する

**エンドポイント:**

```bash
DELETE /v1/:page_id/generic-notices/:generic_notice_id
```

**レスポンスの例:**

```json
{
  "id": "cl9xobpoe00614tvldhh90t0w",
  "name": "Scheduled DNS migration (rescheduled)",
  "message": "The migration has been rescheduled to next month.",
  "messageHtml": "<p>The migration has been rescheduled to next month.</p>",
  "notify": false,
  "isCollapsed": true,
  "createdAt": "2022-11-01T03:52:08.126Z",
  "updatedAt": "2022-11-02T09:14:22.501Z",
  "siteId": "cl9fzgilx14063qjvl5oqdtxtg",
  "importedFrom": null
}
```
