
# 攻撃モードの状態を取得

`GET /v1/attack-protection/attack-mode` · 権限 `attack-protection:read`

環境が攻撃モードかどうかを返します。あわせて、直近90日以内に開始された、または現在も継続中の攻撃モード期間を新しい順に返します（最大100件）。`more` は、そのウィンドウ内にさらに古い期間があるかどうかを示します。

環境が攻撃モードの間は、`bot_protection.mode` の設定にかかわらず、パスワードおよびワンタイムコードの各ステップでより厳しいボットチャレンジが要求されます。パスキーとソーシャルサインインはチャレンジの対象になりません。攻撃モード期間は次の3つの方法のいずれかで開始されます。

- `auto`: 5分間のウィンドウ内の失敗したサインインが、トリガーしきい値（50と環境の中央値の10倍のうち大きい方）を超えた場合。`credential_stuffing` の `log` モードでは、期間は `would_have: true` として記録され、何も適用されません。ただし、そのウィンドウがしきい値の3倍を超えた場合は適用されます。
- `manual_customer`: [`activate`](activate-attack-mode.md) で有効にした場合。
- `manual_platform`: KeenAuth の運用チームが有効にした場合。

`active` が `true` になるのは、適用される期間（`would_have: false`）が環境全体を覆っている間だけです。この場合、`active_until` はそれらの期間の終了時刻のうち最も遅いものになります。終了時刻を過ぎていても、クリーンアップでまだ閉じられていない期間は、`ends_at` に終了したものとして表示されます。手動期間を開始したユーザーは、このレスポンスには含まれず、管理監査ログで確認できます。

## レスポンス

`200 OK`

| フィールド | 型 | 説明 |
|---|---|---|
| `active` | boolean | 現在、環境が攻撃モードであるかどうか。 |
| `active_until` | string (date-time) または null | 自動期間が延長されない場合に、現在の攻撃モードが終了する時刻。`active` が `false` の場合は `null`。 |
| `periods[]` | array | 期間の一覧（新しい順）。 |
| `periods[].id` | string | 期間のID。接頭辞は `atm_`。 |
| `periods[].scope` | string | `environment` または `org_domain`。 |
| `periods[].org_domain` | string または null | `org_domain` 期間の組織のメールドメイン。 |
| `periods[].trigger` | string | `auto`、`manual_customer`、または `manual_platform`。 |
| `periods[].would_have` | boolean | `true` の場合、`log` モードで記録されたもので、適用はされていない。 |
| `periods[].trigger_value` | integer または null | `auto` 期間を開始させた5分間のウィンドウ内の失敗回数。手動期間の場合は `null`。 |
| `periods[].threshold` | integer または null | そのウィンドウが超えたしきい値。手動期間の場合は `null`。 |
| `periods[].started_at` | string (date-time) | 期間が開始した時刻。 |
| `periods[].ends_at` | string (date-time) | 期間が自動的に終了する時刻。`auto` 期間は攻撃が続く間延長されます。 |
| `periods[].ended_at` | string (date-time) または null | 期間が終了した時刻。期間が継続中の間は `null`。 |
| `more` | boolean | 直近90日以内に、さらに古い期間があるかどうか。 |

```json
{
  "active": true,
  "active_until": "2026-10-20T10:00:00Z",
  "periods": [
    {
      "id": "atm_01jaz8m5c3f6t9w2y4b7d0g3k6",
      "scope": "environment",
      "org_domain": null,
      "trigger": "manual_customer",
      "would_have": false,
      "trigger_value": null,
      "threshold": null,
      "started_at": "2026-10-20T09:00:00Z",
      "ends_at": "2026-10-20T10:00:00Z",
      "ended_at": null
    }
  ],
  "more": false
}
```

## エラー

すべてのエラーは、安定した `code` を含む `application/problem+json` のボディで返されます。

| HTTP | `code` | 発生条件 |
|---|---|---|
| 401 | `unauthenticated` | APIキーが指定されていない、無効、または取り消されている。 |
| 403 | `insufficient_permissions` | キーに `attack-protection:read` 権限がない。 |
| 429 | `rate_limited` | レート制限を超えた。`Retry-After` に従ってください。 |
| 503 | `service_unavailable` | 依存先が一時的に利用できない。後で再試行してください。 |

## 例

```bash
curl https://api.eu.keenauth.com/v1/attack-protection/attack-mode \
  -H "Authorization: Bearer $KEENAUTH_SECRET_KEY"
```

CLI: `keenauth attack-protection attack-mode get`
