---
id: SummarizeFeedback
name: Summarize feedback
version: 1.0.0
badges:
  - content: Reviews
    backgroundColor: purple
    textColor: purple
summary: Returns a generated feedback summary, classification, rating metrics, evidence, and confidence for a book.
owners:
  - catalog-experience-team
diagrams:
  - id: rating-summarizer-workflow
    version: 1.0.0
schemaPath: schema.json
operation:
  method: GET
  path: /api/v1/feedbacks/{id}/summarize
  statusCodes: ["200", "404"]
sidebar:
  badge: "GET"
---

`SummarizeFeedback` queries [[service|rating-api]] (`GET /rating/api/v1/feedbacks/{id}/summarize`) to return a synthesized summary, application-computed rating metrics, classification, supporting evidence, and confidence for a book's customer feedback. The operation is read-only, requires Microsoft Entra ID authentication, and caches results.

## Overview

| Property                           | Value                                                                                                                                                                                                          |
| :--------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Bounded Context**                | Reviews                                                                                                                                                                                                        |
| **Owner Service**                  | [[service\|rating-api]]                                                                                                                                                                                        |
| **Protocol / Format**              | HTTP `GET`, `application/json` response                                                                                                                                                                        |
| **Gateway Endpoint**               | `GET /rating/api/v1/feedbacks/{id}/summarize` (service path `/api/v1/feedbacks/{id}/summarize`)                                                                                                                |
| **Authentication & Authorization** | Microsoft Entra ID JWT required                                                                                                                                                                                |
| **Idempotency / Concurrency**      | Read-only and naturally idempotent                                                                                                                                                                             |
| **Rate Limit / Caching**           | Global concurrency (`100`), per-IP fixed-window (`30 req/min`), and per-user token bucket (`30` limit, `20` per `10s`, queue `5`); cached `6 hours` when `reviewCount > 0`, `1 minute` when `reviewCount == 0` |
| **Contract Version**               | `1.0.0` (`ApiVersions.V1`)                                                                                                                                                                                     |

:::note
A book with zero feedback records returns `200 OK` with `"classification": "NoData"` and does **not** invoke the AI model workflow. Do not treat `404 Not Found` or `5xx` errors as equivalent to `NoData`.
:::

## Request & Response Contract

### Path Parameters

| Name | Type              | Required | Constraints | Description                                        |
| :--- | :---------------- | :------- | :---------- | :------------------------------------------------- |
| `id` | `string` (`uuid`) | Yes      | Valid UUID  | Unique identifier of the Catalog book to summarize |

### Success Response (`200 OK`)

Only `summary` is strictly required in the schema; clients should handle remaining fields defensively.

| Name             | Type             | Required | Constraints                               | Description                                                                                                         |
| :--------------- | :--------------- | :------- | :---------------------------------------- | :------------------------------------------------------------------------------------------------------------------ |
| `summary`        | `string`         | Yes      | Non-null                                  | Generated narrative summary of customer feedback, or `"No feedback found for this book."` when `reviewCount` is `0` |
| `classification` | `string`         | No       | Enum: `NoData`, `Bad`, `Good`, `TopRated` | Application-derived classification computed by deterministic business rules                                         |
| `averageRating`  | `number \| null` | No       | `double` or `null`                        | Arithmetic mean rating across included feedback records (`null` when `reviewCount` is `0`)                          |
| `reviewCount`    | `integer`        | No       | `int32`                                   | Number of feedback records included in the summary (`0` when unreviewed)                                            |
| `evidence`       | `string`         | No       | —                                         | Supporting evidence produced by the quality assessment step (empty string when `reviewCount` is `0`)                |
| `confidence`     | `string`         | No       | Free-form string                          | Confidence reported by the quality assessment step (empty string when `reviewCount` is `0`)                         |

## Behavior & Side Effects

- **AI summarization & PII redaction:** When feedback exists, invokes the map-reduce-assess AI workflow with [[service|presidio-api]] PII redaction before generating the summary.
- **Deterministic classification:** Returns `NoData` when fewer than 3 reviews exist (or average is invalid), `Bad` when average `< 3.5` or a dominant negative pattern is found, `TopRated` at average `>= 4.5` with `50+` reviews or `>= 4.0` with `200+` reviews, and `Good` otherwise.
- **Tiered caching:** Caches non-empty summaries for 6 hours and empty (`NoData`) results for 1 minute; invalidated on feedback mutations.

## Error Responses

| Status / Code               | Condition                                                      | Client Recovery Action                                           |
| :-------------------------- | :------------------------------------------------------------- | :--------------------------------------------------------------- |
| `401 Unauthorized`          | Missing, expired, or invalid Entra ID bearer token             | Re-authenticate and retry                                        |
| `403 Forbidden`             | Authenticated principal lacks Rating API authorization         | Request a token with the required Rating API scopes              |
| `404 Not Found`             | Target resource or summary could not be found                  | Surface an unavailable/not-found state; do not treat as `NoData` |
| `429 Too Many Requests`     | Rate limit quota exceeded (`Retry-After` header included)      | Wait for the `Retry-After` duration before retrying              |
| `500 Internal Server Error` | Downstream AI, [[service\|presidio-api]], or Cosmos DB failure | Retry with exponential backoff; do not fall back to `NoData`     |

## Related Documentation

- [[service|rating-api]] — Service overview, Azure Cosmos DB storage, and AI governance.
- [[service|presidio-api]] — PII detection and anonymization service.
- [[entity|feedback]] — Feedback document model.
- [[query|ListFeedbacks]] — Retrieve paginated individual customer reviews for a book.

<NodeGraph />

<SchemaViewer file="schema.json" title="Summarize feedback schema" maxHeight="500" search="true" />


 ## Raw Schema:schema.json

{
	"$schema": "https://json-schema.org/draft/2020-12/schema",
	"title": "SummarizeResult",
	"description": "Generated summary of feedback for a book.",
	"type": "object",
	"required": ["summary"],
	"properties": {
		"summary": {
			"type": "string",
			"description": "Generated summary of the book's feedback."
		},
		"classification": {
			"type": "string",
			"enum": ["NoData", "Bad", "Good", "TopRated"],
			"description": "Application-derived feedback classification."
		},
		"averageRating": {
			"type": ["number", "null"],
			"format": "double",
			"description": "Arithmetic mean rating; null when no feedback exists."
		},
		"reviewCount": {
			"type": "integer",
			"format": "int32",
			"description": "Number of feedback records included in the summary."
		},
		"evidence": {
			"type": "string",
			"description": "Supporting evidence from the feedback assessment."
		},
		"confidence": {
			"type": "string",
			"description": "Assessment confidence; empty when no feedback exists."
		}
	}
}
