---
title: "createOrder"
url: "https://dev-portal.dehaven.org/apis/beer-api-v1/versions/a462a401-23c6-469f-86bf-c6017a4a1733/operations/createOrder"
---

> Full API specification: https://dev-portal.dehaven.org/apis/beer-api-v1/versions/a462a401-23c6-469f-86bf-c6017a4a1733.md

# createOrder

`POST` `/api/v1/customers/{customerId}/orders`

Operation ID: `createOrder`

Place Order

## Path parameters

- `customerId` (string, uuid, required) - Customer Id

## Query parameters

- `pageNumber` (integer, int32, optional) - Page number.
- `pageSize` (integer, int32, optional) - Page size.

## Request body

Content types: `application/json`

## Responses

- `201` - Order Created
- `400` - Bad Reqeust
- `404` - Not Found
- `409` - Conflict

## OpenAPI definition

```yaml
openapi: 3.0.2
info:
  title: SFG Brewery API
  version: "1.3"
servers:
  - url: http://localhost:8080
    description: Local Host
  - url: http://api.springframework.guru
    description: Demo API
paths:
  /api/v1/customers/{customerId}/orders:
    parameters:
      - $ref: "#/components/parameters/CustomerId"
      - $ref: "#/components/parameters/Page"
      - $ref: "#/components/parameters/PageSize"
    post:
      description: Place Order
      operationId: createOrder
      tags:
        - Order Service
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/BeerOrder"
      responses:
        "201":
          description: Order Created
          headers:
            Location:
              description: Reference to created Order
              schema:
                type: string
                format: uri
        "400":
          description: Bad Reqeust
        "404":
          description: Not Found
        "409":
          description: Conflict
      callbacks:
        orderStatusChange:
          "{$request.body#/orderStatusCallback}":
            description: Webhook post to reecive notifcations of order status changes.
            post:
              requestBody:
                $ref: "#/components/requestBodies/OrderStatusCallback"
              responses:
                "200":
                  description: Okay
components:
  parameters:
    CustomerId:
      name: customerId
      in: path
      description: Customer Id
      required: true
      schema:
        type: string
        format: uuid
    Page:
      name: pageNumber
      in: query
      description: Page number.
      required: false
      schema:
        type: integer
        format: int32
        default: 1
    PageSize:
      name: pageSize
      in: query
      description: Page size.
      required: false
      schema:
        type: integer
        format: int32
        default: 25
  schemas:
    BeerOrder:
      type: object
      allOf:
        - $ref: "#/components/schemas/BaseItem"
      required:
        - customerId
      properties:
        customerId:
          type: string
          format: uuid
        customerRef:
          type: string
          nullable: true
        beerOrderLines:
          type: array
          items:
            $ref: "#/components/schemas/BeerOrderLine"
        orderStatus:
          $ref: "#/components/schemas/OrderStatusEnum"
        orderStatusCallbackUrl:
          type: string
          format: uri
    BaseItem:
      type: object
      properties:
        id:
          type: string
          format: uuid
          readOnly: true
          nullable: true
        version:
          type: integer
          readOnly: true
          nullable: true
        createdDate:
          type: string
          format: date-time
          readOnly: true
          nullable: true
        lastModifiedDate:
          type: string
          format: date-time
          readOnly: true
          nullable: true
    BeerOrderLine:
      type: object
      allOf:
        - $ref: "#/components/schemas/BaseItem"
      required:
        - upc
        - orderQuantity
      properties:
        beerId:
          type: string
          format: uuid
          readOnly: true
        upc:
          type: string
        orderQuantity:
          type: integer
          minimum: 1
          maximum: 999
        quantityAllocated:
          type: integer
          readOnly: true
          nullable: true
    OrderStatusEnum:
      type: string
      nullable: true
      enum:
        - NEW
        - VERIFIED
        - ALLOCATED
        - READY
        - PICKED_UP
    OrderStatusUpdate:
      type: object
      allOf:
        - $ref: "#/components/schemas/BaseItem"
      properties:
        orderId:
          type: string
          format: uuid
        customerRef:
          type: string
        orderStatus:
          $ref: "#/components/schemas/OrderStatusEnum"
  requestBodies:
    OrderStatusCallback:
      description: Order Status Update
      content:
        application/json:
          schema:
            type: object
            properties:
              orderId:
                type: string
                format: uuid
              orderStatus:
                $ref: "#/components/schemas/OrderStatusUpdate"
```
