Create and manage Orders
Create an Order from the current basket, retrieve it, and request a valid lifecycle transition.
Audience & Outcome: This guide is for frontend developers, API integrators, and backend engineers working with Order APIServicev1.0.0Order APIAuthenticated Ordering service for Buyer profiles and the Order lifecycle, creating Orders from baskets, snapshotting pr...PublishesGetBasketGrpc, GetBookGrpc +5SubscribesCreateOrder, CompleteOrder +11APIsOpenAPI, AsyncAPI, Carrier Service LevelsOwnercommerce-fulfillment-teamDiagramRepositoryOpen docs. You will learn how checkout locks purchase snapshots, enforces idempotency, and governs one-way order status transitions.
Order APIServicev1.0.0Order APIAuthenticated Ordering service for Buyer profiles and the Order lifecycle,
creating Orders from baskets, snapshotting pr...PublishesGetBasketGrpc, GetBookGrpc +5SubscribesCreateOrder, CompleteOrder +11APIsOpenAPI, AsyncAPI, Carrier Service LevelsOwnercommerce-fulfillment-teamDiagramRepositoryOpen docs converts a customer’s mutable shopping basket into a durable, price-locked purchase record in Order DatabaseContainerv1.0.0Order DatabaseAuthoritative PostgreSQL system of record owned by the Ordering bounded context for buyers, accepted orders, purchase-ti...Ownercommerce-fulfillment-teamDiagramOpen docs and governs its commercial lifecycle (New, Completed, or Cancelled). Separating order acceptance from downstream basket cleanup and email notifications keeps checkout fast while preserving an authoritative audit trail.
Context and motivation
Checkout crosses four bounded contexts: Shopping holds mutable pre-order items, Catalog owns live book metadata and pricing, Ordering records accepted commercial commitments, and Finance coordinates asynchronous post-checkout cleanup and notification requests.
Without strict boundaries at checkout, three failure modes occur:
- Price drift: Subsequent catalog discounts or price updates alter the total of an already accepted OrderEntityv1.0.0OrderDurable purchase record owned by a Buyer, capturing immutable purchase-time line items and governing order lifecycle tra...Ownercommerce-fulfillment-teamOpen docs.
- Duplicate orders: Retried HTTP requests after network timeouts or double-clicks create multiple purchases for the same checkout attempt.
- Conflated status: Callers assume a
201 Createdresponse confirms basket deletion, payment settlement, or email delivery—none of which occur synchronously inside Order APIServicev1.0.0Order APIAuthenticated Ordering service for Buyer profiles and the Order lifecycle, creating Orders from baskets, snapshotting pr...PublishesGetBasketGrpc, GetBookGrpc +5SubscribesCreateOrder, CompleteOrder +11APIsOpenAPI, AsyncAPI, Carrier Service LevelsOwnercommerce-fulfillment-teamDiagramRepositoryOpen docs.
How it works
Customers interact with checkout through the Commerce microfrontend, which routes authenticated requests through the API Gateway to Order APIServicev1.0.0Order APIAuthenticated Ordering service for Buyer profiles and the Order lifecycle,
creating Orders from baskets, snapshotting pr...PublishesGetBasketGrpc, GetBookGrpc +5SubscribesCreateOrder, CompleteOrder +11APIsOpenAPI, AsyncAPI, Carrier Service LevelsOwnercommerce-fulfillment-teamDiagramRepositoryOpen docs. Every order endpoint requires a valid Microsoft Entra ID JWT (customer or admin role with ordering_read/ordering_write scopes) and applies per-user token-bucket rate limiting (30 token limit, 20 tokens per 10s, returning 429 Too Many Requests).
The visual below shows synchronous checkout validation, order persistence, and asynchronous handoff to Order OrchestrationServicev1.0.0Order OrchestrationMessage-driven Finance workflow service that coordinates post-checkout basket cleanup and order notifications using Dura...PublishesPlaceOrderCommand, DeleteBasketCompleteCommand +3SubscribesUserCheckedOutIntegrationEvent, OrderStatusChangedToCompleteIntegrationEvent +3APIsAsyncAPIOwnercommerce-fulfillment-teamDiagramRepositoryOpen docs.
Loading graph...
Order creation and snapshot locking
Caller identity and idempotency check
When a customer submits
POST /api/v1/orderswith a uniquex-request-idheader, Order APIServicev1.0.0Order APIAuthenticated Ordering service for Buyer profiles and the Order lifecycle, creating Orders from baskets, snapshotting pr...PublishesGetBasketGrpc, GetBookGrpc +5SubscribesCreateOrder, CompleteOrder +11APIsOpenAPI, AsyncAPI, Carrier Service LevelsOwnercommerce-fulfillment-teamDiagramRepositoryOpen docs derives the BuyerEntityv1.0.0BuyerRepresents a customer's ordering profile and delivery address within the Ordering bounded context.Ownercommerce-fulfillment-teamOpen docs strictly from the authenticated Entra ID token and stores a 1-hour idempotency marker in Order Cache and Distributed LocksContainerv1.0.0Order Cache and Distributed LocksRedis-backed coordination and caching slice owned by the Ordering bounded context for buyer-scoped creation locks, HTTP ...Ownercommerce-fulfillment-teamDiagramOpen docs. Reusing the samex-request-idreturns409 Conflict(unless an unhandled error clears the marker for safe retry).Basket read and price snapshot
Order APIServicev1.0.0Order APIAuthenticated Ordering service for Buyer profiles and the Order lifecycle, creating Orders from baskets, snapshotting pr...PublishesGetBasketGrpc, GetBookGrpc +5SubscribesCreateOrder, CompleteOrder +11APIsOpenAPI, AsyncAPI, Carrier Service LevelsOwnercommerce-fulfillment-teamDiagramRepositoryOpen docs reads the BasketEntityv1.0.0BasketCustomer-scoped, mutable pre-order collection of requested books and quantities managed prior to checkout.Ownercommerce-fulfillment-teamOpen docs from Basket APIServicev1.0.0Basket APIInternal HTTP and gRPC service for managing customer-scoped shopping baskets, Catalog price enrichment, and post-checkou...PublishesGetBookGrpc, GetBooksGrpc +2SubscribesCreateBasket, UpdateBasket +4APIsOpenAPI, AsyncAPIOwnercommerce-fulfillment-teamDiagramRepositoryOpen docs over gRPC, resolves every BookEntityv1.0.0BookCanonical sellable title in the product catalog, encapsulating descriptive metadata, pricing, stock availability, taxono...Ownercatalog-experience-teamOpen docs via Catalog APIServicev1.0.0Catalog APIInternal HTTP and gRPC service for Catalog product management, hybrid discovery, and authoritative book metadata. PublishesBookUpdatedRatingFailedIntegrationEventSubscribesCreatePublisher, UpdatePublisher +24APIsOpenAPI, AsyncAPIOwnercatalog-experience-teamDiagramRepositoryOpen docs gRPC, locks in each item’s unit price, and calculates the order total from those recorded line totals.
Serialized persistence and outbox handoff
A 1-minute distributed lock in Order Cache and Distributed LocksContainerv1.0.0Order Cache and Distributed LocksRedis-backed coordination and caching slice owned by the Ordering bounded context for buyer-scoped creation locks, HTTP ...Ownercommerce-fulfillment-teamDiagramOpen docs serializes concurrent writes for the same buyer before persisting the OrderEntityv1.0.0OrderDurable purchase record owned by a Buyer, capturing immutable purchase-time line items and governing order lifecycle tra...Ownercommerce-fulfillment-teamOpen docs in Order DatabaseContainerv1.0.0Order DatabaseAuthoritative PostgreSQL system of record owned by the Ordering bounded context for buyers, accepted orders, purchase-ti...Ownercommerce-fulfillment-teamDiagramOpen docs with status
Newand publishing User checked outEventv1.0.0User checked outReports that an Order was placed and its checkout details are ready for Finance coordination. Ownercommerce-fulfillment-teamSchemaDiagramOpen docs through the transactional outbox.NoteReturning
201 Createdconfirms only that Order APIServicev1.0.0Order APIAuthenticated Ordering service for Buyer profiles and the Order lifecycle, creating Orders from baskets, snapshotting pr...PublishesGetBasketGrpc, GetBookGrpc +5SubscribesCreateOrder, CompleteOrder +11APIsOpenAPI, AsyncAPI, Carrier Service LevelsOwnercommerce-fulfillment-teamDiagramRepositoryOpen docs accepted and persisted the order snapshot. Basket deletion and email notifications run asynchronously under Order OrchestrationServicev1.0.0Order OrchestrationMessage-driven Finance workflow service that coordinates post-checkout basket cleanup and order notifications using Dura...PublishesPlaceOrderCommand, DeleteBasketCompleteCommand +3SubscribesUserCheckedOutIntegrationEvent, OrderStatusChangedToCompleteIntegrationEvent +3APIsAsyncAPIOwnercommerce-fulfillment-teamDiagramRepositoryOpen docs.
Order status lifecycle and event history
Order APIServicev1.0.0Order APIAuthenticated Ordering service for Buyer profiles and the Order lifecycle, creating Orders from baskets, snapshotting pr...PublishesGetBasketGrpc, GetBookGrpc +5SubscribesCreateOrder, CompleteOrder +11APIsOpenAPI, AsyncAPI, Carrier Service LevelsOwnercommerce-fulfillment-teamDiagramRepositoryOpen docs enforces a strict one-way state machine for business status:
Loading graph...
- Terminal states: Only a
Neworder can transition toCompletedorCancelled, and bothPATCHendpoints require a uniquex-request-id. Neither terminal state can reopen or move to the other terminal state. - Downstream status events: Successful transitions publish Order completedEventv1.0.0Order completedReports that an Order transitioned from New to Completed. Ownercommerce-fulfillment-teamSchemaDiagramOpen docs or Order cancelledEventv1.0.0Order cancelledReports that an Order transitioned from New to Cancelled. Ownercommerce-fulfillment-teamSchemaDiagramOpen docs to Kafka so Order OrchestrationServicev1.0.0Order OrchestrationMessage-driven Finance workflow service that coordinates post-checkout basket cleanup and order notifications using Dura...PublishesPlaceOrderCommand, DeleteBasketCompleteCommand +3SubscribesUserCheckedOutIntegrationEvent, OrderStatusChangedToCompleteIntegrationEvent +3APIsAsyncAPIOwnercommerce-fulfillment-teamDiagramRepositoryOpen docs updates its workflow and requests the corresponding customer email.
- Read and audit views: Customers query orders scoped to their own buyer ID, while administrators can filter across buyers and inspect chronological audit history or point-in-time summaries.
- Administrative soft delete: Administrator deletion and Handle basket deletion failedCommandv1.0.0Handle basket deletion failedReports Finance's failed basket-cleanup outcome so Order API can
soft-delete the affected Order.
Ownercommerce-fulfillment-teamSchemaDiagramOpen docs mark an order as soft-deleted, hiding it from standard queries without changing its business
StatustoCancelled.
| Decision | Benefits | Costs and limits |
|---|---|---|
| Price snapshot at checkout | Protects customers and financial records from retroactive catalog price edits | Catalog corrections require explicit customer reconciliation |
| Asynchronous post-checkout handoff | Keeps order creation latency low and isolates checkout from Basket/SMTP outages | 201 Created does not confirm basket deletion or email delivery |
Irreversible terminal states (Completed, Cancelled) | Produces a clean, auditable financial and event-sourced history | Correcting an accidental transition requires creating a new order |
| Pre-execution idempotency marker | Blocks duplicate submissions atomically without storing full HTTP payloads | Client timeouts after persistence leave a 1-hour marker without a cached replay |
Rejected alternatives:
- Synchronous distributed transaction across Ordering, Basket, and Notification: Couples order acceptance to non-critical email availability.
- Referencing live Catalog prices on read: Causes historical order totals to drift whenever book prices change.
- Treating soft deletion as
Cancelled: Conflates operational cleanup failure with explicit commercial cancellation.
Related documentation
- User CheckoutFlowv1.0.0User CheckoutAn authenticated customer checks out a persisted basket through Ordering API; Finance coordinates asynchronous basket cl...Ownercommerce-fulfillment-teamView flowOpen docs — End-to-end checkout flow across Shopping, Ordering, and Finance.
- Order Lifecycle and Status TransitionsFlowv1.0.0Order Lifecycle and Status TransitionsCheckout creates a New Order owned by Ordering API, Finance coordinates post-order cleanup and notifications, and explic...Ownercommerce-fulfillment-teamView flowOpen docs — Order status transitions and downstream event propagation.
- ADR-002: Preserve the checkout-time purchase snapshotDecision Recordv1.0.0ADR-002: Preserve the checkout-time purchase snapshotEach accepted Order records the book identifiers, quantities, and prices selected at checkout so later Catalog changes d...Ownercommerce-fulfillment-teamOpen docs — Why checkout locks unit prices and item details.
- ADR-003: Keep Order status separate from Finance saga stateDecision Recordv1.0.0ADR-003: Keep Order status separate from Finance saga stateOrdering owns the Order's business status, while Finance owns checkout coordination state; basket cleanup outcomes do no...Ownercommerce-fulfillment-teamOpen docs — Separation between commercial status and Finance workflow state.