---
id: BasketDeletedCompleteIntegrationEvent
name: Basket deletion completed
version: 1.0.0
summary: |
  Indicates that Basket successfully deleted the submitted basket during
  checkout cleanup.
owners:
  - commerce-fulfillment-team
schemaPath: schema.json
badges:
  - content: Order Lifecycle
    backgroundColor: blue
    textColor: blue
---

`BasketDeletedCompleteIntegrationEvent` (v1.0.0) signals that [[service|basket-api]] removed a submitted customer basket during post-checkout cleanup. [[service|order-orchestration]] consumes this event to advance the order orchestration saga; it confirms basket deletion only and does not imply order completion.

## 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-complete]]                                                                                                                                                                                    |
| **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; producer deduplicates incoming [[command\|PlaceOrderCommand]] via Redis-backed 24-hour idempotency keyed by `OrderId`                                                                                                   |

## 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 was deleted     |
| `basketId`     | `string` (`uuid`)      | Yes      | Valid UUID                      | Identifier of the Redis basket removed during checkout cleanup |
| `totalMoney`   | `number`               | Yes      | Non-negative monetary amount    | Total purchase amount associated with the order                |

### CloudEvents Envelope Headers

| Header        | Value / Source                                             | Purpose                                                     |
| :------------ | :--------------------------------------------------------- | :---------------------------------------------------------- |
| `messagetype` | `BookWorm.Contracts.BasketDeletedCompleteIntegrationEvent` | Explicit message identity for cross-service deserialization |
| `source`      | `urn:bookworm:bookworm-basket`                             | Identifies the producing service                            |
| `requestid`   | Propagated from incoming [[command\|PlaceOrderCommand]]    | End-to-end correlation across HTTP and Kafka hops           |

## Delivery Guarantees & Error Handling

| Condition                                                | System Behavior                                                                                      | Recovery / Compensation                                      |
| :------------------------------------------------------- | :--------------------------------------------------------------------------------------------------- | :----------------------------------------------------------- |
| Duplicate [[command\|PlaceOrderCommand]] within 24 hours | Producer detects the Redis idempotency key for `OrderId` and re-emits this event without re-deleting | Orchestration handles duplicate external events idempotently |
| Transient broker or consumer error                       | Retried with cooldown (`50ms`, `250ms`, `1s`) and full jitter                                        | Exhausted messages route to the consumer 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-complete]] — Kafka channel specification.
- [[event|BasketDeletedFailedIntegrationEvent]] — Companion failure event when Redis deletion returns `false`.
- [[entity|basket]] — Redis basket data model.

<NodeGraph />

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


 ## Raw Schema:schema.json

{
	"$schema": "https://json-schema.org/draft/2020-12/schema",
	"title": "BasketDeletedCompleteIntegrationEvent",
	"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 was deleted."
		},
		"basketId": {
			"type": "string",
			"format": "uuid",
			"description": "Identifier of the basket deleted during checkout cleanup."
		},
		"totalMoney": {
			"type": "number",
			"format": "double",
			"description": "Total purchase amount associated with the order."
		}
	}
}
