---
id: DeleteFeedback
name: Delete feedback
version: 1.0.0
badges:
  - content: Reviews
    backgroundColor: purple
    textColor: purple
summary: Deletes an existing feedback record by its UUID.
owners:
  - catalog-experience-team
schemaPath: schema.json
operation:
  method: DELETE
  path: /api/v1/feedbacks/{id}
  statusCodes: ["204", "404"]
sidebar:
  badge: "DELETE"
---

`DeleteFeedback` is an administrator-only command in [[service|rating-api]] (`DELETE /rating/api/v1/feedbacks/{id}`) that deletes an existing [[entity|feedback]] record from Azure Cosmos DB, publishes [[event|FeedbackDeletedIntegrationEvent]] to Kafka, invalidates cached feedback lists and summaries, and returns `204 No Content`.

## Overview

| Property                           | Value                                                                                                                                                                                |
| :--------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Bounded Context**                | Reviews                                                                                                                                                                              |
| **Owner Service**                  | [[service\|rating-api]]                                                                                                                                                              |
| **Protocol / Format**              | HTTP `DELETE`, path parameter only, empty response (`204 No Content`)                                                                                                                |
| **Gateway Endpoint**               | `DELETE /rating/api/v1/feedbacks/{id}` (service path `/api/v1/feedbacks/{id}`)                                                                                                       |
| **Authentication & Authorization** | Microsoft Entra ID JWT — `admin` policy (role `admin` and scopes `rating_read`, `rating_write`)                                                                                      |
| **Idempotency / Concurrency**      | Not idempotent across retries; repeat calls return `404 Not Found`; Cosmos DB ETag optimistic concurrency                                                                            |
| **Rate Limit / Caching**           | Global concurrency (`100`), per-IP fixed-window (`30 req/min`), and per-user token bucket (`30` tokens, `+20` per `10s`, queue `5`); invalidates feedback list and AI summary caches |
| **Contract Version**               | `1.0.0` (`ApiVersions.V1`)                                                                                                                                                           |

## Request & Response Contract

### Path Parameters

Accepts no request body.

| Name | Type              | Required | Constraints | Description                                        |
| :--- | :---------------- | :------- | :---------- | :------------------------------------------------- |
| `id` | `string` (`uuid`) | Yes      | Valid UUID  | Unique identifier of the feedback record to delete |

### Success Response (`204 No Content`)

Empty response body confirms the feedback record was deleted.

## Behavior & Side Effects

- **Azure Cosmos DB deletion:** Queries Cosmos DB (`ratingdb`/`feedbacks`, partition key `/bookId`), deletes the record with ETag concurrency protection, and returns `404 Not Found` if absent.
- **Kafka integration event:** Publishes [[event|FeedbackDeletedIntegrationEvent]] to [[channel|bookworm.&#123;env&#125;.rating.feedback-delete]] so [[service|catalog-api]] recalculates the book's derived rating summary.
- **Cache invalidation:** Clears cached feedback list entries tagged for `bookId` and the cached AI rating summary for that book.

:::note
OpenAPI metadata declares `404 Not Found` as `application/problem+json`, whereas runtime responses return `application/json` with `{ "detail": "The requested resource was not found." }`.
:::

## Error Responses

| Status / Code               | Condition                                                                   | Client Recovery Action                                               |
| :-------------------------- | :-------------------------------------------------------------------------- | :------------------------------------------------------------------- |
| `400 Bad Request`           | `id` path segment is not a valid UUID                                       | Provide a valid feedback UUID in the path and retry                  |
| `401 Unauthorized`          | Missing, expired, or invalid Entra ID bearer token                          | Acquire a valid Entra ID access token and retry                      |
| `403 Forbidden`             | Valid token missing the `admin` role or `rating_read`/`rating_write` scopes | Authenticate as a store administrator with the required scopes       |
| `404 Not Found`             | No feedback record exists with the specified `id`                           | Refresh the moderation list; do not retry unchanged                  |
| `409 Conflict`              | Cosmos DB ETag concurrency conflict                                         | Re-fetch the feedback state and retry if still present               |
| `429 Too Many Requests`     | Rate limit quota exceeded (`Retry-After` header included)                   | Wait for the `Retry-After` interval before retrying                  |
| `500 Internal Server Error` | Unexpected Cosmos DB, Kafka, or server failure (`traceId` included)         | Retry with exponential backoff; inspect service logs using `traceId` |

## Related Documentation

- [[service|rating-api]] — Service overview, Azure Cosmos DB storage, and authorization policies.
- [[entity|feedback]] — Feedback document model.
- [[command|CreateFeedback]] — Submit a new book feedback record.
- [[event|FeedbackDeletedIntegrationEvent]] — Kafka event published on deletion.
- [[query|ListFeedbacks]] — Retrieve feedback records to locate IDs.

<NodeGraph />

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


 ## Raw Schema:schema.json

{
	"$schema": "https://json-schema.org/draft/2020-12/schema",
	"title": "DeleteFeedbackRequest",
	"description": "The feedback UUID is supplied as the id path parameter; the operation has no request body.",
	"type": "object",
	"additionalProperties": false
}
