Update basket
Replaces a basket's item collection with the supplied items.
/api/v1/basketsUpdateBasket replaces the entire item collection of the authenticated customer’s existing 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 (PUT /basket/api/v1/baskets) and returns 204 No Content. It requires an active basket to exist and rejects requests targeting a missing basket with 404 Not Found.
Overview
| Property | Value |
|---|---|
| Bounded Context | Shopping |
| Owner Service | 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 |
| Protocol / Format | HTTP PUT, application/json request, empty response (204 No Content) |
| Gateway Endpoint | PUT /basket/api/v1/baskets (service path /api/v1/baskets) |
| Authentication & Authorization | Microsoft Entra ID JWT — customer role plus scopes basket_read, basket_write |
| Idempotency / Concurrency | Naturally idempotent full-list replacement (last write wins) |
| Rate Limit / Caching | Global 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 Version | 1.0.0 (ApiVersions.V1) |
Request & Response Contract
Request Body (application/json)
| Name | Type | Required | Constraints | Description |
|---|---|---|---|---|
items | object[] | Yes | Non-empty array | Complete replacement list of items for the customer’s basket |
items[].id | string | Yes | Non-empty string | Identifier of the Catalog book |
items[].quantity | integer | Yes | >= 1 | Updated unit quantity for the book |
Success Response (204 No Content)
Empty response body confirms the basket items were replaced.
Behavior & Side Effects
- Full-list replacement: Replaces all existing items in Redis (
basket:{userId}) with the submitted items (last write wins, no TTL). - No implicit creation: Returns
404 Not Foundif no active basket exists; call Create basketCommandv1.0.0Create basketCreates a basket containing the supplied item identifiers and quantities.Ownercommerce-fulfillment-teamSchemaDiagramOpen docs first or Delete basketCommandv1.0.0Delete basketDeletes the current basket.Ownercommerce-fulfillment-teamSchemaDiagramOpen docs to remove all items. - Deferred catalog enrichment: Stores only book IDs and quantities; 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 updates do not publish any Kafka integration events.
OpenAPI metadata declares 404 Not Found as application/problem+json, whereas runtime responses return application/json with { "detail": "The requested resource was not found." }.
Error Responses
| Status / Code | Condition | Client Recovery Action |
|---|---|---|
400 Bad Request | Missing items, empty items array, empty items[].id, items[].quantity <= 0, or malformed JSON | Fix the failing fields and resubmit |
401 Unauthorized | Missing, expired, or invalid Entra ID bearer token | Acquire a valid Entra ID access token and retry |
403 Forbidden | Valid token missing the customer role or basket_read/basket_write scopes | Request a token with the required role and scopes |
404 Not Found | No active basket exists in Redis for the authenticated customer | Create a basket via Create basketCommandv1.0.0Create basketCreates a basket containing the supplied item identifiers and quantities.Ownercommerce-fulfillment-teamSchemaDiagramOpen docs before updating |
429 Too Many Requests | Rate limit quota exceeded (Retry-After header included) | Wait for the Retry-After interval before retrying |
500 Internal Server Error | Unexpected Redis or server failure (traceId included) | Retry with exponential backoff; inspect service logs using traceId |
Related Documentation
- 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 — Service overview, Redis storage, and authorization policy.
- BasketEntityv1.0.0BasketCustomer-scoped, mutable pre-order collection of requested books and quantities managed prior to checkout.Ownercommerce-fulfillment-teamOpen docs — Basket entity model.
- Create basketCommandv1.0.0Create basketCreates a basket containing the supplied item identifiers and quantities.Ownercommerce-fulfillment-teamSchemaDiagramOpen docs — Initialize a new basket.
- Delete basketCommandv1.0.0Delete basketDeletes the current basket.Ownercommerce-fulfillment-teamSchemaDiagramOpen docs — Delete an active basket.
- Get basketQueryv1.0.0Get basketReturns the current basket and its item details.Ownercommerce-fulfillment-teamSchemaDiagramOpen docs — Retrieve the current basket enriched with Catalog data.