Create orderv1.0.0 · JSON Schema
Creates an Order for the authenticated Buyer using the current basket and Catalog pricing.
1. Place an Order from the Authenticated Customer’s Basket
An authenticated customer submits checkout; Ordering API fetches the shopper’s basket via Basket API gRPC, enriches book prices via Catalog API gRPC, persists the New order, and emits UserCheckedOutIntegrationEvent.
Payload details
x-request-id: Required UUID idempotency key header (HttpHeaders.RequestId).- Request body: Empty on the wire (
ordersApiClient.create(basketId)passesx-request-idand invalidates the basket/order queries).
Using this example
Returns 201 Created with the generated OrderId UUID string, persists the order in PostgreSQL, and publishes UserCheckedOutIntegrationEvent to trigger Finance’s checkout orchestration.
using BookWorm.Chassis.Utilities.Configurations;using BookWorm.Constants.Aspire;using Refit;
public interface IOrderApiClient{ [Post("/api/v1/orders")] Task<Guid> CreateOrderAsync( [Header("x-request-id")] Guid requestId, CancellationToken cancellationToken = default );}
// DI registration following BookWorm.Chassis Refit patternbuilder.Services .AddRefitGeneratedClient<IOrderApiClient>(settings, Services.Ordering) .ConfigureHttpClient(client => client.BaseAddress = new($"https+http://{Services.Ordering}")) .ConfigurePrimaryHttpMessageHandler(() => new SocketsHttpHandler { PooledConnectionLifetime = TimeSpan.FromMinutes(5) } );
// Typed invocationGuid orderId = await orderApiClient.CreateOrderAsync( Guid.CreateVersion7(), cancellationToken);import ordersApiClient from "@workspace/api-client/ordering/orders";import useCreateOrder from "@workspace/api-hooks/ordering/orders/useCreateOrder";
const basketId = "01960a1b-2c3d-7e4f-8a9b-0c1d2e3f4a01";
// 1. Direct @workspace/api-client (Axios) call (sets x-request-id automatically)const orderId = await ordersApiClient.create(basketId);
// 2. React / TanStack Query hook (@workspace/api-hooks)const { mutate: createOrder, isPending } = useCreateOrder({ onSuccess: (createdOrderId) => { console.log(`Placed order ${createdOrderId}`); },});
createOrder(basketId);1{
2 "$schema": "https://json-schema.org/draft/2020-12/schema",
3 "title": "CreateOrderRequest",
4 "description": "Required request header for creating an Order. The operation has no request body.",
5 "type": "object",
6 "required": ["x-request-id"],
7 "properties": {
8 "x-request-id": {
9 "type": "string",
10 "description": "Idempotency key for the Order creation request."
11 }
12 }
13}
14