Skip to main content

Create Order

Creates a new order and automatically generates tasks for each kitchen station based on the products ordered.

Request Body

tableNumber
string
required
The table number for the order. Cannot be null or empty.
products
array
required
List of products in the order. Each product must include name and type.

Response

tableNumber
string
The table number from the request
tasksCreated
integer
Number of tasks created for this order (one per station with products)
message
string
Success message: “Order processed successfully”

Example Request

curl -X POST http://localhost:8080/api/orders \
  -H "Content-Type: application/json" \
  -d '{
    "tableNumber": "5",
    "products": [
      {
        "name": "Caesar Salad",
        "type": "COLD_DISH"
      },
      {
        "name": "Grilled Chicken",
        "type": "HOT_DISH"
      },
      {
        "name": "Coffee",
        "type": "DRINK"
      }
    ]
  }'

Example Response

{
  "tableNumber": "5",
  "tasksCreated": 3,
  "message": "Order processed successfully"
}

Error Responses

400 Bad Request - Missing Table Number:
{
  "error": "Table number cannot be null or empty",
  "message": "Validation failed",
  "timestamp": "2026-03-06T10:30:45.123",
  "status": 400
}
400 Bad Request - Empty Products:
{
  "error": "Products list cannot be null or empty",
  "message": "Validation failed",
  "timestamp": "2026-03-06T10:30:45.123",
  "status": 400
}
400 Bad Request - Invalid Product Type:
{
  "error": "Invalid product type: INVALID_TYPE",
  "message": "Validation failed",
  "timestamp": "2026-03-06T10:30:45.123",
  "status": 400
}

Get Order Status

Retrieves the current status of an order by its ID.

Path Parameters

orderId
long
required
The unique identifier of the order

Response

orderId
string
The order ID from the request
status
string
Current status of the order. Possible values:
  • PENDING - Order tasks are waiting to start
  • IN_PREPARATION - At least one task is being prepared
  • COMPLETED - All tasks are completed

Example Request

curl http://localhost:8080/api/orders/1/status

Example Response

{
  "orderId": "1",
  "status": "IN_PREPARATION"
}

Error Responses

404 Not Found:
{
  "error": "Order with id 999 not found",
  "message": "Order not found",
  "timestamp": "2026-03-06T10:30:45.123",
  "status": 404
}

Order Processing Flow

When an order is created, the system:
  1. Validates the table number and products list
  2. Groups products by their type (station assignment)
  3. Creates one task per station that has products
  4. Returns the number of tasks created
Each task is initially in PENDING status and must be started by a kitchen station.

Product Types and Station Mapping

Product TypeStationExample Products
DRINKBARCoffee, Tea, Juice, Cocktails
HOT_DISHHOT_KITCHENGrilled items, Pasta, Steak
COLD_DISHCOLD_KITCHENSalads, Desserts, Cold appetizers

Build docs developers (and LLMs) love