---
id: OrderStatusChangedToCompleteIntegrationEvent
name: Order completed
version: 1.0.0
summary: |
  Reports that an Order transitioned from New to Completed.
owners:
  - commerce-fulfillment-team
schemaPath: schema.json
badges:
  - content: Order Lifecycle
    backgroundColor: blue
    textColor: blue
---

`OrderStatusChangedToCompleteIntegrationEvent` (v1.0.0) reports that [[service|order-api]] transitioned an [[entity|order]] from `New` to `Completed`. [[service|order-orchestration]] consumes this event to complete its orchestration instance and dispatch [[command|CompleteOrderCommand]] to [[service|notification-api]]; it confirms an authoritative order status change and is neither a completion request nor an email delivery receipt.

## Overview

| Property                             | Value                                                                                               |
| :----------------------------------- | :-------------------------------------------------------------------------------------------------- |
| **Bounded Context**                  | Ordering                                                                                            |
| **Producer**                         | [[service\|order-api]]                                                                              |
| **Consumer(s)**                      | [[service\|order-orchestration]]                                                                    |
| **Protocol / Format**                | Kafka + CloudEvents JSON (camelCase payload)                                                        |
| **Channel / Topic**                  | [[channel\|bookworm.&#123;env&#125;.ordering.order-status-change-to-complete]]                      |
| **Dead-Letter Channel**              | [[channel\|bookworm.&#123;env&#125;.ordering.dead-letter-queue]]                                    |
| **Partition Key**                    | `OrderId`                                                                                           |
| **Delivery / Idempotency Guarantee** | Published via transactional outbox (at-least-once); orchestration routes idempotently per `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 completed order                                          |
| `basketId`     | `string` (`uuid`)      | Yes      | Valid UUID                      | Buyer-linked basket reference supplied by the producer                     |
| `fullName`     | `string \| null`       | Yes      | Nullable string                 | Customer full name when available on the buyer record                      |
| `email`        | `string \| null`       | Yes      | Nullable email format           | Customer email address when available; email dispatch is skipped if absent |
| `totalMoney`   | `number`               | Yes      | Non-negative monetary amount    | Total purchase amount associated with the completed order                  |

:::note
The current producer populates `basketId` with the order's `BuyerId`. Downstream consumers must not assume `basketId` was independently resolved from [[service|basket-api]].
:::

### CloudEvents Envelope Headers

| Header        | Value / Source                                                    | Purpose                                                                |
| :------------ | :---------------------------------------------------------------- | :--------------------------------------------------------------------- |
| `messagetype` | `BookWorm.Contracts.OrderStatusChangedToCompleteIntegrationEvent` | Explicit message identity for cross-service deserialization            |
| `source`      | `urn:bookworm:bookworm-ordering`                                  | Identifies the producing service                                       |
| `requestid`   | Propagated from the triggering HTTP request                       | Correlates order completion across Ordering, Finance, and Notification |

## Delivery Guarantees & Error Handling

| Condition                               | System Behavior                                                                                                                              | Recovery / Compensation                                                                                   |
| :-------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------- |
| `email` or `fullName` is `null`         | Payload remains valid; [[service\|order-orchestration]] checks notification eligibility before dispatching [[command\|CompleteOrderCommand]] | Consumers must tolerate `null` contact fields without failing deserialization                             |
| Transient broker or orchestration error | Transactional outbox guarantees at-least-once publication; Kafka trigger retries delivery                                                    | Inspect orchestration instance state and [[channel\|bookworm.&#123;env&#125;.ordering.dead-letter-queue]] |

## Related Documentation

- [[service|order-api]] — Producer service.
- [[service|order-orchestration]] — Consumer orchestration service.
- [[channel|bookworm.&#123;env&#125;.ordering.order-status-change-to-complete]] — Kafka channel specification.
- [[channel|bookworm.&#123;env&#125;.ordering.dead-letter-queue]] — Dead-letter queue for failed Ordering consumers.
- [[event|OrderStatusChangedToCancelIntegrationEvent]] — Companion event for `New` to `Cancelled` transitions.
- [[event|UserCheckedOutIntegrationEvent]] — Initial order placement event.
- [[entity|order]] — Ordering aggregate schema and status lifecycle.

<NodeGraph />

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


 ## Raw Schema:schema.json

{
	"$schema": "https://json-schema.org/draft/2020-12/schema",
	"title": "OrderStatusChangedToCompleteIntegrationEvent",
	"type": "object",
	"additionalProperties": false,
	"required": ["id", "creationDate", "orderId", "basketId", "fullName", "email", "totalMoney"],
	"properties": {
		"id": {
			"type": "string",
			"format": "uuid",
			"description": "Unique identifier assigned to the integration event."
		},
		"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."
		},
		"basketId": {
			"type": "string",
			"format": "uuid",
			"description": "UUID serialized as basketId. The current EventMapper supplies the\nOrder's BuyerId for this field.\n"
		},
		"fullName": {
			"type": ["string", "null"],
			"description": "Customer name, when available."
		},
		"email": {
			"type": ["string", "null"],
			"format": "email",
			"description": "Customer email, when available."
		},
		"totalMoney": {
			"type": "number",
			"format": "double",
			"description": "Total purchase amount associated with the Order."
		}
	}
}
