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

Read the architecture guide →

Create basket

Creates a basket containing the supplied item identifiers and quantities.

Order Lifecycle
POST/api/v1/baskets

CreateBasket creates a customer-scoped BasketEntityv1.0.0BasketCustomer-scoped, mutable pre-order collection of requested books and quantities managed prior to checkout.Ownercommerce-fulfillment-teamOpen docs in 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 (POST /basket/api/v1/baskets) with an initial non-empty list of book items and quantities, returning the authenticated customer’s identifier. It persists the basket directly in Redis and overwrites any existing basket for the same customer.

Overview

PropertyValue
Bounded ContextShopping
Owner ServiceBasket 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
Protocol / FormatHTTP POST, application/json request and response
Gateway EndpointPOST /basket/api/v1/baskets (service path /api/v1/baskets)
Authentication & AuthorizationMicrosoft Entra ID JWT — customer role plus scopes basket_read, basket_write
Idempotency / ConcurrencyOverwrites any existing basket for the authenticated customer; no x-request-id header is enforced
Rate Limit / CachingGlobal concurrency (100), per-IP fixed-window (30 req/min), and per-user token bucket (30 tokens, +20 per 10s, queue 5); stored in Redis with no TTL
Contract Version1.0.0 (ApiVersions.V1)

Request & Response Contract

Request Body (application/json)

NameTypeRequiredConstraintsDescription
itemsobject[]YesNon-empty arrayInitial collection of books to store in the customer’s basket
items[].idstringYesNon-empty stringIdentifier of the Catalog book
items[].quantityintegerYes>= 1Requested unit quantity for the book

Success Response (201 Created)

NameTypeRequiredConstraintsDescription
Location headerstringYesRelative path /api/v1/baskets?id=<customer-id>URI to retrieve the created basket
Root bodystringYesDerived from caller’s NameIdentifier claimAuthenticated customer ID owning the basket

Behavior & Side Effects

  • Customer scoping: Resolves the basket owner exclusively from the JWT NameIdentifier claim; callers cannot supply a customer ID in the request body or route.
  • Redis storage & overwrite semantics: Persists the basket as camelCase JSON in Redis (basket:{userId}) with no expiration (TTL), overwriting any existing basket for the same customer.
  • Deferred catalog enrichment: Stores only book IDs and quantities; book titles and prices are resolved on read via Get basketQueryv1.0.0Get basketReturns the current basket and its item details.Ownercommerce-fulfillment-teamSchemaDiagramOpen docs.
  • No integration events: HTTP basket creation does not publish any Kafka integration events.

Error Responses

Status / CodeConditionClient Recovery Action
400 Bad RequestMissing items, empty items array, empty items[].id, items[].quantity <= 0, or malformed JSONFix the failing fields and resubmit
401 UnauthorizedMissing, expired, or invalid Entra ID bearer tokenAcquire a valid Entra ID access token and retry
403 ForbiddenValid token missing the customer role or basket_read/basket_write scopesRequest a token with the required role and scopes
429 Too Many RequestsRate limit quota exceeded (Retry-After header included)Wait for the Retry-After interval before retrying
500 Internal Server ErrorRedis write failed or unexpected server error (traceId included)Retry with exponential backoff; inspect service logs using traceId

Create basket schema

3 properties
itemsarray[object]
required