Skip to content

Latest commit

 

History

History
51 lines (37 loc) · 1.13 KB

File metadata and controls

51 lines (37 loc) · 1.13 KB

API examples

The interactive OpenAPI UI is available at http://localhost:8080/docs.

Authenticate

curl -s http://localhost:8080/api/auth/login \
  -H 'Content-Type: application/json' \
  -d '{"email":"demo@orderflow.dev","password":"Demo123!"}'

Store the returned token:

TOKEN="<token>"

Browse products

curl -s http://localhost:8080/api/products

Create an order

Replace the product UUID with one from the catalog response.

curl -i http://localhost:8080/api/orders \
  -H "Authorization: Bearer $TOKEN" \
  -H "Idempotency-Key: demo-checkout-001" \
  -H 'Content-Type: application/json' \
  -d '{
    "items": [{"productId": "<product-uuid>", "quantity": 1}],
    "paymentMethod": "DEMO_APPROVED"
  }'

Repeat the request with the same user and key to receive the same order. Set paymentMethod to DEMO_DECLINED to exercise compensation.

Inspect orders

curl -s http://localhost:8080/api/orders \
  -H "Authorization: Bearer $TOKEN"

Every response includes X-Correlation-Id. Supplying a valid value in that request header preserves it through the API response and logs.