Create order
Creates an Order for the authenticated Buyer using the current basket and Catalog pricing.
/api/v1/ordersCreateOrder creates a New order 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 (POST /ordering/api/v1/orders) for the authenticated buyer by reading the caller’s active basket 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 and resolving current prices from 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 over gRPC.
Overview
| Property | Value |
|---|---|
| Bounded Context | Ordering |
| Owner Service | 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 |
| Protocol / Format | HTTP POST, application/json UUID response |
| Gateway Endpoint | POST /ordering/api/v1/orders (service path /api/v1/orders) |
| Authentication & Authorization | Microsoft Entra ID JWT — customer or admin role plus scopes ordering_read, ordering_write |
| Idempotency / Concurrency | Required x-request-id header (Redis-backed 3600s TTL; returns 409 Conflict on duplicate); per-buyer Redis distributed lock (order-create:{userId}, 1-minute TTL) |
| Rate Limit / Caching | Global concurrency (100), per-IP fixed-window (30 req/min), and per-user token bucket (30 burst, 20 per 10s, queue 5) |
| Contract Version | 1.0.0 (ApiVersions.V1) |
Request & Response Contract
Request Headers
Accepts no request body; basket items and unit prices are resolved server-side.
| Name | Type | Required | Constraints | Description |
|---|---|---|---|---|
x-request-id | string | Yes | Non-empty, non-whitespace | Client-generated idempotency key tracked in Redis for 3600 seconds |
Success Response (201 Created)
| Name | Type | Required | Constraints | Description |
|---|---|---|---|---|
Location header | string | Yes | Relative path /api/v1/orders/{id} | URI to fetch the created order |
| Root body | string (uuid) | Yes | UUIDv7 | Newly created order identifier |
Behavior & Side Effects
- Server-side basket and price resolution: Fetches the buyer’s basket via Get basket over gRPCQueryv1.0.0Get basket over gRPCReturns the current basket through the basket.v1 gRPC contract.Ownercommerce-fulfillment-teamSchemaDiagramOpen docs (10s deadline) and resolves authoritative book pricing (
priceSale ?? price) via Get books over gRPCQueryv1.0.0Get books over gRPCReturns multiple Catalog books by identifier through the book.v1 gRPC contract.Ownercatalog-experience-teamSchemaDiagramOpen docs (10s deadline). Missing catalog books return404 Not Found. - Distributed per-buyer lock: Acquires a 1-minute Redis distributed lock (
order-create:{userId}) to prevent concurrent checkouts by the same buyer (409 Conflictif already held). - Persistence and event pipeline: Saves 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
Newstatus, appends the placement event to the event store, and publishes 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 via transactional outbox to User Checkout Event ChannelChannelv1.0.0User Checkout Event ChannelKafka topic owned by the commerce-fulfillment-team carrying Order API checkout events that initiate Finance post-checkou...Ownercommerce-fulfillment-teamOpen docs (partitioned byOrderId) to start 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. - Idempotency key lifecycle: Claims
x-request-idin Redis for 3600 seconds (409 Conflicton replay) and deletes the key if the operation fails with5xx.
Get basket over gRPCQueryv1.0.0Get basket over gRPCReturns the current basket through the basket.v1 gRPC contract.Ownercommerce-fulfillment-teamSchemaDiagramOpen docs returns an empty response when no basket exists rather than NotFound, and CreateOrder does not reject an empty item list—an empty basket proceeds to persistence and returns 201 Created if saved.
Error Responses
| Status / Code | Condition | Client Recovery Action |
|---|---|---|
400 Bad Request | Missing or whitespace x-request-id header, or non-UUID NameIdentifier claim | Provide a non-empty x-request-id header and valid token claims; do not retry unchanged |
401 Unauthorized | Missing, expired, or invalid Entra ID bearer token | Acquire a fresh Entra ID access token and retry |
403 Forbidden | Caller lacks customer/admin role or ordering_read/ordering_write scopes | Request the required Entra ID role and scopes before retrying |
404 Not Found | One or more basket book IDs do not exist in 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 | Refresh the customer’s basket to remove unavailable items before retrying with a new x-request-id |
409 Conflict | Duplicate x-request-id within the 3600-second TTL, or concurrent checkout lock held for the same buyer | Wait for the in-flight checkout to finish and query order history before retrying |
429 Too Many Requests | Rate limit quota exceeded (Retry-After header included) | Wait for the Retry-After interval before retrying |
500 Internal Server Error | Upstream gRPC timeout/error or persistence failure | Retry with backoff; the Redis idempotency key is cleared on 5xx |
Related Documentation
- 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 — Service architecture, persistence, and endpoints.
- OrderEntityv1.0.0OrderDurable purchase record owned by a Buyer, capturing immutable purchase-time line items and governing order lifecycle tra...Ownercommerce-fulfillment-teamOpen docs — Order aggregate invariants and lifecycle statuses.
- 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 — Kafka event published after order creation.
- User Checkout Event ChannelChannelv1.0.0User Checkout Event ChannelKafka topic owned by the commerce-fulfillment-team carrying Order API checkout events that initiate Finance post-checkou...Ownercommerce-fulfillment-teamOpen docs — Kafka topic specification.
- 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 — Upstream gRPC source for customer baskets.
- 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 — Upstream gRPC source for authoritative book pricing.
Create order schema
Required request header for creating an Order. The operation has no request body.
Idempotency key for the Order creation request.