Storefront has been decoupled into micro-frontends with a dedicated commerce app and shared shell.

Read the architecture guide →

Complete order

Marks an existing Order as Completed when its current status is New.

Order Lifecycle
PATCH/api/v1/orders/{orderId}/complete

CompleteOrder transitions an existing order from New to Completed in 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 (PATCH /ordering/api/v1/orders/{orderId}/complete) and publishes an integration event 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 can dispatch completion notifications.

Overview

PropertyValue
Bounded ContextOrdering
Owner ServiceOrder 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
Protocol / FormatHTTP PATCH, application/json response
Gateway EndpointPATCH /ordering/api/v1/orders/{orderId}/complete (service path /api/v1/orders/{orderId}/complete)
Authentication & AuthorizationMicrosoft Entra ID JWT — customer or admin role plus scopes ordering_read, ordering_write
Idempotency / ConcurrencyRequired x-request-id header (Redis-backed 3600s TTL; returns 409 Conflict on duplicate); optimistic concurrency (412 Precondition Failed on conflict)
Rate Limit / CachingGlobal concurrency (100), per-IP fixed-window (30 req/min), and per-user token bucket (30 burst, 20 per 10s, queue 5)
Contract Version1.0.0 (ApiVersions.V1)

Request & Response Contract

Path Parameters & Headers

Accepts no request body.

NameTypeRequiredConstraintsDescription
orderIdstring (uuid)YesPath parameter; valid UUIDUnique identifier of the order to complete
x-request-idstringYesHTTP header; non-empty, non-whitespaceClient-generated idempotency key tracked in Redis for 3600 seconds

Success Response (200 OK)

NameTypeRequiredConstraintsDescription
idstring (uuid)YesValid UUIDUnique identifier of the completed order
datestring (date-time)YesISO 8601 UTC timestampCreation timestamp
totalnumberYesRounded to 2 decimal placesSum of quantity * price across all order items
statusstringYes"Completed" on successCurrent lifecycle status
itemsobject[]YesArray of line itemsPurchased items belonging to the order
items[].idstring (uuid)YesValid UUIDLine item identifier
items[].quantityintegerYes> 0Purchased quantity for the item
items[].pricenumberYes>= 0, rounded to 2 decimal placesUnit price captured at order creation
items[].namestring | nullNoNullableBook title (null in this response because catalog enrichment is not performed)

Behavior & Side Effects

  • Access scoping: Administrators can target any New order; customers can only target orders matching their authenticated buyer ID.
  • State transition: Transitions New to Completed. Orders already in Completed or Cancelled status cannot transition again (admins receive 404 Not Found; customers targeting their own non-New order receive 500 Internal Server Error).
  • Event publishing: Appends the completion event to the event store and publishes Order completedEventv1.0.0Order completedReports that an Order transitioned from New to Completed. Ownercommerce-fulfillment-teamSchemaDiagramOpen docs via transactional outbox to Order Completion Event ChannelChannelv1.0.0Order Completion Event ChannelKafka topic owned by the commerce-fulfillment-team carrying Order API events when an order transitions from New to Compl...Ownercommerce-fulfillment-teamOpen docs (partitioned by OrderId).
  • Idempotency key lifecycle: Claims the x-request-id key in Redis for 3600 seconds (409 Conflict on replay) and deletes the key if the operation fails with 5xx so retries can proceed.

Error Responses

Status / CodeConditionClient Recovery Action
400 Bad RequestMissing or whitespace x-request-id header, or invalid user identifier claimProvide a non-empty x-request-id header and valid token claims; do not retry unchanged
401 UnauthorizedMissing, expired, or invalid Entra ID bearer tokenAcquire a fresh Entra ID access token and retry
403 ForbiddenCaller lacks customer/admin role or ordering_read/ordering_write scopesRequest the required Entra ID role and scopes before retrying
404 Not FoundOrder does not exist, is soft-deleted, belongs to another buyer, or (for admin) is not in New statusVerify the orderId and current order status; do not retry unchanged
409 ConflictDuplicate x-request-id for this path within the 3600-second TTLTreat as a duplicate submission and query order status before taking further action
412 Precondition FailedConcurrent update conflict on the order or event streamRefresh order state and retry with a new x-request-id if still New
429 Too Many RequestsRate limit quota exceeded (Retry-After header included)Wait for the Retry-After interval before retrying
500 Internal Server ErrorCustomer attempted to complete an owned order already in Completed or Cancelled status, or unhandled server failureInspect the order’s current status; do not retry non-New transitions

Complete order schema

2 properties

Path and header parameters for completing an Order. The operation has no request body.

orderIdstring
required

Unique identifier of the Order to complete.

x-request-idstring
required

Idempotency key for the completion request.