
# 監査エクスポートを取得する

`GET /v1/audit-exports/{export_id}` · 権限 `audit-exports:read`

エクスポートジョブとそのステータスを返します。ステータスは `queued`、`running`、`completed`、`failed`、`expired` のいずれかです。

## リクエスト

| パラメータ | 位置 | 必須 | 説明 |
|---|---|---|---|
| `export_id` | path | はい | エクスポートジョブのID。`aex_` で始まります。 |

## レスポンス

`200 OK` とジョブを返します。空の項目は `null` になります。

- `record_count`、`file`、`manifest_sha256` は、`completed` と `expired` のジョブにのみ設定されます。`file` はパッケージ内の `records.ndjson.gz` を表します（`sha256` は16進数です）。
- `failure_reason` は、`failed` のジョブにのみ設定されます。値は `too_many_records`、`checkpoint_unavailable`、`integrity_error`、`attempts_exhausted` のいずれかです。
- ファイルは `expires_at`（`completed_at` の7日後）に削除されます。その後ジョブは `expired` と表示され、ダウンロードできなくなります。

```json
{
  "id": "aex_01j9xk3m7q8r2s4t6v8w0y2z4e",
  "status": "completed",
  "filter": {
    "stream": "admin",
    "from": "2026-07-01T00:00:00Z",
    "to": "2026-10-01T00:00:00Z",
    "action": "user.",
    "category": null,
    "actor_type": null,
    "actor_id": null,
    "target_type": null,
    "target_id": null,
    "org_id": null,
    "outcome": null,
    "request_id": null,
    "correlation_id": null,
    "agent_only": false
  },
  "include_ip": false,
  "record_count": 18240,
  "file": {
    "name": "records.ndjson.gz",
    "sha256": "9f2c4b8e1d7a3f6c0b5e8d2a4c7f1e3b6a9d0c2e5f8b1a4d7c0e3f6a9b2c5d8e",
    "size": 2381904
  },
  "manifest_sha256": "3b7e1f9c2d5a8e0b4f6c1a3d7e9b2f5c8a0d4e6b1c3f7a9e2d5b8c0f4a6e1d3b",
  "failure_reason": null,
  "created_at": "2026-10-19T09:00:00Z",
  "started_at": "2026-10-19T09:00:02Z",
  "completed_at": "2026-10-19T09:01:10Z",
  "expires_at": "2026-10-26T09:01:10Z",
  "recorded_before": "2026-10-19T09:00:00Z",
  "requested_by": {"type": "api_key", "id": "key_01j9xk3m7q8r2s4t6v8w0y2z4d"}
}
```

## エラー

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

| HTTP | `code` | 発生条件 |
|---|---|---|
| 401 | `unauthenticated` | APIキーが未指定、無効、または取り消されています。 |
| 403 | `insufficient_permissions` | キーに `audit-exports:read` 権限がありません。 |
| 404 | `not_found` | ジョブが存在しないか、別の環境に属しているか、IDの形式が不正です。 |
| 429 | `rate_limited` | レート制限を超えました。`Retry-After` に従ってください。 |
| 503 | `service_unavailable` | 依存先サービスが一時的に利用できません。後で再試行してください。 |

## 例

```bash
curl https://api.eu.keenauth.com/v1/audit-exports/aex_01j9xk3m7q8r2s4t6v8w0y2z4e \
  -H "Authorization: Bearer $KEENAUTH_SECRET_KEY"
```

```bash
keenauth audit-exports get aex_01j9xk3m7q8r2s4t6v8w0y2z4e
```

## 個人データ

このエンドポイントは個人データ（監査イベント）を扱います。[KeenAuth APIにおける個人データ](/docs/policies/personal-data)では、保存される内容、保存期間、削除方法を説明しています。いずれのフィールドにも、特別カテゴリの個人データ（健康、生体データ、宗教、政治的意見、性的指向）を送信しないでください。
