---
id: BasketDeletedFailedIntegrationEvent
name: Basket deletion failed
version: 1.0.0
summary: |
  Indicates that Basket could not delete the submitted basket during checkout
  cleanup.
owners:
  - commerce-fulfillment-team
schemaPath: schema.json
badges:
  - content: Order Lifecycle
    backgroundColor: blue
    textColor: blue
---

`BasketDeletedFailedIntegrationEvent` (v1.0.0) signals that [[service|basket-api]] could not delete a submitted customer basket during post-checkout cleanup. [[service|order-orchestration]] consumes this event to trigger compensating failure handling instead of stalling the checkout orchestration.

## Overview

| Property                             | Value                                                                                                                                                                                                                                           |
| :----------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Bounded Context**                  | Shopping                                                                                                                                                                                                                                        |
| **Producer**                         | [[service\|basket-api]]                                                                                                                                                                                                                         |
| **Consumer(s)**                      | [[service\|order-orchestration]]                                                                                                                                                                                                                |
| **Protocol / Format**                | Kafka + CloudEvents JSON (camelCase payload)                                                                                                                                                                                                    |
| **Channel / Topic**                  | [[channel\|bookworm.&#123;env&#125;.basket.delete-failed]]                                                                                                                                                                                      |
| **Dead-Letter Channel**              | None on consumer ([[service\|order-orchestration]] uses Azure Functions Kafka trigger retries and Durable Task Hub diagnostics; [[channel\|bookworm.&#123;env&#125;.basket.dead-letter-queue]] is for [[service\|basket-api]] inbound failures) |
| **Partition Key**                    | `OrderId`                                                                                                                                                                                                                                       |
| **Delivery / Idempotency Guarantee** | At-least-once delivery; emitted when Redis deletion returns `false` while handling [[command\|PlaceOrderCommand]]                                                                                                                               |

## Payload Fields & Envelope

### Event Payload

| Name           | Type                   | Required | Constraints                          | Description                                                           |
| :------------- | :--------------------- | :------- | :----------------------------------- | :-------------------------------------------------------------------- |
| `id`           | `string` (`uuid`)      | Yes      | UUIDv7                               | Unique identifier for this integration event instance                 |
| `creationDate` | `string` (`date-time`) | Yes      | ISO 8601 UTC timestamp               | UTC timestamp when the event was created                              |
| `orderId`      | `string` (`uuid`)      | Yes      | Valid UUID; Kafka partition key      | Identifier of the order whose submitted basket could not be deleted   |
| `basketId`     | `string` (`uuid`)      | Yes      | Valid UUID                           | Identifier of the basket that could not be removed                    |
| `email`        | `string \| null`       | No       | Email format when non-null; nullable | Customer email used by downstream recovery notifications when present |
| `totalMoney`   | `number`               | Yes      | Non-negative monetary amount         | Total purchase amount associated with the order                       |

:::note
Consumers must handle `email` when it is `null` or omitted and must never interpret `BasketDeletedFailedIntegrationEvent` as a successful cleanup milestone.
:::

### CloudEvents Envelope Headers

| Header        | Value / Source                                           | Purpose                                                     |
| :------------ | :------------------------------------------------------- | :---------------------------------------------------------- |
| `messagetype` | `BookWorm.Contracts.BasketDeletedFailedIntegrationEvent` | Explicit message identity for cross-service deserialization |
| `source`      | `urn:bookworm:bookworm-basket`                           | Identifies the producing service                            |
| `requestid`   | Propagated from incoming [[command\|PlaceOrderCommand]]  | Correlates checkout and recovery logs across services       |

## Delivery Guarantees & Error Handling

| Condition                                                   | System Behavior                                                                          | Recovery / Compensation                                                                                      |
| :---------------------------------------------------------- | :--------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------- |
| Redis deletion returns `false` (key missing or not deleted) | Emits `BasketDeletedFailedIntegrationEvent`                                              | [[service\|order-orchestration]] dispatches [[command\|DeleteBasketFailedCommand]] to [[service\|order-api]] |
| Unhandled exception during Redis deletion                   | Releases the `OrderId` idempotency lock and retries (`50ms`, `250ms`, `1s`, full jitter) | Exhausted messages route to [[channel\|bookworm.&#123;env&#125;.basket.dead-letter-queue]]                   |
| Deserialization failure                                     | Routed immediately to the dead-letter queue without retries                              | Inspect dead-letter payload against contract schema                                                          |

## Related Documentation

- [[service|basket-api]] — Producer service contract and Redis storage details.
- [[service|order-orchestration]] — Consumer orchestration service.
- [[channel|bookworm.&#123;env&#125;.basket.delete-failed]] — Kafka channel specification.
- [[channel|bookworm.&#123;env&#125;.basket.dead-letter-queue]] — Dead-letter channel for failed Basket consumers.
- [[event|BasketDeletedCompleteIntegrationEvent]] — Companion success event for checkout basket cleanup.
- [[entity|basket]] — Redis basket data model.

<NodeGraph />

<SchemaViewer
	file="schema.json"
	title="Basket deletion failed schema"
	maxHeight="500"
	search="true"
/>


 ## Raw Schema:schema.json

{
	"$schema": "https://json-schema.org/draft/2020-12/schema",
	"title": "BasketDeletedFailedIntegrationEvent",
	"type": "object",
	"additionalProperties": false,
	"required": ["id", "creationDate", "orderId", "basketId", "totalMoney"],
	"properties": {
		"id": {
			"type": "string",
			"format": "uuid",
			"description": "Unique identifier assigned by the integration-event building block."
		},
		"creationDate": {
			"type": "string",
			"format": "date-time",
			"description": "UTC timestamp when the integration event was created."
		},
		"orderId": {
			"type": "string",
			"format": "uuid",
			"description": "Identifier of the order whose submitted basket could not be deleted."
		},
		"basketId": {
			"type": "string",
			"format": "uuid",
			"description": "Identifier of the basket that could not be deleted."
		},
		"email": {
			"type": ["string", "null"],
			"format": "email",
			"description": "Customer email used by downstream recovery or notification workflows."
		},
		"totalMoney": {
			"type": "number",
			"format": "double",
			"description": "Total purchase amount associated with the order."
		}
	}
}
