---
title: "Return an AI-generated summary of API traffic for the given window."
method: GET
path: "/projects/{project_id}/api-analytics/summary"
tags: ["Analytics"]
---

# Return an AI-generated summary of API traffic for the given window.

`GET /projects/{project_id}/api-analytics/summary`

## Request

- Base URL: `/api` (relative, and the document was published on a file host, not at the API’s origin)
- URL: `/api/projects/{project_id}/api-analytics/summary`
- Auth: HTTP bearer

The response always includes `enabled` and `unavailable_reason` so the
client can render a meaningful onboarding state even when no AI provider
is configured or the project has not opted in. The `summary` field is
non-null only when all of the following are true:

- `projects.ai_api_traffic_summary_enabled = true`
- An AI provider is configured and available
- The AI call returns parseable JSON within the bounded summary deadline

This endpoint never returns a 5xx from an AI failure — it always returns
200 with `summary: null` and a human-readable `unavailable_reason`.

## Path parameters

- `project_id` integer, required

## Query parameters

- `environment_id` integer
- `start_date` string, required
- `end_date` string, required
- `refresh` boolean

## Response `200`

AI traffic summary (summary field may be null when AI is unavailable)

- ApiTrafficSummaryResponse: Response from the AI traffic summary endpoint.
  - `cached` boolean, required: Whether this response was served from the backend AI-result cache.
  - `enabled` boolean, required: Whether the project has `ai_api_traffic_summary_enabled = true`.
  - `summary` ApiTrafficSummary, nullable: Structured AI summary of API traffic for a given project + time window. Derives `JsonSchema` so `complete_typed` can request this shape from the configured AI provider. All fields are intentionally short — the prompt feeds aggregated stats (not raw log lines) to keep token usage bounded. When AI is not configured or the project has not opted in, the summary endpoint returns `null` for this field rather than an error.
    - `anomalies` string[], required: Anomalies or concerns worth investigating (0–3 items). Empty when traffic appears normal.
    - `findings` string[], required: Bullet-point findings (2–4 items). Each finding is a single sentence.
    - `headline` string, required: One-sentence headline describing the traffic pattern.
    - `recommendation` string, nullable: Optional single actionable recommendation.
  - `unavailable_reason` string, nullable: Why the summary is null when `summary` is None and `enabled` is true: either AI is not configured or the call failed/timed out.

## Other responses

- `400`: Bad request
- `401`: Unauthorized
- `403`: Insufficient permissions
- `500`: Internal server error (DB errors only; AI failures return 200 with summary: null)

## Changes

- **2026-09-07** `2b95ed4ff1d2`: 1 info
  - endpoint added
- **2026-09-07** `f7404eb7ac98`: 1 breaking
  - api path removed without deprecation
- **2026-08-14** `5b69d84f67d1`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/gotempsh/apis/temps/changes/projects/:project_id/api-analytics/summary/get.md)

---

[API](https://skmtc.dev/gotempsh/apis/temps.md) - [All operations](https://skmtc.dev/gotempsh/apis/temps/llms.txt) - [OpenAPI document](https://skmtc.dev/gotempsh/apis/temps/revisions/3b040526eb43?raw)
