---
id: CompleteOrderCommand
name: Send order completed notification
version: 1.0.0
badges:
  - content: Order Lifecycle
    backgroundColor: blue
    textColor: blue
summary: |
  Shared Finance completion command consumed by Notification to render
  and submit a completed-order email.
schemaPath: schema.json
owners:
  - platform-engineering-team
---

`CompleteOrderCommand` is an asynchronous Kafka integration command published by [[service|order-orchestration]] and consumed by [[service|notification-api]] to render and submit a completed-order customer email. It never mutates order state in [[service|order-api]].

## Overview

| Property                             | Value                                                                                |
| :----------------------------------- | :----------------------------------------------------------------------------------- |
| **Bounded Context**                  | Platform / Notifications                                                             |
| **Producer**                         | [[service\|order-orchestration]]                                                     |
| **Consumer(s)**                      | [[service\|notification-api]]                                                        |
| **Protocol / Format**                | Kafka + CloudEvents JSON (camelCase payload)                                         |
| **Channel / Topic**                  | [[channel\|bookworm.&#123;env&#125;.finance.complete-order]]                         |
| **Dead-Letter Channel**              | [[channel\|bookworm.&#123;env&#125;.notification.dead-letter-queue]]                 |
| **Partition Key**                    | `OrderId`                                                                            |
| **Delivery / Idempotency Guarantee** | At-least-once delivery; consumed with Redis-backed 24-hour idempotency keyed by `id` |

:::note
`CompleteOrderCommand` requests a completion confirmation email only. To transition an order's authoritative status to `Completed`, call [[command|CompleteOrder]].
:::

## Payload Fields & Envelope

### Command Payload

| Name           | Type                   | Required | Constraints                                   | Description                                                                                  |
| :------------- | :--------------------- | :------- | :-------------------------------------------- | :------------------------------------------------------------------------------------------- |
| `id`           | `string` (`uuid`)      | Yes      | UUIDv7                                        | Unique message identifier used for 24-hour Redis deduplication                               |
| `creationDate` | `string` (`date-time`) | Yes      | ISO 8601 UTC timestamp                        | UTC timestamp when the command was created                                                   |
| `orderId`      | `string` (`uuid`)      | Yes      | Valid UUID; Kafka partition key               | Identifier of the completed order                                                            |
| `fullName`     | `string \| null`       | No       | Nullable (defaults to `"Customer"` when null) | Customer display name                                                                        |
| `email`        | `string \| null`       | No       | Nullable                                      | Recipient email address; null, empty, or whitespace values skip email rendering and delivery |
| `totalMoney`   | `number`               | Yes      | Non-negative monetary amount                  | Final order total displayed in the completion email template                                 |

## Delivery Guarantees & Error Handling

| Condition                          | System Behavior                                                                                                   | Recovery / Compensation                                                                         |
| :--------------------------------- | :---------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------- |
| Duplicate delivery within 24 hours | Consumer skips reprocessing via Redis-backed 24-hour idempotency keyed by `id`                                    | Safe at-least-once delivery; newly published commands with a different `id` execute again       |
| Blank or `null` `email`            | Consumer returns without error and skips template rendering and SMTP submission                                   | No action required                                                                              |
| Transient SMTP or network failure  | Retried by the notification resilience pipeline (circuit breaker, exponential backoff with jitter, `30s` timeout) | Exhausted retries route to [[channel\|bookworm.&#123;env&#125;.notification.dead-letter-queue]] |
| Permanent SMTP failure             | Retried with cooldown (`50ms`, `250ms`, `1s` with full jitter)                                                    | Routed to [[channel\|bookworm.&#123;env&#125;.notification.dead-letter-queue]]                  |

## Related Documentation

- [[service|notification-api]] — Stateless email worker architecture and SMTP configuration.
- [[service|order-orchestration]] — Producing orchestration service.
- [[channel|bookworm.&#123;env&#125;.finance.complete-order]] — Kafka channel specification.
- [[channel|bookworm.&#123;env&#125;.notification.dead-letter-queue]] — Dead-letter queue for failed Notification consumers.
- [[event|OrderStatusChangedToCompleteIntegrationEvent]] — Upstream Ordering event that triggers completion notification.
- [[command|CompleteOrder]] — Ordering API HTTP command that completes an order.

<NodeGraph />

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


 ## Raw Schema:schema.json

{
	"$schema": "https://json-schema.org/draft/2020-12/schema",
	"title": "CompleteOrderCommand",
	"type": "object",
	"additionalProperties": false,
	"required": ["id", "creationDate", "orderId", "totalMoney"],
	"properties": {
		"id": { "type": "string", "format": "uuid" },
		"creationDate": { "type": "string", "format": "date-time" },
		"orderId": { "type": "string", "format": "uuid" },
		"fullName": { "type": ["string", "null"] },
		"email": { "type": ["string", "null"] },
		"totalMoney": { "type": "number" }
	}
}
