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

Read the architecture guide →

Create buyer

Creates a Buyer profile for the authenticated customer from the supplied address.

Customer Management
POST/api/v1/buyers

CreateBuyer creates a BuyerEntityv1.0.0BuyerRepresents a customer's ordering profile and delivery address within the Ordering bounded context.Ownercommerce-fulfillment-teamOpen docs profile 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/buyers) using the supplied shipping address while deriving the buyer’s identifier and display name from the authenticated Microsoft Entra ID token.

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 POST, application/json request and response
Gateway EndpointPOST /ordering/api/v1/buyers (service path /api/v1/buyers)
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)
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

Request Headers

NameTypeRequiredConstraintsDescription
x-request-idstringYesNon-empty, non-whitespaceClient-generated idempotency key tracked in Redis for 3600 seconds

Request Body (application/json)

NameTypeRequiredConstraintsDescription
streetstringYesNon-empty, max 50 characters; PII-redacted in logsStreet address of the buyer
citystringYesNon-empty, max 50 characters; PII-redacted in logsCity or district of the buyer
provincestringYesNon-empty, max 50 characters; PII-redacted in logsProvince or state of the buyer

Success Response (201 Created)

NameTypeRequiredConstraintsDescription
Location headerstringYesRelative path /api/v1/buyers/{id}URI to fetch the created buyer profile
Root bodystring (uuid)YesMatches caller’s NameIdentifier claimNewly created buyer identifier

Behavior & Side Effects

  • Identity derivation: Extracts the buyer ID from the NameIdentifier claim (must be a valid UUID) and the display name from the name claim (falling back to "anonymous" if absent; stored max length 20 characters).
  • Transactional persistence: Persists the BuyerEntityv1.0.0BuyerRepresents a customer's ordering profile and delivery address within the Ordering bounded context.Ownercommerce-fulfillment-teamOpen docs aggregate and address value object inside a database transaction; emits no domain or integration events.
  • PII redaction: Address fields (street, city, province) are automatically redacted in structured logs.
  • Idempotency key lifecycle: Claims x-request-id in Redis for 3600 seconds (409 Conflict on replay) and deletes the key if the operation fails with 5xx.
Warning

Because the buyer ID is derived directly from the authenticated user’s token, a second CreateBuyer call for the same user with a new x-request-id collides with the existing primary key and fails with 500 Internal Server Error. Use Update buyer addressCommandv1.0.0Update buyer addressUpdates the authenticated Buyer's address using the supplied street, city, and province.Ownercommerce-fulfillment-teamSchemaDiagramOpen docs to update an existing profile.

Error Responses

Status / CodeConditionClient Recovery Action
400 Bad RequestMissing x-request-id header, empty/whitespace address field, field exceeding 50 characters, or non-UUID NameIdentifier claimFix headers, payload fields, or 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
409 ConflictDuplicate x-request-id for this path within the 3600-second TTLTreat as a duplicate submission and fetch the profile via Get buyerQueryv1.0.0Get buyerReturns the Buyer profile selected by identifier, subject to the caller's authorization.Ownercommerce-fulfillment-teamSchemaDiagramOpen docs
429 Too Many RequestsRate limit quota exceeded (Retry-After header included)Wait for the Retry-After interval before retrying
500 Internal Server ErrorDuplicate buyer profile for the authenticated user, display name exceeding 20 characters, or unhandled persistence errorInspect service logs and verify whether the buyer profile already exists

Create buyer schema

3 properties

Address fields required to create a Buyer profile.

streetstring
required
citystring
required
provincestring
required