Spring Boot 3 · Java 21

orderflow-api

An order management HTTP API with JWT roles, a validated status workflow, and idempotent order creation.

API reference Source

What it covers

Auth

Register and log in. Access tokens carry USER or ADMIN, and every protected route checks the account still exists.

Orders

Create an order, page and filter it, then move it through CREATED, PAID, SHIPPED, DELIVERED, or CANCELLED.

Reliability

Idempotency-Key on create, optimistic locking on stock, Flyway migrations, and RFC 7807 errors.

Status workflow

CREATED → PAID → SHIPPED → DELIVERED

CREATED or PAID can also move to CANCELLED. Cancelling puts the stock back. Customers can pay or cancel their own orders. Shipping and delivery are ADMIN actions.

Problem types

Errors use application/problem+json. The type URI points at a row in this table.

CodeWhen
VALIDATION_FAILEDA field, page, or sort value is invalid.
MALFORMED_REQUESTThe JSON body cannot be read.
IDEMPOTENCY_KEY_REQUIREDOrder creation did not send Idempotency-Key.
IDEMPOTENCY_KEY_INVALIDThe key is not 8–128 safe characters.
UNAUTHORIZEDMissing, expired, or wrong credentials.
FORBIDDENThe role cannot perform the action.
ORDER_NOT_FOUNDNo such order for this caller.
PRODUCT_NOT_FOUNDA line references a missing product.
EMAIL_TAKENRegistration email is already used.
SKU_TAKENCatalog SKU is already used.
IDEMPOTENCY_CONFLICTThe key was reused with a different body.
INVALID_TRANSITIONThat status move is not in the workflow.
INSUFFICIENT_STOCKThe catalog cannot cover the quantity.
PRODUCT_UNAVAILABLEThe product is inactive.
CONFLICTA concurrent update or other constraint lost.
INTERNAL_ERRORUnexpected server failure.