Skip to content

Orders — API contract

binding spec openapi/orders.openapi.yaml @ 3.2.0 is the spec of record. It states what must be; implementations converge on it, never the reverse.

Enforced by
  • any change must bump the artifact and service versions (check:version); a silent edit fails CI
  • a breaking change must take a major version (check:compat)
  • Spectral lint, house naming rules included
  • Microcks contract tests hold mocks and implementations to these operations
Version history
VersionFirst releasedService version
3.2.02026-09-093.3.0
3.1.02026-08-303.2.0
3.0.12026-08-293.1.0
3.0.02026-08-273.0.0
2.1.02026-08-231.0.0
Consume it

Operations

POST/orders · placeOrder

Command — Place an order.

Accepts an order for the given customer and lines. On success the order is persisted and an OrderPlaced event is guaranteed to be published - never one without the other.

ParameterInTypeRequired
Idempotency-Keyheaderstringoptional

Request body

FieldTypeRequiredConstraints
customer_idstring (uuid)required—
linesarrayrequiredmin 1 item(s)
lines[].skustringrequired—
lines[].quantityintegerrequired≥ 1
lines[].unit_price_penceintegerrequired≥ 0

Responses

StatusMeaning
201Order accepted; an OrderPlaced event will be published.
400Invalid order - no lines, a line quantity below 1, a negative unit_price_pence, or a line missing its sku.
409Idempotency-Key already used with a different body.

201 body

FieldTypeRequiredConstraints
order_idstring (uuid)required—
customer_idstring (uuid)required—
statusstringrequiredone of placed, paid, cancelled
total_penceintegerrequired≥ 0
Examples (Microcks fixtures)
placed

Request

{
  "customer_id": "22222222-2222-2222-2222-222222222222",
  "lines": [
    {
      "sku": "SKU-001",
      "quantity": 2,
      "unit_price_pence": 1250
    }
  ]
}

Response 201

{
  "order_id": "11111111-1111-1111-1111-111111111111",
  "customer_id": "22222222-2222-2222-2222-222222222222",
  "status": "placed",
  "total_pence": 2500
}

GET/orders/{order_id} · getOrder

Query — Fetch an order.

Returns the order's current state by its id.

ParameterInTypeRequired
order_idpathstring (uuid)required

Responses

StatusMeaning
200The order.
404No such order.

200 body

FieldTypeRequiredConstraints
order_idstring (uuid)required—
customer_idstring (uuid)required—
statusstringrequiredone of placed, paid, cancelled
total_penceintegerrequired≥ 0
Examples (Microcks fixtures)
placed

Response 200

{
  "order_id": "11111111-1111-1111-1111-111111111111",
  "customer_id": "22222222-2222-2222-2222-222222222222",
  "status": "placed",
  "total_pence": 2500
}
not_found

Response 404

{
  "error_code": "order_not_found",
  "message": "No order 99999999-9999-9999-9999-999999999999"
}

Full rendered contract