---
id: DeleteBasket
name: Delete basket
version: 1.0.0
badges:
  - content: Order Lifecycle
    backgroundColor: blue
    textColor: blue
summary: Deletes the current basket.
owners:
  - commerce-fulfillment-team
schemaPath: schema.json
operation:
  method: DELETE
  path: /api/v1/baskets
  statusCodes: ["204", "404"]
sidebar:
  badge: "DELETE"
---

`DeleteBasket` removes the authenticated customer's active [[entity|basket]] from Redis in [[service|basket-api]] (`DELETE /basket/api/v1/baskets`) and returns `204 No Content`. This endpoint handles customer-initiated deletion only; post-checkout basket cleanup runs asynchronously over Kafka via [[command|PlaceOrderCommand]].

## Overview

| Property                           | Value                                                                                                                               |
| :--------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------- |
| **Bounded Context**                | Shopping                                                                                                                            |
| **Owner Service**                  | [[service\|basket-api]]                                                                                                             |
| **Protocol / Format**              | HTTP `DELETE`, empty request and response (`204 No Content`)                                                                        |
| **Gateway Endpoint**               | `DELETE /basket/api/v1/baskets` (service path `/api/v1/baskets`)                                                                    |
| **Authentication & Authorization** | Microsoft Entra ID JWT — `customer` role plus scopes `basket_read`, `basket_write`                                                  |
| **Idempotency / Concurrency**      | Not idempotent across retries; repeat calls return `404 Not Found`                                                                  |
| **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`) |
| **Contract Version**               | `1.0.0` (`ApiVersions.V1`)                                                                                                          |

## Request & Response Contract

### Request Parameters

Accepts no path parameters, query parameters, or request body.

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

Empty response body confirms the basket was deleted.

## Behavior & Side Effects

- **Existence check before deletion:** Checks for an active basket under the authenticated user's ID in Redis and returns `404 Not Found` if none exists.
- **No integration events:** HTTP deletion does not publish [[event|BasketDeletedCompleteIntegrationEvent]] or [[event|BasketDeletedFailedIntegrationEvent]]; post-checkout cleanup is handled separately via [[command|PlaceOrderCommand]].

:::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                                                              |
| :-------------------------- | :----------------------------------------------------------------------------- | :---------------------------------------------------------------------------------- |
| `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 `customer` role or `basket_read`/`basket_write` scopes | Request a token with the required role and scopes                                   |
| `404 Not Found`             | No active basket exists in Redis for the authenticated customer                | Treat the basket as already cleared or refresh client state; do not retry unchanged |
| `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 Redis or server failure (`traceId` included)                        | Retry with exponential backoff; inspect service logs using `traceId`                |

## Related Documentation

- [[service|basket-api]] — Service overview, Redis storage, and authorization policy.
- [[entity|basket]] — Basket entity model.
- [[command|CreateBasket]] — Initialize a basket.
- [[command|UpdateBasket]] — Replace all items in an existing basket.
- [[query|GetBasket]] — Retrieve the current basket.

<NodeGraph />

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


 ## Raw Schema:schema.json

{
	"$schema": "https://json-schema.org/draft/2020-12/schema",
	"title": "DeleteBasketRequest",
	"description": "The OpenAPI operation defines no request body or parameters.",
	"type": "object",
	"additionalProperties": false
}
